Juergen,
This is the diff from a previous copy I had.
Br,
--
- Yigal
....................
diff -c "c:/yigal/dmh-libsmi/libsmi-svn/libsmi/trunk/lib/smi.c.~1~" "c:/yigal/dmh-libsmi/libsmi-svn/libsmi/trunk/lib/smi.c"
*** c:/yigal/dmh-libsmi/libsmi-svn/libsmi/trunk/lib/smi.c.~1~ Wed Feb 20 22:20:23 2008
--- c:/yigal/dmh-libsmi/libsmi-svn/libsmi/trunk/lib/smi.c Mon Nov 3 22:43:25 2008
***************
*** 8,14 ****
* See the file "COPYING" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
! * @(#) $Id: smi.c 7734 2008-02-15 07:49:14Z schoenw $
*/
#include <config.h>
--- 8,14 ----
* See the file "COPYING" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
! * @(#) $Id: smi.c 10607 2008-10-31 11:28:57Z kanev $
*/
#include <config.h>
***************
*** 25,30 ****
--- 25,33 ----
#include <pwd.h>
#endif
+ /* yh-chnages Thu Feb 21 2008 */
+ #include <limits.h>
+
#include "smi.h"
#include "data.h"
#include "error.h"
***************
*** 41,46 ****
--- 44,54 ----
#include "parser-sming.h"
#endif
+ #ifdef BACKEND_YANG
+ #include "scanner-yang.h"
+ #include "parser-yang.h"
+ #endif
+
#ifdef HAVE_DMALLOC_H
#include <dmalloc.h>
#endif
***************
*** 764,770 ****
for (listPtr = typePtr->listPtr; listPtr; listPtr = listPtr->nextPtr) {
if (((NamedNumber *)(listPtr->ptr))->export.name ==
! smiNamedNumberPtr->name)
break;
}
--- 772,778 ----
for (listPtr = typePtr->listPtr; listPtr; listPtr = listPtr->nextPtr) {
if (((NamedNumber *)(listPtr->ptr))->export.name ==
! smiNamedNumberPtr->name)
break;
}
***************
*** 813,819 ****
for (listPtr = attributePtr->listPtr; listPtr; listPtr = listPtr->nextPtr) {
if (((NamedNumber *)(listPtr->ptr))->export.name ==
! smiNamedNumberPtr->name)
break;
}
--- 821,827 ----
for (listPtr = attributePtr->listPtr; listPtr; listPtr = listPtr->nextPtr) {
if (((NamedNumber *)(listPtr->ptr))->export.name ==
! smiNamedNumberPtr->name)
break;
}
***************
*** 921,927 ****
SmiIdentity *smiGetFirstIdentity(SmiModule *smiModulePtr)
{
! if (!smiModulePtr) {
return NULL;
}
--- 929,935 ----
SmiIdentity *smiGetFirstIdentity(SmiModule *smiModulePtr)
{
! if (!smiModulePtr) {
return NULL;
}
***************
*** 953,959 ****
SmiIdentity *smiGetIdentity(SmiModule *smiModulePtr, char *identity)
{
! if (!smiModulePtr) {
return NULL;
}
else
--- 961,967 ----
SmiIdentity *smiGetIdentity(SmiModule *smiModulePtr, char *identity)
{
! if (!smiModulePtr) {
return NULL;
}
else
***************
*** 961,969 ****
SmiIdentity *ide;
for(ide = smiGetFirstIdentity(smiModulePtr);
! ide;
! ide = smiGetNextIdentity(ide))
! if(!strncmp(ide->name,identity,64))return ide;
return NULL;
}
--- 969,977 ----
SmiIdentity *ide;
for(ide = smiGetFirstIdentity(smiModulePtr);
! ide;
! ide = smiGetNextIdentity(ide))
! if(!strncmp(ide->name,identity,64))return ide;
return NULL;
}
***************
*** 978,984 ****
SmiClass *smiGetFirstClass(SmiModule *smiModulePtr)
{
! if (!smiModulePtr) {
return NULL;
}
--- 986,992 ----
SmiClass *smiGetFirstClass(SmiModule *smiModulePtr)
{
! if (!smiModulePtr) {
return NULL;
}
***************
*** 1010,1016 ****
SmiClass *smiGetClass(SmiModule *smiModulePtr, char *class)
{
! if (!smiModulePtr) {
return NULL;
}
else
--- 1018,1024 ----
SmiClass *smiGetClass(SmiModule *smiModulePtr, char *class)
{
! if (!smiModulePtr) {
return NULL;
}
else
***************
*** 1018,1026 ****
SmiClass *cl;
for(cl = smiGetFirstClass(smiModulePtr);
! cl;
! cl = smiGetNextClass(cl))
! if(!strncmp(cl->name,class,64))return cl;
return NULL;
}
--- 1026,1034 ----
SmiClass *cl;
for(cl = smiGetFirstClass(smiModulePtr);
! cl;
! cl = smiGetNextClass(cl))
! if(!strncmp(cl->name,class,64))return cl;
return NULL;
}
***************
*** 1040,1051 ****
return NULL;
}
! attributePtr = ((Class *)smiClassPtr)->firstAttributePtr;
return &attributePtr->export;
}
! SmiAttribute *smiGetNextAttribute( SmiAttribute *smiTypePtr)
{
Attribute *attributePtr;
--- 1048,1059 ----
return NULL;
}
! attributePtr = ((Class *)smiClassPtr)->firstAttributePtr;
return &attributePtr->export;
}
! SmiAttribute *smiGetNextAttribute( SmiAttribute *smiTypePtr)
{
Attribute *attributePtr;
***************
*** 1058,1193 ****
return &attributePtr->export;
}
! SmiAttribute *smiGetAttribute(SmiClass *smiClassPtr, char *attribute)
{
! Attribute *attributePtr;
! if (!smiClassPtr) {
return NULL;
}
! attributePtr = ((Class *)smiClassPtr)->firstAttributePtr;
!
! for(attributePtr = ((Class *)smiClassPtr)->firstAttributePtr;
! attributePtr; attributePtr = attributePtr->nextPtr)
! {
! if(!strncmp(attributePtr->export.name,attribute,64))
! return &attributePtr->export;
! }
!
! //attribute might belong to the parent so check parent if attribute not found
! smiClassPtr = smiGetParentClass(smiClassPtr);
! attributePtr = (Attribute*)smiGetAttribute(smiClassPtr , attribute);
! return &attributePtr->export;
}
! SmiType *smiGetAttributeParentType(SmiAttribute *smiAttributePtr)
{
!
! if (!smiAttributePtr) {
return NULL;
}
!
! Type *parentTypePtr = ((Attribute*)smiAttributePtr)->parentTypePtr;
!
! if(parentTypePtr)
! return &parentTypePtr->export;
! else
! return NULL;
}
SmiClass *smiGetAttributeParentClass( SmiAttribute *smiAttributePtr)
{
! if (!smiAttributePtr) {
return NULL;
}
! Class *parentClassPtr=((Attribute*)smiAttributePtr)->parentClassPtr;
!
! if(parentClassPtr)
! return &parentClassPtr->export;
! else
! return NULL;
}
! SmiAttribute *smiGetFirstUniqueAttribute(SmiClass *smiClassPtr)
{
! Class *classPtr;
!
! if(!smiClassPtr)
! return NULL;
! classPtr = (Class*)smiClassPtr;
! if(classPtr->uniqueList)
! {
! if(classPtr->uniqueList->ptr == classPtr)
! {
! return NULL; //scalar class
! }
! else
! {
! return ( SmiAttribute*)(classPtr->uniqueList->ptr);
! }
! }
! else
! return NULL;
}
! SmiAttribute *smiGetNextUniqueAttribute( SmiAttribute *smiTypePtr)
{
! Class *classPtr;
! List *listPtr;
!
! if(!smiTypePtr)
! return NULL;
!
! classPtr = ((Attribute*)smiTypePtr)->classPtr;
! if(classPtr && classPtr->uniqueList)
! {
! for(listPtr=classPtr->uniqueList;listPtr;
! listPtr=listPtr->nextPtr)
! {
! if(&((Attribute*)(listPtr->ptr))->export == smiTypePtr)
! {
! if(listPtr->nextPtr)
! return &((Attribute*)(listPtr->nextPtr->ptr))->export;
! }
}
}
! return NULL;
}
int smiGetAttributeLine(SmiAttribute *smiAttributePtr)
{
return ((Attribute *)smiAttributePtr)->line;
}
int smiIsClassScalar(SmiClass *smiClassPtr)
{
! Class *classPtr;
!
! if(!smiClassPtr)
! return 0;
!
! classPtr = (Class*)smiClassPtr;
! if(classPtr->uniqueList)
! {
! if(classPtr->uniqueList->ptr == classPtr)
! {
! return 1; //scalar class
! }
! else
! {
! return 0;
! }
! }
! else
! return 0;
}
--- 1066,1194 ----
return &attributePtr->export;
}
! SmiAttribute *smiGetAttribute(SmiClass *smiClassPtr, char *attribute)
{
! Attribute *attributePtr;
! if (! smiClassPtr) {
return NULL;
}
! attributePtr = ((Class *)smiClassPtr)->firstAttributePtr;
!
! for (attributePtr = ((Class *)smiClassPtr)->firstAttributePtr;
! attributePtr; attributePtr = attributePtr->nextPtr)
! {
! if (!strncmp(attributePtr->export.name, attribute,64)) {
! return &attributePtr->export;
! }
! }
!
! /*
! * attribute might belong to the parent so check parent if
! * attribute not found
! */
!
! smiClassPtr = smiGetParentClass(smiClassPtr);
! attributePtr = (Attribute*)smiGetAttribute(smiClassPtr , attribute);
! return &attributePtr->export;
}
! SmiType *smiGetAttributeParentType(SmiAttribute *smiAttributePtr)
{
+ Type *parentTypePtr;
! if (! smiAttributePtr) {
return NULL;
}
!
! parentTypePtr = ((Attribute*)smiAttributePtr)->parentTypePtr;
!
! return (parentTypePtr) ? &parentTypePtr->export : NULL;
}
SmiClass *smiGetAttributeParentClass( SmiAttribute *smiAttributePtr)
{
! Class *parentClassPtr;
!
! if (! smiAttributePtr) {
return NULL;
}
+
+ parentClassPtr = ((Attribute*)smiAttributePtr)->parentClassPtr;
! return parentClassPtr ? &parentClassPtr->export : NULL;
}
! SmiAttribute *smiGetFirstUniqueAttribute(SmiClass *smiClassPtr)
{
! Class *classPtr;
!
! if (! smiClassPtr) {
! return NULL;
! }
! classPtr = (Class*)smiClassPtr;
! if (! classPtr->uniqueList) {
! return NULL;
! }
!
! if (classPtr->uniqueList->ptr == classPtr) {
! return NULL; /* scalar class */
! }
!
! return (SmiAttribute*)(classPtr->uniqueList->ptr);
}
! SmiAttribute *smiGetNextUniqueAttribute( SmiAttribute *smiTypePtr)
{
! Class *classPtr;
! List *listPtr;
!
! if (! smiTypePtr) {
! return NULL;
! }
! classPtr = ((Attribute*)smiTypePtr)->classPtr;
!
! if (classPtr && classPtr->uniqueList) {
! for (listPtr=classPtr->uniqueList;listPtr; listPtr=listPtr->nextPtr) {
! if (&((Attribute*)(listPtr->ptr))->export == smiTypePtr) {
! if (listPtr->nextPtr) {
! return &((Attribute*)(listPtr->nextPtr->ptr))->export;
}
+ }
}
! }
! return NULL;
}
+
+
int smiGetAttributeLine(SmiAttribute *smiAttributePtr)
{
return ((Attribute *)smiAttributePtr)->line;
}
+
+
int smiIsClassScalar(SmiClass *smiClassPtr)
{
! Class *classPtr;
!
! if (! smiClassPtr) {
! return 0;
! }
! classPtr = (Class*)smiClassPtr;
!
! if (! classPtr->uniqueList) {
! return 0;
! }
!
! return (classPtr->uniqueList->ptr == classPtr);
}
***************
*** 1196,1223 ****
{
Event *eventPtr;
! if (!smiClassPtr) {
return NULL;
}
! eventPtr = ((Class *)smiClassPtr)->firstEventPtr;
!
return &(eventPtr->export);
}
SmiEvent *smiGetNextEvent(SmiEvent *smiEventPtr)
{
Event *eventPtr;
! if (!smiEventPtr) {
return NULL;
}
eventPtr = ((Event *)smiEventPtr)->nextPtr;
-
return &eventPtr->export;
}
int smiGetEventLine(SmiEvent *smiEventPtr)
{
return ((Event *)smiEventPtr)->line;
--- 1197,1226 ----
{
Event *eventPtr;
! if (! smiClassPtr) {
return NULL;
}
! eventPtr = ((Class *)smiClassPtr)->firstEventPtr;
return &(eventPtr->export);
}
+
+
SmiEvent *smiGetNextEvent(SmiEvent *smiEventPtr)
{
Event *eventPtr;
! if (! smiEventPtr) {
return NULL;
}
eventPtr = ((Event *)smiEventPtr)->nextPtr;
return &eventPtr->export;
}
+
+
int smiGetEventLine(SmiEvent *smiEventPtr)
{
return ((Event *)smiEventPtr)->line;
***************
*** 1293,1298 ****
--- 1296,1477 ----
return ((Macro *)smiMacroPtr)->line;
}
+ SmiYangNode *smiGetFirstRootNode(SmiModule *module)
+ {
+ YangNode *node = NULL;
+
+ if(module)
+ {
+ node = ((Module*)module)->firstYangNodePtr;
+ }
+
+ return &(node->export);
+ }
+
+ SmiYangNode *smiGetNextRootNode(SmiYangNode *node)
+ {
+ YangNode *tmp;
+
+ if(!node) return NULL;
+
+ tmp = ((YangNode*)node)->nextSiblingPtr;
+
+ return &(tmp->export);
+ }
+
+ SmiYangNode *smiGetFirstChildYangNode(SmiYangNode *node)
+ {
+ YangNode *tmp;
+
+ if(!node) return NULL;
+
+ tmp = ((YangNode*)node)->firstChildPtr;
+
+ return &(tmp->export);
+ }
+
+ SmiYangNode *smiGetNextChildYangNode(SmiYangNode *node)
+ {
+ YangNode *tmp;
+
+ if(!node) return NULL;
+ tmp = ((YangNode*)node)->nextSiblingPtr;
+ return &(tmp->export);
+ }
+
+ SmiType *smiGetYangNodeType(SmiYangNode *node)
+ {
+ SmiType *type;
+ if(!node) return NULL;
+ type = &(((YangNode*)node)->type->export);
+ return type;
+ }
+
+ SmiRange *smiGetYangNodeMinMaxElements(SmiYangNode *node)
+ {
+ SmiRange *range;
+ if(!node) return NULL;
+ range = &(((YangNode*)node)->minMaxElements->export);
+ return range;
+ }
+
+ SmiYangNode *smiGetFirstUniqueYangNode(SmiYangNode *node)
+ {
+ SmiYangNode *result;
+ YangNode *yn;
+
+ if(!node)return NULL;
+ if(node->nodeKind != SMI_DECL_LIST)
+ {
+ return NULL;
+ }
+
+ yn = (YangNode*)node;
+ if(!yn->uniqueList) return NULL;
+ result = &(yn->uniqueList->yangNode->export);
+ return result;
+ }
+
+ SmiYangNode *smiGetNextUniqueYangNode(SmiYangNode *node)
+ {
+ YangNode *parent;
+ YangNodeList *tmp;
+
+ if(!node) return NULL;
+
+ parent = ((YangNode*)node)->parentPtr;
+
+ if(parent->export.nodeKind != SMI_DECL_LIST)
+ {
+ return NULL;
+ }
+
+ for(tmp = parent->uniqueList; tmp; tmp = tmp->next)
+ {
+ if(&(tmp->yangNode->export) == node) break;
+ }
+
+ if(!tmp)
+ {
+ return NULL;
+ }
+ else if(tmp->next)
+ {
+ SmiYangNode *result = &(tmp->next->yangNode->export);
+ return result;
+ }
+ else return NULL;
+
+ }
+
+ SmiYangNode *smiGetFirstKeyYangNode(SmiYangNode *node)
+ {
+ YangNode *yn;
+ SmiYangNode *result;
+
+ if(!node)return NULL;
+ if(node->nodeKind != SMI_DECL_LIST)
+ {
+ return NULL;
+ }
+
+ yn = (YangNode*)node;
+ if(!yn->keyList) return NULL;
+ result = &(yn->keyList->yangNode->export);
+ return result;
+ }
+
+ SmiYangNode *smiGetNextKeyYangNode(SmiYangNode *node)
+ {
+ YangNode *parent;
+ YangNodeList *tmp;
+
+ if(!node) return NULL;
+
+ parent = ((YangNode*)node)->parentPtr;
+
+ if(parent->export.nodeKind != SMI_DECL_LIST)
+ {
+ return NULL;
+ }
+
+ for(tmp = parent->keyList; tmp; tmp = tmp->next)
+ {
+ if(&(tmp->yangNode->export) == node) break;
+ }
+
+ if(!tmp)
+ {
+ return NULL;
+ }
+ else if(tmp->next)
+ {
+ SmiYangNode *result = &(tmp->next->yangNode->export);
+ return result;
+ }
+ else return NULL;
+
+ }
+
+ SmiMustStatement *smiGetFirstMustStatement(SmiYangNode *node)
+ {
+ Must *must = NULL;
+
+ if(node)
+ {
+ must = ((YangNode*)node)->firstMustPtr;
+ }
+
+ return &(must->export);
+ }
+
+ SmiMustStatement *smiGetNextMustStatement(SmiMustStatement *must)
+ {
+ Must *tmp;
+ if(!must) return NULL;
+ tmp = ((Must*)must)->nextPtr;
+ return &(tmp->export);
+ }
SmiNode *smiGetNode(SmiModule *smiModulePtr, const char *node)
{
***************
*** 1724,1730 ****
}
for (listPtr =
! ((Option *)smiOptionPtr)->compliancePtr->optionlistPtr;
listPtr;
listPtr = listPtr->nextPtr) {
if ((Option *)(listPtr->ptr) == (Option *)smiOptionPtr) {
--- 1903,1909 ----
}
for (listPtr =
! ((Option *)smiOptionPtr)->compliancePtr->optionlistPtr;
listPtr;
listPtr = listPtr->nextPtr) {
if ((Option *)(listPtr->ptr) == (Option *)smiOptionPtr) {
***************
*** 1787,1793 ****
}
for (listPtr =
! ((Refinement *)smiRefinementPtr)->compliancePtr->refinementlistPtr;
listPtr;
listPtr = listPtr->nextPtr) {
if ((Refinement *)(listPtr->ptr) == (Refinement *)smiRefinementPtr) {
--- 1966,1972 ----
}
for (listPtr =
! ((Refinement *)smiRefinementPtr)->compliancePtr->refinementlistPtr;
listPtr;
listPtr = listPtr->nextPtr) {
if ((Refinement *)(listPtr->ptr) == (Refinement *)smiRefinementPtr) {
***************
*** 1867,1873 ****
char *smiRenderOID(unsigned int oidlen, SmiSubid *oid, int flags)
{
! SmiNode *nodePtr;
SmiModule *modulePtr = NULL;
unsigned int i = 0;
char *ss, *s = NULL;
--- 2046,2052 ----
char *smiRenderOID(unsigned int oidlen, SmiSubid *oid, int flags)
{
! SmiNode *nodePtr = NULL;
SmiModule *modulePtr = NULL;
unsigned int i = 0;
char *ss, *s = NULL;
***************
*** 1882,1889 ****
}
if (flags & (SMI_RENDER_NAME | SMI_RENDER_QUALIFIED)) {
! nodePtr = smiGetNodeByOID(oidlen, oid);
! if (nodePtr) {
i = nodePtr->oidlen;
if (flags & SMI_RENDER_QUALIFIED) {
modulePtr = smiGetNodeModule(nodePtr);
--- 2061,2072 ----
}
if (flags & (SMI_RENDER_NAME | SMI_RENDER_QUALIFIED)) {
! int len;
! for (len = oidlen; len; len--) {
! nodePtr = smiGetNodeByOID(len, oid);
! if (! nodePtr || nodePtr->name) break;
! }
! if (nodePtr && nodePtr->name) {
i = nodePtr->oidlen;
if (flags & SMI_RENDER_QUALIFIED) {
modulePtr = smiGetNodeModule(nodePtr);
***************
*** 1914,1920 ****
char *smiRenderValue(SmiValue *smiValuePtr, SmiType *smiTypePtr, int flags)
{
! int i, j, k, n, pfx, have_pfx;
char *last_fmt, *fmt;
SmiUnsigned64 vv;
int xlen;
--- 2097,2104 ----
char *smiRenderValue(SmiValue *smiValuePtr, SmiType *smiTypePtr, int flags)
{
! unsigned int i, pfx;
! int j, k, n, have_pfx;
char *last_fmt, *fmt;
SmiUnsigned64 vv;
int xlen;
***************
*** 1934,2178 ****
}
switch (smiValuePtr->basetype) {
! case SMI_BASETYPE_UNSIGNED32:
! if (!(flags & SMI_RENDER_FORMAT) ||
! !smiTypePtr || !smiTypePtr->format ||
! !strlen(smiTypePtr->format) || smiTypePtr->format[0] == 'd') {
! if (smiTypePtr->format && (strlen(smiTypePtr->format) >= 3) &&
! (smiTypePtr->format[1] == '-')) {
! i = atoi(&smiTypePtr->format[2]);
! if (i < 0) i = 0;
! if (i > 20) i = 20;
! smiAsprintf(&s, "%0*lu.",
! 1 + i,
! smiValuePtr->value.unsigned32);
! if (s) {
! for (j = strlen(s) - 1; i > 0; i--, j--) {
! s[j] = s[j-1];
! }
! s[j] = '.';
! }
! } else {
! smiAsprintf(&s, "%lu", smiValuePtr->value.unsigned32);
! }
! } else if (smiTypePtr->format[0] == 'x') {
! smiAsprintf(&s, "%lx", smiValuePtr->value.unsigned32);
! } else if (smiTypePtr->format[0] == 'o') {
! smiAsprintf(&s, "%lo", smiValuePtr->value.unsigned32);
! } else if (smiTypePtr->format[0] == 'b') {
! for (i = 32 - 1;
! i > 0 && !(smiValuePtr->value.unsigned32 & (1 << i)); i--);
! s = smiMalloc(i + 1 + 1);
! if (s) {
! for (j = 0; i >= 0; i--, j++) {
! s[j] = smiValuePtr->value.unsigned32 & (1<<i) ? '1' : '0';
! }
! s[j] = 0;
! }
! }
! break;
! case SMI_BASETYPE_UNSIGNED64:
! if (!(flags & SMI_RENDER_FORMAT) ||
! !smiTypePtr || !smiTypePtr->format ||
! !strlen(smiTypePtr->format) || smiTypePtr->format[0] == 'd') {
! if (smiTypePtr->format && (strlen(smiTypePtr->format) >= 3) &&
! (smiTypePtr->format[1] == '-')) {
! i = atoi(&smiTypePtr->format[2]);
! if (i < 0) i = 0;
! if (i > 20) i = 20;
! sprintf(f, "%%0%s.", UINT64_FORMAT);
! f[2] = '*';
! smiAsprintf(&s, f,
! 1 + i,
! smiValuePtr->value.unsigned64);
! if (s) {
! for (j = strlen(s) - 1; i > 0; i--, j--) {
! s[j] = s[j-1];
! }
! s[j] = '.';
! }
! } else {
! smiAsprintf(&s, UINT64_FORMAT, smiValuePtr->value.unsigned64);
! }
! } else if (smiTypePtr->format[0] == 'x') {
! strcpy(f, UINT64_FORMAT);
! f[strlen(f)-1] = 'x';
! smiAsprintf(&s, f, smiValuePtr->value.unsigned64);
! } else if (smiTypePtr->format[0] == 'o') {
! strcpy(f, UINT64_FORMAT);
! f[strlen(f)-1] = 'o';
! smiAsprintf(&s, f, smiValuePtr->value.unsigned64);
! } else if (smiTypePtr->format[0] == 'b') {
! for (i = 64 - 1;
! i > 0 && !(smiValuePtr->value.unsigned64 & (1 << i)); i--);
! s = smiMalloc(i + 1 + 1);
! if (s) {
! for (j = 0; i >= 0; i--, j++) {
! s[j] = smiValuePtr->value.unsigned64 & (1<<i) ? '1' : '0';
! }
! s[j] = 0;
! }
! }
! break;
! case SMI_BASETYPE_INTEGER32:
! if (!(flags & SMI_RENDER_FORMAT) ||
! !smiTypePtr || !smiTypePtr->format ||
! !strlen(smiTypePtr->format) || smiTypePtr->format[0] == 'd') {
! if (smiTypePtr->format && (strlen(smiTypePtr->format) >= 3) &&
! (smiTypePtr->format[1] == '-')) {
! i = atoi(&smiTypePtr->format[2]);
! if (i < 0) i = 0;
! if (i > 20) i = 20;
! smiAsprintf(&s, "%0*ld.",
! 1 + i + (smiValuePtr->value.integer32 < 0 ? 1 : 0),
! smiValuePtr->value.integer32);
! if (s) {
! for (j = strlen(s) - 1; i > 0; i--, j--) {
! s[j] = s[j-1];
! }
! s[j] = '.';
! }
! } else {
! smiAsprintf(&s, "%ld", smiValuePtr->value.integer32);
! }
! } else if (smiTypePtr->format[0] == 'x') {
! if (smiValuePtr->value.integer32 >= 0) {
! smiAsprintf(&s, "%lx", smiValuePtr->value.integer32);
! } else {
! smiAsprintf(&s, "-%lx", - smiValuePtr->value.integer32);
! }
! } else if (smiTypePtr->format[0] == 'o') {
! if (smiValuePtr->value.integer32 >= 0) {
! smiAsprintf(&s, "%lo", smiValuePtr->value.integer32);
! } else {
! smiAsprintf(&s, "-%lo", - smiValuePtr->value.integer32);
! }
! } else if (smiTypePtr->format[0] == 'b') {
! if (smiValuePtr->value.integer32 >= 0) {
! v32 = smiValuePtr->value.integer32;
! j = 0;
! } else {
! v32 = - smiValuePtr->value.integer32;
! j = 1;
! }
! for (i = 32 - 1;
! i > 0 && !(v32 & (1 << i)); i--);
! s = smiMalloc(i + j + 1 + 1);
! if (s) {
! s[0] = '-';
! for (; i >= 0; i--, j++) {
! s[j] = v32 & (1<<i) ? '1' : '0';
! }
! s[j] = 0;
! }
! }
! break;
! case SMI_BASETYPE_INTEGER64:
! if (!(flags & SMI_RENDER_FORMAT) ||
! !smiTypePtr || !smiTypePtr->format ||
! !strlen(smiTypePtr->format) || smiTypePtr->format[0] == 'd') {
! if (smiTypePtr->format && (strlen(smiTypePtr->format) >= 3) &&
! (smiTypePtr->format[1] == '-')) {
! i = atoi(&smiTypePtr->format[2]);
! if (i < 0) i = 0;
! if (i > 20) i = 20;
! sprintf(f, "%%0%s.", INT64_FORMAT);
! f[2] = '*';
! smiAsprintf(&s, f,
! 1 + i + (smiValuePtr->value.integer64 < 0 ? 1 : 0),
! smiValuePtr->value.integer64);
! if (s) {
! for (j = strlen(s) - 1; i > 0; i--, j--) {
! s[j] = s[j-1];
! }
! s[j] = '.';
! }
! } else {
! smiAsprintf(&s, INT64_FORMAT, smiValuePtr->value.integer64);
! }
! } else if (smiTypePtr->format[0] == 'x') {
! if (smiValuePtr->value.integer64 >= 0) {
! strcpy(f, UINT64_FORMAT);
! f[strlen(f)-1] = 'x';
! smiAsprintf(&s, f, smiValuePtr->value.integer64);
! } else {
! sprintf(f, "-%s", UINT64_FORMAT);
! f[strlen(f)-1] = 'x';
! smiAsprintf(&s, f, - smiValuePtr->value.integer64);
! }
! } else if (smiTypePtr->format[0] == 'o') {
! if (smiValuePtr->value.integer64 >= 0) {
! strcpy(f, UINT64_FORMAT);
! sprintf(f, "-%s", UINT64_FORMAT);
! f[strlen(f)-1] = 'o';
! smiAsprintf(&s, f, smiValuePtr->value.integer64);
! } else {
! smiAsprintf(&s, f, - smiValuePtr->value.integer64);
! }
! } else if (smiTypePtr->format[0] == 'b') {
! if (smiValuePtr->value.integer64 >= 0) {
! v64 = smiValuePtr->value.integer64;
! j = 0;
! } else {
! v64 = - smiValuePtr->value.integer64;
! j = 1;
! }
! for (i = 64 - 1;
! i > 0 && !(v64 & (1 << i)); i--);
! s = smiMalloc(i + j + 1 + 1);
! if (s) {
! s[0] = '-';
! for (; i >= 0; i--, j++) {
! s[j] = v64 & (1<<i) ? '1' : '0';
! }
! s[j] = 0;
! }
! }
! break;
! case SMI_BASETYPE_OBJECTIDENTIFIER:
! s = smiRenderOID(smiValuePtr->len, smiValuePtr->value.oid, flags);
! break;
! case SMI_BASETYPE_OCTETSTRING:
! if (!(flags & SMI_RENDER_FORMAT) ||
! (!smiTypePtr->format &&
! (smiTypePtr->name && strcmp( smiTypePtr->name, "IpAddress")) ) ) {
! for (i = 0; i < smiValuePtr->len; i++) {
! if (!isprint((int)smiValuePtr->value.ptr[i])) break;
! }
! if ((i < smiValuePtr->len) ||
! !(flags & SMI_RENDER_PRINTABLE)) {
! smiAsprintf(&s, "");
! for (i=0; i < smiValuePtr->len; i++) {
! ss = s;
! smiAsprintf(&s, "%s%02x", ss, smiValuePtr->value.ptr[i]);
! smiFree(ss);
! }
! } else {
! smiAsprintf(&s, "%s", smiValuePtr->value.ptr);
! }
! } else {
! i = 0;
! smiAsprintf(&s, "");
! /* SNMPv2-SMI:IpAddress does not have a display hint.
! ==> let's use this one: "1d." if we have an IpAddress here */
! fmt = (smiTypePtr->name &&
! strcmp( smiTypePtr->name, "IpAddress" ) ) ?
! smiTypePtr->format : "1d.";
! while (*fmt && i < smiValuePtr->len) {
! last_fmt = fmt;
! have_pfx = pfx = 0; /* scan prefix: */
! while (*fmt && isdigit((int)*fmt)) {
! pfx = pfx * 10 + *fmt - '0', have_pfx = 1, fmt++;
! }
! if (! have_pfx) {
! pfx = 1;
! }
! switch (*fmt) {
! case 't':
! /* XXX UTF-8 not implemented, fall through to ASCII (a) */
! case 'a':
! n = (pfx < (smiValuePtr->len - i)) ?
! pfx : smiValuePtr->len - i;
for (k = 0; k < n; k++) {
if (! isascii((int) smiValuePtr->value.ptr[i+k])) {
smiFree(s);
--- 2118,2363 ----
}
switch (smiValuePtr->basetype) {
! case SMI_BASETYPE_UNSIGNED32:
! if (!(flags & SMI_RENDER_FORMAT) ||
! !smiTypePtr || !smiTypePtr->format ||
! !strlen(smiTypePtr->format) || smiTypePtr->format[0] == 'd') {
! if (smiTypePtr->format && (strlen(smiTypePtr->format) >= 3) &&
! (smiTypePtr->format[1] == '-')) {
! i = atoi(&smiTypePtr->format[2]);
! if (i < 0) i = 0;
! if (i > 20) i = 20;
! smiAsprintf(&s, "%0*lu.",
! 1 + i,
! smiValuePtr->value.unsigned32);
! if (s) {
! for (j = strlen(s) - 1; i > 0; i--, j--) {
! s[j] = s[j-1];
! }
! s[j] = '.';
! }
! } else {
! smiAsprintf(&s, "%lu", smiValuePtr->value.unsigned32);
! }
! } else if (smiTypePtr->format[0] == 'x') {
! smiAsprintf(&s, "%lx", smiValuePtr->value.unsigned32);
! } else if (smiTypePtr->format[0] == 'o') {
! smiAsprintf(&s, "%lo", smiValuePtr->value.unsigned32);
! } else if (smiTypePtr->format[0] == 'b') {
! for (i = 32 - 1;
! i > 0 && !(smiValuePtr->value.unsigned32 & (1 << i)); i--);
! s = smiMalloc(i + 1 + 1);
! if (s) {
! for (j = 0; i >= 0; i--, j++) {
! s[j] = smiValuePtr->value.unsigned32 & (1<<i) ? '1' : '0';
! }
! s[j] = 0;
! }
! }
! break;
! case SMI_BASETYPE_UNSIGNED64:
! if (!(flags & SMI_RENDER_FORMAT) ||
! !smiTypePtr || !smiTypePtr->format ||
! !strlen(smiTypePtr->format) || smiTypePtr->format[0] == 'd') {
! if (smiTypePtr->format && (strlen(smiTypePtr->format) >= 3) &&
! (smiTypePtr->format[1] == '-')) {
! i = atoi(&smiTypePtr->format[2]);
! if (i < 0) i = 0;
! if (i > 20) i = 20;
! sprintf(f, "%%0%s.", UINT64_FORMAT);
! f[2] = '*';
! smiAsprintf(&s, f,
! 1 + i,
! smiValuePtr->value.unsigned64);
! if (s) {
! for (j = strlen(s) - 1; i > 0; i--, j--) {
! s[j] = s[j-1];
! }
! s[j] = '.';
! }
! } else {
! smiAsprintf(&s, UINT64_FORMAT, smiValuePtr->value.unsigned64);
! }
! } else if (smiTypePtr->format[0] == 'x') {
! strcpy(f, UINT64_FORMAT);
! f[strlen(f)-1] = 'x';
! smiAsprintf(&s, f, smiValuePtr->value.unsigned64);
! } else if (smiTypePtr->format[0] == 'o') {
! strcpy(f, UINT64_FORMAT);
! f[strlen(f)-1] = 'o';
! smiAsprintf(&s, f, smiValuePtr->value.unsigned64);
! } else if (smiTypePtr->format[0] == 'b') {
! for (i = 64 - 1;
! i > 0 && !(smiValuePtr->value.unsigned64 & (1 << i)); i--);
! s = smiMalloc(i + 1 + 1);
! if (s) {
! for (j = 0; i >= 0; i--, j++) {
! s[j] = smiValuePtr->value.unsigned64 & (1<<i) ? '1' : '0';
! }
! s[j] = 0;
! }
! }
! break;
! case SMI_BASETYPE_INTEGER32:
! if (!(flags & SMI_RENDER_FORMAT) ||
! !smiTypePtr || !smiTypePtr->format ||
! !strlen(smiTypePtr->format) || smiTypePtr->format[0] == 'd') {
! if (smiTypePtr->format && (strlen(smiTypePtr->format) >= 3) &&
! (smiTypePtr->format[1] == '-')) {
! i = atoi(&smiTypePtr->format[2]);
! if (i < 0) i = 0;
! if (i > 20) i = 20;
! smiAsprintf(&s, "%0*ld.",
! 1 + i + (smiValuePtr->value.integer32 < 0 ? 1 : 0),
! smiValuePtr->value.integer32);
! if (s) {
! for (j = strlen(s) - 1; i > 0; i--, j--) {
! s[j] = s[j-1];
! }
! s[j] = '.';
! }
! } else {
! smiAsprintf(&s, "%ld", smiValuePtr->value.integer32);
! }
! } else if (smiTypePtr->format[0] == 'x') {
! if (smiValuePtr->value.integer32 >= 0) {
! smiAsprintf(&s, "%lx", smiValuePtr->value.integer32);
! } else {
! smiAsprintf(&s, "-%lx", - smiValuePtr->value.integer32);
! }
! } else if (smiTypePtr->format[0] == 'o') {
! if (smiValuePtr->value.integer32 >= 0) {
! smiAsprintf(&s, "%lo", smiValuePtr->value.integer32);
! } else {
! smiAsprintf(&s, "-%lo", - smiValuePtr->value.integer32);
! }
! } else if (smiTypePtr->format[0] == 'b') {
! if (smiValuePtr->value.integer32 >= 0) {
! v32 = smiValuePtr->value.integer32;
! j = 0;
! } else {
! v32 = - smiValuePtr->value.integer32;
! j = 1;
! }
! for (i = 32 - 1;
! i > 0 && !(v32 & (1 << i)); i--);
! s = smiMalloc(i + j + 1 + 1);
! if (s) {
! s[0] = '-';
! for (; i >= 0; i--, j++) {
! s[j] = v32 & (1<<i) ? '1' : '0';
! }
! s[j] = 0;
! }
! }
! break;
! case SMI_BASETYPE_INTEGER64:
! if (!(flags & SMI_RENDER_FORMAT) ||
! !smiTypePtr || !smiTypePtr->format ||
! !strlen(smiTypePtr->format) || smiTypePtr->format[0] == 'd') {
! if (smiTypePtr->format && (strlen(smiTypePtr->format) >= 3) &&
! (smiTypePtr->format[1] == '-')) {
! i = atoi(&smiTypePtr->format[2]);
! if (i < 0) i = 0;
! if (i > 20) i = 20;
! sprintf(f, "%%0%s.", INT64_FORMAT);
! f[2] = '*';
! smiAsprintf(&s, f,
! 1 + i + (smiValuePtr->value.integer64 < 0 ? 1 : 0),
! smiValuePtr->value.integer64);
! if (s) {
! for (j = strlen(s) - 1; i > 0; i--, j--) {
! s[j] = s[j-1];
! }
! s[j] = '.';
! }
! } else {
! smiAsprintf(&s, INT64_FORMAT, smiValuePtr->value.integer64);
! }
! } else if (smiTypePtr->format[0] == 'x') {
! if (smiValuePtr->value.integer64 >= 0) {
! strcpy(f, UINT64_FORMAT);
! f[strlen(f)-1] = 'x';
! smiAsprintf(&s, f, smiValuePtr->value.integer64);
! } else {
! sprintf(f, "-%s", UINT64_FORMAT);
! f[strlen(f)-1] = 'x';
! smiAsprintf(&s, f, - smiValuePtr->value.integer64);
! }
! } else if (smiTypePtr->format[0] == 'o') {
! if (smiValuePtr->value.integer64 >= 0) {
! strcpy(f, UINT64_FORMAT);
! sprintf(f, "-%s", UINT64_FORMAT);
! f[strlen(f)-1] = 'o';
! smiAsprintf(&s, f, smiValuePtr->value.integer64);
! } else {
! smiAsprintf(&s, f, - smiValuePtr->value.integer64);
! }
! } else if (smiTypePtr->format[0] == 'b') {
! if (smiValuePtr->value.integer64 >= 0) {
! v64 = smiValuePtr->value.integer64;
! j = 0;
! } else {
! v64 = - smiValuePtr->value.integer64;
! j = 1;
! }
! for (i = 64 - 1;
! i > 0 && !(v64 & (1 << i)); i--);
! s = smiMalloc(i + j + 1 + 1);
! if (s) {
! s[0] = '-';
! for (; i >= 0; i--, j++) {
! s[j] = v64 & (1<<i) ? '1' : '0';
! }
! s[j] = 0;
! }
! }
! break;
! case SMI_BASETYPE_OBJECTIDENTIFIER:
! s = smiRenderOID(smiValuePtr->len, smiValuePtr->value.oid, flags);
! break;
! case SMI_BASETYPE_OCTETSTRING:
! if (!(flags & SMI_RENDER_FORMAT) ||
! (!smiTypePtr->format && !smiTypePtr->name) ||
! (!smiTypePtr->format &&
! (smiTypePtr->name && strcmp( smiTypePtr->name, "IpAddress")) ) ) {
! for (i = 0; i < smiValuePtr->len; i++) {
! if (!isprint((int)smiValuePtr->value.ptr[i])) break;
! }
! if ((i < smiValuePtr->len) ||
! !(flags & SMI_RENDER_PRINTABLE)) {
! smiAsprintf(&s, "");
! for (i=0; i < smiValuePtr->len; i++) {
! ss = s;
! smiAsprintf(&s, "%s%02x", ss, smiValuePtr->value.ptr[i]);
! smiFree(ss);
! }
! } else {
! smiAsprintf(&s, "%s", smiValuePtr->value.ptr);
! }
! } else {
! i = 0;
! smiAsprintf(&s, "");
! /* SNMPv2-SMI:IpAddress does not have a display hint.
! ==> let's use this one: "1d." if we have an IpAddress here */
! fmt = (smiTypePtr->name &&
! strcmp( smiTypePtr->name, "IpAddress" ) ) ?
! smiTypePtr->format : "1d.";
! while (*fmt && i < smiValuePtr->len) {
! last_fmt = fmt;
! have_pfx = pfx = 0; /* scan prefix: */
! while (*fmt && isdigit((int)*fmt)) {
! pfx = pfx * 10 + *fmt - '0', have_pfx = 1, fmt++;
! }
! if (! have_pfx) {
! pfx = 1;
! }
! switch (*fmt) {
! case 't':
! /* XXX UTF-8 not implemented, fall through to ASCII (a) */
! case 'a':
! n = (pfx < (smiValuePtr->len - i)) ?
! pfx : smiValuePtr->len - i;
for (k = 0; k < n; k++) {
if (! isascii((int) smiValuePtr->value.ptr[i+k])) {
smiFree(s);
***************
*** 2189,2332 ****
}
i += n;
break;
! case 'b':
! case 'd':
! case 'o':
! case 'x':
! /* XXX: limited to no more than
! sizeof(SmiUnsigned64) octets */
! vv = 0;
! xlen = pfx * 2;
! while (pfx > 0 && i < smiValuePtr->len) {
! vv = vv * 256 +
! ((unsigned char)smiValuePtr->value.ptr[i]);
! i++;
! pfx--;
! }
! switch (*fmt) {
! case 'd':
! ss = s;
! sprintf(f, "%%s%s", UINT64_FORMAT);
! smiAsprintf(&s, f, ss, vv);
! smiFree(ss);
! break;
! case 'o':
! ss = s;
! sprintf(f, "%%s%s", UINT64_FORMAT);
! f[strlen(f)-1] = 'o';
! smiAsprintf(&s, f, ss, vv);
! smiFree(ss);
! break;
! case 'x':
! ss = s;
! sprintf(f, "%%s%%0%s", UINT64_FORMAT);
! f[4] = '*';
! f[strlen(f)-1] = 'x';
! smiAsprintf(&s, f, ss, xlen, vv);
! smiFree(ss);
! break;
! case 'b':
! k = pfx * 8 - 1;
! if (k > sizeof(SmiUnsigned64) * 8 - 1)
! k = sizeof(SmiUnsigned64) * 8 - 1;
! for (j = 0; k >= 0; k--, j++) {
! ss = s;
! smiAsprintf(&s, "%s%c",
! ss, vv & (1 << k) ? '1' : '0');
! smiFree(ss);
! }
! break;
! }
! break;
! default:
! smiFree(s);
! if (flags & SMI_RENDER_UNKNOWN) {
! smiAsprintf(&s, SMI_UNKNOWN_LABEL);
! } else {
! s = NULL;
! }
! return s;
! }
! fmt++;
!
! /*
! * Check for a separator and repeat with last format if
! * data is still available.
! */
! if (*fmt && ! isdigit((int) *fmt) && *fmt != '*') {
! if (i < smiValuePtr->len) {
! ss = s;
! smiAsprintf(&s, "%s%c", ss, fmt[0]);
! smiFree(ss);
! }
! fmt++;
! }
!
! if (! *fmt && (i < smiValuePtr->len)) {
! fmt = last_fmt;
! }
! }
! }
! break;
! case SMI_BASETYPE_ENUM:
! if ((flags & SMI_RENDER_NAME) && (smiTypePtr)) {
! for (nn = smiGetFirstNamedNumber(smiTypePtr); nn;
! nn = smiGetNextNamedNumber(nn)) {
! if (nn->value.value.integer32 == smiValuePtr->value.integer32)
! break;
! }
! if (nn) {
! if (flags & SMI_RENDER_NUMERIC) {
! smiAsprintf(&s, "%s(%ld)",
! nn->name, nn->value.value.integer32);
! } else {
! smiAsprintf(&s, "%s", nn->name);
! }
! } else {
! smiAsprintf(&s, "%ld", smiValuePtr->value.integer32);
! }
! } else {
! smiAsprintf(&s, "%ld", smiValuePtr->value.integer32);
! }
! break;
! case SMI_BASETYPE_BITS:
! smiAsprintf(&s, "");
! for (i = 0, nn = NULL; i < smiValuePtr->len * 8; i++) {
! if (smiValuePtr->value.ptr[i/8] & (1 << (7-(i%8)))) {
! if ((flags & SMI_RENDER_NAME) && (smiTypePtr)) {
! for (nn = smiGetFirstNamedNumber(smiTypePtr); nn;
! nn = smiGetNextNamedNumber(nn)) {
! if (nn->value.value.unsigned32 == i)
! break;
! }
! }
! ss = s;
! if ((flags & SMI_RENDER_NAME) &&
! (flags & SMI_RENDER_NUMERIC) && nn) {
! smiAsprintf(&s, "%s%s%s(%d)",
! ss, strlen(ss) ? " " : "", nn->name, i);
! } else if (nn) {
! smiAsprintf(&s, "%s%s%s",
! ss, strlen(ss) ? " " : "", nn->name);
! } else {
! smiAsprintf(&s, "%s%s%d",
! ss, strlen(ss) ? " " : "", i);
! }
! smiFree(ss);
! }
! }
! break;
! case SMI_BASETYPE_FLOAT32:
! case SMI_BASETYPE_FLOAT64:
! case SMI_BASETYPE_FLOAT128:
! case SMI_BASETYPE_UNKNOWN:
! default:
! if (flags & SMI_RENDER_UNKNOWN) {
! smiAsprintf(&s, SMI_UNKNOWN_LABEL);
! } else {
! s = NULL;
! }
! break;
}
return s;
--- 2374,2517 ----
}
i += n;
break;
! case 'b':
! case 'd':
! case 'o':
! case 'x':
! /* XXX: limited to no more than
! sizeof(SmiUnsigned64) octets */
! vv = 0;
! xlen = pfx * 2;
! while (pfx > 0 && i < smiValuePtr->len) {
! vv = vv * 256 +
! ((unsigned char)smiValuePtr->value.ptr[i]);
! i++;
! pfx--;
! }
! switch (*fmt) {
! case 'd':
! ss = s;
! sprintf(f, "%%s%s", UINT64_FORMAT);
! smiAsprintf(&s, f, ss, vv);
! smiFree(ss);
! break;
! case 'o':
! ss = s;
! sprintf(f, "%%s%s", UINT64_FORMAT);
! f[strlen(f)-1] = 'o';
! smiAsprintf(&s, f, ss, vv);
! smiFree(ss);
! break;
! case 'x':
! ss = s;
! sprintf(f, "%%s%%0%s", UINT64_FORMAT);
! f[4] = '*';
! f[strlen(f)-1] = 'x';
! smiAsprintf(&s, f, ss, xlen, vv);
! smiFree(ss);
! break;
! case 'b':
! k = pfx * 8 - 1;
! if (k > sizeof(SmiUnsigned64) * 8 - 1)
! k = sizeof(SmiUnsigned64) * 8 - 1;
! for (j = 0; k >= 0; k--, j++) {
! ss = s;
! smiAsprintf(&s, "%s%c",
! ss, vv & (1 << k) ? '1' : '0');
! smiFree(ss);
! }
! break;
! }
! break;
! default:
! smiFree(s);
! if (flags & SMI_RENDER_UNKNOWN) {
! smiAsprintf(&s, SMI_UNKNOWN_LABEL);
! } else {
! s = NULL;
! }
! return s;
! }
! fmt++;
!
! /*
! * Check for a separator and repeat with last format if
! * data is still available.
! */
! if (*fmt && ! isdigit((int) *fmt) && *fmt != '*') {
! if (i < smiValuePtr->len) {
! ss = s;
! smiAsprintf(&s, "%s%c", ss, fmt[0]);
! smiFree(ss);
! }
! fmt++;
! }
!
! if (! *fmt && (i < smiValuePtr->len)) {
! fmt = last_fmt;
! }
! }
! }
! break;
! case SMI_BASETYPE_ENUM:
! if ((flags & SMI_RENDER_NAME) && (smiTypePtr)) {
! for (nn = smiGetFirstNamedNumber(smiTypePtr); nn;
! nn = smiGetNextNamedNumber(nn)) {
! if (nn->value.value.integer32 == smiValuePtr->value.integer32)
! break;
! }
! if (nn) {
! if (flags & SMI_RENDER_NUMERIC) {
! smiAsprintf(&s, "%s(%ld)",
! nn->name, nn->value.value.integer32);
! } else {
! smiAsprintf(&s, "%s", nn->name);
! }
! } else {
! smiAsprintf(&s, "%ld", smiValuePtr->value.integer32);
! }
! } else {
! smiAsprintf(&s, "%ld", smiValuePtr->value.integer32);
! }
! break;
! case SMI_BASETYPE_BITS:
! smiAsprintf(&s, "");
! for (i = 0, nn = NULL; i < smiValuePtr->len * 8; i++) {
! if (smiValuePtr->value.ptr[i/8] & (1 << (7-(i%8)))) {
! if ((flags & SMI_RENDER_NAME) && (smiTypePtr)) {
! for (nn = smiGetFirstNamedNumber(smiTypePtr); nn;
! nn = smiGetNextNamedNumber(nn)) {
! if (nn->value.value.unsigned32 == i)
! break;
! }
! }
! ss = s;
! if ((flags & SMI_RENDER_NAME) &&
! (flags & SMI_RENDER_NUMERIC) && nn) {
! smiAsprintf(&s, "%s%s%s(%d)",
! ss, strlen(ss) ? " " : "", nn->name, i);
! } else if (nn) {
! smiAsprintf(&s, "%s%s%s",
! ss, strlen(ss) ? " " : "", nn->name);
! } else {
! smiAsprintf(&s, "%s%s%d",
! ss, strlen(ss) ? " " : "", i);
! }
! smiFree(ss);
! }
! }
! break;
! case SMI_BASETYPE_FLOAT32:
! case SMI_BASETYPE_FLOAT64:
! case SMI_BASETYPE_FLOAT128:
! case SMI_BASETYPE_UNKNOWN:
! default:
! if (flags & SMI_RENDER_UNKNOWN) {
! smiAsprintf(&s, SMI_UNKNOWN_LABEL);
! } else {
! s = NULL;
! }
! break;
}
return s;
***************
*** 2391,2404 ****
unsigned int min = 65535, size;
switch (smiType->basetype) {
! case SMI_BASETYPE_BITS:
! return 0;
! case SMI_BASETYPE_OCTETSTRING:
! case SMI_BASETYPE_OBJECTIDENTIFIER:
! size = 0;
! break;
! default:
! return 0;
}
for (smiRange = smiGetFirstRange(smiType);
--- 2576,2589 ----
unsigned int min = 65535, size;
switch (smiType->basetype) {
! case SMI_BASETYPE_BITS:
! return 0;
! case SMI_BASETYPE_OCTETSTRING:
! case SMI_BASETYPE_OBJECTIDENTIFIER:
! size = 0;
! break;
! default:
! return 0;
}
for (smiRange = smiGetFirstRange(smiType);
***************
*** 2432,2446 ****
unsigned int max = 0, size;
switch (smiType->basetype) {
! case SMI_BASETYPE_BITS:
! case SMI_BASETYPE_OCTETSTRING:
! size = 65535;
! break;
! case SMI_BASETYPE_OBJECTIDENTIFIER:
! size = 128;
! break;
! default:
! return 0xffffffff;
}
if (smiType->basetype == SMI_BASETYPE_BITS) {
--- 2617,2631 ----
unsigned int max = 0, size;
switch (smiType->basetype) {
! case SMI_BASETYPE_BITS:
! case SMI_BASETYPE_OCTETSTRING:
! size = 65535;
! break;
! case SMI_BASETYPE_OBJECTIDENTIFIER:
! size = 128;
! break;
! default:
! return 0xffffffff;
}
if (smiType->basetype == SMI_BASETYPE_BITS) {
***************
*** 2492,2511 ****
}
switch (row->indexkind) {
! case SMI_INDEX_INDEX:
! case SMI_INDEX_REORDER:
! indexNode = row;
! break;
! case SMI_INDEX_EXPAND: /* TODO: we have to do more work here! */
! indexNode = NULL;
! break;
! case SMI_INDEX_AUGMENT:
! case SMI_INDEX_SPARSE:
! indexNode = smiGetRelatedNode(row);
! break;
! case SMI_INDEX_UNKNOWN:
! indexNode = NULL;
! break;
}
*valslen = 0;
--- 2677,2696 ----
}
switch (row->indexkind) {
! case SMI_INDEX_INDEX:
! case SMI_INDEX_REORDER:
! indexNode = row;
! break;
! case SMI_INDEX_EXPAND: /* TODO: we have to do more work here! */
! indexNode = NULL;
! break;
! case SMI_INDEX_AUGMENT:
! case SMI_INDEX_SPARSE:
! indexNode = smiGetRelatedNode(row);
! break;
! case SMI_INDEX_UNKNOWN:
! indexNode = NULL;
! break;
}
*valslen = 0;
***************
*** 2532,2552 ****
fprintf(stderr, "** %s (%s)\n", iNode->name, iType->name);
(*vals)[i].basetype = iType->basetype;
switch (iType->basetype) {
! case SMI_BASETYPE_ENUM:
! case SMI_BASETYPE_INTEGER32:
! (*vals)[i].value.integer32 = oid[j]; j++;
! break;
! case SMI_BASETYPE_UNSIGNED32:
! (*vals)[i].value.unsigned32 = oid[j]; j++;
! break;
! case SMI_BASETYPE_OCTETSTRING:
! /* need to know whether implied/fixed length or not */
! break;
! case SMI_BASETYPE_OBJECTIDENTIFIER:
! /* need to know whether implied/fixed length or not */
! break;
! default:
! return 0;
}
}
--- 2717,2737 ----
fprintf(stderr, "** %s (%s)\n", iNode->name, iType->name);
(*vals)[i].basetype = iType->basetype;
switch (iType->basetype) {
! case SMI_BASETYPE_ENUM:
! case SMI_BASETYPE_INTEGER32:
! (*vals)[i].value.integer32 = oid[j]; j++;
! break;
! case SMI_BASETYPE_UNSIGNED32:
! (*vals)[i].value.unsigned32 = oid[j]; j++;
! break;
! case SMI_BASETYPE_OCTETSTRING:
! /* need to know whether implied/fixed length or not */
! break;
! case SMI_BASETYPE_OBJECTIDENTIFIER:
! /* need to know whether implied/fixed length or not */
! break;
! default:
! return 0;
}
}
***************
*** 2600,2665 ****
min->basetype = max->basetype = basetype;
switch (basetype) {
! case SMI_BASETYPE_INTEGER32:
! min->value.integer32 = SMI_BASETYPE_INTEGER32_MAX;
! max->value.integer32 = SMI_BASETYPE_INTEGER32_MIN;
! break;
! case SMI_BASETYPE_INTEGER64:
! min->value.integer64 = SMI_BASETYPE_INTEGER64_MAX;
! max->value.integer64 = SMI_BASETYPE_INTEGER64_MIN;
! break;
! case SMI_BASETYPE_UNSIGNED32:
! min->value.unsigned32 = SMI_BASETYPE_UNSIGNED32_MAX;
! max->value.unsigned32 = SMI_BASETYPE_UNSIGNED32_MIN;
! break;
! case SMI_BASETYPE_UNSIGNED64:
! min->value.unsigned64 = SMI_BASETYPE_UNSIGNED64_MAX;
! max->value.unsigned64 = SMI_BASETYPE_UNSIGNED32_MIN;
! break;
! default:
! fprintf(stderr, "smidump: unexpected basetype %d\n", basetype);
! return -1;
}
for (range = smiGetFirstRange(smiType);
range;
range = smiGetNextRange(range)) {
switch (basetype) {
! case SMI_BASETYPE_INTEGER32:
! if (range->minValue.value.integer32 < min->value.integer32) {
! min->value.integer32 = range->minValue.value.integer32;
! }
! if (range->maxValue.value.integer32 > max->value.integer32) {
! max->value.integer32 = range->maxValue.value.integer32;
! }
! break;
! case SMI_BASETYPE_INTEGER64:
! if (range->minValue.value.integer64 < min->value.integer64) {
! min->value.integer64 = range->minValue.value.integer64;
! }
! if (range->maxValue.value.integer64 > max->value.integer64) {
! max->value.integer64 = range->maxValue.value.integer64;
! }
! break;
! case SMI_BASETYPE_UNSIGNED32:
! if (range->minValue.value.unsigned32 < min->value.unsigned32) {
! min->value.unsigned32 = range->minValue.value.unsigned32;
! }
! if (range->maxValue.value.unsigned32 > max->value.unsigned32) {
! max->value.unsigned32 = range->maxValue.value.unsigned32;
! }
! break;
! case SMI_BASETYPE_UNSIGNED64:
! if (range->minValue.value.unsigned64 < min->value.unsigned64) {
! min->value.unsigned64 = range->minValue.value.unsigned64;
! }
! if (range->maxValue.value.unsigned64 > max->value.unsigned64) {
! max->value.unsigned64 = range->maxValue.value.unsigned64;
! }
! break;
! default:
! fprintf(stderr, "smidump: unexpected basetype %d\n", basetype);
! return -1;
}
}
--- 2785,2850 ----
min->basetype = max->basetype = basetype;
switch (basetype) {
! case SMI_BASETYPE_INTEGER32:
! min->value.integer32 = SMI_BASETYPE_INTEGER32_MAX;
! max->value.integer32 = SMI_BASETYPE_INTEGER32_MIN;
! break;
! case SMI_BASETYPE_INTEGER64:
! min->value.integer64 = SMI_BASETYPE_INTEGER64_MAX;
! max->value.integer64 = SMI_BASETYPE_INTEGER64_MIN;
! break;
! case SMI_BASETYPE_UNSIGNED32:
! min->value.unsigned32 = SMI_BASETYPE_UNSIGNED32_MAX;
! max->value.unsigned32 = SMI_BASETYPE_UNSIGNED32_MIN;
! break;
! case SMI_BASETYPE_UNSIGNED64:
! min->value.unsigned64 = SMI_BASETYPE_UNSIGNED64_MAX;
! max->value.unsigned64 = SMI_BASETYPE_UNSIGNED32_MIN;
! break;
! default:
! fprintf(stderr, "smidump: unexpected basetype %d\n", basetype);
! return -1;
}
for (range = smiGetFirstRange(smiType);
range;
range = smiGetNextRange(range)) {
switch (basetype) {
! case SMI_BASETYPE_INTEGER32:
! if (range->minValue.value.integer32 < min->value.integer32) {
! min->value.integer32 = range->minValue.value.integer32;
! }
! if (range->maxValue.value.integer32 > max->value.integer32) {
! max->value.integer32 = range->maxValue.value.integer32;
! }
! break;
! case SMI_BASETYPE_INTEGER64:
! if (range->minValue.value.integer64 < min->value.integer64) {
! min->value.integer64 = range->minValue.value.integer64;
! }
! if (range->maxValue.value.integer64 > max->value.integer64) {
! max->value.integer64 = range->maxValue.value.integer64;
! }
! break;
! case SMI_BASETYPE_UNSIGNED32:
! if (range->minValue.value.unsigned32 < min->value.unsigned32) {
! min->value.unsigned32 = range->minValue.value.unsigned32;
! }
! if (range->maxValue.value.unsigned32 > max->value.unsigned32) {
! max->value.unsigned32 = range->maxValue.value.unsigned32;
! }
! break;
! case SMI_BASETYPE_UNSIGNED64:
! if (range->minValue.value.unsigned64 < min->value.unsigned64) {
! min->value.unsigned64 = range->minValue.value.unsigned64;
! }
! if (range->maxValue.value.unsigned64 > max->value.unsigned64) {
! max->value.unsigned64 = range->maxValue.value.unsigned64;
! }
! break;
! default:
! fprintf(stderr, "smidump: unexpected basetype %d\n", basetype);
! return -1;
}
}
Diff finished. Tue Nov 04 21:36:07 2008
....................