int compareWithNoCase2(const char_type* str1, const char_type* str2) { char_type *str1_2 = new char_type[type_length(str1)]; char_type *str2_2 = new char_type[type_length(str2)]; type_copy(str1_2, str1); type_copy(str2_2, str2); toupper(*str1_2); toupper(*str2_2); int result = type_compare(str1_2, str2_2); delete[] str1_2; delete[] str2_2; return result; }
int CCommonFnc::SCSAT_EnsureFileHeader(string_type filePath, SCSAT_MEASURE_INFO* pInfo) { int status = STAT_OK; char_type iniValue[MAX_INI_VALUE_CHAR]; // CHECK IF HEADER EXISTS BOOL bNewFormat = FALSE; int fileLength = 0; fstream_type file; file.open(filePath, std::fstream::in | std::fstream::out); if (file.is_open()) { char_type buffer[100]; memset(buffer, 0, sizeof(buffer)); file.read(buffer, 100); file.seekg(0, std::ios_base::end); //fileLength = file.tellg(); file.seekg(0, std::ios_base::beg); string_type header = buffer; string_type part = header.substr(1, (int)SCSAT_MEASURE_SECTION.length()); if (compareWithNoCase2(SCSAT_MEASURE_SECTION.c_str(), part.c_str()) == 0) bNewFormat = TRUE; //if (part.compareWithNoCase(SCSAT_MEASURE_SECTION) == 0) bNewFormat = TRUE; else bNewFormat = FALSE; // WRITE IF NOT if (!bNewFormat) { string_type tmp; if (pInfo->sampleUniqueID == 0) { CCommonFnc::Sample_GenerateSampleUniqueID(&(pInfo->sampleUniqueID)); } pInfo->formatToString(&tmp); file.seekg(0, std::ios_base::beg); file.seekp(0, std::ios_base::beg); file.write(tmp.c_str(), tmp.length()); } file.close(); // if the sampleUniqueID is not present if(bNewFormat) { GetPrivateProfileString(SCSAT_MEASURE_SECTION.c_str(), SCSAT_MEASURE_SAMPLEUNIQUEID.c_str(), _CONV(""), iniValue, MAX_INI_VALUE_CHAR, (LPCTSTR) filePath.c_str()); if (type_length(iniValue) == 0) { if (pInfo->sampleUniqueID == 0) { CCommonFnc::Sample_GenerateSampleUniqueID(&(pInfo->sampleUniqueID)); } string_type tmp; tmp = string_format(_CONV("%lld"), pInfo->sampleUniqueID); //tmp.AtlUtil::Format("%lld", pInfo->sampleUniqueID); WritePrivateProfileString(SCSAT_MEASURE_SECTION.c_str(),SCSAT_MEASURE_SAMPLEUNIQUEID.c_str(), tmp.c_str(), filePath.c_str()); } } } return status; }
void main(int argc, string argv[]) { string type, name; initparam(argv, defv); type = getparam("type"); name = getparam("name"); printf("type_length(\"%s\") = %d\n", type, type_length(type)); printf("type_name(\"%s\") = %s\n", type, type_name(type)); printf("type_base(\"%s\") = %s\n", type, type_base(type)); printf("type_fmt(\"%s\", TRUE) = %s\n", type, type_fmt(type, TRUE)); printf("type_fmt(\"%s\", FALSE) = %s\n", type, type_fmt(type, FALSE)); printf("name_type(\"%s\") = %s\n", name, name_type(name)); }