summaryrefslogtreecommitdiff
path: root/ace/Configuration.cpp
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>2001-01-20 20:56:50 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>2001-01-20 20:56:50 +0000
commit8827fc710debc42b9b260cbfae2c69fa7773a605 (patch)
tree7bc2b4a61e6683825801772a7f5e3ff5e50d7357 /ace/Configuration.cpp
parent8e91c1f500f6519c2e15a06a60358bc624d7f2b7 (diff)
downloadATCD-8827fc710debc42b9b260cbfae2c69fa7773a605.tar.gz
ChangeLogTag:Sat Jan 20 14:53:07 2001 Douglas C. Schmidt <schmidt@ace.cs.wustl.edu>
Diffstat (limited to 'ace/Configuration.cpp')
-rw-r--r--ace/Configuration.cpp446
1 files changed, 221 insertions, 225 deletions
diff --git a/ace/Configuration.cpp b/ace/Configuration.cpp
index ce7db1000e6..3f559598b5a 100644
--- a/ace/Configuration.cpp
+++ b/ace/Configuration.cpp
@@ -165,62 +165,39 @@ ACE_Configuration::expand_path (const ACE_Configuration_Section_Key& key,
ACE_Configuration_Section_Key& key_out,
int create)
{
- const ACE_TCHAR* begin = path_in.fast_rep ();
- const ACE_TCHAR* end = 0;
-
// Make a copy of key
ACE_Configuration_Section_Key current_section = key;
-
- // recurse through the path
- while (1)
- {
- // Detmine the begin/ending of the key name
- end = ACE_OS::strchr (begin, ACE_LIB_TEXT ('\\'));
- size_t length = end ? (size_t)(end-begin) : ACE_OS::strlen (begin);
-
- // Make sure length is not 0
- if (!length)
- return -1;
-
- ACE_TString section (begin, length);
-
- // Open the section
- ACE_Configuration_Section_Key child_section;
- if (open_section (current_section,
- section.fast_rep (),
- create,
- child_section))
- return -1;
-
- current_section = child_section;
-
- // If end is NULL, we are done, return the result
- if (!end)
- {
- key_out = current_section;
- break;
- }
- begin = end + 1;
- }
+ ACE_TString data (path_in);
+ ACE_TCHAR *pData = (ACE_TCHAR *) data.c_str ();
+ ACE_Tokenizer parser (pData);
+ parser.delimiter_replace ('\\', '\0');
+ parser.delimiter_replace ('/', '\0');
+
+ for (char *temp, parser.next (); current_section = key_out)
+ // Open the section
+ if (open_section (current_section,
+ temp,
+ create,
+ key_out))
+ return -1;
return 0;
}
int
-ACE_Configuration::validate_name (const ACE_TCHAR* name)
+ACE_Configuration::validate_name (const ACE_TCHAR *name)
{
- const ACE_TCHAR* pos = name;
- // make sure it doesn't contain any invalid characters
- while (*pos)
- {
- if (ACE_OS::strchr (ACE_LIB_TEXT ("\\]["), *pos))
- return -1;
+ const ACE_TCHAR *pos;
- pos++;
- }
+ for (pos = name;
+ // Make sure it doesn't contain any invalid characters
+ *pos != '\0';
+ pos++)
+ if (ACE_OS::strchr (ACE_LIB_TEXT ("\\]["), *pos))
+ return -1;
- // Make sure its not too long
- if (pos - name > 255)
+ // Make sure its not too long.
+ if (pos - name > ACE_Configuration::MAX_NAME_LEN)
return -2;
return 0;
@@ -252,6 +229,7 @@ ACE_Configuration::export_section (const ACE_Configuration_Section_Key& section,
void* binary_data;
u_int binary_length;
ACE_TString string_value;
+
while (!enumerate_values (section, index, name, type))
{
line = ACE_LIB_TEXT ("\"") + name + ACE_LIB_TEXT ("\"=");
@@ -279,33 +257,32 @@ ACE_Configuration::export_section (const ACE_Configuration_Section_Key& section,
line += string_value + ACE_LIB_TEXT ("\"");
break;
}
-#ifdef _WIN32
+#if defined (ACE_WIN32)
case INVALID:
-#endif
+#endif /* ACE_WIN32 */
case BINARY:
{
// not supported yet - maybe use BASE64 codeing?
- if(get_binary_value(section,
- name.fast_rep(),
- binary_data,
- binary_length))
+ if (get_binary_value (section,
+ name.fast_rep (),
+ binary_data,
+ binary_length))
return -2;
line += ACE_LIB_TEXT ("hex:");
- unsigned char* ptr = (unsigned char*)binary_data;
- while(binary_length)
- {
- if(ptr != binary_data)
+ u_char *ptr = (u_char *) binary_data;
+ while (binary_length)
{
- line += ACE_LIB_TEXT (",");
+ if (ptr != binary_data)
+ line += ACE_LIB_TEXT (",");
+
+ ACE_OS::sprintf (bin_value, ACE_LIB_TEXT ("%02x"), *ptr);
+ line += bin_value;
+ --binary_length;
+ ++ptr;
}
- ACE_OS::sprintf(bin_value, ACE_LIB_TEXT ("%02x"), *ptr);
- line += bin_value;
- --binary_length;
- ++ptr;
- }
- delete (char *)binary_data;
+ delete (char *) binary_data;
break;
}
default:
@@ -348,7 +325,7 @@ ACE_Configuration::export_section (const ACE_Configuration_Section_Key& section,
int
ACE_Configuration::export_config (const ACE_TCHAR* filename)
{
- FILE* out = ACE_OS::fopen (filename, ACE_LIB_TEXT ("w"));
+ FILE *out = ACE_OS::fopen (filename, ACE_LIB_TEXT ("w"));
if (!out)
return -1;
@@ -376,102 +353,98 @@ ACE_Configuration::import_config (const ACE_TCHAR* filename)
if (buffer[0] == ACE_LIB_TEXT ('['))
{
// We have a new section here, strip out the section name
- ACE_TCHAR* end = ACE_OS::strrchr(buffer, ACE_LIB_TEXT (']'));
- if(!end)
- {
- fclose(in);
- return -3;
- }
+ ACE_TCHAR* end = ACE_OS::strrchr (buffer, ACE_LIB_TEXT (']'));
+ if (!end)
+ {
+ ACE_OS::fclose (in);
+ return -3;
+ }
*end = 0;
if (expand_path (root_, buffer + 1, section, 1))
- {
- fclose(in);
- return -3;
- }
+ {
+ ACE_OS::fclose (in);
+ return -3;
+ }
continue;
}
- if(buffer[0] == ACE_LIB_TEXT ('"'))
- {
- // we have a value
- ACE_TCHAR* end = ACE_OS::strchr (buffer+1, '"');
- if (!end) // no closing quote, not a value so just skip it
- continue;
+ if (buffer[0] == ACE_LIB_TEXT ('"'))
+ {
+ // we have a value
+ ACE_TCHAR* end = ACE_OS::strchr (buffer+1, '"');
+ if (!end) // no closing quote, not a value so just skip it
+ continue;
- // null terminate the name
- *end = 0;
- ACE_TCHAR* name = buffer + 1;
- end+=2;
- // determine the type
- if (*end == '\"')
- {
- // string type
- // truncate trailing "
- ++end;
- ACE_TCHAR* trailing = ACE_OS::strrchr(end, '"');
- if(trailing)
- {
- *trailing = 0;
- }
- if (set_string_value (section, name, end))
- {
- fclose(in);
- return -4;
- }
- }
- else if (ACE_OS::strncmp(end, ACE_LIB_TEXT ("dword:"), 6) == 0)
- {
- // number type
- ACE_TCHAR* endptr = 0;
- u_int value = ACE_OS::strtoul(end + 6, &endptr, 16);
- if (set_integer_value (section, name, value))
+ // null terminate the name
+ *end = 0;
+ ACE_TCHAR* name = buffer + 1;
+ end+=2;
+ // determine the type
+ if (*end == '\"')
{
- fclose(in);
- return -4;
+ // string type
+ // truncate trailing "
+ ++end;
+ ACE_TCHAR* trailing = ACE_OS::strrchr (end, '"');
+ if (trailing)
+ *trailing = 0;
+ if (set_string_value (section, name, end))
+ {
+ ACE_OS::fclose (in);
+ return -4;
+ }
}
- }
- else if(ACE_OS::strncmp(end, ACE_LIB_TEXT ("hex:"), 4) == 0)
- {
- // binary type
- u_int string_length = ACE_OS::strlen(end+4);
- // divide by 3 to get the actual buffer length
- u_int length = string_length / 3;
- u_int remaining = length;
- u_char* data = new u_char[length];
- u_char* out = data;
- ACE_TCHAR* inb = end + 4;
- ACE_TCHAR* endptr = 0;
- while(remaining)
+ else if (ACE_OS::strncmp (end, ACE_LIB_TEXT ("dword:"), 6) == 0)
{
- u_char charin = (u_char)ACE_OS::strtoul(inb, &endptr, 16);
- *out = charin;
- ++out;
- --remaining;
- inb += 3;
+ // number type
+ ACE_TCHAR* endptr = 0;
+ u_int value = ACE_OS::strtoul (end + 6, &endptr, 16);
+ if (set_integer_value (section, name, value))
+ {
+ ACE_OS::fclose (in);
+ return -4;
+ }
}
- if(set_binary_value(section, name, data, length))
+ else if (ACE_OS::strncmp (end, ACE_LIB_TEXT ("hex:"), 4) == 0)
{
- fclose(in);
- return -4;
+ // binary type
+ u_int string_length = ACE_OS::strlen (end + 4);
+ // divide by 3 to get the actual buffer length
+ u_int length = string_length / 3;
+ u_int remaining = length;
+ u_char* data = new u_char[length];
+ u_char* out = data;
+ ACE_TCHAR* inb = end + 4;
+ ACE_TCHAR* endptr = 0;
+ while (remaining)
+ {
+ u_char charin = (u_char) ACE_OS::strtoul (inb, &endptr, 16);
+ *out = charin;
+ ++out;
+ --remaining;
+ inb += 3;
+ }
+ if (set_binary_value (section, name, data, length))
+ {
+ ACE_OS::fclose (in);
+ return -4;
+ }
}
- }
- else
- {
+ else
// invalid type, ignore
continue;
- }
- }
+ }
}
if (ferror (in))
- {
- fclose(in);
- return -1;
- }
+ {
+ ACE_OS::fclose (in);
+ return -1;
+ }
- fclose(in);
+ ACE_OS::fclose (in);
return 0;
}
@@ -485,7 +458,7 @@ ACE_Configuration::root_section (void)
#if defined (WIN32)
-static const int ACE_DEFAULT_BUFSIZE = 256;
+static const int ACE_DEFAULT_BUFSIZE = ACE_Configuration::MAX_NAME_LEN + 1;
ACE_Section_Key_Win32::ACE_Section_Key_Win32 (HKEY hKey)
: hKey_ (hKey)
@@ -688,7 +661,7 @@ ACE_Configuration_Win32Registry::set_string_value (const ACE_Configuration_Secti
name,
0,
REG_SZ,
- (BYTE *) value.fast_rep (),
+ (BYTE *) value.fast_rep (),
value.length () + 1) != ERROR_SUCCESS)
return -2;
@@ -711,7 +684,7 @@ ACE_Configuration_Win32Registry::set_integer_value (const ACE_Configuration_Sect
name,
0,
REG_DWORD,
- (BYTE *) &value,
+ (BYTE *) &value,
sizeof (value)) != ERROR_SUCCESS)
return -2;
@@ -735,7 +708,7 @@ ACE_Configuration_Win32Registry::set_binary_value (const ACE_Configuration_Secti
name,
0,
REG_BINARY,
- (BYTE*)data,
+ (BYTE*)data,
length) != ERROR_SUCCESS)
return -2;
@@ -754,21 +727,36 @@ ACE_Configuration_Win32Registry::get_string_value (const ACE_Configuration_Secti
if (load_key (key, base_key))
return -1;
- ACE_TCHAR buffer[ACE_DEFAULT_BUFSIZE];
- DWORD 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,
- &length) != ERROR_SUCCESS)
+ name,
+ NULL,
+ &type,
+ (BYTE*)0,
+ &buffer_length) != ERROR_SUCCESS)
return -2;
if (type != REG_SZ)
return -3;
+ ACE_TCHAR* buffer;
+ ACE_NEW_RETURN (buffer, ACE_TCHAR[buffer_length], -4);
+
+ if (ACE_TEXT_RegQueryValueEx (base_key,
+ name,
+ NULL,
+ &type,
+ (BYTE*)buffer,
+ &buffer_length) != ERROR_SUCCESS)
+ {
+ delete[] buffer;
+ return -5;
+ }
+
value = buffer;
+ delete[] buffer;
return 0;
}
@@ -790,7 +778,7 @@ ACE_Configuration_Win32Registry::get_integer_value (const ACE_Configuration_Sect
name,
NULL,
&type,
- (BYTE*)&value,
+ (BYTE*)&value,
&length) != ERROR_SUCCESS)
return -2;
@@ -820,7 +808,7 @@ ACE_Configuration_Win32Registry::get_binary_value (const ACE_Configuration_Secti
name,
NULL,
&type,
- (BYTE*)0,
+ (BYTE*)0,
&buffer_length) != ERROR_SUCCESS)
return -2;
@@ -829,16 +817,16 @@ ACE_Configuration_Win32Registry::get_binary_value (const ACE_Configuration_Secti
length = buffer_length;
- ACE_NEW_RETURN (data, unsigned char[length], -4);
+ ACE_NEW_RETURN (data, u_char[length], -4);
if (ACE_TEXT_RegQueryValueEx (base_key,
name,
NULL,
&type,
- (BYTE*)data,
+ (BYTE*)data,
&buffer_length) != ERROR_SUCCESS)
{
- delete data;
+ delete[] data;
data = 0;
return -5;
}
@@ -846,7 +834,7 @@ ACE_Configuration_Win32Registry::get_binary_value (const ACE_Configuration_Secti
return 0;
}
-int ACE_Configuration_Win32Registry::find_value(const ACE_Configuration_Section_Key& key,
+int ACE_Configuration_Win32Registry::find_value (const ACE_Configuration_Section_Key& key,
const ACE_TCHAR* name,
VALUETYPE& type_out)
{
@@ -857,18 +845,20 @@ int ACE_Configuration_Win32Registry::find_value(const ACE_Configuration_Section_
if (load_key (key, base_key))
return -1;
- unsigned char buffer[ACE_DEFAULT_BUFSIZE];
- DWORD buffer_length = ACE_DEFAULT_BUFSIZE;
+ DWORD buffer_length=0;
DWORD type;
- if (ACE_TEXT_RegQueryValueEx (base_key,
+ int result=ACE_TEXT_RegQueryValueEx (base_key,
name,
NULL,
&type,
- (BYTE*)&buffer,
- &buffer_length) != ERROR_SUCCESS)
+ NULL,
+ &buffer_length);
+ if (result != ERROR_SUCCESS)
+ {
return -1;
+ }
- switch(type)
+ switch (type)
{
case REG_SZ:
type_out = STRING;
@@ -935,7 +925,7 @@ ACE_Configuration_Win32Registry::resolve_key (HKEY hKey,
{
// Detmine the begin/ending of the key name
end = ACE_OS::strchr (begin, ACE_LIB_TEXT ('\\'));
- size_t length = end ? (size_t)(end-begin) : ACE_OS::strlen (begin);
+ size_t length = end ? (size_t) (end-begin) : ACE_OS::strlen (begin);
// Make sure length is not 0
if (!length)
@@ -979,13 +969,8 @@ ACE_Configuration_Win32Registry::resolve_key (HKEY hKey,
#endif // ghs
}
-
-
#endif // WIN_32
-
-
-
///////////////////////////////////////////////////////////////
ACE_Configuration_Value_IntId::ACE_Configuration_Value_IntId (void)
@@ -1149,8 +1134,8 @@ ACE_Configuration_Section_IntId::operator= (const ACE_Configuration_Section_IntI
void
ACE_Configuration_Section_IntId::free (ACE_Allocator* allocator)
{
- allocator->free ((void *)(value_hash_map_));
- allocator->free ((void *)(section_hash_map_));
+ allocator->free ((void *) (value_hash_map_));
+ allocator->free ((void *) (section_hash_map_));
}
ACE_Configuration_Section_Key_Heap::ACE_Configuration_Section_Key_Heap (const ACE_TCHAR* path)
@@ -1174,7 +1159,7 @@ ACE_Configuration_Heap::ACE_Configuration_Heap (void)
: allocator_ (0),
index_ (0),
default_map_size_ (0),
- persistent_(0)
+ persistent_ (0)
{
ACE_Configuration_Section_Key_Heap *temp = 0;
@@ -1187,8 +1172,8 @@ ACE_Configuration_Heap::~ACE_Configuration_Heap (void)
if (allocator_)
{
allocator_->sync ();
- if(!persistent_)
- allocator_->remove();
+ if (!persistent_)
+ allocator_->remove ();
}
delete allocator_;
}
@@ -1290,7 +1275,7 @@ int
ACE_Configuration_Heap::create_index_helper (void *buffer)
{
ACE_NEW_RETURN (this->index_,
- (buffer) SECTION_MAP (this->allocator_),
+ (buffer) SECTION_MAP (this->allocator_),
-1);
return 0;
}
@@ -1361,7 +1346,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 * sizeof(ACE_TCHAR));
+ ACE_TCHAR *ptr = (ACE_TCHAR*) this->allocator_->malloc (section_len * sizeof (ACE_TCHAR));
int return_value = -1;
@@ -1406,7 +1391,7 @@ ACE_Configuration_Heap::new_section (const ACE_TString& section,
ACE_Configuration_ExtId name (ptr);
ACE_Configuration_Section_IntId entry ((VALUE_MAP*)value_hash_map ,
- (SUBSECTION_MAP*)section_hash_map);
+ (SUBSECTION_MAP*)section_hash_map);
// Do a normal bind. This will fail if there's already an
// entry with the same name.
@@ -1424,7 +1409,7 @@ ACE_Configuration_Heap::new_section (const ACE_TString& section,
// Free our dynamically allocated memory.
this->allocator_->free ((void *) ptr);
else
- // If bind() succeed, it will automatically sync
+ // If bind () succeed, it will automatically sync
// up the map manager entry. However, we must sync up our
// name/value memory.
this->allocator_->sync (ptr, section_len);
@@ -1443,7 +1428,7 @@ ACE_Configuration_Heap::value_open_helper (size_t hash_table_size,
void *buffer)
{
ACE_NEW_RETURN (buffer,
- (buffer) VALUE_MAP (hash_table_size, this->allocator_),
+ (buffer) VALUE_MAP (hash_table_size, this->allocator_),
-1);
return 0;
}
@@ -1453,7 +1438,7 @@ ACE_Configuration_Heap::section_open_helper (size_t hash_table_size,
void *buffer)
{
ACE_NEW_RETURN (buffer,
- (buffer) SUBSECTION_MAP (hash_table_size, this->allocator_),
+ (buffer) SUBSECTION_MAP (hash_table_size, this->allocator_),
-1);
return 0;
}
@@ -1549,7 +1534,7 @@ ACE_Configuration_Heap::remove_section (const ACE_Configuration_Section_Key& key
// Now remove subkey from parent key
ACE_Configuration_ExtId SubSExtId (sub_section);
SUBSECTION_ENTRY* subsection_entry;
- if (((SUBSECTION_HASH*)ParentIntId.section_hash_map_)->
+ if (( (SUBSECTION_HASH*)ParentIntId.section_hash_map_)->
find (SubSExtId, subsection_entry))
return -4;
@@ -1565,6 +1550,7 @@ ACE_Configuration_Heap::remove_section (const ACE_Configuration_Section_Key& key
// iterate over all values and free memory
VALUE_HASH* value_hash_map = section_entry->int_id_.value_hash_map_;
VALUE_HASH::ITERATOR value_iter = value_hash_map->begin ();
+
while (!value_iter.done ())
{
VALUE_ENTRY* value_entry;
@@ -1611,12 +1597,14 @@ ACE_Configuration_Heap::enumerate_values (const ACE_Configuration_Section_Key& k
// Handle iterator resets
if (index == 0)
{
- ACE_Hash_Map_Manager_Ex<ACE_Configuration_ExtId , ACE_Configuration_Value_IntId, ACE_Hash<ACE_Configuration_ExtId>, ACE_Equal_To<ACE_Configuration_ExtId>, ACE_Null_Mutex>* hash_map = IntId.value_hash_map_;
- // @@ This zero pointer check is redundant -Ossama
- // if (pKey->value_iter_)
+ ACE_Hash_Map_Manager_Ex<ACE_Configuration_ExtId ,
+ ACE_Configuration_Value_IntId,
+ ACE_Hash<ACE_Configuration_ExtId>,
+ ACE_Equal_To<ACE_Configuration_ExtId>,
+ ACE_Null_Mutex>* hash_map = IntId.value_hash_map_;
delete pKey->value_iter_;
- ACE_NEW_RETURN (pKey->value_iter_, VALUE_HASH::ITERATOR(hash_map->begin()), -3);
+ ACE_NEW_RETURN (pKey->value_iter_, VALUE_HASH::ITERATOR (hash_map->begin ()), -3);
}
// Get the next entry
@@ -1653,10 +1641,11 @@ ACE_Configuration_Heap::enumerate_sections (const ACE_Configuration_Section_Key&
// Handle iterator resets
if (index == 0)
{
- if (pKey->section_iter_)
- delete pKey->section_iter_;
+ delete pKey->section_iter_;
- ACE_NEW_RETURN (pKey->section_iter_, SUBSECTION_HASH::ITERATOR (IntId.section_hash_map_->begin ()), -3);
+ ACE_NEW_RETURN (pKey->section_iter_,
+ SUBSECTION_HASH::ITERATOR (IntId.section_hash_map_->begin ()),
+ -3);
}
// Get the next entry
@@ -1690,27 +1679,30 @@ ACE_Configuration_Heap::set_string_value (const ACE_Configuration_Section_Key& k
// Get the entry for this item (if it exists)
VALUE_ENTRY* entry;
- ACE_Configuration_ExtId item_name(name);
- if(section_int.value_hash_map_->VALUE_HASH::find(item_name, entry) == 0)
+ ACE_Configuration_ExtId item_name (name);
+ if (section_int.value_hash_map_->VALUE_HASH::find (item_name, entry) == 0)
{
// found item, replace it
// Free the old value
- entry->int_id_.free(allocator_);
+ entry->int_id_.free (allocator_);
// Allocate the new value in this heap
- ACE_TCHAR* pers_value = (ACE_TCHAR*)allocator_->malloc ((value.length () + 1) * sizeof (ACE_TCHAR));
- ACE_OS::strcpy (pers_value, value.fast_rep());
- ACE_Configuration_Value_IntId new_value_int(pers_value);
+ ACE_TCHAR* pers_value =
+ (ACE_TCHAR*) allocator_->malloc ((value.length () + 1) * sizeof (ACE_TCHAR));
+ ACE_OS::strcpy (pers_value, value.fast_rep ());
+ ACE_Configuration_Value_IntId new_value_int (pers_value);
entry->int_id_ = new_value_int;
}
else
{
// it doesn't exist, bind it
- ACE_TCHAR* pers_name = (ACE_TCHAR*)allocator_->malloc ((ACE_OS::strlen (name) + 1) * sizeof (ACE_TCHAR));
+ ACE_TCHAR* pers_name =
+ (ACE_TCHAR*) allocator_->malloc ((ACE_OS::strlen (name) + 1) * sizeof (ACE_TCHAR));
ACE_OS::strcpy (pers_name, name);
- ACE_TCHAR* pers_value = (ACE_TCHAR*)allocator_->malloc ((value.length () + 1) * sizeof (ACE_TCHAR));
+ ACE_TCHAR* pers_value =
+ (ACE_TCHAR*) allocator_->malloc ((value.length () + 1) * sizeof (ACE_TCHAR));
ACE_OS::strcpy (pers_value, value.fast_rep ());
- ACE_Configuration_ExtId item_name(pers_name);
- ACE_Configuration_Value_IntId item_value(pers_value);
+ ACE_Configuration_ExtId item_name (pers_name);
+ ACE_Configuration_Value_IntId item_value (pers_value);
if (section_int.value_hash_map_->bind (item_name, item_value, allocator_))
{
allocator_->free (pers_value);
@@ -1737,27 +1729,28 @@ ACE_Configuration_Heap::set_integer_value (const ACE_Configuration_Section_Key&
return -1;
// Find this section
- ACE_Configuration_ExtId section_ext(section.fast_rep ());
+ ACE_Configuration_ExtId section_ext (section.fast_rep ());
ACE_Configuration_Section_IntId section_int;
if (index_->find (section_ext, section_int, allocator_))
return -2; // section does not exist
// Get the entry for this item (if it exists)
VALUE_ENTRY* entry;
- ACE_Configuration_ExtId item_name(name);
- if(section_int.value_hash_map_->VALUE_HASH::find(item_name, entry) == 0)
+ ACE_Configuration_ExtId item_name (name);
+ if (section_int.value_hash_map_->VALUE_HASH::find (item_name, entry) == 0)
{
// found item, replace it
- ACE_Configuration_Value_IntId new_value_int(value);
+ ACE_Configuration_Value_IntId new_value_int (value);
entry->int_id_ = new_value_int;
}
else
{
// it doesn't exist, bind it
- ACE_TCHAR* pers_name = (ACE_TCHAR*)allocator_->malloc ((ACE_OS::strlen (name) + 1) * sizeof (ACE_TCHAR));
+ ACE_TCHAR* pers_name =
+ (ACE_TCHAR*) allocator_->malloc ((ACE_OS::strlen (name) + 1) * sizeof (ACE_TCHAR));
ACE_OS::strcpy (pers_name, name);
- ACE_Configuration_ExtId item_name(pers_name);
- ACE_Configuration_Value_IntId item_value(value);
+ ACE_Configuration_ExtId item_name (pers_name);
+ ACE_Configuration_Value_IntId item_value (value);
if (section_int.value_hash_map_->bind (item_name, item_value, allocator_))
{
allocator_->free (pers_name);
@@ -1791,27 +1784,28 @@ ACE_Configuration_Heap::set_binary_value (const ACE_Configuration_Section_Key& k
// Get the entry for this item (if it exists)
VALUE_ENTRY* entry;
- ACE_Configuration_ExtId item_name(name);
- if(section_int.value_hash_map_->VALUE_HASH::find(item_name, entry) == 0)
+ ACE_Configuration_ExtId item_name (name);
+ if (section_int.value_hash_map_->VALUE_HASH::find (item_name, entry) == 0)
{
// found item, replace it
// Free the old value
- entry->int_id_.free(allocator_);
+ entry->int_id_.free (allocator_);
// Allocate the new value in this heap
- ACE_TCHAR* pers_value = (ACE_TCHAR*)allocator_->malloc (length);
+ ACE_TCHAR* pers_value = (ACE_TCHAR*)allocator_->malloc (length);
ACE_OS::memcpy (pers_value, data, length);
- ACE_Configuration_Value_IntId new_value_int(pers_value, length);
+ ACE_Configuration_Value_IntId new_value_int (pers_value, length);
entry->int_id_ = new_value_int;
}
else
{
// it doesn't exist, bind it
- ACE_TCHAR* pers_name = (ACE_TCHAR*)allocator_->malloc ((ACE_OS::strlen (name) + 1) * sizeof (ACE_TCHAR));
+ ACE_TCHAR* pers_name =
+ (ACE_TCHAR*) allocator_->malloc ((ACE_OS::strlen (name) + 1) * sizeof (ACE_TCHAR));
ACE_OS::strcpy (pers_name, name);
- ACE_TCHAR* pers_value = (ACE_TCHAR*)allocator_->malloc (length);
+ ACE_TCHAR* pers_value = (ACE_TCHAR*)allocator_->malloc (length);
ACE_OS::memcpy (pers_value, data, length);
- ACE_Configuration_ExtId item_name(pers_name);
- ACE_Configuration_Value_IntId item_value(pers_value, length);
+ ACE_Configuration_ExtId item_name (pers_name);
+ ACE_Configuration_Value_IntId item_value (pers_value, length);
if (section_int.value_hash_map_->bind (item_name, item_value, allocator_))
{
allocator_->free (pers_value);
@@ -1834,9 +1828,10 @@ ACE_Configuration_Heap::set_binary_value (const ACE_Configuration_Section_Key& k
if (IntId.value_hash_map_->find (VExtIdFind, VIntIdFind, allocator_))
{
// it doesn't exist, bind it
- ACE_TCHAR* pers_name = (ACE_TCHAR*)allocator_->malloc ((ACE_OS::strlen (name) + 1) * sizeof (ACE_TCHAR));
+ ACE_TCHAR* pers_name =
+ (ACE_TCHAR*) allocator_->malloc ((ACE_OS::strlen (name) + 1) * sizeof (ACE_TCHAR));
ACE_OS::strcpy (pers_name, name);
- ACE_TCHAR* pers_value = (ACE_TCHAR*)allocator_->malloc (length);
+ ACE_TCHAR* pers_value = (ACE_TCHAR*)allocator_->malloc (length);
ACE_OS::memcpy (pers_value, data, length);
ACE_Configuration_ExtId VExtId (pers_name);
ACE_Configuration_Value_IntId VIntId (pers_value, length);
@@ -1853,7 +1848,7 @@ ACE_Configuration_Heap::set_binary_value (const ACE_Configuration_Section_Key& k
// it does exist, free the old value memory
VIntIdFind.free (allocator_);
// Assign a new value
- ACE_TCHAR* pers_value = (ACE_TCHAR*)allocator_->malloc (length);
+ ACE_TCHAR* pers_value = (ACE_TCHAR*)allocator_->malloc (length);
ACE_OS::memcpy (pers_value, data, length);
VIntIdFind = ACE_Configuration_Value_IntId (pers_value, length);
}
@@ -1926,7 +1921,7 @@ ACE_Configuration_Heap::get_integer_value (const ACE_Configuration_Section_Key&
return -4;
// Everythings ok, return the data
- value = (u_int)((long)VIntId.data_);
+ value = (u_int) ((long)VIntId.data_);
return 0;
}
@@ -1968,7 +1963,7 @@ ACE_Configuration_Heap::get_binary_value (const ACE_Configuration_Section_Key& k
}
int
-ACE_Configuration_Heap::find_value(const ACE_Configuration_Section_Key& key,
+ACE_Configuration_Heap::find_value (const ACE_Configuration_Section_Key& key,
const ACE_TCHAR* name,
VALUETYPE& type_out)
{
@@ -1989,7 +1984,7 @@ ACE_Configuration_Heap::find_value(const ACE_Configuration_Section_Key& key,
// Find it
ACE_Configuration_ExtId ValueExtId (name);
VALUE_ENTRY* value_entry;
- if (((VALUE_HASH*)IntId.value_hash_map_)->find (ValueExtId, value_entry))
+ if (( (VALUE_HASH*)IntId.value_hash_map_)->find (ValueExtId, value_entry))
return -1; // value does not exist
type_out = value_entry->int_id_.type_;
@@ -2018,7 +2013,7 @@ ACE_Configuration_Heap::remove_value (const ACE_Configuration_Section_Key& key,
// Find it
ACE_Configuration_ExtId ValueExtId (name);
VALUE_ENTRY* value_entry;
- if (((VALUE_HASH*)IntId.value_hash_map_)->find (ValueExtId, value_entry))
+ if (( (VALUE_HASH*)IntId.value_hash_map_)->find (ValueExtId, value_entry))
return -4;
// free it
@@ -2039,15 +2034,16 @@ ACE_Configuration::import_config_as_strings (const ACE_TCHAR* filename)
if (!in)
return -1;
- ACE_TCHAR buffer[BUFSIZ];
+ // @@ Make this a dynamic size!
+ ACE_TCHAR buffer[4096];
ACE_Configuration_Section_Key section;
- while (ACE_OS::fgets (buffer, BUFSIZ, in))
+ while (ACE_OS::fgets (buffer, sizeof buffer, in))
{
// Check for a comment and blank line
if (buffer[0] == ACE_LIB_TEXT (';') || buffer[0] == ACE_LIB_TEXT ('#')
||
buffer[0] == ACE_LIB_TEXT ('\r') || buffer[0] == ACE_LIB_TEXT
- ('\n'))
+ ('\n'))
continue;
if (buffer[0] == ACE_LIB_TEXT ('['))
@@ -2122,7 +2118,7 @@ ACE_TCHAR *
ACE_Configuration::skip_whitespace (ACE_TCHAR *src)
{
ACE_TCHAR *cp = src;
- while ((*cp != '\0') && ((*cp == ' ') || (*cp == '\t')))
+ while ((*cp != '\0') && ((*cp == ' ') || (*cp == '\t')))
cp++;
return cp;