这篇教程C++ xstrlen函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中xstrlen函数的典型用法代码示例。如果您正苦于以下问题:C++ xstrlen函数的具体用法?C++ xstrlen怎么用?C++ xstrlen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了xstrlen函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: bsubst// bsubst rewites b to replace all occurrences of x with y.voidbsubst(Buf *b, char *x, char *y){ char *p; int nx, ny, pos; nx = xstrlen(x); ny = xstrlen(y); pos = 0; for(;;) { p = xstrstr(bstr(b)+pos, x); if(p == nil) break; if(nx != ny) { if(nx < ny) { pos = p - b->p; bgrow(b, ny-nx); p = b->p + pos; } xmemmove(p+ny, p+nx, (b->p+b->len)-(p+nx)); } xmemmove(p, y, ny); pos = p+ny - b->p; b->len += ny - nx; }}
开发者ID:29decibel,项目名称:golang,代码行数:28,
示例2: n2a_event_host_checkintn2a_event_host_check (int event_type __attribute__ ((__unused__)), void *data){ //logger(LG_DEBUG, "Event: event_service_check"); nebstruct_host_check_data *c = (nebstruct_host_check_data *) data; if (c->type == NEBTYPE_HOSTCHECK_PROCESSED) { //logger(LG_DEBUG, "HOSTCHECK_PROCESSED: %s", c->host_name); char *buffer = NULL, *key = NULL; size_t l = xstrlen(g_options.connector) + xstrlen(g_options.eventsource_name) + xstrlen(c->host_name) + 20; nebstruct_host_check_data_to_json(&buffer, c); // DO NOT FREE !!! xalloca(key, xmin(g_options.max_size, (int)l) * sizeof(char)); snprintf(key, xmin(g_options.max_size, (int)l), "%s.%s.check.component.%s", g_options.connector, g_options.eventsource_name, c->host_name); if (c_size == -10000 || c_size / 2 == 0) amqp_publish(key, buffer); else n2a_record_cache (key, buffer); xfree(buffer); } return 0;}
开发者ID:damirboss,项目名称:canopsis-nagios,代码行数:32,
示例3: mod_insertstatic int mod_insert ( char *mod, int argc, char **argv ){ struct mod_list_t *tail = 0; struct mod_list_t *head = 0; int rc = 0; // get dep list for module mod check_dep ( mod, &head, &tail ); if ( head && tail ) { int i; int l = 0; // append module args l = xstrlen ( head-> m_module ); for ( i = 0; i < argc; i++ ) l += ( xstrlen ( argv [i] ) + 1 ); head-> m_module = xrealloc ( head-> m_module, l + 1 ); for ( i = 0; i < argc; i++ ) { strcat ( head-> m_module, " " ); strcat ( head-> m_module, argv [i] ); } // process tail ---> head rc |= mod_process ( tail, 1 ); } else rc = 1; return rc;}
开发者ID:zipangotes,项目名称:DSL-G624T_GPL_code,代码行数:33,
示例4: mainmain(int argc, string argv[]){ int i; long lstr[32], *lcop; stream opt, ipt; for (i = 0; i < 32; i++) lstr[i] = (i < 21 ? 12345 + 512 * i : (int) NULL); printf("xstrlen(lstr, %d) == %d/n", sizeof(long), xstrlen(lstr, sizeof(long))); lcop = (long *) copxstr(lstr, sizeof(long)); printf("xstrlen(lcop, %d) == %d/n", sizeof(long), xstrlen(lcop, sizeof(long))); printf("xstreq(lstr, lcop, %d) == %d/n", sizeof(long), xstreq(lstr, lcop, sizeof(long))); printf("changing *lcop/n"); *lcop = -1; printf("xstreq(lstr, lcop, %d) == %d/n", sizeof(long), xstreq(lstr, lcop, sizeof(long))); opt = stropen("foobar.dat", "w!"); printf("putxstr(opt, lstr, %d) == %d/n", sizeof(long), putxstr(opt, lstr, sizeof(long))); printf("putxstr(opt, lcop, %d) == %d/n", sizeof(long), putxstr(opt, lcop, sizeof(long))); fclose(opt); ipt = stropen("foobar.dat", "r"); lcop = (long *) getxstr(ipt, sizeof(long)); if (lcop == NULL) printf("getxstr(ipt, %d) failed/n", sizeof(long)); printf("xstreq(lstr, lcop, %d) == %d/n", sizeof(long), xstreq(lstr, lcop, sizeof(long)));}
开发者ID:jasminegrosso,项目名称:zeno,代码行数:32,
示例5: xreallocchar *plv(char *msg, t_player *player){ msg = xrealloc(msg, (xstrlen(msg) + 19) * sizeof(char)); snprintf(msg + xstrlen(msg), 19, "plv %i %i/n", player->player_id, player->level); return (msg);}
开发者ID:Surogate,项目名称:epi-pizza,代码行数:7,
示例6: xststr//int xstrstr(char *base,char *pattern)int xststr(){int len1=xstrlen(base);int len2=xstrlen(pattern);if(len1<len2) return -1;if(len1==0 || len2==0) return -1;int index=0,i=0,j=0;for(i=0;i<len1;i++){ if(base[i]==pattern[0]) { index=i; for(j=1;j<len2;j++) { if(base[i]!=pattern[j]) break; } if(pattern[j]=='/0') return index; else { i-=j; j=0; } } } return -1; }
开发者ID:kodingmach12,项目名称:MyCodes,代码行数:30,
示例7: tableSetint tableSet(PTable t,const pchar Name,const pchar Value){ PTablePage p=t->pFirst,q; int idx0,idx=0,res=0; p=tableFind(p,&idx,Name); if(p) { q=p;idx0=idx; while((p=tableFind(p,&idx,Name))) { if(t->iFlags&TABLE_FLAG_ALLOCNAME)xfree(p->Values[idx].szName); if(t->iFlags&TABLE_FLAG_ALLOCVALUE)xfree(p->Values[idx].szValue); if(idx!=p->iCount-1)memmove(&p->Values[idx],&p->Values[idx+1],sizeof(SAttr)*(p->iCount-idx-1)); p->iCount--; t->iCount--; res++; } if(res)t->iHoles++; if(t->iFlags&TABLE_FLAG_ALLOCVALUE)xfree(q->Values[idx].szValue); if(xstrlen(q->Values[idx0].szValue)>=xstrlen(Value)) xstrcpy(q->Values[idx0].szValue,Value); else q->Values[idx0].szValue=xstrdup(t->pPool,Value); return t->iCount; }else return tableAdd(t,Name,Value);}
开发者ID:Maximus5,项目名称:evil-programmers,代码行数:26,
示例8: starts_withstatic bool starts_with(const xmlChar *str, const xmlChar *prefix){ size_t prefix_len = xstrlen(prefix), str_len = xstrlen(str); return str_len < prefix_len ? FALSE : xstrncmp(prefix, str, prefix_len) == 0;}
开发者ID:JATS4R,项目名称:xml.js,代码行数:8,
示例9: add_tagstatic void add_tag(ani_request_t *request){ static int counter = 0; assert(NULL != request); (void)snprintf(request->tag, TAG_LEN, "tag%d", counter++); (void)strncat(request->msg, "&tag=", RAW_LEN - xstrlen(request->msg)); (void)strncat(request->msg, request->tag, RAW_LEN - xstrlen(request->msg));}
开发者ID:ameingast,项目名称:libanidb,代码行数:9,
示例10: xmlSetItemContentvoid xmlSetItemContent(void *Pool,PXMLNode x,pchar Content){ if(!x)return; if(xstrlen(x->szCont)>=xstrlen(Content)) xstrcpy(x->szCont,Content); else x->szCont=xstrdup(Pool,Content); if(x->eType==xmlEmpty)x->eType=xmlLeaf;}
开发者ID:Maximus5,项目名称:evil-programmers,代码行数:9,
示例11: add_sessionstatic void add_session(ani_request_t *request){ const char *session = ani_session(); assert(NULL != request); if (NULL != session && '/0' != *session) { (void)xstrncpy(request->session, session, SESSION_LEN); (void)strncat(request->msg, "&s=", RAW_LEN - xstrlen(request->msg)); (void)strncat(request->msg, request->session, RAW_LEN - xstrlen(request->msg)); }}
开发者ID:ameingast,项目名称:libanidb,代码行数:14,
示例12: filtername/* * return the full path to a filter based on a short name * or, if the shortname is the full path, return itself */string filtername(string shortname){ int nsp; static char fullname[256]; char line[MAX_LINELEN]; string *sp, fpath; stream fstr; if (nemo_file_size(shortname) > 0) return shortname; fpath = getenv("NEMODAT"); if (fpath == 0) error("NEMODAT does not exist"); sprintf(fullname,"%s/filter/Fnames",fpath); dprintf(1,"Alias table %s/n",fullname); fstr = stropen(fullname,"r"); while (fgets(line,MAX_LINELEN,fstr)) { if (line[0] == '#') continue; sp = burststring(line," /n"); nsp = xstrlen(sp,sizeof(sp))-1; if (nsp > 1) { if (streq(shortname,sp[0])) { sprintf(fullname,"%s/filter/%s",fpath,sp[1]); dprintf(1,"Matching %s/n",fullname); freestrings(sp); return fullname; } } freestrings(sp); } return shortname;}
开发者ID:Milkyway-at-home,项目名称:nemo,代码行数:36,
示例13: wrap_linestatic int wrap_line(window_t *w, int width, char *str, fstr_attr_t *attr, int *last_space) { int i, j, eat, printed, len = xstrlen(str); if (len==0 || xmbswidth(str, len)<width || width < 1) return len; if (w->nowrap) return break_word(str, width); for (i=0, printed=0; printed <= width && i < len; printed += j, i += eat) { j = get_word_width(str+i, attr+i, &eat); if (printed + j <= width) continue; if (printed+j == width+1 && str[i+eat-1]==' ') { *last_space = 1; return i + eat - 1; } else if (i==0) { return break_word(str, width); } else if ((j > width) && (width-printed>8)) { return i + break_word(str+i, width-printed); } return i; } return len;}
开发者ID:hiciu,项目名称:ekg2,代码行数:27,
示例14: break_wordstatic int break_word(gchar *str, int width) { size_t i; int len = xstrlen(str);#if USE_UNICODE int sum = 0; mbtowc(NULL, NULL, 0); for (i = 0; i < len && sum<width; ) { wchar_t ch; int ch_len = mbtowc(&ch, &str[i], len - i); if (ch_len!=-1) { int wc_width = wcwidth(ch); if (wc_width == -1) wc_width = 1; if (sum + wc_width > width) break; sum += wc_width; i += ch_len; } else { i++; sum++; } }#else i = (len>=width ? width : len);#endif return i;}
开发者ID:hiciu,项目名称:ekg2,代码行数:30,
示例15: IS_TRUE0/*Return VAR if there is already related to 's',otherwise create a new VAR.'var_name': name of the variable, it is optional.'s': string's content.*/VAR * VAR_MGR::register_str(CHAR const* var_name, SYM * s, UINT align){ IS_TRUE0(s != NULL); VAR * v; if ((v = m_str_tab.get(s)) != NULL) { return v; } v = new_var(); CHAR buf[64]; if (var_name == NULL) { sprintf(buf, ".rodata_%zu", m_str_count++); VAR_name(v) = m_ru_mgr->add_to_symtab(buf); } else { VAR_name(v) = m_ru_mgr->add_to_symtab(var_name); } VAR_str(v) = s; VAR_data_type(v) = D_STR; VAR_elem_type(v) = D_UNDEF; IS_TRUE0(sizeof(CHAR) == 1); VAR_data_size(v) = xstrlen(SYM_name(s)) + 1; VAR_align(v) = align; VAR_is_global(v) = 1; //store in .data or .rodata assign_var_id(v); m_str_tab.set(s, v); return v;}
开发者ID:Grainspring,项目名称:xoc,代码行数:33,
示例16: nemoinpxint nemoinpx( char *expr, double *a, int na){ int nret, ncomp; string *vals, *comp; vals = burststring(expr,","); for (nret=0; vals[nret] != NULL; nret++) { if (nret>=na) return -23; comp = burststring(vals[nret],":"); ncomp = xstrlen(comp,sizeof(string))-1; if (ncomp < 1 || ncomp > 3) return -13; a[nret] = atof(comp[0]); if (ncomp==1) continue; a[nret] += atof(comp[1])/60.0; if (ncomp==2) continue; a[nret] += atof(comp[2])/3600.0; freestrings(comp); } freestrings(vals); return nret;}
开发者ID:Milkyway-at-home,项目名称:nemo,代码行数:26,
示例17: watch_writeint watch_write(watch_t *w, const char *format, ...) { /* XXX, refactory: watch_writef() */ char *text; int textlen; va_list ap; int res; if (!w || !format) return -1; va_start(ap, format); text = vsaprintf(format, ap); va_end(ap); textlen = xstrlen(text); debug_io("[watch]_send: %s/n", text ? textlen ? text: "[0LENGTH]":"[FAILED]"); if (!text) return -1; res = watch_write_data(w, text, textlen); xfree(text); return res;}
开发者ID:dmilith,项目名称:ekg2-bsd,代码行数:25,
示例18: convertlocal void convert(stream instr, stream outstr){ char line[MAX_LINELEN]; /* input linelength */ int i, nlines, noutv; string *outv; /* pointer to vector of strings to write */ char *cp, *seps=", /t"; /* column separators */ nlines=0; /* count lines read so far */ for (;;) { if (get_line(instr, line) < 0) /* EOF */ return; dprintf(3,"LINE: (%s)/n",line); if (iscomment(line)) continue; nlines++; tab2space(line); /* work around a Gipsy (?) problem */ outv = burststring(line,seps); noutv = xstrlen(outv,sizeof(string)) - 1; if (noutv < maxcol) error("Too few columns in input file (%d < %d)",noutv,maxcol); if (Qall) nkeep = noutv; for (i=0; i<nkeep; i++) { if (keep[i] == 0) fprintf(outstr,"%d",nlines); else fprintf(outstr,"%s",outv[keep[i]-1]); if (i < nkeep-1) fprintf(outstr,"%c",colsep); } if (colsep != 'n') fprintf(outstr,"/n"); /* end of line */ }}
开发者ID:Milkyway-at-home,项目名称:nemo,代码行数:35,
示例19: debugstatic logs_log_t *logs_log_new(logs_log_t *l, const char *session, const char *uid) { logs_log_t *ll; int created = 0; debug("[logs] log_new uid = %s session %s", __(uid), __(session)); ll = l ? l : logs_log_find(session, uid, 0); debug(" logs_log_t %x/n", ll); if (!ll) { ll = xmalloc(sizeof(logs_log_t)); ll->session = xstrdup(session); ll->uid = xstrdup(uid); created = 1; } if (!(ll->lw)) { ll->lw = xmalloc(sizeof(log_window_t)); logs_window_check(ll, time(NULL)); /* l->log_format i l->path, l->t */ ll->lw->file = logs_open_file(ll->lw->path, ll->lw->logformat); } if (created) { if (ll->lw->logformat == LOG_FORMAT_IRSSI && xstrlen(IRSSI_LOG_EKG2_OPENED)) { logs_irssi(ll->lw->file, session, NULL, prepare_timestamp_format(IRSSI_LOG_EKG2_OPENED, time(NULL)), 0, EKG_MSGCLASS_SYSTEM); } list_add(&log_logs, ll); } return ll;}
开发者ID:11mariom,项目名称:ekg2,代码行数:31,
示例20: debugPyObject *ekg_cmd_plugin_get(PyObject * self, PyObject * pyargs){ ekg_pluginObj *pyplugin; plugin_t *p; char *name = NULL; int prio = -1; if (!PyArg_ParseTuple(pyargs, "s:plugin_get", &name)) return NULL; debug("[python] checking for plugin '%s'/n", name); p = plugin_find(name); if (p) { prio = p->prio; } debug("[python] Building object for plugin '%s'/n", name); pyplugin = PyObject_New(ekg_pluginObj, &ekg_plugin_type); pyplugin->loaded = prio < 0 ? 0 : 1; pyplugin->prio = prio < 0 ? 0 : prio; pyplugin->name = xmalloc(xstrlen(name)+1); xstrcpy(pyplugin->name, name); Py_INCREF(pyplugin); return (PyObject *)pyplugin;}
开发者ID:dmilith,项目名称:ekg2-bsd,代码行数:26,
示例21: mainint main(){ char input[11];int test;int l;int i=0;int flag=0; scanf("%d",&test); while(test--) {scanf("%s",input); l = xstrlen(input); // printf("%d/n",l); while(i<l){ if(input[i]==input[l-i-1]) { flag++; } i++; } //printf("flag = %d/n",flag); if(flag == l) printf("YES/n"); else printf("NO/n"); memset(input,0,10); i=0;flag=0; } return 0;//system("pause");}
开发者ID:rajarshisarkar,项目名称:Competitive-Coding,代码行数:31,
示例22: g_checksum_newchar *jabber_dcc_digest(char *sid, char *initiator, char *target) { GChecksum *ctx; unsigned char digest[20]; static char result[41]; gsize i, dsize; ctx = g_checksum_new(G_CHECKSUM_SHA1); g_checksum_update(ctx, (const guchar *)sid, xstrlen(sid)); g_checksum_update(ctx, (const guchar *)initiator, xstrlen(initiator)); g_checksum_update(ctx, (const guchar *)target, xstrlen(target)); g_checksum_get_digest(ctx, digest, &dsize); for (i = 0; i < 20; i++) sprintf(result + i * 2, "%.2x", digest[i]); return result;}
开发者ID:hiciu,项目名称:ekg2,代码行数:17,
示例23: mainvoid main(){int l;char string[]="haha";l=xstrlen(string);printf("%d",l);getch();}
开发者ID:dush1729,项目名称:Pacman,代码行数:8,
示例24: xstrlenchar *update_txtbox(char *str, SDL_KeyboardEvent *event){ int len; char *tmp; // enter 13 + numpad 271 // bksp = 8 // esc = 27 len = xstrlen(str); if (event->keysym.sym >= ' ' && event->keysym.sym <= '~') { tmp = (char*)xmalloc(len + 2); xstrncpy(tmp, str, len); tmp[len] = event->keysym.sym; tmp[len + 1] = 0; free(str); str = tmp; } else if (event->keysym.sym == 266) { tmp = (char*)xmalloc(len + 2); xstrncpy(tmp, str, len); tmp[len] = '.'; tmp[len + 1] = 0; free(str); str = tmp; } else if (event->keysym.sym >= 256 && event->keysym.sym <= 265) { tmp = (char*)xmalloc(len + 2); xstrncpy(tmp, str, len); tmp[len] = (event->keysym.sym - 256 + '0'); tmp[len + 1] = 0; free(str); str = tmp; } else if (event->keysym.sym == 27) gfx->win->focus = -1; else if (event->keysym.sym == 8) { if (len > 1) { tmp = xstrndup(str, len - 1); free(str); str = tmp; } else if (len == 1) { free(str); str = 0; } else if (!str) printf("%c", 7); } return (str);}
开发者ID:BackupTheBerlios,项目名称:freewar-svn,代码行数:58,
示例25: nemo_mainvoid nemo_main(){ int n; stream parstr, outstr; string molfile = getparam("mol"); string outfile = getparam("out"); string outdir = getparam("outdir"); string exefile = "radex"; string datfile = "mol.dat"; string parfile = "input.txt"; string logfile = "radex.txt"; char dname[256], cmd[256]; real fmin = getdparam("fmin"); real fmax = getdparam("fmax"); real tkin = getdparam("tkin"); int npartner; string *partner; real density[MAXPARTNER]; real tbg = getdparam("tbg"); real cdmol = getdparam("cdmol"); real deltav = getdparam("deltav"); partner = burststring(getparam("partner"),","); npartner = xstrlen(partner,sizeof(string))-1; if (npartner < 1 || npartner>MAXPARTNER) error("too few/many partners"); n = nemoinpr(getparam("density"),density,MAXPARTNER); if (n != npartner) error("need matching numbers for partner= and density="); run_mkdir(outdir); sprintf(dname,"%s/%s",outdir,parfile); parstr = stropen(dname,"w"); fprintf(parstr,"%s/n",molfile); fprintf(parstr,"%s/n",outfile); fprintf(parstr,"%g %g/n",fmin,fmax); fprintf(parstr,"%g/n",tkin); fprintf(parstr,"%d/n",npartner); for (n=0; n<npartner; n++) { fprintf(parstr,"%s/n",partner[n]); fprintf(parstr,"%g/n",density[n]); } fprintf(parstr,"%g/n",tbg); fprintf(parstr,"%g/n",cdmol); fprintf(parstr,"%g/n",deltav); fprintf(parstr,"0/n"); strclose(parstr); run_cd(outdir); sprintf(cmd,"%s < %s > %s ", exefile, parfile, logfile); run_sh(cmd);}
开发者ID:jobovy,项目名称:nemo,代码行数:57,
示例26: count_chars/* Count the number of times a character occurs in a string. */static int count_chars(const xmlChar* string, char ch) { int count = 0; int length = xstrlen(string); for (int i = 0; i < length; ++i) { if (string[i] == ch) count++; } return count;}
开发者ID:JATS4R,项目名称:xml.js,代码行数:10,
注:本文中的xstrlen函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ xstrncpy函数代码示例 C++ xstrfmt函数代码示例 |