这篇教程C++ strtok函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中strtok函数的典型用法代码示例。如果您正苦于以下问题:C++ strtok函数的具体用法?C++ strtok怎么用?C++ strtok使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了strtok函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: sem_waitvoid NoVoHT::merge(){ char buf[300]; char sec[300]; sem_wait(&map_lock); sem_wait(&write_lock); fflush(dbfile); rewind(dbfile); while (readTabString(dbfile,buf) != NULL){ if(buf[0] == '~'){ readTabString(dbfile, sec); char * pos; pos = strtok(sec, ","); while (pos != NULL) { fseek(swapFile, (off_t) atoi(pos), SEEK_SET); char test[300]; readTabString(swapFile,test); if (strcmp(test,(buf+1)) == 0){ fseek(swapFile, (off_t) atoi(pos), SEEK_SET); fputc('~',swapFile); } pos = strtok(NULL, ","); } } else{ //while (map_lock) {} //map_lock = true; //sem_wait(&map_lock); fseek(swapFile, 0, SEEK_END); string s(buf); readTabString(dbfile,sec); kvpair* p = kvpairs[hash(s)%size]; while (p != NULL){ if (p->key.compare(s) == 0){ destroyFposList(p->positions); p->positions = new fpos_list; p->positions->next = NULL; fgetpos(swapFile, &(p->positions->pos)); fprintf(swapFile, "%s/t%s/t", p->key.c_str(), p->val.c_str()); printf("%s/t%s/t", p->key.c_str(), p->val.c_str()); p->diff = false; break; } else p = p->next; } //map_lock = false; //sem_post(&map_lock); } } fclose(dbfile); fclose(swapFile); rename(".novoht.swp", filename.c_str()); dbfile = fopen(filename.c_str(), "r+"); //remove(".novoht.mrg"); int rmrc = unlink(".novoht.mrg"); if (rmrc) { perror("Error deleting merge file"); } rewriting = false; sem_post(&map_lock); sem_post(&write_lock);}
开发者ID:SandeepPalur,项目名称:NoVoHT,代码行数:62,
示例2: nis_get_serviceint nis_get_service ( int num_connect_fails, char *generic_service_name, char *service_name, char *node, int *mode) {static int init = 1;static char nodes[2][31+1];static int modes[] = { RPC_K_MASTER, RPC_K_LOCAL };int stat, ret_stat, i, item;unsigned short len;struct dsc$descriptor dsc;char *ptr, buf[127+1]; if ( init ) { strcpy( nodes[0], "ORIB01" ); strcpy( nodes[1], "ORIB01" ); init = 0; } if ( strstr( generic_service_name, "::" ) ) { strncpy( buf, generic_service_name, 127 ); ptr = strtok( buf, "::" ); strncpy( node, ptr, 7 ); ptr = strtok( NULL, "::" ); strcpy( service_name, ptr ); } else if ( strncmp( generic_service_name, "IOSCNR", strlen("IOSCNR") ) == 0 ) { i = 0; strcpy( service_name, "IOS" ); strncpy( node, nodes[i], 7 ); *mode = modes[i]; } else if ( strncmp( generic_service_name, "REM_CONSOLE", strlen("REM_CONSOLE") ) == 0 ) { i = 0; strcpy( service_name, "CONSOLE" ); strncpy( node, nodes[i], 7 ); *mode = modes[i]; } else if ( strncmp( generic_service_name, "DBSCANSRV", strlen("DBSCANSRV") ) == 0 ) { i = 0; strcpy( service_name, "DBSCANSRV" ); strncpy( node, nodes[i], 7 ); *mode = modes[i]; } else if ( strncmp( generic_service_name, "TEST", strlen("TEST") ) == 0 ) { i = 0; strcpy( service_name, "TEST" ); strncpy( node, nodes[i], 7 ); *mode = modes[i]; } else { ret_stat = NIS_UNKSVC; goto err_return; }norm_return: return NIS_SUCCESS;err_return: strcpy( service_name, "" ); strcpy( node, "" ); *mode = 0; return ret_stat;}
开发者ID:epicsdeb,项目名称:edm,代码行数:90,
示例3: vcdSymbolTable//-----------------------------------------------------------------------------// A Scene image file contains all the compiled .XCD//-----------------------------------------------------------------------------bool CSceneImage::CreateSceneImageFile( CUtlBuffer &targetBuffer, char const *pchModPath, bool bLittleEndian, bool bQuiet, ISceneCompileStatus *pStatus ){ CUtlVector<fileList_t> vcdFileList; CUtlSymbolTable vcdSymbolTable( 0, 32, true ); Msg( "/n" ); // get all the VCD files according to the seacrh paths char searchPaths[512]; g_pFullFileSystem->GetSearchPath( "GAME", false, searchPaths, sizeof( searchPaths ) ); char *pPath = strtok( searchPaths, ";" ); while ( pPath ) { int currentCount = vcdFileList.Count(); char szPath[MAX_PATH]; V_ComposeFileName( pPath, "scenes/*.vcd", szPath, sizeof( szPath ) ); scriptlib->FindFiles( szPath, true, vcdFileList ); Msg( "Scenes: Searching '%s' - Found %d scenes./n", szPath, vcdFileList.Count() - currentCount ); pPath = strtok( NULL, ";" ); } if ( !vcdFileList.Count() ) { Msg( "Scenes: No Scene Files found!/n" ); return false; } // iterate and convert all the VCD files bool bGameIsTF = V_stristr( pchModPath, "//tf" ) != NULL; for ( int i=0; i<vcdFileList.Count(); i++ ) { const char *pFilename = vcdFileList[i].fileName.String(); const char *pSceneName = V_stristr( pFilename, "scenes//" ); if ( !pSceneName ) { continue; } if ( !bLittleEndian && bGameIsTF && V_stristr( pSceneName, "high//" ) ) { continue; } // process files in order they would be found in search paths // i.e. skipping later processed files that match an earlier conversion UtlSymId_t symbol = vcdSymbolTable.Find( pSceneName ); if ( symbol == UTL_INVAL_SYMBOL ) { vcdSymbolTable.AddString( pSceneName ); pStatus->UpdateStatus( pFilename, bQuiet, i, vcdFileList.Count() ); if ( !CreateTargetFile_VCD( pFilename, "", false, bLittleEndian ) ) { Error( "CreateSceneImageFile: Failed on '%s' conversion!/n", pFilename ); } } } if ( !g_SceneFiles.Count() ) { // nothing to do return true; } Msg( "Scenes: Finalizing %d unique scenes./n", g_SceneFiles.Count() ); // get the string pool CUtlVector< unsigned int > stringOffsets; CUtlBuffer stringPool; g_ChoreoStringPool.GetTableAndPool( stringOffsets, stringPool ); if ( !bQuiet ) { Msg( "Scenes: String Table: %d bytes/n", stringOffsets.Count() * sizeof( int ) ); Msg( "Scenes: String Pool: %d bytes/n", stringPool.TellMaxPut() ); } // first header, then lookup table, then string pool blob int stringPoolStart = sizeof( SceneImageHeader_t ) + stringOffsets.Count() * sizeof( int ); // then directory int sceneEntryStart = stringPoolStart + stringPool.TellMaxPut(); // then variable sized summaries int sceneSummaryStart = sceneEntryStart + g_SceneFiles.Count() * sizeof( SceneImageEntry_t ); // then variable sized compiled binary scene data int sceneDataStart = 0; // construct header SceneImageHeader_t imageHeader = { 0 }; imageHeader.nId = SCENE_IMAGE_ID;//.........这里部分代码省略.........
开发者ID:xxauroraxx,项目名称:Source.Python,代码行数:101,
示例4: _dbg_sendmessage//.........这里部分代码省略......... } break; case DBG_SETTINGS_UPDATED: { valuesetsignedcalc(!settingboolget("Engine", "CalculationType")); //0:signed, 1:unsigned SetEngineVariable(UE_ENGINE_SET_DEBUG_PRIVILEGE, settingboolget("Engine", "EnableDebugPrivilege")); bOnlyCipAutoComments = settingboolget("Disassembler", "OnlyCipAutoComments"); bListAllPages = settingboolget("Engine", "ListAllPages"); bUndecorateSymbolNames = settingboolget("Engine", "UndecorateSymbolNames"); bEnableSourceDebugging = settingboolget("Engine", "EnableSourceDebugging"); uint setting; if(BridgeSettingGetUint("Engine", "BreakpointType", &setting)) { switch(setting) { case 0: //break_int3short SetBPXOptions(UE_BREAKPOINT_INT3); break; case 1: //break_int3long SetBPXOptions(UE_BREAKPOINT_LONG_INT3); break; case 2: //break_ud2 SetBPXOptions(UE_BREAKPOINT_UD2); break; } } char exceptionRange[MAX_SETTING_SIZE] = ""; dbgclearignoredexceptions(); if(BridgeSettingGet("Exceptions", "IgnoreRange", exceptionRange)) { char* entry = strtok(exceptionRange, ","); while(entry) { unsigned long start; unsigned long end; if(sscanf(entry, "%08X-%08X", &start, &end) == 2 && start <= end) { ExceptionRange range; range.start = start; range.end = end; dbgaddignoredexception(range); } entry = strtok(0, ","); } } char cachePath[MAX_SETTING_SIZE]; if(BridgeSettingGet("Symbols", "CachePath", cachePath)) { // Trim the buffer to fit inside MAX_PATH strncpy_s(szSymbolCachePath, cachePath, _TRUNCATE); } } break; case DBG_DISASM_FAST_AT: { if(!param1 || !param2) return 0; BASIC_INSTRUCTION_INFO* basicinfo = (BASIC_INSTRUCTION_INFO*)param2; if(!disasmfast((uint)param1, basicinfo)) basicinfo->size = 1; return 0;
开发者ID:songzhaochun,项目名称:x64dbg,代码行数:67,
示例5: parse_repair_conf_fileint parse_repair_conf_file(char *repair_conf_file, repair_arguments_t *ra) { char *buf = NULL; FILE *fp; struct stat file_stats; int nbytes; char *tmp = NULL; if(stat(repair_conf_file, &file_stats) == -1) { printf("Error: %s is not valid file name/n", repair_conf_file); fflush(stdout); return -1; } /* Allocate memory for buf */ if(!(buf = (char*)calloc((file_stats.st_size + 1), sizeof(char)))) { printf("Could not alloc memory for buffer!/n"); fflush(stdout); return -1; } if((fp = fopen(repair_conf_file, "rb")) == NULL) { printf("Error: unable to open file %s/n", repair_conf_file); fflush(stdout); free(buf); return -1; } nbytes = fread(buf, 1, file_stats.st_size, fp); if(nbytes <= 0) { free(buf); fclose(fp); return -1; } fclose(fp); tmp = strtok (buf, "="); while(tmp != NULL) { if(strcmp(tmp, "RepairMethod") == 0) { tmp = strtok(NULL, "/n"); memset(ra->repair_method, 0, MAX_PATH_LENGTH); strcpy(ra->repair_method, tmp); if(ra->repair_method[strlen(ra->repair_method)-1] == '/r') { ra->repair_method[strlen(ra->repair_method)-1] = '/0'; } } else if(strcmp(tmp, "RequestedBlocksFile") == 0) { tmp = strtok(NULL, "/n"); memset(ra->requested_blocks_file, 0, MAX_PATH_LENGTH); strcpy(ra->requested_blocks_file, tmp); if(ra->requested_blocks_file[strlen(ra->requested_blocks_file)-1] == '/r') { ra->requested_blocks_file[strlen(ra->requested_blocks_file)-1] = '/0'; } } else if(strcmp(tmp, "PTMRepairSDPFile") == 0) { tmp = strtok(NULL, "/n"); memset(ra->ptm_repair_sdp_file, 0, MAX_PATH_LENGTH); strcpy(ra->ptm_repair_sdp_file, tmp); if(ra->ptm_repair_sdp_file[strlen(ra->ptm_repair_sdp_file)-1] == '/r') { ra->ptm_repair_sdp_file[strlen(ra->ptm_repair_sdp_file)-1] = '/0'; } } else if(strcmp(tmp, "FluteConfFile") == 0) { tmp = strtok(NULL, "/n"); memset(ra->flute_conf_file, 0, MAX_PATH_LENGTH); strcpy(ra->flute_conf_file, tmp); if(ra->flute_conf_file[strlen(ra->flute_conf_file)-1] == '/r') { ra->flute_conf_file[strlen(ra->flute_conf_file)-1] = '/0'; } } tmp = strtok (NULL, "="); } free(buf); return 0;}
开发者ID:graingert,项目名称:6share,代码行数:87,
|