Roxen.git / server / etc / modules / SNMP.pmod

version» Context lines:

Roxen.git/server/etc/modules/SNMP.pmod:1:   //   // SNMP helper stuff.   // - // $Id: SNMP.pmod,v 1.5 2007/10/25 12:43:44 grubba Exp $ + // $Id: SNMP.pmod,v 1.6 2007/10/25 12:53:46 grubba Exp $   //   // 2007-08-29 Henrik Grubbström   //      // Some OIDs      //! iso.organizations.dod.internet   constant INTERNET_OID = ({ 1, 3, 6, 1 });      //! iso.organizations.dod.internet.private.enterprises.roxenis
Roxen.git/server/etc/modules/SNMP.pmod:49:    update::create(UNDEFINED);    integer::create(val);    } else {    update::create(val);    integer::create(0);    }    doc::create(name, doc_string);    }    static string _sprintf(int t)    { -  if (t == 's') return (string)value; -  return ::_sprintf(t); +  switch(t) { +  case 's': return (string)value; +  default: return sprintf("%s[%d][%d](%O)", type_name, cls, tag, value);    }    } -  + }      class app_octet_string   {    inherit Standards.ASN1.Types.asn1_octet_string : octet_string;    inherit Documentation : doc;    inherit Updateable : update;    constant cls = 1;    constant type_name = "APPLICATION OCTET_STRING";    constant tag = 0;    static void create(string|function(:string) val, string|void name, string|void doc_string)
Roxen.git/server/etc/modules/SNMP.pmod:75:    update::create(UNDEFINED);    octet_string::create(val);    } else {    update::create(val);    octet_string::create("");    }    doc::create(name, doc_string);    }    static string _sprintf(int t)    { -  if (t == 's') return value; -  return ::_sprintf(t); +  switch(t) { +  case 's': return (string)value; +  default: return sprintf("%s[%d][%d](%O)", type_name, cls, tag, value);    }    } -  + }      class OID   {    inherit Standards.ASN1.Types.asn1_identifier : identifier;    inherit Documentation : doc;    constant type_name = "OID";    static void create(array(int) oid, string|void name, string|void doc_string)    {    identifier::create(@oid);    doc::create(name, doc_string);    }    static string _sprintf(int t)    { -  if (t == 's') { -  return ((array(string))id) * "."; +  switch(t) { +  case 's': return ((array(string))id) * "."; +  default: return sprintf("%s[%d][%d](%O)", +  type_name, cls, tag, +  ((array(string))id) * ".");    } -  return ::_sprintf(t); +     }   }      class Integer   {    inherit Standards.ASN1.Types.asn1_integer : integer;    inherit Documentation : doc;    inherit Updateable : update;    constant type_name = "INTEGER";    static void create(int|function(:int) val, string|void name, string|void doc_string)
Roxen.git/server/etc/modules/SNMP.pmod:118:    update::create(UNDEFINED);    integer::create(val);    } else {    update::create(val);    integer::create(0);    }    doc::create(name, doc_string);    }    static string _sprintf(int t)    { -  if (t == 's' || t == 'd') { -  return (string)value; +  switch(t) { +  case 'd': +  case 's': return (string)value; +  default: return sprintf("%s[%d][%d](%O)", type_name, cls, tag, value);    } -  return ::_sprintf(t); +     }   }      class String   {    inherit Standards.ASN1.Types.asn1_octet_string : octet_string;    inherit Documentation : doc;    inherit Updateable : update;    constant type_name = "STRING";    static void create(string|function(:string) val, string|void name, string|void doc_string)
Roxen.git/server/etc/modules/SNMP.pmod:144:    update::create(UNDEFINED);    octet_string::create(val);    } else {    update::create(val);    octet_string::create("");    }    doc::create(name, doc_string);    }    static string _sprintf(int t)    { -  if (t == 's') { -  return value; +  switch(t) { +  case 's': return (string)value; +  default: return sprintf("%s[%d][%d](%O)", +  type_name, cls, tag, (string)value);    } -  return ::_sprintf(t); +     }   }      class Counter   {    inherit app_integer;    constant tag = 1;    constant type_name = "COUNTER";   }   
Roxen.git/server/etc/modules/SNMP.pmod:173:   }      //! One tick is 1/100 seconds.   class Tick   {    inherit app_integer;    constant tag = 3;    constant type_name = "TICK";    static string _sprintf(int t)    { -  if (t == 'd') { -  return (string)value; -  } +     if (t == 's') {    return Roxen.short_date(time(1) + value/100);    }    return ::_sprintf(t);    }   }      class Opaque   {    inherit app_octet_string;