#include "headers.hxx" #include "..\CSVDSReader.hpp" #include "..\constants.hpp" #include "..\global.hpp" HINSTANCE hResourceModuleHandle = 0; const wchar_t* HELPFILE_NAME = 0; // no context help available const wchar_t* RUNTIME_NAME = L"W2KStrs"; DWORD DEFAULT_LOGGING_OPTIONS = Log::OUTPUT_TO_FILE | Log::OUTPUT_FUNCCALLS | Log::OUTPUT_LOGS | Log::OUTPUT_ERRORS | Log::OUTPUT_HEADER; Popup popup(L"W2KStrs", false); // Keep all printable characters and escape the others. // Escaping means representing the character as &xxxx // where the x is an hexadecimal digit // This routine also replaces & for && // The unescape function is in ..\global.cpp String escape(const wchar_t *str) { LOG_FUNCTION(escape); String dest; wchar_t strNum[5]; while(*str!=0) { if(*str=='&') { dest+=L"&&"; } else { if ( (*str >= L'a' && *str <= L'z') || (*str >= L'A' && *str <= L'Z') || (*str >= L'0' && *str <= L'9') || wcschr(L" !@#$%^*()-_=+[{]}\"';:.>,c_str(), W2KValue ); BREAK_ON_FAILED_HRESULT(hr); if(W2KValue.size()==0) { error=L"Did not find value(s)",L"Error"; hr=E_FAIL; break; } size_t pos=W2KValue.find(L','); if(pos==String::npos) { error=L"MultipleValue without comma",L"Error"; hr=E_FAIL; break; } } // by now the W2KValue is loaded // The test sequence // This test sequence is usefull when you already have // replaceW2KStrs from a previous run and you want to // test that the strings have been correctly // retrieved, encoded and decoded //pair tmpIndxLoc; //tmpIndxLoc.first=index; //tmpIndxLoc.second=locale; //String tmpValue=replaceW2KStrs[tmpIndxLoc]; //if (tmpValue!=W2KValue) //{ //hr=E_FAIL; //break; //} long index = *value; hr=FS::WriteLine(file, String::format(L"tmpIndxLoc.first=%1!d!;",index)); BREAK_ON_FAILED_HRESULT(hr); hr=FS::WriteLine(file, String::format(L"tmpIndxLoc.second=0x%1!3x!;",locale)); BREAK_ON_FAILED_HRESULT(hr); hr=FS::Write ( file, String::format ( L"replaceW2KStrs[tmpIndxLoc]=L\"%1\";\r\n", escape( W2KValue.c_str() ).c_str() ) ); BREAK_ON_FAILED_HRESULT(hr); } // if(changes[c].change== is REPLACE multiple or single } // for c (for each change in the entry) BREAK_ON_FAILED_HRESULT(hr); }// for i (for each entry in the change list) BREAK_ON_FAILED_HRESULT(hr); }// for l (for each locale) BREAK_ON_FAILED_HRESULT(hr); } while(0); CloseHandle(file); if (FAILED(hr)) { MessageBox(NULL,L"Problems during generation",L"Error",MB_OK); } else { MessageBox(NULL,L"Generation Successfull",L"Success",MB_OK); } LOG_HRESULT(hr); return 1; }