"Fossies" - the Fresh Open Source Software Archive

Member "npadmin-0.14/structfill.h" (19 Apr 2001, 2193 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 __STRUCTFILL_H__
   22 #define __STRUCTFILL_H__
   23 
   24 #include <stdarg.h>
   25 #include <string.h>
   26 
   27 #include "session.h"
   28 #include "oidseq.h"
   29 
   30 class TableEntry {
   31 public:
   32   const char *oidstr;
   33   Tags type;
   34   unsigned int offset;
   35 
   36   struct TableEntry *next;
   37 
   38   TableEntry(const char *ostr,Tags thetype,unsigned int off,
   39          TableEntry *nxt);
   40   
   41   int operator==(const char *str){ return !strcmp(str,oidstr);}
   42 };
   43 
   44 class SNMP_structFiller{
   45   TableEntry *tabdef;
   46   OidSeq *oidseq;
   47   OidSeq *retseq;
   48   SNMP_session &session;
   49 
   50   SNMP_structFiller(SNMP_session &sess, unsigned int num, va_list args);
   51   int fillStruct(OidSeq *data,unsigned char *curstruct);
   52 public:
   53   inline SNMP_structFiller(SNMP_session &sess): tabdef(NULL),oidseq(NULL),
   54     retseq(NULL),session(sess){}
   55 
   56   ~SNMP_structFiller();
   57 
   58   void append(const char *oidstr,Tags tag,unsigned int offset);
   59   void remove(const char *oidstr);
   60   void reset(){delete retseq; retseq=NULL;}
   61 
   62   void *get(void *tobefilled);
   63   void *get_next(void *tobefilled);
   64 };
   65 
   66 class SNMP_table:public SNMP_structFiller{
   67   unsigned int structlen;
   68 public:
   69   inline SNMP_table(SNMP_session &sess, unsigned int slen):
   70     SNMP_structFiller(sess),structlen(slen){}
   71 
   72   /* returns a pointer to a vector of the type defined with the 
   73      data elements filled in. needs to be freed. */
   74   void *get(unsigned int &len);
   75 };
   76 
   77 #endif