diff options
author | Steve Huston <shuston@riverace.com> | 2001-08-22 22:14:51 +0000 |
---|---|---|
committer | Steve Huston <shuston@riverace.com> | 2001-08-22 22:14:51 +0000 |
commit | b6ec360e458b19e01d661cdc302d68f037b90d60 (patch) | |
tree | b7fd00875ceacea411c9fcdc2c5f43d21bcf3bb2 /ace | |
parent | dd600ab98d9d6a6d51e984ace1f3b30beff40c0d (diff) | |
download | ATCD-b6ec360e458b19e01d661cdc302d68f037b90d60.tar.gz |
ChangeLogTag:Wed Aug 22 17:33:29 2001 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Configuration.cpp | 4 | ||||
-rw-r--r-- | ace/Configuration_Import_Export.cpp | 61 | ||||
-rw-r--r-- | ace/Configuration_Import_Export.h | 3 |
3 files changed, 61 insertions, 7 deletions
diff --git a/ace/Configuration.cpp b/ace/Configuration.cpp index 39f3e68d18a..5e0c3834e04 100644 --- a/ace/Configuration.cpp +++ b/ace/Configuration.cpp @@ -200,14 +200,14 @@ ACE_Configuration::expand_path (const ACE_Configuration_Section_Key& key, int ACE_Configuration::export_config (const ACE_TCHAR* filename) { - ACE_Ini_ImpExp exporter (*this); + ACE_Registry_ImpExp exporter (*this); return exporter.export_config (filename); } int ACE_Configuration::import_config (const ACE_TCHAR* filename) { - ACE_Ini_ImpExp importer (*this); + ACE_Registry_ImpExp importer (*this); return importer.import_config (filename); } diff --git a/ace/Configuration_Import_Export.cpp b/ace/Configuration_Import_Export.cpp index 17bceddd235..1e37d504053 100644 --- a/ace/Configuration_Import_Export.cpp +++ b/ace/Configuration_Import_Export.cpp @@ -56,7 +56,7 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) return -3; } continue; - } + } // end if firs char is a [ if (buffer[0] == ACE_LIB_TEXT ('"')) { @@ -125,8 +125,21 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) // invalid type, ignore continue; } - } - } + }// end if first char is a " + else + { + // if the first character is not a ", [, ;, or # we may be + // processing a file in the old format. + // Try and process the line as such and if it fails, + // return an error + int rc; + if ((rc = process_previous_line_format (buffer, section)) != 0) + { + ACE_OS::fclose (in); + return rc; + } + } // end if maybe old format + } // end while fgets if (ferror (in)) { @@ -271,6 +284,44 @@ ACE_Registry_ImpExp::export_section (const ACE_Configuration_Section_Key& sectio return 0; } +// +// This method read the line format origionally used in ACE 5.1 +// +int +ACE_Registry_ImpExp::process_previous_line_format (ACE_TCHAR* buffer, + ACE_Configuration_Section_Key& section) +{ + // Chop any cr/lf at the end of the line. + ACE_TCHAR *endp = ACE_OS_String::strpbrk (buffer, ACE_TEXT ("\r\n")); + if (endp != 0) + *endp = '\0'; + + // assume this is a value, read in the value name + ACE_TCHAR* end = ACE_OS::strchr (buffer, '='); + if (end) // no =, not a value so just skip it + { + // null terminate the name + *end = 0; + end++; + // determine the type + if (*end == '\"') + { + // string type + if(config_.set_string_value (section, buffer, end + 1)) + return -4; + } + else if (*end == '#') + { + // number type + u_int value = atoi((end + 1)); + if (config_.set_integer_value (section, buffer, value)) + return -4; + } + } + return 0; +} // end read_previous_line_format + + ACE_Ini_ImpExp::ACE_Ini_ImpExp (ACE_Configuration& config) : ACE_Config_ImpExp_Base (config) { @@ -356,8 +407,8 @@ ACE_Ini_ImpExp::import_config (const ACE_TCHAR* fileName) ACE_OS::fclose (in); return -4; } - } - } + } // end if (name) + } // end while fgets if (ferror (in)) { diff --git a/ace/Configuration_Import_Export.h b/ace/Configuration_Import_Export.h index add5fe77fb5..fdb90ae6373 100644 --- a/ace/Configuration_Import_Export.h +++ b/ace/Configuration_Import_Export.h @@ -116,6 +116,9 @@ private: const ACE_TString& path, FILE* out); + int process_previous_line_format (ACE_TCHAR* buffer, + ACE_Configuration_Section_Key& section); + ACE_Registry_ImpExp ( const ACE_Registry_ImpExp&); ACE_Registry_ImpExp& operator= ( const ACE_Registry_ImpExp&); }; |