/****************************************************************************** * This function is the main entry point to the setValue type of action. It * receives the currently read line and dispatch the work depending on the * context. */ void doSetValue(LPTSTR stdInput) { /* * We encountered the end of the file, make sure we * close the opened key and exit */ if (stdInput == NULL) { if (bTheKeyIsOpen != FALSE) closeKey(); return; } if (stdInput[0] == _T('[')) { /* We are reading a new key */ if (bTheKeyIsOpen != FALSE) { closeKey(); /* Close the previous key before */ } if (openKey(stdInput) != ERROR_SUCCESS) { _tprintf(_T("doSetValue failed to open key %s\n"), stdInput); } } else if ((bTheKeyIsOpen) && ((stdInput[0] == _T('@')) || /* reading a default @=data pair */ (stdInput[0] == _T('\"')))) { /* reading a new value=data pair */ processSetValue(stdInput); } else { /* since we are assuming that the file format is */ if (bTheKeyIsOpen) /* valid we must be reading a blank line which */ closeKey(); /* indicate end of this key processing */ } }
/****************************************************************************** * This function receives the currently read entry and performs the * corresponding action. * isUnicode affects parsing of REG_MULTI_SZ values */ static void processRegEntry(WCHAR* stdInput, BOOL isUnicode) { /* * We encountered the end of the file, make sure we * close the opened key and exit */ if (stdInput == NULL) { closeKey(); return; } if ( stdInput[0] == '[') /* We are reading a new key */ { WCHAR* keyEnd; closeKey(); /* Close the previous key */ /* Get rid of the square brackets */ stdInput++; keyEnd = strrchrW(stdInput, ']'); if (keyEnd) *keyEnd='\0'; /* delete the key if we encounter '-' at the start of reg key */ if ( stdInput[0] == '-') { delete_registry_key(stdInput + 1); } else if ( openKeyW(stdInput) != ERROR_SUCCESS ) { char* stdInputA = GetMultiByteString(stdInput); fprintf(stderr,"%s: setValue failed to open key %s\n", getAppName(), stdInputA); HeapFree(GetProcessHeap(), 0, stdInputA); } } else if( currentKeyHandle && (( stdInput[0] == '@') || /* reading a default @=data pair */ ( stdInput[0] == '\"'))) /* reading a new value=data pair */ { processSetValue(stdInput, isUnicode); } else { /* Since we are assuming that the file format is valid we must be * reading a blank line which indicates the end of this key processing */ closeKey(); } }
/****************************************************************************** * This function receives the currently read entry and performs the * corresponding action. * isUnicode affects parsing of REG_MULTI_SZ values */ static void processRegEntry(WCHAR* stdInput, BOOL isUnicode) { /* * We encountered the end of the file, make sure we * close the opened key and exit */ if (stdInput == NULL) { closeKey(); return; } if ( stdInput[0] == '[') /* We are reading a new key */ { WCHAR* keyEnd; closeKey(); /* Close the previous key */ /* Get rid of the square brackets */ stdInput++; keyEnd = strrchrW(stdInput, ']'); if (keyEnd) *keyEnd='\0'; /* delete the key if we encounter '-' at the start of reg key */ if (stdInput[0] == '-') delete_registry_key(stdInput + 1); else if (openKeyW(stdInput) != ERROR_SUCCESS) output_message(STRING_OPEN_KEY_FAILED, stdInput); } else if( currentKeyHandle && (( stdInput[0] == '@') || /* reading a default @=data pair */ ( stdInput[0] == '\"'))) /* reading a new value=data pair */ { processSetValue(stdInput, isUnicode); } else { /* Since we are assuming that the file format is valid we must be * reading a blank line which indicates the end of this key processing */ closeKey(); } }