"Fossies" - the Fresh Open Source Software Archive

Member "npadmin-0.14/oidseq.h" (19 Apr 2001, 2561 Bytes) of package /linux/misc/old/npadmin-0.14.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /* Copyright (c) 2000 Ben Woodard
    2  * All rights reserved.
    3  *
    4  * This program is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU General Public Licence
    6  * as published by the Free Software Foundation; either version 2
    7  * of the Licence, or (at your option) any later version.
    8  *
    9  * This program is distributed in the hope that it will be useful,
   10  * but WITHOUT ANY WARRENTY; without even the implied warrenty of
   11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   12  * GNU General Public Licence in the COPYING file for more
   13  * details.
   14  *
   15  * You should have received a copy of the GNU Library General 
   16  * Public License along with the GNU C Library; see the file 
   17  * COPYING.LIB.  If not, write to the Free Software Foundation, 
   18  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
   19  */
   20 
   21 #ifndef __OIDSEQ_H__
   22 #define __OIDSEQ_H__
   23 
   24 #include <string.h>
   25 
   26 #include "ber.h"
   27 
   28 struct TableEntry;
   29 
   30 class Assoc{
   31  public:
   32   char *str;
   33   BerOid *oid;
   34   
   35   Assoc *next;
   36   
   37   Assoc(const char *oidstr,Assoc *nxt);
   38   Assoc(const char *oidstr,BerOid *oid,Assoc *nxt);
   39   inline ~Assoc(){ delete str;}
   40 
   41   inline int operator==(const char *oidstr){ return !strcmp(oidstr,str);}
   42 };
   43 
   44 
   45 class OidSeq {
   46   BerSequence *seq;
   47   Assoc *index;
   48 
   49 public:
   50   /* converts a list of strings with the ascii representation of 
   51      oids into an OidSeq. The strings that are passed in are 
   52      duplicated so that there is no confusion as to who should 
   53      delete them. */
   54   inline OidSeq():seq(NULL),index(NULL){}
   55   OidSeq(unsigned int num...); 
   56   OidSeq(BerSequence *valseq); // takes ownership of valseq
   57   /* just grabs the oidstrs out of the table doesn't modify the 
   58      table */
   59   OidSeq(TableEntry *table); 
   60   ~OidSeq();
   61 
   62   //for gets
   63   void append(const char *oidstr);
   64 
   65   //for sets of ints and counters.
   66   void append(const char *oidstr,Tags type, long data);
   67 
   68   //for sets of strings oid's and ipaddrs
   69   void append(CONST char *oidstr,Tags type, void *data, 
   70           unsigned int len);
   71 
   72   void remove(const char *oidstr);
   73 
   74   // returns the pointer to the value (keeps ownership)
   75   BerBase *value(const char* oid); 
   76   BerBase *value(BerOid &oid);
   77   /* returns the pointer to the value of the child whose oid this
   78      is */
   79   BerBase *child(const char *oid);
   80   /* returns the pointer to the beroid who was created with this 
   81      ascii version of the oid */
   82   BerOid *key(const char *oid);
   83 
   84   inline int print(char* str,unsigned int len){ 
   85     return seq->print(str,len);}
   86   inline BerSequence *Seq(){ return seq;}
   87 };
   88 
   89 #endif