这篇教程C++ strncpy0函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中strncpy0函数的典型用法代码示例。如果您正苦于以下问题:C++ strncpy0函数的具体用法?C++ strncpy0怎么用?C++ strncpy0使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了strncpy0函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: pressed_file_configurevoid pressed_file_configure(){ spawn_dd tdata; spawn_row *rp; char txt[64], *s; int i, j; rp = tdata.strs = calloc(FACTION_ROWS_TOTAL, sizeof(spawn_row)); if (!rp) return; // Not enough memory for (i = 1; i <= FACTION_ROWS_TOTAL; i++ , rp++) { for (j = 0; j < 3; j++) { sprintf(txt, faction_ini[j], i); s = inifile_get(txt, ""); if (!j) strncpy0(rp->name, s, sizeof(rp->name)); else if (j == 1) gtkuncpy(rp->cmd, s, sizeof(rp->cmd)); else strncpy0(rp->dir, s, sizeof(rp->dir)); } } tdata.name = tdata.cmd = ""; tdata.dir[0] = '/0'; tdata.idx = -1; tdata.nidx = 0; tdata.cnt = FACTION_ROWS_TOTAL; tdata.lock = FALSE; run_create(spawn_code, &tdata, sizeof(tdata));}
开发者ID:matyler,项目名称:mtPaint,代码行数:31,
示例2: s_AdjustNetParamsstatic const char* s_AdjustNetParams(const char* service, SConnNetInfo* net_info, EReqMethod req_method, const char* cgi_path, const char* cgi_args, const char* args, const char* static_header, EMIME_Type mime_t, EMIME_SubType mime_s, EMIME_Encoding mime_e, char* dynamic_header/*freed!*/){ const char *retval = 0; net_info->req_method = req_method; if (cgi_path) strncpy0(net_info->path, cgi_path, sizeof(net_info->path) - 1); if (args) strncpy0(net_info->args, args, sizeof(net_info->args) - 1); ConnNetInfo_DeleteAllArgs(net_info, cgi_args); if (ConnNetInfo_PrependArg(net_info, cgi_args, 0)) { size_t sh_len = static_header ? strlen(static_header) : 0; size_t dh_len = dynamic_header ? strlen(dynamic_header) : 0; char c_t[MAX_CONTENT_TYPE_LEN]; size_t ct_len, len; if (s_IsContentTypeDefined(service, net_info, mime_t, mime_s, mime_e) || !MIME_ComposeContentTypeEx(mime_t, mime_s, mime_e, c_t, sizeof(c_t))) { c_t[0] = '/0'; ct_len = 0; } else ct_len = strlen(c_t); if ((len = sh_len + dh_len + ct_len) != 0) { char* temp = (char*) malloc(len + 1/*EOL*/); if (temp) { strcpy(temp, static_header ? static_header : ""); strcpy(temp + sh_len, dynamic_header ? dynamic_header : ""); strcpy(temp + sh_len + dh_len, c_t); retval = temp; } } else retval = ""; } if (dynamic_header) free(dynamic_header); return retval;}
开发者ID:hsptools,项目名称:hsp-wrap,代码行数:52,
示例3: s_GetSysinfo/*ARGSUSED*/static const SLBSM_Sysinfo* s_GetSysinfo(const HOST_INFO hinfo, int/*bool*/ warn){ const SLBSM_Sysinfo* si = (const SLBSM_Sysinfo*)((const char*) hinfo + sizeof(*hinfo)); assert(hinfo);#if defined(_DEBUG) && !defined(NDEBUG) && defined(NETDAEMONS_VERSION_INT) if (si->data.version < NETDAEMONS_VERSION_INT && warn) { static int s_Warn = 0; if (s_Warn < 20) { char addr[64]; if (SOCK_ntoa(hinfo->addr, addr, sizeof(addr)) != 0) strncpy0(addr, "unknown", sizeof(addr) - 1); CORE_LOGF(s_Warn++ < 5 ? eLOG_Warning : eLOG_Trace, ("HINFO may be incorrect for obsolete daemon on %s" " (detected=%hu.%hu.%hu, expected=%s+)", addr, NETDAEMONS_MAJOR_OF(si->data.version), NETDAEMONS_MINOR_OF(si->data.version), NETDAEMONS_PATCH_OF(si->data.version), NETDAEMONS_VERSION_STR)); } }#endif /*_DEBUG && !NDEBUG && NETDAEMONS_VERSION_INT*/ return si;}
开发者ID:timothyjlaurent,项目名称:nacl_blast,代码行数:26,
示例4: ProReadAuthOrgan/* * 函数功能:读取授权机构代码 * 入口参数:无 * 出口参数:无 * 返 回 值:NORMAL--成功 * EXCEPTION--失败 */int ProReadAuthOrgan(void){ char szBuffer[30]; char cRet; int nLen; if(strlen(TlvSendValue.szAuthOrgan)>0) { BUFCLR(szBuffer); memcpy(szBuffer,TlvSendValue.szAuthOrgan,11); } else { PubClearAll(); PubDisplay(2, "输入授权机构代码:"); BUFCLR(szAuthOrgan); do { BUFCLR(szBuffer); cRet = PubGetNStr(4, 0, szBuffer, 11); nLen = strlen(szBuffer); if (cRet == CANCELED||cRet == APPTIMEOUT) return EXCEPTION; } while (nLen != 11); }// strcpy(szAuthOrgan, szBuffer); strncpy0(szAuthOrgan, szBuffer, sizeof(szAuthOrgan)); return NORMAL;}
开发者ID:chengzhang-90,项目名称:JSYLSW,代码行数:38,
示例5: sync_espeak_Synth_Markespeak_ERROR sync_espeak_Synth_Mark(unsigned int unique_identifier, const void *text, size_t size, const char *index_mark, unsigned int end_position, unsigned int flags, void* user_data){//========================================================================= espeak_ERROR aStatus; InitText(flags); my_unique_identifier = unique_identifier; my_user_data = user_data; if(index_mark != NULL) { strncpy0(skip_marker, index_mark, sizeof(skip_marker)); skipping_text = 1; } end_character_position = end_position; aStatus = Synthesize(unique_identifier, text, flags | espeakSSML); SHOW_TIME("LEAVE sync_espeak_Synth_Mark"); return (aStatus);} // end of sync_espeak_Synth_Mark
开发者ID:alltoy,项目名称:espeak,代码行数:25,
示例6: fpick_cleanse_path/* !!! Expects that "txt" points to PATHBUF-sized buffer */static void fpick_cleanse_path(char *txt) // Clean up null terminated path{ char *src, *dest;#ifdef WIN32 // Unify path separators reseparate(txt);#endif // Expand home directory if ((txt[0] == '~') && (txt[1] == DIR_SEP)) { src = file_in_homedir(NULL, txt + 2, PATHBUF); strncpy0(txt, src, PATHBUF - 1); free(src); } // Remove multiple consecutive occurences of DIR_SEP if ((dest = src = strstr(txt, DIR_SEP_STR DIR_SEP_STR))) { while (*src) { if (*src == DIR_SEP) while (src[1] == DIR_SEP) src++; *dest++ = *src++; } *dest++ = '/0'; }}
开发者ID:matyler,项目名称:mtPaint,代码行数:27,
示例7: getTrackBuffervoid CDROM::startTrack(const char *trackName) { if (!_LICbuffer) return; byte *matchPtr = getTrackBuffer(trackName); if (!matchPtr) { warning("CDROM: Track /"%s/" not found", trackName); return; } strncpy0(_curTrack, trackName, 15); stopPlaying(); _curTrackBuffer = matchPtr; while (getTrackPos() >= 0) ; uint32 start = READ_LE_UINT32(matchPtr + 12); uint32 end = READ_LE_UINT32(matchPtr + 16); play(start, end); _startTime = g_system->getMillis(); _trackStop = _startTime + (end - start + 1 + 150) * 40 / 3;}
开发者ID:havlenapetr,项目名称:Scummvm,代码行数:26,
示例8: ProReadAuthOrgan/* * 函数功能:读取授权机构代码 * 入口参数:无 * 出口参数:无 * 返 回 值:NORMAL--成功 * EXCEPTION--失败 */int ProReadAuthOrgan(void){ char szBuffer[30]; char cRet; int nLen; PubClearAll(); PubDisplay(2, "输入授权机构代码:"); BUFCLR(szAuthOrgan); do { BUFCLR(szBuffer); cRet = PubGetNStr(4, 0, szBuffer, 11); nLen = strlen(szBuffer); if (cRet == CANCELED||cRet == APPTIMEOUT) return EXCEPTION;//add by baijz 20120625 if(nLen == 11) break; PubDisplay(2, "位数不足,请重输:"); PubDisplay(4, "");//add end } while (nLen != 11);// strcpy(szAuthOrgan, szBuffer); strncpy0(szAuthOrgan, szBuffer, sizeof(szAuthOrgan)); return NORMAL;}
开发者ID:chengzhang-90,项目名称:RCBANK,代码行数:37,
示例9: osip_boot_helperstatic intosip_boot_helper( int sel, int *args ){ char *ustr, *s, *p, *buf; switch( args[0] ) { case kBootHAscii2Unicode: /* unicode_dest, src, maxlen -- uni_strlen */ ustr = transl_mphys( args[1] ); s = transl_mphys( args[2] ); if( !ustr || !s ) return -1; return asc2uni( (unsigned char *)ustr, s, args[3] ); case kBootHUnicode2Ascii: /* dest, uni_str, uni_strlen, maxlen -- strlen */ s = transl_mphys( args[1] ); ustr = transl_mphys( args[2] ); if( !ustr || !s ) return -1; return uni2asc( s, (unsigned char *)ustr, args[3], args[4] ); case kBootHGetStrResInd: /* resname, buf, len, index, argnum */ p = transl_mphys( args[1] ); buf = transl_mphys( args[2] ); if( !p || !(s=get_str_res_ind(p,args[4],args[5])) ) return 0; if( args[2] && buf ) strncpy0( buf, s, args[3] ); return args[2]; case kBootHGetRAMSize: return ram.size; } return -1;}
开发者ID:threader,项目名称:Mac-On-Linux,代码行数:34,
示例10: fpick_scan_directory/* Scan directory, populate widgets; return 1 if success, 0 if total failure, * -1 if failed with original dir and scanned a different one */static int fpick_scan_directory(fpick_dd *dt, char *name, char *select){ DIR *dp; char *cp, *parent = NULL; char full_name[PATHBUF]; int len, fail, res = 1; strncpy0(full_name, name, PATHBUF - 1); len = strlen(full_name); /* Ensure the invariant */ if (!len || (full_name[len - 1] != DIR_SEP)) full_name[len++] = DIR_SEP , full_name[len] = 0; /* Step up the path till a searchable dir is found */ fail = 0; while (!(dp = opendir(full_name))) { res = -1; // Remember that original path was invalid full_name[len - 1] = 0; cp = strrchr(full_name, DIR_SEP); // Try to go one level up if (cp) len = cp - full_name + 1; // No luck - restart with current dir else if (!fail++) { getcwd(full_name, PATHBUF - 1); len = strlen(full_name); full_name[len++] = DIR_SEP; } // If current dir hasn't helped either, give up else return (0); full_name[len] = 0; } /* If we're going up the path and want to show from where */ if (!select) { if (!strncmp(dt->txt_directory, full_name, len) && dt->txt_directory[len]) { cp = strchr(dt->txt_directory + len, DIR_SEP); // Guaranteed parent = dt->txt_directory + len; select = parent = g_strndup(parent, cp - parent); } } /* If we've nothing to show */ else if (!select[0]) select = NULL; strncpy(dt->txt_directory, full_name, PATHBUF); fpick_directory_new(dt, full_name); // Register directory in combo scan_dir(dt, dp, select); g_free(parent); closedir(dp); filter_dir(dt, dt->txt_mask); cmd_reset(dt->list, dt); return (res);}
开发者ID:matyler,项目名称:mtPaint,代码行数:62,
示例11: faction_changedstatic void faction_changed(spawn_dd *dt, void **wdata, int what, void **where){ void *cause; spawn_row *rp; if (dt->lock) return; cause = cmd_read(where, dt); rp = dt->strs + dt->idx; if (cause == dt->dir) strncpy(rp->dir, dt->dir, sizeof(rp->dir)); else { strncpy0(rp->name, dt->name, sizeof(rp->name)); strncpy0(rp->cmd, dt->cmd, sizeof(rp->cmd)); cmd_setv(dt->list, (void *)dt->idx, LISTC_RESET_ROW); }}
开发者ID:matyler,项目名称:mtPaint,代码行数:17,
示例12: DrawEnvelopesvoid DrawEnvelopes(){//================ int ix_env; int y_base; int x; FILE *f_txt=NULL; unsigned char *env; char name[200]; wxBitmap bitmap(WD_ENV,HT_ENV*n_envelopes); // Create a memory DC wxMemoryDC dc; dc.SelectObject(bitmap); dc.SetBrush(*wxWHITE_BRUSH); dc.SetFont(*wxSWISS_FONT); dc.Clear(); sprintf(name,"%s%s",path_source,"envelopes.txt");// f_txt = fopen(name,"w"); for(ix_env=0; ix_env<n_envelopes; ix_env++) { y_base = HT_ENV * ix_env; dc.SetPen(*wxLIGHT_GREY_PEN); dc.DrawLine(0,y_base+0,256,y_base+0); dc.DrawLine(0,y_base+64,256,y_base+64); dc.DrawLine(0,y_base+128,256,y_base+128); dc.DrawLine(128,y_base+0,128,y_base+128); dc.SetPen(*wxBLACK_PEN); strncpy0(name,envelope_paths[ix_env],sizeof(name)); dc.DrawText(wxString(name,wxConvLocal),1,y_base); env = envelope_dat[ix_env]; y_base = y_base+128; for(x=0; x<127; x++) { dc.DrawLine(x*2, y_base-env[x]/2, (x+1)*2, y_base-env[x+1]/2); } if(f_txt != NULL) { fprintf(f_txt,"%s/n",name); for(x=0; x<128; x++) { fprintf(f_txt," 0x%.2x,",env[x]); if((x & 0xf) == 0xf) fputc('/n',f_txt); } fputc('/n',f_txt); } } bitmap.SaveFile(path_phsource+_T("/envelopes.png"),wxBITMAP_TYPE_PNG); if(f_txt != NULL) fclose(f_txt);}
开发者ID:Zekom,项目名称:espeak,代码行数:58,
示例13: SetVoiceByNameespeak_ERROR SetVoiceByName(const char *name){//========================================= espeak_VOICE *v; int ix; espeak_VOICE voice_selector; char *variant_name; static char buf[60]; strncpy0(buf,name,sizeof(buf)); variant_name = ExtractVoiceVariantName(buf, 0, 1); for(ix=0; ; ix++) { // convert voice name to lower case (ascii) if((buf[ix] = tolower(buf[ix])) == 0) break; } memset(&voice_selector,0,sizeof(voice_selector)); voice_selector.name = (char *)name; // include variant name in voice stack ?? // first check for a voice with this filename // This may avoid the need to call espeak_ListVoices(). if(LoadVoice(buf,1) != NULL) { if(variant_name[0] != 0) { LoadVoice(variant_name,2); } DoVoiceChange(voice); voice_selector.languages = voice->language_name; SetVoiceStack(&voice_selector, variant_name); return(EE_OK); } if(n_voices_list == 0) espeak_ListVoices(NULL); // create the voices list if((v = SelectVoiceByName(voices_list,buf)) != NULL) { if(LoadVoice(v->identifier,0) != NULL) { if(variant_name[0] != 0) { LoadVoice(variant_name,2); } DoVoiceChange(voice); voice_selector.languages = voice->language_name; SetVoiceStack(&voice_selector, variant_name); return(EE_OK); } } return(EE_INTERNAL_ERROR); // voice name not found} // end of SetVoiceByName
开发者ID:MobileAppCodes,项目名称:espeak,代码行数:57,
示例14: any_HOOKstatic intany_HOOK(TBUFF **rp, const char *vp, HOOK * hook){ if (rp) { tb_scopy(rp, hook->proc); return TRUE; } else if (vp) { (void) strncpy0(hook->proc, vp, (size_t) NBUFN); return TRUE; } else { return FALSE; }}
开发者ID:ricksladkey,项目名称:vile,代码行数:13,
示例15: espeak_ListVoicesespeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name2){ int ix; int match_fname = -1; int match_fname2 = -1; int match_name = -1; const char *id; // this is the filename within espeak-data/voices char *variant_name; int last_part_len; char last_part[41]; char name[40]; if (voices == NULL) { if (n_voices_list == 0) espeak_ListVoices(NULL); // create the voices list voices = voices_list; } strncpy0(name, name2, sizeof(name)); if ((variant_name = strchr(name, '+')) != NULL) { *variant_name = 0; variant_name++; } sprintf(last_part, "%c%s", PATHSEP, name); last_part_len = strlen(last_part); for (ix = 0; voices[ix] != NULL; ix++) { if (strcasecmp(name, voices[ix]->name) == 0) { match_name = ix; // found matching voice name break; } else { id = voices[ix]->identifier; if (strcasecmp(name, id) == 0) match_fname = ix; // matching identifier, use this if no matching name else if (strcasecmp(last_part, &id[strlen(id)-last_part_len]) == 0) match_fname2 = ix; } } if (match_name < 0) { match_name = match_fname; // no matching name, try matching filename if (match_name < 0) match_name = match_fname2; // try matching just the last part of the filename } if (match_name < 0) return NULL; return voices[match_name];}
开发者ID:niedzielski,项目名称:espeak-ng,代码行数:51,
示例16: ini_parse/* See documentation in header file. */intini_parse(const char* filename, int(*handler)(void*, const char*, const char*, const char*), void* user){ FIL file; int error; if (f_open(&file, (TCHAR*) filename, FA_READ) != FR_OK) { strncpy0(ini_error, "f_open", 7); return -1; } error = ini_parse_file(&file, handler, user); f_close(&file); return error;}
开发者ID:Kaeptn,项目名称:LightwallController,代码行数:17,
示例17: s_MakeFromstatic void s_MakeFrom(char* buf, size_t buf_size){ size_t buf_len, hostname_len; if (!CORE_GetUsername(buf, buf_size) || !*buf) strncpy0(buf, "anonymous", buf_size - 1); buf_len = strlen(buf); hostname_len = buf_size - buf_len; if (hostname_len-- > 1) { buf[buf_len++] = '@'; if ((!SOCK_gethostbyaddr(0, &buf[buf_len], hostname_len) || !strchr(&buf[buf_len], '.')) && SOCK_gethostname(&buf[buf_len], hostname_len) != 0) { buf[--buf_len] = '/0'; } }}
开发者ID:jbreitbart,项目名称:mpifast,代码行数:17,
示例18: fat_read_line// reads a file from the SD card one line at a timeint fat_read_line(struct fat_file_struct* fd, uint8_t* buffer, uint8_t buffer_len){ char internal[INI_MAX_LINE]; int bytesRead, bytesToCopy; int32_t offset; char* pchar; bytesRead = fat_read_file(fd, internal, INI_MAX_LINE);#if INI_DEBUG printf("read_line start: bytesRead=%d/r/n", bytesRead);#endif if(bytesRead > 0) { // 0 on EOF, bytes read for >0 pchar = strchr(internal, '/n'); // return a pointer to the first newline if(pchar) { // if newline found, compute byte number for matching char bytesToCopy = pchar - internal + 1; } else { // if newline not found, copy all the bytes read bytesToCopy = bytesRead; } if(bytesToCopy > buffer_len) { // warn user or exit? bytesToCopy = buffer_len; } // copy the bytes to the destination buffer strncpy0(buffer, internal, bytesToCopy); // seek backwards from current file pointer to end of copied text offset = bytesToCopy - bytesRead; //offset = bytesToCopy;#if INI_DEBUG printf( "offset=%d, bytesRead=%d, bytesToCopy=%d/r/n", (int)offset, bytesRead, bytesToCopy);#endif if(!fat_seek_file(fd, &offset, FAT_SEEK_CUR)) { //if(!fat_seek_file(fd, &offset, FAT_SEEK_SET)) {#if INI_DEBUG printf("fat_seek_file: failure/r/n");#endif }#if INI_DEBUG printf("after seek: offset=%d/r/n", offset);#endif return bytesToCopy; } return bytesRead;}
开发者ID:kevlar1818,项目名称:umeter,代码行数:47,
示例19: sync_espeak_Synth_Markespeak_ng_STATUS sync_espeak_Synth_Mark(unsigned int unique_identifier, const void *text, const char *index_mark, unsigned int end_position, unsigned int flags, void *user_data){ InitText(flags); my_unique_identifier = unique_identifier; my_user_data = user_data; if (index_mark != NULL) { strncpy0(skip_marker, index_mark, sizeof(skip_marker)); skipping_text = true; } end_character_position = end_position; return Synthesize(unique_identifier, text, flags | espeakSSML);}
开发者ID:rhdunn,项目名称:espeak,代码行数:18,
示例20: strncpy0voice_t *LoadVoiceVariant(const char *vname, int variant_num){ // Load a voice file. // Also apply a voice variant if specified by "variant", or by "+number" or "+name" in the "vname" voice_t *v; char *variant_name; char buf[60]; strncpy0(buf, vname, sizeof(buf)); variant_name = ExtractVoiceVariantName(buf, variant_num, 1); if ((v = LoadVoice(buf, 0)) == NULL) return NULL; if (variant_name[0] != 0) v = LoadVoice(variant_name, 2); return v;}
开发者ID:niedzielski,项目名称:espeak-ng,代码行数:19,
示例21: strncpy0void Inter_v6::o6_openItk() { char fileName[32]; _vm->_game->_script->evalExpr(0); strncpy0(fileName, _vm->_game->_script->getResultStr(), 27); if (!strchr(fileName, '.')) strcat(fileName, ".ITK"); _vm->_dataIO->openDataFile(fileName, true); // WORKAROUND: The CD number detection in Urban Runner is quite daft // (it checks CD1.ITK - CD4.ITK and the first that's found determines // the CD number), while its NO_CD modus wants everything in CD1.ITK. // So we just open the other ITKs, too. if (_vm->_global->_noCd && !scumm_stricmp(fileName, "CD1.ITK")) { _vm->_dataIO->openDataFile("CD2.ITK", true); _vm->_dataIO->openDataFile("CD3.ITK", true); _vm->_dataIO->openDataFile("CD4.ITK", true); }}
开发者ID:havlenapetr,项目名称:Scummvm,代码行数:20,
示例22: sprintfstatic char *ExtractVoiceVariantName(char *vname, int variant_num){//===============================================================// Remove any voice variant suffix (name or number) from a voice name// Returns the voice variant name char *p; static char variant_name[20]; char variant_prefix[5]; variant_name[0] = 0; sprintf(variant_prefix,"!v%c",PATHSEP); if(vname != NULL) { if((p = strchr(vname,'+')) != NULL) { // The voice name has a +variant suffix *p++ = 0; // delete the suffix from the voice name if(isdigit(*p)) { variant_num = atoi(p); // variant number } else { // voice variant name, not number strcpy(variant_name,variant_prefix); strncpy0(&variant_name[3],p,sizeof(variant_name)-3); } } } if(variant_num > 0) { if(variant_num < 10) sprintf(variant_name,"%sm%d",variant_prefix, variant_num); // male else sprintf(variant_name,"%sf%d",variant_prefix, variant_num-10); // female } return(variant_name);} // end of ExtractVoiceVariantName
开发者ID:Jalakas,项目名称:navit,代码行数:41,
示例23: DBLB_GetServerNameconst char* DBLB_GetServerName(const char* lb_name, char* server_name_buf, size_t server_name_buflen, const char* const skip_servers[], char* errmsg_buf, size_t errmsg_buflen){ EDBLB_Status result; const char* retval = DBLB_GetServer(lb_name, fDBLB_None, 0/*preference*/, skip_servers, 0/*CP*/, server_name_buf, server_name_buflen, &result); if (errmsg_buf) { const char* errstr; assert(errmsg_buflen); errstr = DBLB_StatusStr(result); strncpy0(errmsg_buf, errstr ? errstr : "Unknown error", errmsg_buflen - 1); } return retval;}
开发者ID:swuecho,项目名称:igblast,代码行数:21,
示例24: ProGetBaseDialFixvoid ProGetBaseDialFix(void){ char szValue[100]; char szGetBuf[30]; int i; uint nLen; // 银联商务要求每次都读主控应用的分机前缀 BUFCLR(szValue); if(EA_ucParamFileFindPara("Base56x0", "parafile", "Base0004", &nLen, szValue) == EM_SUCCESS) { BUFCLR(szGetBuf); memcpy(szGetBuf, FV.gbNacInfo.szDialFix, 4); if (szValue[0] != 0) { strncpy0(szGetBuf + 4, szValue, sizeof(szGetBuf)); for (i = 0; szGetBuf[i] != 0x0; i++) if (szGetBuf[i] == '.') szGetBuf[i] = ','; } strcpy(FV.gbNacInfo.szDialFix, szGetBuf); }}
开发者ID:chengzhang-90,项目名称:JSYLSW,代码行数:24,
示例25: s_SockReadResponsestatic int/*bool*/ s_SockReadResponse(SOCK sock, int code, int alt_code, char* buf, size_t buf_size){ int c = s_SockRead(sock, buf, buf_size); if (c <= 0) { const char* message = 0; switch (c) { case SMTP_READERR: message = "Read error"; break; case SMTP_READTMO: message = "Read timed out"; break; case SMTP_RESPERR: message = "Error reading response prefix"; break; case SMTP_NOCODE: message = "No response code detected"; break; case SMTP_BADCODE: message = "Response code doesn't match in lines"; break; case SMTP_BADRESP: message = "Malformed response"; break; default: message = "Unknown error"; assert(0); break; } assert(message); strncpy0(buf, message, buf_size - 1); } else if (c == code || (alt_code && c == alt_code)) return 1/*success*/; return 0/*failure*/;}
开发者ID:jbreitbart,项目名称:mpifast,代码行数:36,
示例26: write_final_stateint write_final_state(control *c, params *p, state *s){ /* Write the final state to the input param file so we can easily restart the model. This function copies the input param file with the exception of anything in the git hash and the state which it replaces with the updated stuff. */ char line[STRING_LENGTH]; char saved_line[STRING_LENGTH]; char section[STRING_LENGTH] = ""; char prev_name[STRING_LENGTH] = ""; char *start; char *end; char *name; char *value; int error = 0; int line_number = 0; int match = FALSE; while (fgets(line, sizeof(line), c->ifp) != NULL) { strcpy(saved_line, line); line_number++; start = lskip(rstrip(line)); if (*start == ';' || *start == '#') { /* Per Python ConfigParser, allow '#' comments at start of line */ } else if (*start == '[') { /* A "[section]" line */ end = find_char_or_comment(start + 1, ']'); if (*end == ']') { *end = '/0'; strncpy0(section, start + 1, sizeof(section)); *prev_name = '/0'; } else if (!error) { /* No ']' found on section line */ error = line_number; } } else if (*start && *start != ';') { /* Not a comment, must be a name[=:]value pair */ end = find_char_or_comment(start, '='); if (*end != '=') { end = find_char_or_comment(start, ':'); } if (*end == '=' || *end == ':') { *end = '/0'; name = rstrip(start); value = lskip(end + 1); end = find_char_or_comment(value, '/0'); if (*end == ';') *end = '/0'; rstrip(value); /* Valid name[=:]value pair found, call handler */ strncpy0(prev_name, name, sizeof(prev_name)); if (!ohandler(section, name, value, c, p, s, &match) && !error) error = line_number; } else if (!error) { /* No '=' or ':' found on name[=:]value line */ error = line_number; break; } } if (match == FALSE) fprintf(c->ofp, "%s", saved_line); else match = FALSE; /* reset match flag */ } return error;}
开发者ID:bmedlyn,项目名称:GDAY,代码行数:80,
示例27: ini_parse_string_implint ini_parse_string_impl(const std::string & s, int (*handler)(void*, const char*, const char*, const char*), void* user){ std::istringstream input(s); /* Uses a fair bit of stack (use heap instead if you need to) */ char section[MAX_INI_STRING] = ""; bool has_group = false; int lineno = 0; int error = 0; /* Scan through file line by line */ while (!at_end(input)) { std::string newline; get_line(input, newline); char * line = (char*)newline.c_str(); lineno++; char * start = line; char * end; // UTF-8 BOM if (lineno == 1 && (unsigned char)start[0] == 0xEF && (unsigned char)start[1] == 0xBB && (unsigned char)start[2] == 0xBF) { start += 3; } start = lskip(rstrip(start)); char c = *start; if (c == ';' || c == '#' || (c == '/' && start[1] == '/')) { /* Per Python ConfigParser, allow '#' comments at start of line */ } else if (c == '[') { /* A "[section]" line */ end = find_char_or_comment(start + 1, ']'); if (*end == ']') { *end = '/0'; strncpy0(section, start + 1, sizeof(section)); has_group = true; } else if (!error) { /* No ']' found on section line */ error = lineno; } } else if (c && c != ';' && has_group) { /* Not a comment, must be a name[=:]value pair */ end = find_char_or_comment(start, '='); if (*end != '=') { end = find_char_or_comment(start, ':'); } if (*end == '=' || *end == ':') { *end = '/0'; char * name = rstrip(start); char * value = lskip(end + 1); end = find_char_or_comment(value, '/0'); if (*end == ';') *end = '/0'; rstrip(value); /* Valid name[=:]value pair found, call handler */ if (!handler(user, section, name, value) && !error) error = lineno; } else if (!error) { /* No '=' or ':' found on name[=:]value line */ error = lineno; } } } return error;}
开发者ID:mattl,项目名称:anaconda,代码行数:75,
示例28: ini_parse_file/* See documentation in header file. */int ini_parse_file(FILE* file,const struct IniConfig* config, void* user){ /* Uses a fair bit of stack (use heap instead if you need to) */#if INI_USE_STACK char line[INI_MAX_LINE];#else char* line;#endif char section[MAX_SECTION] = ""; char prev_name[MAX_NAME] = ""; char* start; char* end; char* name; char* value; int lineno = 0; int error = 0;#if !INI_USE_STACK line = (char*)malloc(INI_MAX_LINE); if (!line) { return -2; }#endif /* Scan through file line by line */ while (fgets(line, INI_MAX_LINE, file) != NULL) { lineno++; start = line;#if INI_ALLOW_BOM if (lineno == 1 && (unsigned char)start[0] == 0xEF && (unsigned char)start[1] == 0xBB && (unsigned char)start[2] == 0xBF) { start += 3; }#endif start = lskip(rstrip(start)); if (*start == ';' || *start == '#') { start += 1; if (!config->commentHandler(user, start) && !error) error = lineno; /* Per Python ConfigParser, allow '#' comments at start of line */ } else if (config->supportMultiline && *prev_name && *start && start > line) { /* Non-black line with leading whitespace, treat as continuation of previous name's value (as per Python ConfigParser). */ if (!config->keyHandler(user, section, prev_name, start, 1) && !error) error = lineno; } else if (*start == '[') { /* A "[section]" line */ end = find_char_or_comment(start + 1, ']'); if (*end == ']') { *end = '/0'; strncpy0(section, start + 1, sizeof(section)); *prev_name = '/0'; if(!config->sectionHandler(user, section) && !error) error = lineno; } else if (!error) { /* No ']' found on section line */ error = lineno; } } else if (*start && *start != ';') { /* Not a comment, must be a name[=:]value pair */ end = find_char_or_comment(start, '='); if (*end != '=') { end = find_char_or_comment(start, ':'); } if (*end == '=' || *end == ':') { *end = '/0'; name = rstrip(start); value = lskip(end + 1); end = find_char_or_comment(value, '/0'); if (*end == ';') *end = '/0'; rstrip(value); /* Valid name[=:]value pair found, call handler */ strncpy0(prev_name, name, sizeof(prev_name)); if (!config->keyHandler(user, section, name, value, 0) && !error) error = lineno; } else if (!error) { /* No '=' or ':' found on name[=:]value line */ error = lineno; } }#if INI_STOP_ON_FIRST_ERROR if (error) break;#endif }//.........这里部分代码省略.........
开发者ID:beku,项目名称:libelektra,代码行数:101,
示例29: load // read and parse int load(const char* filename) { FILE *file = fopen(filename, "r"); if(!file) return false; char *line = new char[INI_MAX_LINE]; std::string prev_value, prev_name; char *section = new char [MAX_SECTION]; *section = '/0'; int bMultiline = 0; int lineno = 0, error=0; char *start, *end, *name, *value; while (fgets(line, INI_MAX_LINE, file) != NULL) { lineno++; start = line; start = lskip(start); // remove comment end = find_char_or_comment(start, '/0'); if( *end != '/0' ) // it points to a comment char *end = '/0'; rstrip(start, &end); if( start == end ) continue; if ( bMultiline ) { if( *(end-1) == '//' && (end-1 == start || *(end-2) == ' ') ) { // continue reading next line // remove " /" *(--end) = '/0'; if( end > start && *(end-1) == ' ') *(--end) = '/0'; prev_value += start; } else{ prev_value += start; if( !handle_record(section, prev_name.c_str(), prev_value.c_str()) ) error = lineno; bMultiline = 0; prev_value = ""; prev_name = ""; } } else if( *start == '[' ) { // found section end = find_char_or_comment(start + 1, ']'); if (*end == ']') { *end = '/0'; strncpy0(section, start + 1, MAX_SECTION); } else{ /* No ']' found on section line */ error = lineno; } bMultiline = false; } else { /* Not a comment, must be a name[=:]value pair */ bMultiline = false; char *nend = find_char_or_comment(start, '='); if (*nend != '=') { nend = find_char_or_comment(start, ':'); } if (*nend == '=' || *nend == ':') { *nend = '/0'; value = lskip(nend + 1); name = rstrip(start, &nend); /* Valid name[=:]value pair found, call handler */ if( *(end-1) == '//' && (end-1 == value || *(end-2) == ' ') ) { // continue reading next line // remove " /" *(--end) = '/0'; if( end > value && *(end-1) == ' ') *(--end) = '/0'; prev_value = value; prev_name = name; bMultiline = true; } if( !bMultiline ) if (!handle_record(section, name, value)) error = lineno; } else if (!error) { /* No '=' or ':' found on name[=:]value line */ error = lineno; } } if (error) break; } // while getline fclose(file); delete [] line; delete [] section; return error; } // read function
开发者ID:adenzhang,项目名称:iniparser,代码行数:96,
示例30: mainint main(int argc, char **argv){ static struct option long_options[] = { { "help", no_argument, 0, 'h' }, { "stdin", no_argument, 0, 0x100 }, { "compile-debug", optional_argument, 0, 0x101 }, { "compile", optional_argument, 0, 0x102 }, { "punct", optional_argument, 0, 0x103 }, { "voices", optional_argument, 0, 0x104 }, { "stdout", no_argument, 0, 0x105 }, { "split", optional_argument, 0, 0x106 }, { "path", required_argument, 0, 0x107 }, { "phonout", required_argument, 0, 0x108 }, { "pho", no_argument, 0, 0x109 }, { "ipa", optional_argument, 0, 0x10a }, { "version", no_argument, 0, 0x10b }, { "sep", optional_argument, 0, 0x10c }, { "tie", optional_argument, 0, 0x10d }, { "compile-mbrola", optional_argument, 0, 0x10e }, { "compile-intonations", no_argument, 0, 0x10f }, { "compile-phonemes", optional_argument, 0, 0x110 }, { 0, 0, 0, 0 } }; FILE *f_text = NULL; char *p_text = NULL; FILE *f_phonemes_out = stdout; char *data_path = NULL; // use default path for espeak-ng-data int option_index = 0; int c; int ix; char *optarg2; int value; int flag_stdin = 0; int flag_compile = 0; int filesize = 0; int synth_flags = espeakCHARS_AUTO | espeakPHONEMES | espeakENDPAUSE; int volume = -1; int speed = -1; int pitch = -1; int wordgap = -1; int option_capitals = -1; int option_punctuation = -1; int phonemes_separator = 0; int phoneme_options = 0; int option_linelength = 0; int option_waveout = 0; espeak_VOICE voice_select; char filename[200]; char voicename[40]; char devicename[200]; #define N_PUNCTLIST 100 wchar_t option_punctlist[N_PUNCTLIST]; voicename[0] = 0; wavefile[0] = 0; filename[0] = 0; devicename[0] = 0; option_punctlist[0] = 0; while (true) { c = getopt_long(argc, argv, "a:b:d:f:g:hk:l:mp:qs:v:w:xXz", long_options, &option_index); // Detect the end of the options. if (c == -1) break; optarg2 = optarg; switch (c) { case 'b': // input character encoding, 8bit, 16bit, UTF8 if ((sscanf(optarg2, "%d", &value) == 1) && (value <= 4)) synth_flags |= value; else synth_flags |= espeakCHARS_8BIT; break; case 'd': strncpy0(devicename, optarg2, sizeof(devicename)); break; case 'h': printf("/n"); PrintVersion(); printf("%s", help_text); return 0; case 'k': option_capitals = atoi(optarg2); break; case 'x': phoneme_options |= espeakPHONEMES_SHOW; break; case 'X': phoneme_options |= espeakPHONEMES_TRACE; break; case 'm': synth_flags |= espeakSSML;//.........这里部分代码省略.........
开发者ID:rhdunn,项目名称:espeak,代码行数:101,
注:本文中的strncpy0函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ strncpy_IFNAMSIZ函数代码示例 C++ strncpy函数代码示例 |