📄 smic.c
字号:
/*
* Copyright 1992 SynOptics Communications, Inc. All Rights Reserved.
* SynOptics grants a non-exclusive license to use, copy, modify, and
* distribute this software for any purpose and without fee, provided
* that this copyright notice and license appear on all copies and
* supporting documentation.
* SynOptics makes no representations about the suitability of this
* software for any particular purpose. The software is supplied
* "AS IS", and SynOptics makes no warranty, either express or implied,
* as to the use, operation, condition, or performance of the software.
* SynOptics retains all title and ownership in the software.
*
* file: SMIC.C - SNMP Concise MIB Compiler
*
* Use: SMIC <options> <file>
*
* $Revision: 1.4 $ $Date: 27 Jul 1992 19:49:34 $
* $Log: R:/MIBTOOLS/V1.0/SMIC/SRC/SMIC.C_V $
*
* Rev 1.4 27 Jul 1992 19:49:34 gfoster
* Changed the -7 option to make stricter checking
* of index items instead of looser checking.
*
* Added brackets around the word "options" in
* the usage line.
*
* Rev 1.3 08 Jul 1992 17:31:48 gfoster
* Removed unnecessary revision comment lines added by
* PVCS to make revision history easier to read.
*
* Rev 1.2 08 Jul 1992 16:53:42 gfoster
* Added new option "0" to assign message (error)
* file to output file.
*
* Rev 1.1 19 Jun 1992 16:07:40 gfoster
* Copyright text was reformated.
*
* Name of the variable "usOptChar" changed to "chOptChar".
*
* Added support for environment variable for the include
* file directory.
*
* Changed program help for OID list to indicate it
* also prints traps.
*
* Rev 1.0 27 May 1992 15:57:36 gfoster
* Initial revision.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "allocmem.h"
#include <string.h>
#include <ctype.h>
#include "tds.h"
#include "smscdefs.h"
#include "smstdefs.h"
#include "smsydefs.h"
#include "smic.h"
#include "smicpro.h"
/* BOOL fNoStr;*/ /* suppress strings in scanner */
extern BOOL fNoStrSav; /* saved value when processing directives
(or any thing else where suppressing
is a problem) */
#define MXOPT 4 /* depth of options stack */
USHORT afOpt[MXOPT]; /* stack for options */
USHORT iOpt; /* current depth of option stack */
typedef struct _optEntry {
BOOL *pbOpt; /* ptr to option */
USHORT fVal; /* value for option */
UCHAR chVal; /* char value for option */
} OPTENTRY;
OPTENTRY optTab[] = {
{&fNoStrSav, 0x0001, 'X'}, /* the "saved" value of fNoStr must
be used since the directives
include strings */
{&fCheckRoIndx, 0x0002, 'R'},
{&fCheckSEQ, 0x0004, 'W'},
{&fCheckSR, 0x0008, 'C'},
{&fCheckISR, 0x0010, 'B'},
{&fCheckIndxSeq, 0x0020, '7'},
{&fNoCheckTab, 0x0040, '6'},
{&fNoSeqTcErr, 0x0080, 'E'},
{&fAllowIndx, 0x0100, '3'},
{&fNoUnUsedWarn, 0x0200, 'G'},
{&fAllowAccess, 0x0400, '4'},
{&fAllowOpt, 0x0800, '5'},
{&fAllowDV, 0x1000, 'J'}
};
/** pushOpt - push options on stack
*
* returns:
* TRUE - options pushed
* FALSE - an error
*/
BOOL
#ifdef __STDC__
pushOpt(VOID)
#else
pushOpt()
#endif /* __STDC__ */
{
USHORT fOpt;
USHORT i;
if (iOpt >= MXOPT) {
yyerror("Option stack already at max depth");
return(FALSE);
}
for (i = 0, fOpt = 0; i < sizeof(optTab)/sizeof(OPTENTRY); i++) {
if (*(optTab[i].pbOpt))
fOpt |= optTab[i].fVal;
}
afOpt[iOpt++] = fOpt;
return(TRUE);
} /* pushOpt */
/** popOpt - pop options from stack
*
* returns:
* TRUE - options popped
* FALSE - an error
*/
BOOL
#ifdef __STDC__
popOpt(VOID)
#else
popOpt()
#endif /* __STDC__ */
{
USHORT fOpt;
USHORT i;
if (iOpt == 0) {
yyerror("Option stack empty");
return(FALSE);
}
for (i = 0, fOpt = afOpt[--iOpt]; i < sizeof(optTab)/sizeof(OPTENTRY); i++) {
if (fOpt & optTab[i].fVal)
*(optTab[i].pbOpt) = TRUE;
else
*(optTab[i].pbOpt) = FALSE;
}
return(TRUE);
} /* popOpt */
/** printOpt - print options
*
*/
VOID
#ifdef __STDC__
printOpt(VOID)
#else
printOpt()
#endif /* __STDC__ */
{
USHORT i;
BOOL fNone;
fprintf(fhMsg, "options:");
for (i = 0, fNone = TRUE; i < sizeof(optTab)/sizeof(OPTENTRY); i++) {
if (*(optTab[i].pbOpt)) {
fNone = FALSE;
fprintf(fhMsg, " %c", optTab[i].chVal);
}
}
if (fNone)
fprintf(fhMsg, " **none set**");
fprintf(fhMsg, "\n");
} /* printOpt */
/** addOpt - set on specified options
*
* call with:
* pVal - string of options to turn on
*
* returns:
* TRUE - options set
* FALSE - an error
*/
BOOL
#ifdef __STDC__
addOpt(STRTAB *pVal)
#else
addOpt(pVal)
STRTAB *pVal;
#endif /* __STDC__ */
{
USHORT usOpt;
PSZ pszOpt;
BOOL bRt;
USHORT i;
for (bRt = TRUE, pszOpt = pVal->pszVal; *pszOpt != 0; pszOpt++) {
if (isspace(*pszOpt))
continue;
usOpt = toupper(*pszOpt);
for (i = 0; i < sizeof(optTab)/sizeof(OPTENTRY); i++) {
if (optTab[i].chVal == (UCHAR)usOpt)
break;
}
if (i == sizeof(optTab)/sizeof(OPTENTRY)) {
yyerror("unknown option \'%c\' in \"%s\"",
*pszOpt, pVal->pszVal);
bRt = FALSE;
continue;
}
*(optTab[i].pbOpt) = TRUE; /* turn on option */
}
return(bRt);
} /* addOpt */
/** removeOpt - turn off specified options
*
* call with:
* pVal - string of options to turn off
*
* returns:
* TRUE - options turned off
* FALSE - an error
*/
BOOL
#ifdef __STDC__
removeOpt(STRTAB *pVal)
#else
removeOpt(pVal)
STRTAB *pVal;
#endif /* __STDC__ */
{
USHORT usOpt;
PSZ pszOpt;
BOOL bRt;
USHORT i;
for (bRt = TRUE, pszOpt = pVal->pszVal; *pszOpt != 0; pszOpt++) {
if (isspace(*pszOpt))
continue;
usOpt = toupper(*pszOpt);
for (i = 0; i < sizeof(optTab)/sizeof(OPTENTRY); i++) {
if (optTab[i].chVal == (UCHAR)usOpt)
break;
}
if (i == sizeof(optTab)/sizeof(OPTENTRY)) {
yyerror("unknown option \'%c\' in \"%s\"",
*pszOpt, pVal->pszVal);
bRt = FALSE;
continue;
}
*(optTab[i].pbOpt) = FALSE; /* turn off option */
}
return(bRt);
} /* removeOpt */
/** dirHelp - print help for directives
*
*/
VOID
#ifdef __STDC__
dirHelp(VOID)
#else
dirHelp()
#endif
{
fprintf(fhMsg, "Directives\n");
fprintf(fhMsg, " #help -- print this list\n");
fprintf(fhMsg, " #include \"<fileName>\" -- process include file\n");
fprintf(fhMsg, " #aliasModule <module> <alias> -- alias a module\n");
fprintf(fhMsg, " #aliasSymbol <module> <object> <alias> -- alias an object\n");
fprintf(fhMsg, " #pushOpt -- push options\n");
fprintf(fhMsg, " #popOpt -- pop options\n");
fprintf(fhMsg, " #addOpt \"<options>\" -- add one or more options\n");
fprintf(fhMsg, " #removeOpt \"<options>\" -- remove one or more options\n");
fprintf(fhMsg, " #printOpt -- print options\n");
} /* dirHelp */
/** GetArgs - parse program arguments
*
* call with:
* argc - number of arguments
* argv - program arguments
*
* returns:
* TRUE - arguments parsed OK
* FALSE - error with argument syntax
*/
BOOL
#ifdef __STDC__
GetArgs(INT argc, CHAR *argv[])
#else
GetArgs(argc, argv)
INT argc;
CHAR *argv[];
#endif /* __STDC__ */
{
SHORT i;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -