summaryrefslogtreecommitdiff
path: root/ace/Configuration.cpp
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-09-01 18:30:23 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-09-01 18:30:23 +0000
commit0dfb1ac9f85c222a4b2d6ed0dabcb5b30212bdc5 (patch)
tree58c5905d92a6d827c36b605642639c3eadb4e388 /ace/Configuration.cpp
parent0cc3fd84bd7942b369c0638feabd922093d08348 (diff)
downloadATCD-0dfb1ac9f85c222a4b2d6ed0dabcb5b30212bdc5.tar.gz
ChangeLogTag: Fri Sep 1 13:25:24 2000 Jeff Parsons <parsons@cs.wustl.edu>
Diffstat (limited to 'ace/Configuration.cpp')
-rw-r--r--ace/Configuration.cpp82
1 files changed, 41 insertions, 41 deletions
diff --git a/ace/Configuration.cpp b/ace/Configuration.cpp
index eab5447ff93..a07950b4433 100644
--- a/ace/Configuration.cpp
+++ b/ace/Configuration.cpp
@@ -279,6 +279,9 @@ ACE_Configuration::export_section (const ACE_Configuration_Section_Key& section,
line += string_value + ACE_TEXT("\"");
break;
}
+#ifdef _WIN32
+ case INVALID:
+#endif
case BINARY:
{
// not supported yet - maybe use BASE64 codeing?
@@ -302,6 +305,7 @@ ACE_Configuration::export_section (const ACE_Configuration_Section_Key& section,
--binary_length;
++ptr;
}
+ delete(binary_data);
break;
}
default:
@@ -375,12 +379,16 @@ ACE_Configuration::import_config (const ACE_TCHAR* filename)
ACE_TCHAR* end = ACE_OS::strrchr(buffer, ACE_TEXT(']'));
if(!end)
{
+ fclose(in);
return -3;
}
*end = 0;
if (expand_path (root_, buffer + 1, section, 1))
+ {
+ fclose(in);
return -3;
+ }
continue;
}
@@ -408,7 +416,10 @@ ACE_Configuration::import_config (const ACE_TCHAR* filename)
*trailing = 0;
}
if (set_string_value (section, name, end))
+ {
+ fclose(in);
return -4;
+ }
}
else if (ACE_OS::strncmp(end, ACE_TEXT ("dword:"), 6) == 0)
{
@@ -416,7 +427,10 @@ ACE_Configuration::import_config (const ACE_TCHAR* filename)
ACE_TCHAR* endptr = 0;
u_int value = ACE_OS::strtoul(end + 6, &endptr, 16);
if (set_integer_value (section, name, value))
+ {
+ fclose(in);
return -4;
+ }
}
else if(ACE_OS::strncmp(end, ACE_TEXT ("hex:"), 4) == 0)
{
@@ -427,18 +441,21 @@ ACE_Configuration::import_config (const ACE_TCHAR* filename)
u_int remaining = length;
u_char* data = new u_char[length];
u_char* out = data;
- ACE_TCHAR* in = end + 4;
+ ACE_TCHAR* inb = end + 4;
ACE_TCHAR* endptr = 0;
while(remaining)
{
- u_char charin = (u_char)ACE_OS::strtoul(in, &endptr, 16);
+ u_char charin = (u_char)ACE_OS::strtoul(inb, &endptr, 16);
*out = charin;
++out;
--remaining;
- in += 3;
+ inb += 3;
}
if(set_binary_value(section, name, data, length))
+ {
+ fclose(in);
return -4;
+ }
}
else
{
@@ -447,40 +464,14 @@ ACE_Configuration::import_config (const ACE_TCHAR* filename)
}
}
}
- /*
- // assume this is a value, read in the value name
- ACE_TCHAR* end = ACE_OS::strchr (buffer, ACE_TEXT ('='));
- if (!end) // no =, not a value so just skip it
- continue;
-
- // null terminate the name
- *end = 0;
- end++;
- // determine the type
- if (*end == ACE_TEXT ('\"'))
- {
- // string type
- if (set_string_value (section, buffer, end + 1))
- return -4;
- }
- else if (*end == ACE_TEXT ('#'))
- {
- // number type
- u_int value = ACE_OS::atoi (end + 1);
- if (set_integer_value (section, buffer, value))
- return -4;
- }
- else
- {
- // invalid type, ignore
- continue;
- }
- }
- */
if (ferror (in))
+ {
+ fclose(in);
return -1;
+ }
+ fclose(in);
return 0;
}
@@ -822,14 +813,14 @@ ACE_Configuration_Win32Registry::get_binary_value (const ACE_Configuration_Secti
if (load_key (key, base_key))
return -1;
- unsigned char buffer[ACE_DEFAULT_BUFSIZE];
- DWORD buffer_length = ACE_DEFAULT_BUFSIZE;
+ // Get the size of the binary data from windows
+ DWORD buffer_length = 0;
DWORD type;
if (ACE_TEXT_RegQueryValueEx (base_key,
name,
NULL,
&type,
- (BYTE*)&buffer,
+ (BYTE*)0,
&buffer_length) != ERROR_SUCCESS)
return -2;
@@ -838,11 +829,20 @@ ACE_Configuration_Win32Registry::get_binary_value (const ACE_Configuration_Secti
length = buffer_length;
- char* new_data;
- ACE_NEW_RETURN (new_data, char[length], -4);
+ ACE_NEW_RETURN (data, unsigned char[length], -4);
+
+ if (ACE_TEXT_RegQueryValueEx (base_key,
+ name,
+ NULL,
+ &type,
+ (BYTE*)data,
+ &buffer_length) != ERROR_SUCCESS)
+ {
+ delete data;
+ data = 0;
+ return -5;
+ }
- ACE_OS::memcpy (new_data, buffer, length);
- data = new_data;
return 0;
}
@@ -1354,7 +1354,7 @@ ACE_Configuration_Heap::new_section (const ACE_TString& section,
// Allocate memory for items to be stored in the table.
size_t section_len = section.length () + 1;
- ACE_TCHAR *ptr = (ACE_TCHAR*) this->allocator_->malloc (section_len);
+ ACE_TCHAR *ptr = (ACE_TCHAR*) this->allocator_->malloc (section_len * sizeof(ACE_TCHAR));
int return_value = -1;