这篇教程C++ strchrnul函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中strchrnul函数的典型用法代码示例。如果您正苦于以下问题:C++ strchrnul函数的具体用法?C++ strchrnul怎么用?C++ strchrnul使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了strchrnul函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: memmemstatic const char *find_encoding(const char *begin, const char *end){ const char *needle = "/nencoding "; char *bol, *eol; bol = memmem(begin, end ? end - begin : strlen(begin), needle, strlen(needle)); if (!bol) return git_commit_encoding; bol += strlen(needle); eol = strchrnul(bol, '/n'); *eol = '/0'; return bol;}
开发者ID:7sOddities,项目名称:git,代码行数:14,
示例2: anonymize_path/* * We anonymize each component of a path individually, * so that paths a/b and a/c will share a common root. * The paths are cached via anonymize_mem so that repeated * lookups for "a" will yield the same value. */static void anonymize_path(struct strbuf *out, const char *path, struct hashmap *map, void *(*generate)(const void *, size_t *)){ while (*path) { const char *end_of_component = strchrnul(path, '/'); size_t len = end_of_component - path; const char *c = anonymize_mem(map, generate, path, &len); strbuf_add(out, c, len); path = end_of_component; if (*path) strbuf_addch(out, *path++); }}
开发者ID:PKRoma,项目名称:git-for-windows,代码行数:20,
示例3: show_sig_linesstatic void show_sig_lines(struct rev_info *opt, int status, const char *bol){ const char *color, *reset, *eol; color = diff_get_color_opt(&opt->diffopt, status ? DIFF_WHITESPACE : DIFF_FRAGINFO); reset = diff_get_color_opt(&opt->diffopt, DIFF_RESET); while (*bol) { eol = strchrnul(bol, '/n'); printf("%s%.*s%s%s", color, (int)(eol - bol), bol, reset, *eol ? "/n" : ""); bol = (*eol) ? (eol + 1) : eol; }}
开发者ID:NitzanDavari,项目名称:ios-perl,代码行数:14,
示例4: undebugq3char *undebugq3(char *in, char *needle){ char *p = NULL; char *pt = in -1;// temporary pointer do { p = pt + 1; if ((pt = strmatch(p, needle)) != NULL) { if (*pt == ' ') { char *ip = pt + 1; char *ipt = NULL; size_t nsize = pt - p; do { ipt = strchrnul(ip,' '); if (*ipt == ' ') { if ( backcmp(ipt - nsize, needle, nsize) ) { ip = ipt; continue; } else { user_memmove(p, pt+1, ipt-pt-1-nsize); p += ipt-pt-1-nsize; ip = ipt+1; pt = ipt; continue; } } if (*ipt == '/0') { if ( backcmp(ipt - nsize, needle, nsize) ) { user_memmove(p, pt+1, ipt-pt); } else { user_memmove(p, pt+1, ipt - pt - nsize - 1); p += ipt - pt - nsize - 1; *p = '/0'; } return in; } } while(*(ip++)); return in; } if (*pt == '/0') { *p = '/0'; return in; } p = pt; } pt = strchr(p, ' '); } while (pt); return in;}
开发者ID:dim13,项目名称:lor-contest,代码行数:49,
示例5: foreach_reported_to_linestatic void foreach_reported_to_line(const char *reported_to, foreach_reported_to_line_cb_type callback, void *user_data){ const char *p = reported_to; unsigned lineno = 0; while (*p) { ++lineno; const char *record = p; const char *record_label_end = strchrnul(p, ':'); const size_t label_len = record_label_end - p; const char *record_end = strchrnul(p, '/n'); p = record_end + (record_end[0] != '/0'); if (label_len == 0 || record_label_end[0] == '/0' || record_end < record_label_end) { log_notice("Miss formatted 'reported_to' record on line %d", lineno); continue; } callback(record, label_len, user_data); }}
开发者ID:scottgfhong,项目名称:libreport,代码行数:24,
示例6: strbuf_add_indented_textstatic void strbuf_add_indented_text(struct strbuf *buf, const char *text, int indent, int indent2){ if (indent < 0) indent = 0; while (*text) { const char *eol = strchrnul(text, '/n'); if (*eol == '/n') eol++; strbuf_addchars(buf, ' ', indent); strbuf_add(buf, text, eol - text); text = eol; indent = indent2; }}
开发者ID:Advael,项目名称:git,代码行数:15,
示例7: undebugq2char *undebugq2(char *in, char *needle){ char *p = NULL; char *pt = in-1; // temporary pointer do { p = pt + 1; if ((pt = strmatch(p, needle)) != NULL) { if (*pt == ' ') { char *ip = pt + 1; char *ipt = NULL; do { if ((ipt = strmatch(ip, needle)) != NULL) { if (*ipt == ' ') { user_memmove(p, pt+1, ip-pt-1); p += ip-pt-1; ip = ipt+1; pt = ipt; } if (*ipt == '/0') { if (ip - pt - 1) { user_memmove(p, pt+1, ip-pt-1); p += ip-pt-2; } *p = '/0'; return in; } ip = ipt; } ip = strchrnul(ip, ' '); if (!(*ip)) { user_memmove(p, pt+1, ip-pt); return in; } ip++; } while (*ip); return in; } if (*pt == '/0') { *p = '/0'; return in; } p = pt; } pt = strchr(p, ' '); } while (pt); return in;}
开发者ID:dim13,项目名称:lor-contest,代码行数:48,
示例8: findInPathstatic const char* findInPath(const char* file){ static __thread char buffer[DARWIN_MAXPATHLEN]; if (*file == '/') return file; if (strchr(file, '/') != 0) { // No PATH resolution, only fix the case strcpy(buffer, file); translatePathCI(buffer); return buffer; } const char* path = getenv("PATH"); if (!path) { // Get the default path. size_t len = confstr(_CS_PATH, 0, 0); char* buf = reinterpret_cast<char*>( alloca(len + 1) ); buf[0] = ':'; confstr(_CS_PATH, buf + 1, len); path = buf; } const char* p = path; do { const char* end = strchrnul(p, ':'); size_t len = end-p; memcpy(buffer, p, len); if (buffer[len-1] != '/') buffer[len++] = '/'; strcpy(buffer+len, file); translatePathCI(buffer); if (::access(buffer, X_OK) == 0) return buffer; } while (*p++); return 0;}
开发者ID:eccstartup,项目名称:darling,代码行数:48,
示例9: http_auth_initstatic void http_auth_init(const char *url){ char *at, *colon, *cp, *slash, *decoded; int len; cp = strstr(url, "://"); if (!cp) return; /* * Ok, the URL looks like "proto://something". Which one? * "proto://<user>:<pass>@<host>/...", * "proto://<user>@<host>/...", or just * "proto://<host>/..."? */ cp += 3; at = strchr(cp, '@'); colon = strchr(cp, ':'); slash = strchrnul(cp, '/'); if (!at || slash <= at) return; /* No credentials */ if (!colon || at <= colon) { /* Only username */ len = at - cp; user_name = xmalloc(len + 1); memcpy(user_name, cp, len); user_name[len] = '/0'; decoded = url_decode(user_name); free(user_name); user_name = decoded; user_pass = NULL; } else { len = colon - cp; user_name = xmalloc(len + 1); memcpy(user_name, cp, len); user_name[len] = '/0'; decoded = url_decode(user_name); free(user_name); user_name = decoded; len = at - (colon + 1); user_pass = xmalloc(len + 1); memcpy(user_pass, colon + 1, len); user_pass[len] = '/0'; decoded = url_decode(user_pass); free(user_pass); user_pass = decoded; }}
开发者ID:AsherBond,项目名称:MondocosmOS-Dependencies,代码行数:48,
示例10: parse_whitespace_ruleunsigned parse_whitespace_rule(const char *string){ unsigned rule = WS_DEFAULT_RULE; while (string) { int i; size_t len; const char *ep; int negated = 0; string = string + strspn(string, ", /t/n/r"); ep = strchrnul(string, ','); len = ep - string; if (*string == '-') { negated = 1; string++; len--; } if (!len) break; for (i = 0; i < ARRAY_SIZE(whitespace_rule_names); i++) { if (strncmp(whitespace_rule_names[i].rule_name, string, len)) continue; if (negated) rule &= ~whitespace_rule_names[i].rule_bits; else rule |= whitespace_rule_names[i].rule_bits; break; } if (strncmp(string, "tabwidth=", 9) == 0) { unsigned tabwidth = atoi(string + 9); if (0 < tabwidth && tabwidth < 0100) { rule &= ~WS_TAB_WIDTH_MASK; rule |= tabwidth; } else warning("tabwidth %.*s out of range", (int)(len - 9), string + 9); } string = ep; } if (rule & WS_TAB_IN_INDENT && rule & WS_INDENT_WITH_NON_TAB) die("cannot enforce both tab-in-indent and indent-with-non-tab"); return rule;}
开发者ID:foggg7777,项目名称:git,代码行数:48,
示例11: read_mailmap_bufstatic void read_mailmap_buf(struct string_list *map, const char *buf, unsigned long len, char **repo_abbrev){ while (len) { const char *end = strchrnul(buf, '/n'); unsigned long linelen = end - buf + 1; char *line = xmemdupz(buf, linelen); read_mailmap_line(map, line, repo_abbrev); free(line); buf += linelen; len -= linelen; }}
开发者ID:00027jang27,项目名称:git,代码行数:16,
示例12: mainint main(void){ char string[N]; char c; printf("Input a string!/n"); gets(string); printf("Input a character to look up for!/n"); scanf("%c",&c); char *rp = strchrnul(string,c); printf("The 1th character '%c' that found, the next character is '%c'/n",*rp,*(rp+1)); return 0;}
开发者ID:charlie-wong,项目名称:wlc,代码行数:16,
示例13: is_in_comma_separated_listbool is_in_comma_separated_list(const char *value, const char *list){ if (!list) return false; unsigned len = strlen(value); while (*list) { const char *comma = strchrnul(list, ','); if ((comma - list == len) && strncmp(value, list, len) == 0) return true; if (!*comma) break; list = comma + 1; } return false;}
开发者ID:abrt,项目名称:libreport,代码行数:16,
示例14: add_cookiestatic inline void add_cookie(struct hashtable *ht, const char *str) { const char *name = str; const char *name_end = strchrnul(str, '='); const char *val = *name_end ? name_end + 1 : name_end; /* get rid of quotes */ const char *val_st = val, *val_st_end = val + strlen(val); if ('"' == *val_st) ++val_st; if (val_st != val_st_end && '"' == *(val_st_end - 1)) --val_st_end; size_t l = val_st_end - val_st; uint32_t loc = hashtable_insert(ht, name, name_end - name, val_st, l + 1); *(char *)(hashtable_get_val(ht, loc) + l) = 0;}
开发者ID:chinnurtb,项目名称:ribs2,代码行数:16,
示例15: crm_log_filterstatic voidcrm_log_filter(struct qb_log_callsite *cs){ int lpc = 0; static int need_init = 1; static const char *trace_fns = NULL; static const char *trace_tags = NULL; static const char *trace_fmts = NULL; static const char *trace_files = NULL; static const char *trace_blackbox = NULL; if (need_init) { need_init = 0; trace_fns = getenv("PCMK_trace_functions"); trace_fmts = getenv("PCMK_trace_formats"); trace_tags = getenv("PCMK_trace_tags"); trace_files = getenv("PCMK_trace_files"); trace_blackbox = getenv("PCMK_trace_blackbox"); if (trace_tags != NULL) { uint32_t tag; char token[500]; const char *offset = NULL; const char *next = trace_tags; do { offset = next; next = strchrnul(offset, ','); snprintf(token, 499, "%.*s", (int)(next - offset), offset); tag = g_quark_from_string(token); crm_info("Created GQuark %u from token '%s' in '%s'", tag, token, trace_tags); if (next[0] != 0) { next++; } } while (next != NULL && next[0] != 0); } } cs->targets = 0; /* Reset then find targets to enable */ for (lpc = QB_LOG_SYSLOG; lpc < QB_LOG_TARGET_MAX; lpc++) { crm_log_filter_source(lpc, trace_files, trace_fns, trace_fmts, trace_tags, trace_blackbox, cs); }}
开发者ID:dirkmueller,项目名称:pacemaker,代码行数:47,
示例16: rerere_mem_getlinestatic int rerere_mem_getline(struct strbuf *sb, struct rerere_io *io_){ struct rerere_io_mem *io = (struct rerere_io_mem *)io_; char *ep; size_t len; strbuf_release(sb); if (!io->input.len) return -1; ep = strchrnul(io->input.buf, '/n'); if (*ep == '/n') ep++; len = ep - io->input.buf; strbuf_add(sb, io->input.buf, len); strbuf_remove(&io->input, 0, len); return 0;}
开发者ID:LittleForker,项目名称:git,代码行数:17,
示例17: parse_signature_linesstatic void parse_signature_lines(struct format_commit_context *ctx){ const char *buf = ctx->signature.gpg_output; int i; for (i = 0; i < ARRAY_SIZE(signature_check); i++) { const char *found = strstr(buf, signature_check[i].check); const char *next; if (!found) continue; ctx->signature.good_bad = signature_check[i].result; found += strlen(signature_check[i].check); next = strchrnul(found, '/n'); ctx->signature.signer = xmemdupz(found, next - found); break; }}
开发者ID:Advael,项目名称:git,代码行数:17,
示例18: do_invalidate_pathstatic int do_invalidate_path(struct cache_tree *it, const char *path){ /* a/b/c * ==> invalidate self * ==> find "a", have it invalidate "b/c" * a * ==> invalidate self * ==> if "a" exists as a subtree, remove it. */ const char *slash; int namelen; struct cache_tree_sub *down;#if DEBUG fprintf(stderr, "cache-tree invalidate <%s>/n", path);#endif if (!it) return 0; slash = strchrnul(path, '/'); namelen = slash - path; it->entry_count = -1; if (!*slash) { int pos; pos = subtree_pos(it, path, namelen); if (0 <= pos) { cache_tree_free(&it->down[pos]->cache_tree); free(it->down[pos]); /* 0 1 2 3 4 5 * ^ ^subtree_nr = 6 * pos * move 4 and 5 up one place (2 entries) * 2 = 6 - 3 - 1 = subtree_nr - pos - 1 */ memmove(it->down+pos, it->down+pos+1, sizeof(struct cache_tree_sub *) * (it->subtree_nr - pos - 1)); it->subtree_nr--; } return 1; } down = find_subtree(it, path, namelen, 0); if (down) do_invalidate_path(down->cache_tree, slash + 1); return 1;}
开发者ID:9b,项目名称:git,代码行数:46,
示例19: template_desc_init_fieldsstatic int template_desc_init_fields(const char *template_fmt, struct ima_template_field ***fields, int *num_fields){ const char *template_fmt_ptr; struct ima_template_field *found_fields[IMA_TEMPLATE_NUM_FIELDS_MAX]; int template_num_fields = template_fmt_size(template_fmt); int i, len; if (template_num_fields > IMA_TEMPLATE_NUM_FIELDS_MAX) { pr_err("format string '%s' contains too many fields/n", template_fmt); return -EINVAL; } for (i = 0, template_fmt_ptr = template_fmt; i < template_num_fields; i++, template_fmt_ptr += len + 1) { char tmp_field_id[IMA_TEMPLATE_FIELD_ID_MAX_LEN + 1]; len = strchrnul(template_fmt_ptr, '|') - template_fmt_ptr; if (len == 0 || len > IMA_TEMPLATE_FIELD_ID_MAX_LEN) { pr_err("Invalid field with length %d/n", len); return -EINVAL; } memcpy(tmp_field_id, template_fmt_ptr, len); tmp_field_id[len] = '/0'; found_fields[i] = lookup_template_field(tmp_field_id); if (!found_fields[i]) { pr_err("field '%s' not found/n", tmp_field_id); return -ENOENT; } } if (fields && num_fields) { *fields = kmalloc_array(i, sizeof(*fields), GFP_KERNEL); if (*fields == NULL) return -ENOMEM; memcpy(*fields, found_fields, i * sizeof(*fields)); *num_fields = i; } return 0;}
开发者ID:19Dan01,项目名称:linux,代码行数:45,
示例20: dnsmasqCapsSetFromBufferstatic intdnsmasqCapsSetFromBuffer(dnsmasqCapsPtr caps, const char *buf){ const char *p; caps->noRefresh = true; p = STRSKIP(buf, DNSMASQ_VERSION_STR); if (!p) goto fail; virSkipSpaces(&p); if (virParseVersionString(p, &caps->version, true) < 0) goto fail; if (strstr(buf, "--bind-dynamic")) dnsmasqCapsSet(caps, DNSMASQ_CAPS_BIND_DYNAMIC); /* if this string is a part of the --version output, dnsmasq * has been patched to use SO_BINDTODEVICE when listening, * so that it will only accept requests that arrived on the * listening interface(s) */ if (strstr(buf, "--bind-interfaces with SO_BINDTODEVICE")) dnsmasqCapsSet(caps, DNSMASQ_CAPS_BINDTODEVICE); if (strstr(buf, "--ra-param")) dnsmasqCapsSet(caps, DNSMASQ_CAPS_RA_PARAM); VIR_INFO("dnsmasq version is %d.%d, --bind-dynamic is %spresent, " "SO_BINDTODEVICE is %sin use, --ra-param is %spresent", (int)caps->version / 1000000, (int)(caps->version % 1000000) / 1000, dnsmasqCapsGet(caps, DNSMASQ_CAPS_BIND_DYNAMIC) ? "" : "NOT ", dnsmasqCapsGet(caps, DNSMASQ_CAPS_BINDTODEVICE) ? "" : "NOT ", dnsmasqCapsGet(caps, DNSMASQ_CAPS_RA_PARAM) ? "" : "NOT "); return 0; fail: p = strchrnul(buf, '/n'); virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse %s version number in '%.*s'"), caps->binaryPath, (int) (p - buf), buf); return -1;}
开发者ID:Archer-sys,项目名称:libvirt,代码行数:45,
示例21: add_branch_descstatic void add_branch_desc(struct strbuf *out, const char *name){ struct strbuf desc = STRBUF_INIT; if (!read_branch_desc(&desc, name)) { const char *bp = desc.buf; while (*bp) { const char *ep = strchrnul(bp, '/n'); if (*ep) ep++; strbuf_addf(out, " : %.*s", (int)(ep - bp), bp); bp = ep; } if (out->buf[out->len - 1] != '/n') strbuf_addch(out, '/n'); } strbuf_release(&desc);}
开发者ID:CCorreia,项目名称:git,代码行数:18,
示例22: parse_userstatic void parse_user(const char *t, char **name, char **email, unsigned long *date, int *tz){ struct ident_split ident; unsigned email_len; if (!split_ident_line(&ident, t, strchrnul(t, '/n') - t)) { *name = substr(ident.name_begin, ident.name_end); email_len = ident.mail_end - ident.mail_begin; *email = xmalloc(strlen("<") + email_len + strlen(">") + 1); sprintf(*email, "<%.*s>", email_len, ident.mail_begin); if (ident.date_begin) *date = strtoul(ident.date_begin, NULL, 10); if (ident.tz_begin) *tz = atoi(ident.tz_begin); }}
开发者ID:tim-nordell-lpd,项目名称:cgit,代码行数:18,
示例23: advisevoid advise(const char *advice, ...){ struct strbuf buf = STRBUF_INIT; va_list params; const char *cp, *np; va_start(params, advice); strbuf_vaddf(&buf, advice, params); va_end(params); for (cp = buf.buf; *cp; cp = np) { np = strchrnul(cp, '/n'); fprintf(stderr, _("hint: %.*s/n"), (int)(np - cp), cp); if (*np) np++; } strbuf_release(&buf);}
开发者ID:LinTeX9527,项目名称:git,代码行数:18,
示例24: strbuf_resetstatic const char *quote_literal_for_format(const char *s){ static struct strbuf buf = STRBUF_INIT; strbuf_reset(&buf); while (*s) { const char *ep = strchrnul(s, '%'); if (s < ep) strbuf_add(&buf, s, ep - s); if (*ep == '%') { strbuf_addstr(&buf, "%%"); s = ep + 1; } else { s = ep; } } return buf.buf;}
开发者ID:KarthikNayak,项目名称:git,代码行数:18,
示例25: is_in_comma_separated_list_of_glob_patternsbool is_in_comma_separated_list_of_glob_patterns(const char *value, const char *list){ if (!list) return false; while (*list) { const char *comma = strchrnul(list, ','); char *pattern = xstrndup(list, comma - list); int match = !fnmatch(pattern, value, /*flags:*/ 0); free(pattern); if (match) return true; if (!*comma) break; list = comma + 1; } return false;}
开发者ID:abrt,项目名称:libreport,代码行数:18,
示例26: _cs_matches_filter_static int32_t_cs_matches_filter_(struct qb_log_callsite *cs, enum qb_log_filter_type type, const char *text, uint8_t high_priority, uint8_t low_priority){ int32_t match = QB_FALSE; if (cs->priority > low_priority || cs->priority < high_priority) { return QB_FALSE; } if (strcmp(text, "*") == 0) { return QB_TRUE; } if (type == QB_LOG_FILTER_FILE || type == QB_LOG_FILTER_FUNCTION) { char token[500]; const char *offset = NULL; const char *next = text; do { offset = next; next = strchrnul(offset, ','); snprintf(token, 499, "%.*s", (int)(next - offset), offset); if (type == QB_LOG_FILTER_FILE) { match = (strstr(cs->filename, token) != NULL); } else { match = (strstr(cs->function, token) != NULL); } if (!match && next[0] != 0) { next++; } } while (match == QB_FALSE && next != NULL && next[0] != 0); } else if (type == QB_LOG_FILTER_FORMAT) { if (strstr(cs->format, text)) { match = QB_TRUE; } } return match;}
开发者ID:lkunemail,项目名称:libqb,代码行数:44,
示例27: cmdline_tokenizestatic void cmdline_tokenize(Cmdline *cmdline){ char ch[] = {0,'/0'}; int st, ed, pos; char *str = cmdline->line; bool esc = false; st = ed = pos = 0; for (;;) { ch[0] = str[pos++]; if (ch[0] == '/0') { create_token(cmdline->tokens, str, st, ed, false); break; } else if (ch[0] == '//' && !esc) { esc = true; continue; } else if ((ch[0] == '/"' || ch[0] == '/'') && !esc) { char *closech = strchrnul(&str[pos], ch[0]); if (closech[-1] != '//') { int end = (closech - &str[pos]) + pos; bool quote = str[end] == '/0'; pos = quote ? pos-1 : pos; create_token(cmdline->tokens, str, pos, end, !quote); st = pos = quote ? end : ++end; } } else if (strpbrk(ch, TOKENCHARS) && !esc) { create_token(cmdline->tokens, str, st, ed, false); if (*ch != ' ') { create_token(cmdline->tokens, str, pos-1, pos, false); ed = pos; } st = pos; } else ed = pos; esc = false; } cmdline->cont = esc;}
开发者ID:jollywho,项目名称:nav,代码行数:44,
注:本文中的strchrnul函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ strclone函数代码示例 C++ strchr函数代码示例 |