这篇教程C++ strequal函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中strequal函数的典型用法代码示例。如果您正苦于以下问题:C++ strequal函数的具体用法?C++ strequal怎么用?C++ strequal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了strequal函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: enum_dom_groups/* list all domain groups */static NTSTATUS enum_dom_groups(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, uint32 *num_entries, struct wb_acct_info **info){ ADS_STRUCT *ads = NULL; const char *attrs[] = {"userPrincipalName", "sAMAccountName", "name", "objectSid", NULL}; int i, count; ADS_STATUS rc; LDAPMessage *res = NULL; LDAPMessage *msg = NULL; NTSTATUS status = NT_STATUS_UNSUCCESSFUL; const char *filter; bool enum_dom_local_groups = False; *num_entries = 0; DEBUG(3,("ads: enum_dom_groups/n")); if ( !winbindd_can_contact_domain( domain ) ) { DEBUG(10,("enum_dom_groups: No incoming trust for domain %s/n", domain->name)); return NT_STATUS_OK; } /* only grab domain local groups for our domain */ if ( domain->active_directory && strequal(lp_realm(), domain->alt_name) ) { enum_dom_local_groups = True; } /* Workaround ADS LDAP bug present in MS W2K3 SP0 and W2K SP4 w/o * rollup-fixes: * * According to Section 5.1(4) of RFC 2251 if a value of a type is it's * default value, it MUST be absent. In case of extensible matching the * "dnattr" boolean defaults to FALSE and so it must be only be present * when set to TRUE. * * When it is set to FALSE and the OpenLDAP lib (correctly) encodes a * filter using bitwise matching rule then the buggy AD fails to decode * the extensible match. As a workaround set it to TRUE and thereby add * the dnAttributes "dn" field to cope with those older AD versions. * It should not harm and won't put any additional load on the AD since * none of the dn components have a bitmask-attribute. * * Thanks to Ralf Haferkamp for input and testing - Guenther */ filter = talloc_asprintf(mem_ctx, "(&(objectCategory=group)(&(groupType:dn:%s:=%d)(!(groupType:dn:%s:=%d))))", ADS_LDAP_MATCHING_RULE_BIT_AND, GROUP_TYPE_SECURITY_ENABLED, ADS_LDAP_MATCHING_RULE_BIT_AND, enum_dom_local_groups ? GROUP_TYPE_BUILTIN_LOCAL_GROUP : GROUP_TYPE_RESOURCE_GROUP); if (filter == NULL) { status = NT_STATUS_NO_MEMORY; goto done; } ads = ads_cached_connection(domain); if (!ads) { domain->last_status = NT_STATUS_SERVER_DISABLED; goto done; } rc = ads_search_retry(ads, &res, filter, attrs); if (!ADS_ERR_OK(rc) || !res) { DEBUG(1,("enum_dom_groups ads_search: %s/n", ads_errstr(rc))); goto done; } count = ads_count_replies(ads, res); if (count == 0) { DEBUG(1,("enum_dom_groups: No groups found/n")); goto done; } (*info) = talloc_zero_array(mem_ctx, struct wb_acct_info, count); if (!*info) { status = NT_STATUS_NO_MEMORY; goto done; } i = 0; for (msg = ads_first_entry(ads, res); msg; msg = ads_next_entry(ads, msg)) { char *name, *gecos; struct dom_sid sid; uint32 rid; name = ads_pull_username(ads, mem_ctx, msg); gecos = ads_pull_string(ads, mem_ctx, msg, "name"); if (!ads_pull_sid(ads, msg, "objectSid", &sid)) { DEBUG(1,("No sid for %s !?/n", name)); continue; } if (!sid_peek_check_rid(&domain->sid, &sid, &rid)) { DEBUG(1,("No rid for %s !?/n", name));//.........这里部分代码省略.........
开发者ID:Arkhont,项目名称:samba,代码行数:101,
示例2: lookup_namebool lookup_name(TALLOC_CTX *mem_ctx, const char *full_name, int flags, const char **ret_domain, const char **ret_name, DOM_SID *ret_sid, enum lsa_SidType *ret_type){ char *p; const char *tmp; const char *domain = NULL; const char *name = NULL; uint32 rid; DOM_SID sid; enum lsa_SidType type; TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); if (tmp_ctx == NULL) { DEBUG(0, ("talloc_new failed/n")); return false; } p = strchr_m(full_name, '//'); if (p != NULL) { domain = talloc_strndup(tmp_ctx, full_name, PTR_DIFF(p, full_name)); name = talloc_strdup(tmp_ctx, p+1); } else { domain = talloc_strdup(tmp_ctx, ""); name = talloc_strdup(tmp_ctx, full_name); } if ((domain == NULL) || (name == NULL)) { DEBUG(0, ("talloc failed/n")); TALLOC_FREE(tmp_ctx); return false; } DEBUG(10,("lookup_name: %s => %s (domain), %s (name)/n", full_name, domain, name)); DEBUG(10, ("lookup_name: flags = 0x0%x/n", flags)); if ((flags & LOOKUP_NAME_DOMAIN) && strequal(domain, get_global_sam_name())) { /* It's our own domain, lookup the name in passdb */ if (lookup_global_sam_name(name, flags, &rid, &type)) { sid_copy(&sid, get_global_sam_sid()); sid_append_rid(&sid, rid); goto ok; } TALLOC_FREE(tmp_ctx); return false; } if ((flags & LOOKUP_NAME_BUILTIN) && strequal(domain, builtin_domain_name())) { /* Explicit request for a name in BUILTIN */ if (lookup_builtin_name(name, &rid)) { sid_copy(&sid, &global_sid_Builtin); sid_append_rid(&sid, rid); type = SID_NAME_ALIAS; goto ok; } TALLOC_FREE(tmp_ctx); return false; } /* Try the explicit winbind lookup first, don't let it guess the * domain yet at this point yet. This comes later. */ if ((domain[0] != '/0') && (flags & ~(LOOKUP_NAME_DOMAIN|LOOKUP_NAME_ISOLATED)) && (winbind_lookup_name(domain, name, &sid, &type))) { goto ok; } if (!(flags & LOOKUP_NAME_EXPLICIT) && strequal(domain, unix_users_domain_name())) { if (lookup_unix_user_name(name, &sid)) { type = SID_NAME_USER; goto ok; } TALLOC_FREE(tmp_ctx); return false; } if (!(flags & LOOKUP_NAME_EXPLICIT) && strequal(domain, unix_groups_domain_name())) { if (lookup_unix_group_name(name, &sid)) { type = SID_NAME_DOM_GRP; goto ok; } TALLOC_FREE(tmp_ctx); return false; } if ((domain[0] == '/0') && (!(flags & LOOKUP_NAME_ISOLATED))) { TALLOC_FREE(tmp_ctx); return false; }//.........这里部分代码省略.........
开发者ID:gojdic,项目名称:samba,代码行数:101,
示例3: net_ads_join//.........这里部分代码省略......... if (!ADS_ERR_OK(rc)) { d_printf("ads_join_realm: %s/n", ads_errstr(rc)); ads_destroy(&ads); return -1; } rc = ads_join_realm(ads, global_myname(), account_type, org_unit); if (!ADS_ERR_OK(rc)) { d_printf("ads_join_realm: %s/n", ads_errstr(rc)); ads_destroy(&ads); return -1; } rc = ads_domain_sid(ads, &dom_sid); if (!ADS_ERR_OK(rc)) { d_printf("ads_domain_sid: %s/n", ads_errstr(rc)); ads_destroy(&ads); return -1; } if (asprintf(&machine_account, "%s$", global_myname()) == -1) { d_printf("asprintf failed/n"); ads_destroy(&ads); return -1; } rc = ads_set_machine_password(ads, machine_account, password); if (!ADS_ERR_OK(rc)) { d_printf("ads_set_machine_password: %s/n", ads_errstr(rc)); ads_destroy(&ads); return -1; } /* make sure we get the right workgroup */ if ( !(ctx = talloc_init("net ads join")) ) { d_printf("talloc_init() failed!/n"); ads_destroy(&ads); return -1; } rc = ads_workgroup_name(ads, ctx, &short_domain_name); if ( ADS_ERR_OK(rc) ) { if ( !strequal(lp_workgroup(), short_domain_name) ) { d_printf("The workgroup in smb.conf does not match the short/n"); d_printf("domain name obtained from the server./n"); d_printf("Using the name [%s] from the server./n", short_domain_name); d_printf("You should set /"workgroup = %s/" in smb.conf./n", short_domain_name); } } else { short_domain_name = lp_workgroup(); } d_printf("Using short domain name -- %s/n", short_domain_name); /* HACK ALRET! Store the sid and password under bother the lp_workgroup() value from smb.conf and the string returned from the server. The former is neede to bootstrap winbindd's first connection to the DC to get the real short domain name --jerry */ if (!secrets_store_domain_sid(lp_workgroup(), &dom_sid)) { DEBUG(1,("Failed to save domain sid/n")); ads_destroy(&ads); return -1; } if (!secrets_store_machine_password(password, lp_workgroup(), sec_channel_type)) { DEBUG(1,("Failed to save machine password/n")); ads_destroy(&ads); return -1; } if (!secrets_store_domain_sid(short_domain_name, &dom_sid)) { DEBUG(1,("Failed to save domain sid/n")); ads_destroy(&ads); return -1; } if (!secrets_store_machine_password(password, short_domain_name, sec_channel_type)) { DEBUG(1,("Failed to save machine password/n")); ads_destroy(&ads); return -1; } /* Now build the keytab, using the same ADS connection */ if (lp_use_kerberos_keytab() && ads_keytab_create_default(ads)) { DEBUG(1,("Error creating host keytab!/n")); } d_printf("Joined '%s' to realm '%s'/n", global_myname(), ads->config.realm); SAFE_FREE(password); SAFE_FREE(machine_account); if ( ctx ) { talloc_destroy(ctx); } ads_destroy(&ads); return 0;}
开发者ID:niubl,项目名称:camera_project,代码行数:101,
示例4: Curl_parsenetrc/* returns -1 on failure, 0 if the host is found, 1 is the host isn't found */int Curl_parsenetrc(char *host, char *login, char *password, char *netrcfile){ FILE *file; int retcode=1; int specific_login = (login[0] != 0); char *home = NULL; bool home_alloc = FALSE; bool netrc_alloc = FALSE; int state=NOTHING; char state_login=0; /* Found a login keyword */ char state_password=0; /* Found a password keyword */ int state_our_login=FALSE; /* With specific_login, found *our* login name */#define NETRC DOT_CHAR "netrc"#ifdef CURLDEBUG { /* This is a hack to allow testing. * If compiled with --enable-debug and CURL_DEBUG_NETRC is defined, * then it's the path to a substitute .netrc for testing purposes *only* */ char *override = curl_getenv("CURL_DEBUG_NETRC"); if (override) { fprintf(stderr, "NETRC: overridden " NETRC " file: %s/n", override); netrcfile = override; netrc_alloc = TRUE; } }#endif /* CURLDEBUG */ if(!netrcfile) { home = curl_getenv("HOME"); /* portable environment reader */ if(home) { home_alloc = TRUE;#if defined(HAVE_GETPWUID) && defined(HAVE_GETEUID) } else { struct passwd *pw; pw= getpwuid(geteuid()); if (pw) {#ifdef VMS home = decc$translate_vms(pw->pw_dir);#else home = pw->pw_dir;#endif }#endif } if(!home) return -1; netrcfile = curl_maprintf("%s%s%s", home, DIR_CHAR, NETRC); if(!netrcfile) { if(home_alloc) free(home); return -1; } netrc_alloc = TRUE; } file = fopen(netrcfile, "r"); if(file) { char *tok; char *tok_buf; bool done=FALSE; char netrcbuffer[256]; while(!done && fgets(netrcbuffer, sizeof(netrcbuffer), file)) { tok=strtok_r(netrcbuffer, " /t/n", &tok_buf); while(!done && tok) { if (login[0] && password[0]) { done=TRUE; break; } switch(state) { case NOTHING: if(strequal("machine", tok)) { /* the next tok is the machine name, this is in itself the delimiter that starts the stuff entered for this machine, after this we need to search for 'login' and 'password'. */ state=HOSTFOUND; } break; case HOSTFOUND: if(strequal(host, tok)) { /* and yes, this is our host! */ state=HOSTVALID;#ifdef _NETRC_DEBUG fprintf(stderr, "HOST: %s/n", tok);#endif retcode=0; /* we did find our host *///.........这里部分代码省略.........
开发者ID:Tudi,项目名称:PG2-firewall,代码行数:101,
示例5: delete_all_streamsNTSTATUS delete_all_streams(connection_struct *conn, const char *fname){ struct stream_struct *stream_info = NULL; int i; unsigned int num_streams = 0; TALLOC_CTX *frame = talloc_stackframe(); NTSTATUS status; status = vfs_streaminfo(conn, NULL, fname, talloc_tos(), &num_streams, &stream_info); if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)) { DEBUG(10, ("no streams around/n")); TALLOC_FREE(frame); return NT_STATUS_OK; } if (!NT_STATUS_IS_OK(status)) { DEBUG(10, ("vfs_streaminfo failed: %s/n", nt_errstr(status))); goto fail; } DEBUG(10, ("delete_all_streams found %d streams/n", num_streams)); if (num_streams == 0) { TALLOC_FREE(frame); return NT_STATUS_OK; } for (i=0; i<num_streams; i++) { int res; struct smb_filename *smb_fname_stream; if (strequal(stream_info[i].name, "::$DATA")) { continue; } smb_fname_stream = synthetic_smb_fname( talloc_tos(), fname, stream_info[i].name, NULL); if (smb_fname_stream == NULL) { DEBUG(0, ("talloc_aprintf failed/n")); status = NT_STATUS_NO_MEMORY; goto fail; } res = SMB_VFS_UNLINK(conn, smb_fname_stream); if (res == -1) { status = map_nt_error_from_unix(errno); DEBUG(10, ("Could not delete stream %s: %s/n", smb_fname_str_dbg(smb_fname_stream), strerror(errno))); TALLOC_FREE(smb_fname_stream); break; } TALLOC_FREE(smb_fname_stream); } fail: TALLOC_FREE(frame); return status;}
开发者ID:vormetriclabs,项目名称:samba,代码行数:65,
示例6: obj_parse_mtl_fileint obj_parse_mtl_file(char *filename, list *material_list) { int line_number = 0; char *current_token; char current_line[OBJ_LINE_SIZE]; char material_open = 0; obj_material *current_mtl = NULL; FILE *mtl_file_stream; // open scene mtl_file_stream = fopen(filename, "r"); if (mtl_file_stream == 0) { fprintf(stderr, "Error reading file: %s/n", filename); return 0; } list_make(material_list, 10, 1); while (fgets(current_line, OBJ_LINE_SIZE, mtl_file_stream)) { current_token = strtok(current_line, " /t/n/r"); line_number++; //skip comments if (current_token == NULL || strequal(current_token, "//") || strequal(current_token, "#")) continue; //start material else if (strequal(current_token, "newmtl")) { material_open = 1; current_mtl = (obj_material *) malloc(sizeof(obj_material)); obj_set_material_defaults(current_mtl); // get the name strncpy(current_mtl->name, strtok(NULL, " /t"), MATERIAL_NAME_SIZE); list_add_item(material_list, current_mtl, current_mtl->name); } //ambient else if (strequal(current_token, "Ka") && material_open) { current_mtl->amb[0] = atof(strtok(NULL, " /t")); current_mtl->amb[1] = atof(strtok(NULL, " /t")); current_mtl->amb[2] = atof(strtok(NULL, " /t")); } //diff else if (strequal(current_token, "Kd") && material_open) { current_mtl->diff[0] = atof(strtok(NULL, " /t")); current_mtl->diff[1] = atof(strtok(NULL, " /t")); current_mtl->diff[2] = atof(strtok(NULL, " /t")); } //specular else if (strequal(current_token, "Ks") && material_open) { current_mtl->spec[0] = atof(strtok(NULL, " /t")); current_mtl->spec[1] = atof(strtok(NULL, " /t")); current_mtl->spec[2] = atof(strtok(NULL, " /t")); } //shiny else if (strequal(current_token, "Ns") && material_open) { current_mtl->shiny = atof(strtok(NULL, " /t")); } //transparent else if (strequal(current_token, "d") && material_open) { current_mtl->trans = atof(strtok(NULL, " /t")); } //reflection else if (strequal(current_token, "r") && material_open) { current_mtl->reflect = atof(strtok(NULL, " /t")); } //glossy else if (strequal(current_token, "sharpness") && material_open) { current_mtl->glossy = atof(strtok(NULL, " /t")); } //refract index else if (strequal(current_token, "Ni") && material_open) { current_mtl->refract_index = atof(strtok(NULL, " /t")); } // illumination type else if (strequal(current_token, "illum") && material_open) { } // texture map else if (strequal(current_token, "map_Ka") && material_open) { strncpy(current_mtl->texture_filename, strtok(NULL, " /t"), OBJ_FILENAME_LENGTH); } else { fprintf(stderr, "Unknown command '%s' in material file %s at line %i:/n/t%s/n", current_token, filename, line_number, current_line); //return 0; } } fclose(mtl_file_stream); return 1;}
开发者ID:alxshine,项目名称:graphix,代码行数:96,
示例7: register_name_responsestatic void register_name_response(struct subnet_record *subrec, struct response_record *rrec, struct packet_struct *p){ /* * If we are registering broadcast, then getting a response is an * error - we do not have the name. If we are registering unicast, * then we expect to get a response. */ struct nmb_packet *nmb = &p->packet.nmb; BOOL bcast = nmb->header.nm_flags.bcast; BOOL success = True; struct nmb_name *question_name = &rrec->packet->packet.nmb.question.question_name; struct nmb_name *answer_name = &nmb->answers->rr_name; struct nmb_packet *sent_nmb = &rrec->packet->packet.nmb; int ttl = 0; uint16 nb_flags = 0; struct in_addr register_ip; fstring reg_name; putip(®ister_ip,&sent_nmb->additional->rdata[2]); fstrcpy(reg_name, inet_ntoa(register_ip)); if (subrec == unicast_subnet) { /* we know that this wins server is definately alive - for the moment! */ wins_srv_alive(rrec->packet->ip, register_ip); } /* Sanity check. Ensure that the answer name in the incoming packet is the same as the requested name in the outgoing packet. */ if(!question_name || !answer_name) { DEBUG(0,("register_name_response: malformed response (%s is NULL)./n", question_name ? "question_name" : "answer_name" )); return; } if(!nmb_name_equal(question_name, answer_name)) { DEBUG(0,("register_name_response: Answer name %s differs from question name %s./n", nmb_namestr(answer_name), nmb_namestr(question_name))); return; } if(bcast) { /* * Special hack to cope with old Samba nmbd's. * Earlier versions of Samba (up to 1.9.16p11) respond * to a broadcast name registration of WORKGROUP<1b> when * they should not. Hence, until these versions are gone, * we should treat such errors as success for this particular * case only. [email C++ strerr_die2sys函数代码示例 C++ streq_ptr函数代码示例
|