Imported Upstream version 0.4.8
[platform/upstream/libsmi.git] / lib / smi.h.in
1 /*
2  * smi.h --
3  *
4  *      Interface Definition of libsmi (version @VERSION_LIBTOOL@).
5  *
6  * Copyright (c) 1999,2000 Frank Strauss, Technical University of Braunschweig.
7  *
8  * See the file "COPYING" for information on usage and redistribution
9  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10  *
11  * @(#) $Id: smi.h.in 8090 2008-04-18 12:56:29Z strauss $
12  */
13
14 #ifndef _SMI_H
15 #define _SMI_H
16
17 #include <stdlib.h>
18 #include <stdarg.h>
19 #ifdef HAVE_STDINT_H
20 #include <stdint.h>
21 #endif
22 #ifdef HAVE_LIMITS_H
23 #include "limits.h"
24 #endif
25 #include <time.h>
26
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32
33 #define SMI_LIBRARY_VERSION "@VERSION_LIBTOOL@"
34 extern const char *smi_library_version;
35
36 #define SMI_VERSION_MAJOR @LIBSMI_MAJOR@
37 #define SMI_VERSION_MINOR @LIBSMI_MINOR@
38 #define SMI_VERSION_PATCHLEVEL @LIBSMI_PATCHLEVEL@
39 #define SMI_VERSION_STRING "@VERSION_STRING@"
40 extern const char *smi_version_string;
41
42
43
44 #define SMI_FLAG_NODESCR   0x0800 /* do not load descriptions/references.    */
45 #define SMI_FLAG_VIEWALL   0x1000 /* all modules are `known', need no views. */
46 #define SMI_FLAG_ERRORS    0x2000 /* print parser errors.                    */
47 #define SMI_FLAG_RECURSIVE 0x4000 /* recursively parse imported modules.     */
48 #define SMI_FLAG_STATS     0x8000 /* print statistics after parsing module.  */
49 #define SMI_FLAG_MASK      (SMI_FLAG_NODESCR|SMI_FLAG_VIEWALL|SMI_FLAG_STATS|\
50                             SMI_FLAG_RECURSIVE|SMI_FLAG_ERRORS)
51
52
53
54 /* misc mappings of SMI types to C types                                     */
55 typedef char                    *SmiIdentifier;
56 typedef unsigned long           SmiUnsigned32;
57 typedef long                    SmiInteger32;
58 #ifdef _MSC_VER /* if using MSVC and not configure */
59 typedef __int64                 SmiInteger64;
60 typedef unsigned __int64        SmiUnsigned64;
61 #else
62 typedef @UINT64_TYPE@           SmiUnsigned64;
63 typedef @INT64_TYPE@            SmiInteger64;
64 #endif
65 typedef unsigned int            SmiSubid;
66 typedef float                   SmiFloat32;
67 typedef double                  SmiFloat64;
68 typedef long double             SmiFloat128;
69
70
71
72 /* SmiLanguage -- language of an actual MIB module                           */
73 typedef enum SmiLanguage {
74     SMI_LANGUAGE_UNKNOWN                = 0,  /* should not occur            */
75     SMI_LANGUAGE_SMIV1                  = 1,
76     SMI_LANGUAGE_SMIV2                  = 2,
77     SMI_LANGUAGE_SMING                  = 3,
78     SMI_LANGUAGE_SPPI                   = 4
79 } SmiLanguage;
80
81 /* SmiBasetype -- base types of all languages                                */
82 typedef enum SmiBasetype {
83     SMI_BASETYPE_UNKNOWN                = 0,  /* should not occur            */
84     SMI_BASETYPE_INTEGER32              = 1,  /* also SMIv1/v2 INTEGER       */
85     SMI_BASETYPE_OCTETSTRING            = 2,
86     SMI_BASETYPE_OBJECTIDENTIFIER       = 3,
87     SMI_BASETYPE_UNSIGNED32             = 4,
88     SMI_BASETYPE_INTEGER64              = 5,  /* SMIng and SPPI              */
89     SMI_BASETYPE_UNSIGNED64             = 6,  /* SMIv2, SMIng and SPPI       */
90     SMI_BASETYPE_FLOAT32                = 7,  /* only SMIng                  */
91     SMI_BASETYPE_FLOAT64                = 8,  /* only SMIng                  */
92     SMI_BASETYPE_FLOAT128               = 9,  /* only SMIng                  */
93     SMI_BASETYPE_ENUM                   = 10,
94     SMI_BASETYPE_BITS                   = 11, /* SMIv2, SMIng and SPPI       */
95     SMI_BASETYPE_POINTER                = 12  /* only SMIng                  */
96 } SmiBasetype;
97
98 #ifdef INT32_MIN
99 #define SMI_BASETYPE_INTEGER32_MIN  INT32_MIN
100 #else
101 #define SMI_BASETYPE_INTEGER32_MIN  INT_MIN
102 #endif
103 #ifdef INT32_MAX
104 #define SMI_BASETYPE_INTEGER32_MAX  INT32_MAX
105 #else
106 #define SMI_BASETYPE_INTEGER32_MAX  INT_MAX
107 #endif
108 #define SMI_BASETYPE_INTEGER64_MIN  LIBSMI_INT64_MIN
109 #define SMI_BASETYPE_INTEGER64_MAX  LIBSMI_INT64_MAX
110 #define SMI_BASETYPE_UNSIGNED32_MIN 0
111 #ifdef UINT32_MAX
112 #define SMI_BASETYPE_UNSIGNED32_MAX UINT32_MAX
113 #else
114 #define SMI_BASETYPE_UNSIGNED32_MAX UINT_MAX
115 #endif
116 #define SMI_BASETYPE_UNSIGNED64_MIN 0
117 #define SMI_BASETYPE_UNSIGNED64_MAX LIBSMI_UINT64_MAX
118
119 /* SmiStatus -- values of status levels                                      */
120 typedef enum SmiStatus {
121     SMI_STATUS_UNKNOWN          = 0, /* should not occur                     */
122     SMI_STATUS_CURRENT          = 1, /* only SMIv2, SMIng and SPPI           */
123     SMI_STATUS_DEPRECATED       = 2, /* SMIv1, SMIv2, SMIng and SPPI         */
124     SMI_STATUS_MANDATORY        = 3, /* only SMIv1                           */
125     SMI_STATUS_OPTIONAL         = 4, /* only SMIv1                           */
126     SMI_STATUS_OBSOLETE         = 5  /* SMIv1, SMIv2, SMIng and SPPI         */
127 } SmiStatus;
128
129 /* SmiAccess -- values of access levels                                      */
130 typedef enum SmiAccess {
131     SMI_ACCESS_UNKNOWN          = 0, /* should not occur                     */
132     SMI_ACCESS_NOT_IMPLEMENTED  = 1, /* only for agent capability variations */
133     SMI_ACCESS_NOT_ACCESSIBLE   = 2, /* the values 2 to 5 are allowed to be  */
134     SMI_ACCESS_NOTIFY           = 3, /* compared by relational operators.    */
135     SMI_ACCESS_READ_ONLY        = 4,
136     SMI_ACCESS_READ_WRITE       = 5,
137     SMI_ACCESS_INSTALL          = 6, /* these three entries are only valid   */
138     SMI_ACCESS_INSTALL_NOTIFY   = 7, /* for SPPI                             */
139     SMI_ACCESS_REPORT_ONLY      = 8,
140     SMI_ACCESS_EVENT_ONLY       = 9      /* this entry is valid only for SMIng   */
141 } SmiAccess;
142
143 /* SmiNodekind -- type or statement that leads to a definition               */
144 typedef unsigned int SmiNodekind;
145 #define SMI_NODEKIND_UNKNOWN      0x0000     /* should not occur             */
146 #define SMI_NODEKIND_NODE         0x0001
147 #define SMI_NODEKIND_SCALAR       0x0002
148 #define SMI_NODEKIND_TABLE        0x0004
149 #define SMI_NODEKIND_ROW          0x0008
150 #define SMI_NODEKIND_COLUMN       0x0010
151 #define SMI_NODEKIND_NOTIFICATION 0x0020
152 #define SMI_NODEKIND_GROUP        0x0040
153 #define SMI_NODEKIND_COMPLIANCE   0x0080
154 #define SMI_NODEKIND_CAPABILITIES 0x0100
155 #define SMI_NODEKIND_ANY          0xffff
156
157 /* SmiDecl -- type or statement that leads to a definition                   */
158 typedef enum SmiDecl {
159     SMI_DECL_UNKNOWN            = 0,  /* should not occur                    */
160     /* SMIv1/v2 ASN.1 statements and macros */
161     SMI_DECL_IMPLICIT_TYPE      = 1,
162     SMI_DECL_TYPEASSIGNMENT     = 2,
163     SMI_DECL_IMPL_SEQUENCEOF    = 4,    /* this will go away */
164     SMI_DECL_VALUEASSIGNMENT    = 5,
165     SMI_DECL_OBJECTTYPE         = 6,    /* values >= 6 are assumed to be */
166     SMI_DECL_OBJECTIDENTITY     = 7,    /* registering an OID, see check.c */
167     SMI_DECL_MODULEIDENTITY     = 8,
168     SMI_DECL_NOTIFICATIONTYPE   = 9,
169     SMI_DECL_TRAPTYPE           = 10,
170     SMI_DECL_OBJECTGROUP        = 11, 
171     SMI_DECL_NOTIFICATIONGROUP  = 12,
172     SMI_DECL_MODULECOMPLIANCE   = 13,
173     SMI_DECL_AGENTCAPABILITIES  = 14,
174     SMI_DECL_TEXTUALCONVENTION  = 15,
175     SMI_DECL_MACRO              = 16,
176     SMI_DECL_COMPL_GROUP        = 17,
177     SMI_DECL_COMPL_OBJECT       = 18,
178     SMI_DECL_IMPL_OBJECT        = 19,   /* object label in sth like "iso(1)" */
179     /* SMIng statements */
180     SMI_DECL_MODULE             = 33,
181     SMI_DECL_EXTENSION          = 34,
182     SMI_DECL_TYPEDEF            = 35,
183     SMI_DECL_NODE               = 36,
184     SMI_DECL_SCALAR             = 37,
185     SMI_DECL_TABLE              = 38,
186     SMI_DECL_ROW                = 39,
187     SMI_DECL_COLUMN             = 40,
188     SMI_DECL_NOTIFICATION       = 41,
189     SMI_DECL_GROUP              = 42,
190     SMI_DECL_COMPLIANCE         = 43,
191     SMI_DECL_IDENTITY           = 44,
192     SMI_DECL_CLASS              = 45,
193     SMI_DECL_ATTRIBUTE          = 46,
194     SMI_DECL_EVENT              = 47
195 } SmiDecl;
196
197 /* SmiIndexkind -- actual kind of a table row's index method                 */
198 typedef enum SmiIndexkind {
199     SMI_INDEX_UNKNOWN           = 0, 
200     SMI_INDEX_INDEX             = 1,
201     SMI_INDEX_AUGMENT           = 2,
202     SMI_INDEX_REORDER           = 3,
203     SMI_INDEX_SPARSE            = 4,
204     SMI_INDEX_EXPAND            = 5
205 } SmiIndexkind;
206
207 /* SmiValue -- any single value; for use in default values and subtyping     */
208 typedef struct SmiValue {
209     SmiBasetype             basetype;
210     unsigned int            len;         /* OID, OctetString, Bits           */
211     union {
212         SmiUnsigned64       unsigned64;
213         SmiInteger64        integer64;
214         SmiUnsigned32       unsigned32;
215         SmiInteger32        integer32;
216         SmiFloat32          float32;
217         SmiFloat64          float64;
218         SmiFloat128         float128;
219         SmiSubid            *oid;
220         char                *ptr;        /* OctetString, Bits                */
221     } value;
222 } SmiValue;
223
224 /* SmiNamedNumber -- a named number; for enumeration and bitset types        */
225 typedef struct SmiNamedNumber {
226     SmiIdentifier       name;
227     SmiValue            value;
228 } SmiNamedNumber;
229
230 /* SmiRange -- a min-max value range; for subtyping of sizes or numbers      */
231 typedef struct SmiRange {
232     SmiValue            minValue;
233     SmiValue            maxValue;
234 } SmiRange;
235
236 /* SmiModule -- the main structure of a module                               */
237 typedef struct SmiModule {
238     SmiIdentifier       name;
239     char                *path;
240     char                *organization;
241     char                *contactinfo;
242     char                *description;
243     char                *reference;
244     SmiLanguage         language;
245     int                 conformance;
246 } SmiModule;
247
248 /* SmiRevision -- content of a single module's revision clause               */
249 typedef struct SmiRevision {
250     time_t              date;
251     char                *description;
252 } SmiRevision;
253
254 /* SmiImport -- an imported descriptor                                       */
255 typedef struct SmiImport {
256     SmiIdentifier       module;
257     SmiIdentifier       name;
258 } SmiImport;
259
260 /* SmiMacro -- the main structure of a SMIv1/v2 macro or SMIng extension     */
261 typedef struct SmiMacro {
262     SmiIdentifier       name;
263     SmiDecl             decl;
264     SmiStatus           status;
265     char                *description;
266     char                *reference;
267     char                *abnf; /* only for SMIng */
268 } SmiMacro;
269
270 /* SmiIdentity -- the main structure of a SMIng Identity.                    */
271 /* NOTE: Not to be confused with SMIv2 MODULE-IDENTITY */
272 typedef struct SmiIdentity {
273     SmiIdentifier       name;
274     SmiDecl             decl;
275     SmiStatus           status;
276     char                *description;
277     char                *reference;
278 } SmiIdentity;
279
280 /* SmiType -- the main structure of a type definition (also base types)      */
281 /* also SMIng attributes      */
282 typedef struct SmiType {
283     SmiIdentifier       name;
284     SmiBasetype         basetype;
285     SmiDecl             decl;
286     char                *format;
287     SmiValue            value;
288     char                *units;
289     SmiStatus           status;
290     char                *description;
291     char                *reference;
292 } SmiType;
293
294 /* SmiNode -- the main structure of any clause that defines a node           */
295 typedef struct SmiNode {
296     SmiIdentifier       name;
297     unsigned int        oidlen;
298     SmiSubid            *oid;         /* array of length oidlen */
299     SmiDecl             decl;
300     SmiAccess           access;
301     SmiStatus           status;
302     char                *format;
303     SmiValue            value;
304     char                *units;
305     char                *description;
306     char                *reference;
307     SmiIndexkind        indexkind;    /* only valid for rows */
308     int                 implied;      /* only valid for rows */
309     int                 create;       /* only valid for rows */
310     SmiNodekind         nodekind;
311 } SmiNode;
312
313 /* SmiElement -- an item in a list (row index column, notification object)   */
314 typedef struct SmiElement {
315 #ifndef __GNUC__
316     char dummy;         /* many compilers are unhappy with empty structures. */
317 #endif
318     /* no visible attributes */
319 } SmiElement;
320
321 /* SmiOption -- an optional group in a compliance statement                  */
322 typedef struct SmiOption {
323     char                *description;
324 } SmiOption;
325
326 /* SmiRefinement -- a refined object in a compliance statement               */
327 typedef struct SmiRefinement {
328     SmiAccess           access;
329     char                *description;
330 } SmiRefinement;
331
332 /* SmiClass -- main structure for SMIng class statement               */
333 typedef struct SmiClass {
334     SmiIdentifier       name;
335     SmiDecl             decl;
336     SmiStatus           status;
337     char                *description;
338     char                *reference;
339 } SmiClass;
340
341 /* SmiClass -- main structure for class attribute               */
342 typedef struct SmiAttribute {
343     SmiIdentifier       name;
344     SmiBasetype         basetype;
345     SmiDecl             decl;
346     char                *format;
347     SmiValue            value;
348     char                *units;
349     SmiStatus           status;
350     char                *description;
351     char                *reference;
352     SmiAccess           access;
353 } SmiAttribute;
354
355
356 /* SmiEvent -- the main structure of a SMIng Event(part of class definition).*/
357 typedef struct SmiEvent {
358     SmiIdentifier       name;
359     SmiDecl             decl;
360     SmiStatus           status;
361     char                *description;
362     char                *reference;
363 } SmiEvent;
364
365
366
367 extern int smiInit(const char *tag);
368
369 extern void smiExit(void);
370
371 extern void smiSetErrorLevel(int level);
372
373 extern int smiGetFlags(void);
374
375 extern void smiSetFlags(int userflags);
376
377 extern char *smiGetPath(void);
378
379 extern int smiSetPath(const char *path);
380
381 extern void smiSetSeverity(char *pattern, int severity);
382
383 extern int smiReadConfig(const char *filename, const char *tag);
384
385 extern char *smiLoadModule(const char *module);
386
387 extern int smiIsLoaded(const char *module);
388
389
390 typedef void (SmiErrorHandler) (char *path, int line, int severity, char *msg, char *tag);
391
392 extern void smiSetErrorHandler(SmiErrorHandler smiErrorHandler);
393
394
395 extern SmiModule *smiGetModule(const char *module);
396
397 extern SmiModule *smiGetFirstModule(void);
398
399 extern SmiModule *smiGetNextModule(SmiModule *smiModulePtr);
400       
401 extern SmiNode *smiGetModuleIdentityNode(SmiModule *smiModulePtr);
402
403 extern SmiImport *smiGetFirstImport(SmiModule *smiModulePtr);
404
405 extern SmiImport *smiGetNextImport(SmiImport *smiImportPtr);
406
407 extern int smiIsImported(SmiModule *smiModulePtr,
408                          SmiModule *importedModulePtr, char *importedName);
409
410 extern SmiRevision *smiGetFirstRevision(SmiModule *smiModulePtr);
411
412 extern SmiRevision *smiGetNextRevision(SmiRevision *smiRevisionPtr);
413
414 extern int smiGetRevisionLine(SmiRevision *smiRevisionPtr);
415
416
417
418 extern SmiIdentity *smiGetFirstIdentity(SmiModule *smiModulePtr);
419
420 extern SmiIdentity *smiGetNextIdentity(SmiIdentity *smiIdentityPtr);
421
422 extern SmiIdentity *smiGetParentIdentity(SmiIdentity *smiIdentityPtr);
423
424 extern int smiGetIdentityLine(SmiIdentity *smiIdentityPtr);
425
426 extern SmiModule *smiGetIdentityModule(SmiIdentity *smiIdentityPtr);
427
428 extern SmiIdentity *smiGetIdentity(SmiModule *smiModulePtr,char *identity);
429
430
431
432 extern SmiType *smiGetType(SmiModule *smiModulePtr, char *type);
433
434 extern SmiType *smiGetFirstType(SmiModule *smiModulePtr);
435
436 extern SmiType *smiGetNextType(SmiType *smiTypePtr);
437
438 extern SmiType *smiGetParentType(SmiType *smiTypePtr);
439
440 extern SmiModule *smiGetTypeModule(SmiType *smiTypePtr);
441
442 extern int smiGetTypeLine(SmiType *smiTypePtr);
443
444 extern SmiRange *smiGetFirstRange(SmiType *smiTypePtr);
445
446 extern SmiRange *smiGetNextRange(SmiRange *smiRangePtr);
447
448 extern int smiGetMinMaxRange(SmiType *smiType, SmiValue *min, SmiValue *max);
449
450 extern SmiNamedNumber *smiGetFirstNamedNumber(SmiType *smiTypePtr);
451
452 extern SmiNamedNumber *smiGetNextNamedNumber(SmiNamedNumber
453                                                  *smiNamedNumberPtr);
454                                                  
455                                                  
456 extern SmiClass *smiGetFirstClass(SmiModule *smiModulePtr);
457
458 extern SmiClass *smiGetNextClass(SmiClass *smiClassPtr);
459
460 extern SmiClass *smiGetParentClass(SmiClass *smiClassPtr);
461
462 extern SmiModule *smiGetClassModule(SmiClass *smiClassPtr);
463
464 extern SmiClass *smiGetClass(SmiModule *smiModulePtr,char *class);
465
466 extern int smiGetClassLine(SmiClass *smiClassPtr);
467
468
469
470 extern SmiAttribute *smiGetAttribute(SmiClass *smiClassPtr, char *attribute);
471
472 extern SmiAttribute *smiGetFirstAttribute(SmiClass *smiClassPtr);
473
474 extern SmiAttribute *smiGetNextAttribute(SmiAttribute *smiAtrributePtr);
475
476 extern SmiType *smiGetAttributeParentType(SmiAttribute *smiAtrributePtr);
477
478 extern SmiClass *smiGetAttributeParentClass(SmiAttribute *smiAtrributePtr);
479
480 extern SmiAttribute *smiGetFirstUniqueAttribute(SmiClass *smiClassPtr);
481
482 extern SmiAttribute *smiGetNextUniqueAttribute(SmiAttribute *smiTypePtr);
483
484 extern int              smiIsClassScalar(SmiClass *smiClassPtr);
485
486 extern SmiNamedNumber *smiGetAttributeFirstNamedNumber(SmiAttribute *smiAttributePtr);
487
488 extern SmiNamedNumber *smiGetAttributeNextNamedNumber(SmiNamedNumber
489                                                  *smiNamedNumberPtr);
490 extern SmiRange *smiGetAttributeFirstRange(SmiAttribute *smiAttributePtr);
491
492 extern SmiRange *smiGetAttributeNextRange(SmiRange *smiRangePtr);
493
494 extern int smiGetAttributeLine(SmiAttribute *smiAttributePtr);
495
496
497 extern SmiEvent *smiGetEvent(SmiClass *smiClassPtr, char *attribute);
498
499 extern SmiEvent *smiGetFirstEvent(SmiClass *smiClassPtr);
500
501 extern SmiEvent *smiGetNextEvent(SmiEvent *smiEventPtr);
502
503 extern int smiGetEventLine(SmiEvent *smiEventPtr);
504
505
506 extern SmiMacro *smiGetMacro(SmiModule *smiModulePtr, char *macro);
507
508 extern SmiMacro *smiGetFirstMacro(SmiModule *smiModulePtr);
509
510 extern SmiMacro *smiGetNextMacro(SmiMacro *smiMacroPtr);
511
512 extern SmiModule *smiGetMacroModule(SmiMacro *smiMacroPtr);
513
514 extern int smiGetMacroLine(SmiMacro *smiMacroPtr);
515
516
517 extern SmiNode *smiGetNode(SmiModule *smiModulePtr, const char *name);
518
519 extern SmiNode *smiGetNodeByOID(unsigned int oidlen, SmiSubid oid[]);
520
521 extern SmiNode *smiGetFirstNode(SmiModule *smiModulePtr, SmiNodekind nodekind);
522
523 extern SmiNode *smiGetNextNode(SmiNode *smiNodePtr, SmiNodekind nodekind);
524
525 extern SmiNode *smiGetParentNode(SmiNode *smiNodePtr);
526
527 extern SmiNode *smiGetRelatedNode(SmiNode *smiNodePtr);
528
529 extern SmiNode *smiGetFirstChildNode(SmiNode *smiNodePtr);
530
531 extern SmiNode *smiGetNextChildNode(SmiNode *smiNodePtr);
532
533 extern SmiModule *smiGetNodeModule(SmiNode *smiNodePtr);
534
535 extern SmiType *smiGetNodeType(SmiNode *smiNodePtr);
536
537 extern int smiGetNodeLine(SmiNode *smiNodePtr);
538
539
540
541
542 extern SmiElement *smiGetFirstElement(SmiNode *smiNodePtr);
543
544 extern SmiElement *smiGetNextElement(SmiElement *smiElementPtr);
545
546 extern SmiNode *smiGetElementNode(SmiElement *smiElementPtr);
547
548
549
550 extern SmiOption *smiGetFirstOption(SmiNode *smiComplianceNodePtr);
551
552 extern SmiOption *smiGetNextOption(SmiOption *smiOptionPtr);
553
554 extern SmiNode *smiGetOptionNode(SmiOption *smiOptionPtr);
555
556 extern int smiGetOptionLine(SmiOption *smiOptionPtr);
557
558
559 extern SmiRefinement *smiGetFirstRefinement(SmiNode *smiComplianceNodePtr);
560
561 extern SmiRefinement *smiGetNextRefinement(SmiRefinement *smiRefinementPtr);
562
563 extern SmiNode *smiGetRefinementNode(SmiRefinement *smiRefinementPtr);
564
565 extern SmiType *smiGetRefinementType(SmiRefinement *smiRefinementPtr);
566
567 extern SmiType *smiGetRefinementWriteType(SmiRefinement *smiRefinementPtr);
568
569 extern int smiGetRefinementLine(SmiRefinement *smiRefinementPtr);
570
571
572 extern SmiElement *smiGetFirstUniquenessElement(SmiNode *smiNodePtr);
573
574 #define smiGetNextUniquenessElement(p) smiGetNextElement(p)
575
576 extern char *smiRenderOID(unsigned int oidlen, SmiSubid *oid, int flags);
577
578 extern char *smiRenderValue(SmiValue *smiValuePtr, SmiType *smiTypePtr,
579                             int flags);
580
581 extern char *smiRenderNode(SmiNode *smiNodePtr, int flags);
582
583 extern char *smiRenderType(SmiType *smiTypePtr, int flags);
584
585 #define SMI_RENDER_NUMERIC   0x01 /* render as numeric values */
586 #define SMI_RENDER_NAME      0x02 /* render as names */
587 #define SMI_RENDER_QUALIFIED 0x04 /* render names with module prefix */
588 #define SMI_RENDER_FORMAT    0x08 /* render by applying the type's format if
589                                      type is given and format is present */
590 #define SMI_RENDER_PRINTABLE 0x10 /* render string values as a printable
591                                      string if all octets are isprint() */
592 #define SMI_RENDER_UNKNOWN   0x20 /* render even unknown items as strings
593                                      ("<unknown>") so that we never get NULL */
594 #define SMI_RENDER_ALL       0xff /* render as `human friendly' as possible */
595
596 #define SMI_UNKNOWN_LABEL "<unknown>"
597
598    
599 /*
600  * The functions smiGetMaxSize() and smiGetMinSize() compute the
601  * max size constraint on a given BITS, OCTET STRING or OBJECT
602  * IDENTIFIER type. The functions recurse towards the top of the
603  * type derivation tree.
604  */
605
606 extern unsigned int smiGetMinSize(SmiType *smiType);
607 extern unsigned int smiGetMaxSize(SmiType *smiType);
608
609 /*
610  * Two utility functions to pack and unpack instance identifiers.
611  * The smiUnpack() function allocates the array of SmiValues and
612  * the smiPack() function allocates the array of SmiSubids.
613  */
614
615 extern int smiUnpack(SmiNode *row, SmiSubid *oid, unsigned int oidlen,
616                      SmiValue **vals, int *valslen);
617
618 extern int smiPack(SmiNode *row, SmiValue *vals, int valslen,
619                    SmiSubid **oid, unsigned int *oidlen);
620
621 /*
622  * Two printf functions that allocate memory dynamically. The call has
623  * to free the allocated memory.
624  */
625
626 extern int smiAsprintf(char **strp, const char *format, ...);
627
628 extern int smiVasprintf(char **strp, const char *format, va_list ap);
629
630
631 /*
632  * The functions smiMalloc() and friends are used within the library
633  * for all memory allocations and deallocations. These functions are
634  * simple wrappers around the standard malloc() and friends functions,
635  * sometimes with some additional checking. We export these functions
636  * because on some systems (e.g. Windows) it is necessary to allocate
637  * / deallocate memory with the 'right' version of malloc() and
638  * friends.
639  */
640
641 #ifdef HAVE_DMALLOC_H
642
643 extern void *_smiMalloc(char *, int, size_t);
644 extern void *_smiRealloc(char *, int, void *ptr, size_t size);
645 extern char *_smiStrdup(char *, int, const char *s1);
646 extern char *_smiStrndup(char *, int, const char *s1, size_t n);
647 extern void _smiFree(char *, int, void *ptr);
648
649 #define smiMalloc(s)    _smiMalloc(__FILE__, __LINE__, s)
650 #define smiRealloc(p,s) _smiRealloc(__FILE__, __LINE__, p, s)
651 #define smiStrdup(s)    _smiStrdup(__FILE__, __LINE__, s)
652 #define smiStrndup(s,n) _smiStrndup(__FILE__, __LINE__, s, n)
653 #define smiFree(p)      _smiFree(__FILE__, __LINE__, p)
654
655 #else
656 extern void *smiMalloc(size_t size);
657 extern void *smiRealloc(void *ptr, size_t size);
658 extern char *smiStrdup(const char *s1);
659 extern char *smiStrndup(const char *s1, size_t n);
660 extern void smiFree(void *ptr);
661 #endif
662
663 #ifdef __cplusplus
664 }
665 #endif
666
667
668 #endif /* _SMI_H */