Exemple #1
0
//==============[Oid:: operator += const char *a ]=========================
// append operator, appends a string
//
// allocate some space for a max oid string
// extract current string into space
// concat new string
// free up existing oid
// make a new oid from string
// delete allocated space
Oid& Oid::operator+=(const char *a)
{
  unsigned int n;

  if (!a) return *this;

  if (*a == '.') ++a;

  n = (smival.value.oid.len * SNMPCHARSIZE) + (smival.value.oid.len)
       + 1 + SAFE_UINT_CAST(strlen(a));
  char *ptr = new char[n];
  if (ptr)
  {
    /// @todo optimze this function (avoid conversion to string)
    OidToStr(&smival.value.oid, n, ptr);
    if (ptr[0])
      STRCAT(ptr,".");
    STRCAT(ptr,a);

    delete_oid_ptr();

    StrToOid(ptr, &smival.value.oid);
    delete [] ptr;
  }
  return *this;
}
Exemple #2
0
//==============[Oid:: operator += const char *a ]=========================
// append operator, appends a string
//
// allocate some space for a max oid string
// extract current string into space
// concat new string
// free up existing oid
// make a new oid from string
// delete allocated space
Oid& Oid::operator+=( const char *a)
{
  unsigned long n;

  if (!a)
    return *this;

  if ( *a=='.')
    a++;
  size_t sz = ACE_OS::strlen(a);

  if (valid()) {
    n = (smival.value.oid.len *SNMPCHARSIZE) + smival.value.oid.len + 1 + sz;
    char *ptr;
    ACE_NEW_RETURN(ptr, char[ n], *this);
    size_t byte_counter;
    if (OidToStr(&smival.value.oid, n,ptr, byte_counter) > 0) {
        delete [] ptr;
        set_invalid();
        return *this;
      }

   if (ACE_OS::strlen(ptr))
     ACE_OS::strcat(ptr,".");
   ACE_OS::strcat(ptr,a);
   if ( smival.value.oid.len !=0) {
     set_invalid();
    }

   if (StrToOid( (char *) ptr, &smival.value.oid, byte_counter) < 0) {
       set_invalid();
   }
   delete [] ptr;
  }
  else {