void cacheConfigFile(){ DWORD l_pos; //first we check if HANDLE is valid DWORD l_err; BOOL l_rc; DWORD l_actual_read; char* cText; // char* key; char *value, *value2; char* line; char _line[1024]; // propCache.count=0; comPortList.count=0; int i; for (i=0;i<CACHE_lIST_SIZE;i++){ memset(propCache.hash[i].key,0,HASH_KEY_SIZE); memset(propCache.hash[i].value,0,HASH_VALUE_SIZE); } for (i=0;i<COM_LIST_SIZE;i++){ memset((comPortList.list+i),0,sizeof(COMELEMENT)); } trace("Function cacheConfigFile"); l_pos = SetFilePointer(configFileHandle, 0, 0, FILE_END); LPVOID l_file= LocalAlloc(LPTR, l_pos+1); cText = (char *)LocalAlloc(LPTR, l_pos+1); SetFilePointer(configFileHandle, 0, 0, FILE_BEGIN); l_rc = ReadFile(configFileHandle, l_file, l_pos, &l_actual_read, NULL); if (l_rc ==0){ l_err = GetLastError(); printErrorMsg(_T("Could not read the config file, reason"),l_err,1,1); destroyConfig(); exit(1); } *((char*)l_file+l_pos)=0; //whe are done, close file closeConfigFile(); convertToANSI((TCHAR *)l_file,l_pos+1,cText,l_pos+1); LocalFree(l_file); //we have converted everything to ansi so! line=0; while ((line = fetchNextLine(cText,line,l_pos+1)) != NULL){ //copy line strcpy(_line,line); if (isCommentOrEmptyLine(_line)){ continue; } splitKeyValue(_line,'=',&key,&value); if (stricmp(key,PROP_PORTNAME)==0){ trace("property PROP_PORTNAME found"); insertOrReplacePropertyByKey(key, value); strcpy(_line,line); trace(trim(strupr(_line))); continue; } } }
std::istream& readCAF(std::istream& in, Contig& c) { std::string line; getline(in, line); std::stringstream tokenizer(line); std::string token; while(tokenizer >> token) { std::string key; std::string value; splitKeyValue(token, key, value); c.setFromKeyValue(key, value); } assert(c.getSequence().size() == c.getLength()); return in; }