ACE_Service_Gestalt::Processed_Static_Svc:: Processed_Static_Svc (const ACE_Static_Svc_Descriptor *assd) :name_(0), assd_(assd) { #if defined (ACE_HAS_ALLOC_HOOKS) ACE_ALLOCATOR_NORETURN (name_, static_cast<ACE_TCHAR*>(ACE_Allocator::instance()->malloc (sizeof(ACE_TCHAR) * (ACE_OS::strlen(assd->name_)+1)))); #else ACE_NEW_NORETURN (name_, ACE_TCHAR[ACE_OS::strlen(assd->name_)+1]); #endif /* ACE_HAS_ALLOC_HOOKS */ ACE_OS::strcpy(name_,assd->name_); }
ACE_Log_Record::ACE_Log_Record (void) : length_ (0), type_ (0), secs_ (0), usecs_ (0), pid_ (0), msg_data_ (0), msg_data_size_ (0), category_(0) { // ACE_TRACE ("ACE_Log_Record::ACE_Log_Record"); #if defined (ACE_HAS_ALLOC_HOOKS) ACE_ALLOCATOR_NORETURN (this->msg_data_, static_cast<ACE_TCHAR*> (ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * MAXLOGMSGLEN))); #else ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]); #endif /* ACE_HAS_ALLOC_HOOKS */ if (0 != this->msg_data_) { this->msg_data_size_ = MAXLOGMSGLEN; this->msg_data_[0] = '\0'; } }
ACE_Log_Record::ACE_Log_Record (ACE_Log_Priority lp, const ACE_Time_Value &ts, long p) : length_ (0), type_ (ACE_UINT32 (lp)), secs_ (ts.sec ()), usecs_ ((ACE_UINT32) ts.usec ()), pid_ (ACE_UINT32 (p)), msg_data_ (0), msg_data_size_ (0), category_(0) { // ACE_TRACE ("ACE_Log_Record::ACE_Log_Record"); #if defined (ACE_HAS_ALLOC_HOOKS) ACE_ALLOCATOR_NORETURN (this->msg_data_, static_cast<ACE_TCHAR*> (ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * MAXLOGMSGLEN))); #else ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]); #endif /* ACE_HAS_ALLOC_HOOKS */ if (0 != this->msg_data_) { this->msg_data_size_ = MAXLOGMSGLEN; this->msg_data_[0] = '\0'; } }
// Imports the configuration database from filename. // No existing data is removed. int ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) { if (0 == filename) { errno = EINVAL; return -1; } FILE* in = ACE_OS::fopen (filename, ACE_TEXT ("r")); if (!in) return -1; u_int buffer_size = 4096; u_int read_pos = 0; ACE_TCHAR *buffer = 0; #if defined (ACE_HAS_ALLOC_HOOKS) ACE_ALLOCATOR_NORETURN (buffer, static_cast<ACE_TCHAR*> (ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * buffer_size))); #else ACE_NEW_NORETURN (buffer, ACE_TCHAR[buffer_size]); #endif /* ACE_HAS_ALLOC_HOOKS */ if (!buffer) { ACE_Errno_Guard guard (errno); (void) ACE_OS::fclose (in); return -1; } ACE_Configuration_Section_Key section; ACE_TCHAR *end = 0; while (ACE_OS::fgets (buffer+read_pos, buffer_size - read_pos, in)) { // Check if we got all the line. end = ACE_OS::strrchr (buffer + read_pos, ACE_TEXT ('\n')); // look for end of line if (!end) // we havn't reach the end of the line yet { // allocate a new buffer - double size the previous one ACE_TCHAR *temp_buffer; #if defined (ACE_HAS_ALLOC_HOOKS) ACE_ALLOCATOR_NORETURN (temp_buffer, static_cast<ACE_TCHAR*> (ACE_Allocator::instance()->malloc(sizeof (ACE_TCHAR) * buffer_size * 2))); #else ACE_NEW_NORETURN (temp_buffer, ACE_TCHAR[buffer_size * 2]); #endif /* ACE_HAS_ALLOC_HOOKS */ if (!temp_buffer) { ACE_Errno_Guard guard (errno); #if defined (ACE_HAS_ALLOC_HOOKS) ACE_Allocator::instance()->free(buffer); #else delete [] buffer; #endif /* ACE_HAS_ALLOC_HOOKS */ (void) ACE_OS::fclose (in); return -1; } // copy the beginnning of the line ACE_OS::memcpy (temp_buffer, buffer, buffer_size); read_pos = buffer_size - 1; buffer_size *= 2; #if defined (ACE_HAS_ALLOC_HOOKS) ACE_Allocator::instance()->free(buffer); #else delete [] buffer; #endif /* ACE_HAS_ALLOC_HOOKS */ buffer = temp_buffer; continue; } read_pos = 0; // Check for a comment if (buffer[0] == ACE_TEXT (';') || buffer[0] == ACE_TEXT ('#')) continue; if (buffer[0] == ACE_TEXT ('[')) { // We have a new section here, strip out the section name end = ACE_OS::strrchr (buffer, ACE_TEXT (']')); if (!end) { ACE_OS::fclose (in); #if defined (ACE_HAS_ALLOC_HOOKS) ACE_Allocator::instance()->free(buffer); #else delete [] buffer; #endif /* ACE_HAS_ALLOC_HOOKS */ return -3; } *end = 0; if (config_.expand_path (config_.root_section (), buffer + 1, section, 1)) { ACE_OS::fclose (in); #if defined (ACE_HAS_ALLOC_HOOKS) ACE_Allocator::instance()->free(buffer); #else delete [] buffer; #endif /* ACE_HAS_ALLOC_HOOKS */ return -3; } continue; } // end if firs char is a [ if (buffer[0] == ACE_TEXT ('"')) { // we have a value 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 (config_.set_string_value (section, name, end)) { ACE_OS::fclose (in); #if defined (ACE_HAS_ALLOC_HOOKS) ACE_Allocator::instance()->free(buffer); #else delete [] buffer; #endif /* ACE_HAS_ALLOC_HOOKS */ return -4; } } else if (ACE_OS::strncmp (end, ACE_TEXT ("dword:"), 6) == 0) { // number type ACE_TCHAR* endptr = 0; unsigned long value = ACE_OS::strtoul (end + 6, &endptr, 16); if (config_.set_integer_value (section, name, static_cast<u_int> (value))) { ACE_OS::fclose (in); #if defined (ACE_HAS_ALLOC_HOOKS) ACE_Allocator::instance()->free(buffer); #else delete [] buffer; #endif /* ACE_HAS_ALLOC_HOOKS */ return -4; } } else if (ACE_OS::strncmp (end, ACE_TEXT ("hex:"), 4) == 0) { // binary type size_t string_length = ACE_OS::strlen (end + 4); // divide by 3 to get the actual buffer length size_t length = string_length / 3; size_t remaining = length; u_char* data = 0; #if defined (ACE_HAS_ALLOC_HOOKS) ACE_ALLOCATOR_RETURN (data, static_cast<u_char*> (ACE_Allocator::instance()->malloc(sizeof(u_char) * length)), -1); #else ACE_NEW_RETURN (data, u_char[length], -1); #endif /* ACE_HAS_ALLOC_HOOKS */ 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 (config_.set_binary_value (section, name, data, length)) { ACE_OS::fclose (in); #if defined (ACE_HAS_ALLOC_HOOKS) ACE_Allocator::instance()->free(data); ACE_Allocator::instance()->free(buffer); #else delete [] data; delete [] buffer; #endif /* ACE_HAS_ALLOC_HOOKS */ return -4; } else #if defined (ACE_HAS_ALLOC_HOOKS) ACE_Allocator::instance()->free(data); #else delete [] data; #endif /* ACE_HAS_ALLOC_HOOKS */ } else { // 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 = process_previous_line_format (buffer, section); if (rc != 0) { ACE_OS::fclose (in); #if defined (ACE_HAS_ALLOC_HOOKS) ACE_Allocator::instance()->free(buffer); #else delete [] buffer; #endif /* ACE_HAS_ALLOC_HOOKS */ return rc; } } // end if maybe old format } // end while fgets if (ferror (in)) { ACE_OS::fclose (in); #if defined (ACE_HAS_ALLOC_HOOKS) ACE_Allocator::instance()->free(buffer); #else delete [] buffer; #endif /* ACE_HAS_ALLOC_HOOKS */ return -1; } ACE_OS::fclose (in); #if defined (ACE_HAS_ALLOC_HOOKS) ACE_Allocator::instance()->free(buffer); #else delete [] buffer; #endif /* ACE_HAS_ALLOC_HOOKS */ return 0; }