|
|
BSD 4.3reno
*** _Makefile Mon Feb 19 22:43:02 1990
--- Makefile Thu Feb 22 22:04:21 1990
***************
*** 81,90 ****
# Also choose just one of -g and -O.
#CC= gcc
! OPTIMIZE= -O
PROFILE= #-pg
DEBUG= #-DDEBUG #-DMEMDEBUG #-DFUNC_TRACE #-DMPROF
! DEBUGGER= #-g -Bstatic
WARN= #-W -Wunused -Wimplicit -Wreturn-type -Wcomment # for gcc only
# Parser to use on grammar -- if you don't have bison use the first one
--- 81,90 ----
# Also choose just one of -g and -O.
#CC= gcc
! OPTIMIZE= #-O
PROFILE= #-pg
DEBUG= #-DDEBUG #-DMEMDEBUG #-DFUNC_TRACE #-DMPROF
! DEBUGGER= -g # -Bstatic
WARN= #-W -Wunused -Wimplicit -Wreturn-type -Wcomment # for gcc only
# Parser to use on grammar -- if you don't have bison use the first one
***************
*** 102,113 ****
# need to customize this file below this point.
#
! FLAGS= $(MISSING) $(DEBUG)
CFLAGS= $(FLAGS) $(DEBUGGER) $(PROFILE) $(OPTIMIZE) $(WARN)
# object files
AWKOBJS = main.o eval.o builtin.o msg.o debug.o io.o field.o array.o node.o \
! version.o missing.o
ALLOBJS = $(AWKOBJS) awk.tab.o
--- 102,116 ----
# need to customize this file below this point.
#
! FLAGS= $(MISSING) $(DEBUG) -DSNMP
CFLAGS= $(FLAGS) $(DEBUGGER) $(PROFILE) $(OPTIMIZE) $(WARN)
+ SNMP-C = snmp.c
+ SNMP-O = snmp.o
+ SNMP-LIB= -lisnmp -lisode
# object files
AWKOBJS = main.o eval.o builtin.o msg.o debug.o io.o field.o array.o node.o \
! version.o missing.o $(SNMP-O)
ALLOBJS = $(AWKOBJS) awk.tab.o
***************
*** 117,123 ****
# source and documentation files
SRC = main.c eval.c builtin.c msg.c \
! debug.c io.c field.c array.c node.c missing.c
ALLSRC= $(SRC) awk.tab.c
--- 120,126 ----
# source and documentation files
SRC = main.c eval.c builtin.c msg.c \
! debug.c io.c field.c array.c node.c missing.c $(SNMP-C)
ALLSRC= $(SRC) awk.tab.c
***************
*** 153,159 ****
# rules to build gawk
gawk: $(ALLOBJS) $(GNUOBJS)
! $(CC) -o gawk $(CFLAGS) $(ALLOBJS) $(GNUOBJS) -lm
$(AWKOBJS): awk.h
--- 156,162 ----
# rules to build gawk
gawk: $(ALLOBJS) $(GNUOBJS)
! $(CC) -o gawk $(CFLAGS) $(ALLOBJS) $(GNUOBJS) $(SNMP-LIB) -lm
$(AWKOBJS): awk.h
*** _array.c Thu Aug 31 08:46:15 1989
--- array.c Fri Feb 23 06:49:17 1990
***************
*** 35,41 ****
--- 35,46 ----
#define MAKE_POS(v) (v & ~0x80000000) /* make number positive */
NODE *
+ #ifndef SNMP
concat_exp(tree)
+ #else
+ concat_exp(tree,isnmp)
+ int isnmp;
+ #endif
NODE *tree;
{
NODE *r;
***************
*** 51,58 ****
--- 56,73 ----
r = force_string(tree_eval(tree->lnode));
if (tree->rnode == NULL)
return r;
+ #ifdef SNMP
+ if (isnmp) {
+ subseplen = Ndot_string -> stlen;
+ subsep = Ndot_string -> stptr;
+ }
+ else {
+ #endif
subseplen = SUBSEP_node->lnode->stlen;
subsep = SUBSEP_node->lnode->stptr;
+ #ifdef SNMP
+ }
+ #endif
len = r->stlen + subseplen + 1;
emalloc(str, char *, len, "concat_exp");
s = str;
***************
*** 90,95 ****
--- 105,114 ----
int i;
NODE *bucket, *next;
+ #ifdef SNMP
+ if (symbol -> magic)
+ fatal ("split into SNMP array variable not allowed");
+ #endif
if (symbol->var_array == 0)
return;
for (i = 0; i < ASSOC_HASHSIZE; i++) {
***************
*** 133,138 ****
--- 152,162 ----
{
register NODE *bucket;
+ #ifdef SNMP
+ if (symbol -> magic)
+ fatal ("assoc_find: internal error");
+ #endif
+
for (bucket = symbol->var_array[hash1]; bucket; bucket = bucket->ahnext) {
if (cmp_nodes(bucket->ahname, subs))
continue;
***************
*** 152,160 ****
--- 176,193 ----
if (symbol->type == Node_param_list)
symbol = stack_ptr[symbol->param_cnt];
+ #ifdef SNMP
+ if (symbol -> magic)
+ return *assoc_lookup (symbol, concat_exp (subs, 1))
+ != Nnull_string;
+ #endif
if (symbol->var_array == 0)
return 0;
+ #ifndef SNMP
subs = concat_exp(subs);
+ #else
+ subs = concat_exp(subs,0);
+ #endif
hash1 = hash_calc(subs);
if (assoc_find(symbol, subs, hash1) == NULL) {
free_temp(subs);
***************
*** 181,186 ****
--- 214,225 ----
hash1 = hash_calc(subs);
+ #ifdef SNMP
+ if (symbol -> magic) {
+ snmp_get (symbol, force_string (subs) -> stptr);
+ return &symbol -> var_value;
+ }
+ #endif
if (symbol->var_array == 0) { /* this table really should grow
* dynamically */
emalloc(symbol->var_array, NODE **, (sizeof(NODE *) *
***************
*** 211,219 ****
--- 250,266 ----
register NODE *bucket, *last;
NODE *subs;
+ #ifdef SNMP
+ if (symbol -> magic)
+ fatal ("delete into SNMP array variable not allowed");
+ #endif
if (symbol->var_array == 0)
return;
+ #ifndef SNMP
subs = concat_exp(tree);
+ #else
+ subs = concat_exp(tree,0);
+ #endif
hash1 = hash_calc(subs);
last = NULL;
***************
*** 240,245 ****
--- 287,296 ----
{
struct search *lookat;
+ #ifdef SNMP
+ if (symbol -> magic)
+ return snmp_assoc_scan (symbol);
+ #endif
if (!symbol->var_array)
return 0;
emalloc(lookat, struct search *, sizeof(struct search), "assoc_scan");
***************
*** 246,258 ****
--- 297,322 ----
lookat->numleft = ASSOC_HASHSIZE;
lookat->arr_ptr = symbol->var_array;
lookat->bucket = symbol->var_array[0];
+ #ifndef SNMP
return assoc_next(lookat);
+ #else
+ return assoc_next(symbol, lookat);
+ #endif
}
struct search *
+ #ifndef SNMP
assoc_next(lookat)
+ #else
+ assoc_next(symbol, lookat)
+ NODE *symbol;
+ #endif
struct search *lookat;
{
+ #ifdef SNMP
+ if (symbol -> magic)
+ return snmp_assoc_next (lookat, 0);
+ #endif
for (; lookat->numleft; lookat->numleft--) {
while (lookat->bucket != 0) {
lookat->retval = lookat->bucket->ahname;
*** _awk.h Mon Oct 23 16:18:23 1989
--- awk.h Tue Mar 6 14:19:04 1990
***************
*** 62,68 ****
#endif
#ifdef __STDC__
! extern void *malloc(unsigned), *realloc(void *, unsigned);
extern void free(char *);
extern char *getenv(char *);
--- 62,68 ----
#endif
#ifdef __STDC__
! extern char *malloc(unsigned), *realloc(void *, unsigned);
extern void free(char *);
extern char *getenv(char *);
***************
*** 237,242 ****
--- 237,245 ----
/* Variables */
Node_var, /* rnode is value, lnode is array stuff */
+ #ifdef SNMP
+ /* magic is pointer to (OT) */
+ #endif
Node_var_array, /* array is ptr to elements, asize num of
* eles */
Node_val, /* node is a value - type in flags */
***************
*** 290,295 ****
--- 293,301 ----
char *name;
short number;
unsigned char recase;
+ #ifdef SNMP
+ caddr_t cookie;
+ #endif
} nodep;
struct {
AWKNUM fltnum; /* this is here for optimal packing of
***************
*** 333,338 ****
--- 339,347 ----
#define lnode sub.nodep.l.lptr
#define nextp sub.nodep.l.nextnode
#define rnode sub.nodep.r.rptr
+ #ifdef SNMP
+ #define magic sub.nodep.cookie
+ #endif
#define source_file sub.nodep.name
#define source_line sub.nodep.number
#define param_cnt sub.nodep.number
***************
*** 525,531 ****
--- 534,544 ----
extern NODE **get_lhs(NODE *, int);
extern void do_deref(void );
extern struct search *assoc_scan(NODE *);
+ #ifndef SNMP
extern struct search *assoc_next(struct search *);
+ #else SNMP
+ extern struct search *assoc_next(NODE *symbol, struct search *lookat);
+ #endif SNMP
extern NODE **assoc_lookup(NODE *, NODE *);
extern double r_force_number(NODE *);
extern NODE *r_force_string(NODE *);
***************
*** 596,598 ****
--- 609,640 ----
#endif
extern char casetable[]; /* for case-independent regexp matching */
+
+
+ #ifdef SNMP
+ extern NODE *AGENT_node,
+ *COMMUNITY_node,
+ *DIAGNOSTIC_node,
+ *ERROR_node,
+ *RETRIES_node,
+ *TIMEOUT_node;
+
+ extern NODE *Ndot_string;
+
+ extern int snmp_enabled;
+ extern char *snmp_file;
+
+
+ #ifdef __STDC__
+ int check_snmp(NODE *r, char *name);
+ int snmp_get(NODE *ptr, char *instname);
+ char *snmp_name(NODE *ptr);
+ struct search *snmp_assoc_scan(NODE *symbol);
+ struct search *snmp_assoc_next(struct search *lookat, int done);
+ #else
+ int check_snmp ();
+ int snmp_get ();
+ char *snmp_name ();
+ struct search *snmp_assoc_scan (), *snmp_assoc_next ();
+ #endif
+ #endif
*** _awk.tab.c Tue Oct 24 13:37:57 1989
--- awk.tab.c Tue Feb 27 17:33:59 1990
***************
*** 1930,1935 ****
--- 1930,1938 ----
*do_split(), *do_system(), *do_int(), *do_close(),
*do_atan2(), *do_sin(), *do_cos(), *do_rand(),
*do_srand(), *do_match(), *do_tolower(), *do_toupper(),
+ #ifdef SNMP
+ *do_band (), *do_bor (),
+ #endif
*do_sub(), *do_gsub();
/* Special functions for debugging */
***************
*** 1943,1948 ****
--- 1946,1955 ----
{ "BEGIN", Node_illegal, LEX_BEGIN, 0, 0 },
{ "END", Node_illegal, LEX_END, 0, 0 },
{ "atan2", Node_builtin, LEX_BUILTIN, 0, do_atan2 },
+ #ifdef SNMP
+ { "bit_and", Node_builtin, LEX_BUILTIN, 0, do_band },
+ { "bit_or", Node_builtin, LEX_BUILTIN, 0, do_bor },
+ #endif
#ifdef DEBUG
{ "bp", Node_builtin, LEX_BUILTIN, 0, do_bp },
#endif
***************
*** 2926,2932 ****
--- 2933,2947 ----
register NODE *r;
if ((r = lookup(variables, name)) == NULL)
+ #ifdef SNMP
+ {
+ #endif
r = install(variables, name,
node(Nnull_string, Node_var, (NODE *) NULL));
+ #ifdef SNMP
+ if (snmp_enabled && r)
+ check_snmp (r, name);
+ }
+ #endif
return r;
}
*** _awk.y Wed Oct 18 08:02:07 1989
--- awk.y Tue Feb 27 17:33:31 1990
***************
*** 684,689 ****
--- 684,692 ----
*do_split(), *do_system(), *do_int(), *do_close(),
*do_atan2(), *do_sin(), *do_cos(), *do_rand(),
*do_srand(), *do_match(), *do_tolower(), *do_toupper(),
+ #ifdef SNMP
+ *do_band (), *do_bor (),
+ #endif
*do_sub(), *do_gsub();
/* Special functions for debugging */
***************
*** 697,702 ****
--- 700,709 ----
{ "BEGIN", Node_illegal, LEX_BEGIN, 0, 0 },
{ "END", Node_illegal, LEX_END, 0, 0 },
{ "atan2", Node_builtin, LEX_BUILTIN, 0, do_atan2 },
+ #ifdef SNMP
+ { "bit_and", Node_builtin, LEX_BUILTIN, 0, do_band },
+ { "bit_or", Node_builtin, LEX_BUILTIN, 0, do_bor },
+ #endif
#ifdef DEBUG
{ "bp", Node_builtin, LEX_BUILTIN, 0, do_bp },
#endif
***************
*** 1680,1686 ****
--- 1687,1701 ----
register NODE *r;
if ((r = lookup(variables, name)) == NULL)
+ #ifdef SNMP
+ {
+ #endif
r = install(variables, name,
node(Nnull_string, Node_var, (NODE *) NULL));
+ #ifdef SNMP
+ if (snmp_enabled && r)
+ check_snmp (r, name);
+ }
+ #endif
return r;
}
*** _builtin.c Wed Oct 18 08:02:08 1989
--- builtin.c Tue Feb 27 17:33:32 1990
***************
*** 535,540 ****
--- 535,608 ----
fflush(fp);
}
+ #ifdef SNMP
+ NODE *do_band (tree)
+ NODE *tree;
+ {
+ #ifdef sun386
+ long l;
+ #endif
+ unsigned long d1,
+ d2;
+ NODE *s1,
+ *s2;
+
+ get_two (tree, &s1, &s2);
+
+ #ifdef sun386
+ l = force_number (s1);
+ d1 = (unsigned long) l;
+ #else
+ d1 = (unsigned long) force_number (s1);
+ #endif
+
+ #ifdef sun386
+ l = force_number (s2);
+ d2 = (unsigned long) l;
+ #else
+ d2 = (unsigned long) force_number (s2);
+ #endif
+
+ free_temp (s1);
+ free_temp (s2);
+
+ return tmp_number ((AWKNUM) ((unsigned long) (d1 & d2)));
+ }
+
+ NODE *do_bor (tree)
+ NODE *tree;
+ {
+ #ifdef sun386
+ long l;
+ #endif
+ unsigned long d1,
+ d2;
+ NODE *s1,
+ *s2;
+
+ get_two (tree, &s1, &s2);
+
+ #ifdef sun386
+ l = force_number (s1);
+ d1 = (unsigned long) l;
+ #else
+ d1 = (unsigned long) force_number (s1);
+ #endif
+
+ #ifdef sun386
+ l = force_number (s2);
+ d2 = (unsigned long) l;
+ #else
+ d2 = (unsigned long) force_number (s2);
+ #endif
+
+ free_temp (s1);
+ free_temp (s2);
+
+ return tmp_number ((AWKNUM) ((unsigned long) (d1 | d2)));
+ }
+ #endif
+
NODE *
do_sqrt(tree)
NODE *tree;
*** _debug.c Wed Aug 9 20:06:00 1989
--- debug.c Thu Feb 22 16:27:38 1990
***************
*** 109,116 ****
--- 109,124 ----
{
struct search *l;
+ #ifndef SNMP
printf("(0x%x Array)\n", ptr);
for (l = assoc_scan(ptr); l; l = assoc_next(l)) {
+ #else
+ printf("(0x%x Array%s)\n", ptr,
+ ptr -> magic ? " {SNMP}": "");
+ if (ptr -> magic)
+ return;
+ for (l = assoc_scan(ptr); l; l = assoc_next(ptr, l)) {
+ #endif
printf("\tindex: ");
print_parse_tree(l->retval);
printf("\tvalue: ");
***************
*** 343,348 ****
--- 351,360 ----
for (buc = variables[n]; buc; buc = buc->hnext) {
if (buc->hvalue == ptr) {
printf("%.*s", buc->hlength, buc->hname);
+ #ifdef SNMP
+ if (ptr -> magic)
+ printf ("{SNMP}");
+ #endif
n = HASHSIZE;
break;
}
*** _eval.c Wed Oct 18 08:02:09 1989
--- eval.c Tue Feb 27 08:33:06 1990
***************
*** 302,308 ****
--- 302,312 ----
if (t->type == Node_param_list)
t = stack_ptr[t->param_cnt];
stable_tree = tree;
+ #ifndef SNMP
for (l = assoc_scan(t); l; l = assoc_next((struct search *)l)) {
+ #else
+ for (l = assoc_scan(t); l; l = assoc_next(t, l)) {
+ #endif
deref = *((NODE **) lhs);
do_deref();
*lhs = dupnode(l->retval);
***************
*** 318,323 ****
--- 322,331 ----
break;
case TAG_BREAK:
+ #ifdef SNMP
+ if (t -> magic)
+ (void) snmp_assoc_next (l, 1);
+ #endif
RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid);
field_num = -1;
return 1;
***************
*** 912,918 ****
--- 920,930 ----
*/
if (arg->type == Node_param_list)
arg = stack_ptr[arg->param_cnt];
+ #ifndef SNMP
if (arg->type == Node_var_array)
+ #else
+ if (arg -> type == Node_var_array && !arg -> magic)
+ #endif
*r = *arg;
else {
n = tree_eval(arg);
***************
*** 980,985 ****
--- 992,1002 ----
arg = argp->lnode;
n = *sp++;
if (arg->type == Node_var && n->type == Node_var_array) {
+ #ifdef SNMP
+ if (arg -> magic)
+ fatal ("array assignment to SNMP scalar variable \"%s\"",
+ snmp_name (arg));
+ #endif
arg->var_array = n->var_array;
arg->type = Node_var_array;
}
***************
*** 1031,1036 ****
--- 1048,1062 ----
switch (ptr->type) {
case Node_var:
case Node_var_array:
+ #ifdef SNMP
+ if (ptr -> magic)
+ if (assign)
+ fatal ("attempt to set SNMP %s variable \"%s\"",
+ ptr -> type == Node_var ? "scalar" : "array",
+ snmp_name (ptr));
+ else
+ snmp_get (ptr, (char *) NULL);
+ #endif
if (ptr == NF_node && (int) NF_node->var_value->numbr == -1)
(void) get_field(HUGE-1, assign); /* parse record */
deref = ptr->var_value;
***************
*** 1067,1073 ****
--- 1093,1107 ----
n = ptr->lnode;
if (n->type == Node_param_list)
n = stack_ptr[n->param_cnt];
+ #ifdef SNMP
+ if (n -> magic && assign)
+ fatal ("attempt to set SNMP array variable \"%s\"",
+ snmp_name (n));
+ aptr = assoc_lookup(n,
+ concat_exp(ptr->rnode, n -> magic ? 1 : 0));
+ #else
aptr = assoc_lookup(n, concat_exp(ptr->rnode));
+ #endif
deref = *aptr;
#ifdef DEBUG
if (deref->type != Node_val)
*** _main.c Tue Oct 17 10:08:24 1989
--- main.c Mon Feb 26 17:18:48 1990
***************
*** 94,101 ****
--- 94,106 ----
*/
#define EXTENSIONS 8 /* where to clear */
#ifdef DEBUG
+ #ifndef SNMP
char awk_opts[] = "F:f:v:caeCVdD";
#else
+ char awk_opts[] = "F:f:v:caeCVdDsS";
+ extern int debug;
+ #endif
+ #else
char awk_opts[] = "F:f:v:caeCV";
#endif
***************
*** 189,195 ****
--- 194,210 ----
debugging++;
yydebug = 2;
break;
+
+ #ifdef SNMP
+ case 's':
+ debug = 1;
+ break;
+
+ case 'S':
+ debug = 2;
+ break;
#endif
+ #endif
#ifndef STRICT
case 'c':
***************
*** 478,483 ****
--- 493,506 ----
RSTART_node = spc_var("RSTART", make_number(0.0));
SUBSEP_node = spc_var("SUBSEP", make_string("\034", 1));
IGNORECASE_node = spc_var("IGNORECASE", make_number(0.0));
+ #ifdef SNMP
+ AGENT_node = spc_var ("AGENT", make_string ("localhost", 9));
+ COMMUNITY_node = spc_var ("COMMUNITY", make_string ("public", 6));
+ DIAGNOSTIC_node = spc_var ("DIAGNOSTIC", Nnull_string);
+ ERROR_node = spc_var ("ERROR", make_number (0.0));
+ RETRIES_node = spc_var ("RETRIES", make_number (3.0));
+ TIMEOUT_node = spc_var ("TIMEOUT", make_number (10.0));
+ #endif
ENVIRON_node = spc_var("ENVIRON", Nnull_string);
for (i = 0; environ[i]; i++) {
*** _node.c Wed Oct 11 15:57:31 1989
--- node.c Fri Feb 23 06:43:17 1990
***************
*** 276,281 ****
--- 276,284 ----
#endif
it->type = ty;
it->flags = MALLOC;
+ #ifdef SNMP
+ it->magic = NULL;
+ #endif
#ifdef MEMDEBUG
fprintf(stderr, "node: new: %0x\n", it);
#endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.