|
|
1.1 root 1: *** _Makefile Mon Feb 19 22:43:02 1990
2: --- Makefile Thu Feb 22 22:04:21 1990
3: ***************
4: *** 81,90 ****
5: # Also choose just one of -g and -O.
6: #CC= gcc
7:
8: ! OPTIMIZE= -O
9: PROFILE= #-pg
10: DEBUG= #-DDEBUG #-DMEMDEBUG #-DFUNC_TRACE #-DMPROF
11: ! DEBUGGER= #-g -Bstatic
12: WARN= #-W -Wunused -Wimplicit -Wreturn-type -Wcomment # for gcc only
13:
14: # Parser to use on grammar -- if you don't have bison use the first one
15: --- 81,90 ----
16: # Also choose just one of -g and -O.
17: #CC= gcc
18:
19: ! OPTIMIZE= #-O
20: PROFILE= #-pg
21: DEBUG= #-DDEBUG #-DMEMDEBUG #-DFUNC_TRACE #-DMPROF
22: ! DEBUGGER= -g # -Bstatic
23: WARN= #-W -Wunused -Wimplicit -Wreturn-type -Wcomment # for gcc only
24:
25: # Parser to use on grammar -- if you don't have bison use the first one
26: ***************
27: *** 102,113 ****
28: # need to customize this file below this point.
29: #
30:
31: ! FLAGS= $(MISSING) $(DEBUG)
32: CFLAGS= $(FLAGS) $(DEBUGGER) $(PROFILE) $(OPTIMIZE) $(WARN)
33:
34: # object files
35: AWKOBJS = main.o eval.o builtin.o msg.o debug.o io.o field.o array.o node.o \
36: ! version.o missing.o
37:
38: ALLOBJS = $(AWKOBJS) awk.tab.o
39:
40: --- 102,116 ----
41: # need to customize this file below this point.
42: #
43:
44: ! FLAGS= $(MISSING) $(DEBUG) -DSNMP
45: CFLAGS= $(FLAGS) $(DEBUGGER) $(PROFILE) $(OPTIMIZE) $(WARN)
46: + SNMP-C = snmp.c
47: + SNMP-O = snmp.o
48: + SNMP-LIB= -lisnmp -lisode
49:
50: # object files
51: AWKOBJS = main.o eval.o builtin.o msg.o debug.o io.o field.o array.o node.o \
52: ! version.o missing.o $(SNMP-O)
53:
54: ALLOBJS = $(AWKOBJS) awk.tab.o
55:
56: ***************
57: *** 117,123 ****
58:
59: # source and documentation files
60: SRC = main.c eval.c builtin.c msg.c \
61: ! debug.c io.c field.c array.c node.c missing.c
62:
63: ALLSRC= $(SRC) awk.tab.c
64:
65: --- 120,126 ----
66:
67: # source and documentation files
68: SRC = main.c eval.c builtin.c msg.c \
69: ! debug.c io.c field.c array.c node.c missing.c $(SNMP-C)
70:
71: ALLSRC= $(SRC) awk.tab.c
72:
73: ***************
74: *** 153,159 ****
75:
76: # rules to build gawk
77: gawk: $(ALLOBJS) $(GNUOBJS)
78: ! $(CC) -o gawk $(CFLAGS) $(ALLOBJS) $(GNUOBJS) -lm
79:
80: $(AWKOBJS): awk.h
81:
82: --- 156,162 ----
83:
84: # rules to build gawk
85: gawk: $(ALLOBJS) $(GNUOBJS)
86: ! $(CC) -o gawk $(CFLAGS) $(ALLOBJS) $(GNUOBJS) $(SNMP-LIB) -lm
87:
88: $(AWKOBJS): awk.h
89:
90: *** _array.c Thu Aug 31 08:46:15 1989
91: --- array.c Fri Feb 23 06:49:17 1990
92: ***************
93: *** 35,41 ****
94: --- 35,46 ----
95: #define MAKE_POS(v) (v & ~0x80000000) /* make number positive */
96:
97: NODE *
98: + #ifndef SNMP
99: concat_exp(tree)
100: + #else
101: + concat_exp(tree,isnmp)
102: + int isnmp;
103: + #endif
104: NODE *tree;
105: {
106: NODE *r;
107: ***************
108: *** 51,58 ****
109: --- 56,73 ----
110: r = force_string(tree_eval(tree->lnode));
111: if (tree->rnode == NULL)
112: return r;
113: + #ifdef SNMP
114: + if (isnmp) {
115: + subseplen = Ndot_string -> stlen;
116: + subsep = Ndot_string -> stptr;
117: + }
118: + else {
119: + #endif
120: subseplen = SUBSEP_node->lnode->stlen;
121: subsep = SUBSEP_node->lnode->stptr;
122: + #ifdef SNMP
123: + }
124: + #endif
125: len = r->stlen + subseplen + 1;
126: emalloc(str, char *, len, "concat_exp");
127: s = str;
128: ***************
129: *** 90,95 ****
130: --- 105,114 ----
131: int i;
132: NODE *bucket, *next;
133:
134: + #ifdef SNMP
135: + if (symbol -> magic)
136: + fatal ("split into SNMP array variable not allowed");
137: + #endif
138: if (symbol->var_array == 0)
139: return;
140: for (i = 0; i < ASSOC_HASHSIZE; i++) {
141: ***************
142: *** 133,138 ****
143: --- 152,162 ----
144: {
145: register NODE *bucket;
146:
147: + #ifdef SNMP
148: + if (symbol -> magic)
149: + fatal ("assoc_find: internal error");
150: + #endif
151: +
152: for (bucket = symbol->var_array[hash1]; bucket; bucket = bucket->ahnext) {
153: if (cmp_nodes(bucket->ahname, subs))
154: continue;
155: ***************
156: *** 152,160 ****
157: --- 176,193 ----
158:
159: if (symbol->type == Node_param_list)
160: symbol = stack_ptr[symbol->param_cnt];
161: + #ifdef SNMP
162: + if (symbol -> magic)
163: + return *assoc_lookup (symbol, concat_exp (subs, 1))
164: + != Nnull_string;
165: + #endif
166: if (symbol->var_array == 0)
167: return 0;
168: + #ifndef SNMP
169: subs = concat_exp(subs);
170: + #else
171: + subs = concat_exp(subs,0);
172: + #endif
173: hash1 = hash_calc(subs);
174: if (assoc_find(symbol, subs, hash1) == NULL) {
175: free_temp(subs);
176: ***************
177: *** 181,186 ****
178: --- 214,225 ----
179:
180: hash1 = hash_calc(subs);
181:
182: + #ifdef SNMP
183: + if (symbol -> magic) {
184: + snmp_get (symbol, force_string (subs) -> stptr);
185: + return &symbol -> var_value;
186: + }
187: + #endif
188: if (symbol->var_array == 0) { /* this table really should grow
189: * dynamically */
190: emalloc(symbol->var_array, NODE **, (sizeof(NODE *) *
191: ***************
192: *** 211,219 ****
193: --- 250,266 ----
194: register NODE *bucket, *last;
195: NODE *subs;
196:
197: + #ifdef SNMP
198: + if (symbol -> magic)
199: + fatal ("delete into SNMP array variable not allowed");
200: + #endif
201: if (symbol->var_array == 0)
202: return;
203: + #ifndef SNMP
204: subs = concat_exp(tree);
205: + #else
206: + subs = concat_exp(tree,0);
207: + #endif
208: hash1 = hash_calc(subs);
209:
210: last = NULL;
211: ***************
212: *** 240,245 ****
213: --- 287,296 ----
214: {
215: struct search *lookat;
216:
217: + #ifdef SNMP
218: + if (symbol -> magic)
219: + return snmp_assoc_scan (symbol);
220: + #endif
221: if (!symbol->var_array)
222: return 0;
223: emalloc(lookat, struct search *, sizeof(struct search), "assoc_scan");
224: ***************
225: *** 246,258 ****
226: --- 297,322 ----
227: lookat->numleft = ASSOC_HASHSIZE;
228: lookat->arr_ptr = symbol->var_array;
229: lookat->bucket = symbol->var_array[0];
230: + #ifndef SNMP
231: return assoc_next(lookat);
232: + #else
233: + return assoc_next(symbol, lookat);
234: + #endif
235: }
236:
237: struct search *
238: + #ifndef SNMP
239: assoc_next(lookat)
240: + #else
241: + assoc_next(symbol, lookat)
242: + NODE *symbol;
243: + #endif
244: struct search *lookat;
245: {
246: + #ifdef SNMP
247: + if (symbol -> magic)
248: + return snmp_assoc_next (lookat, 0);
249: + #endif
250: for (; lookat->numleft; lookat->numleft--) {
251: while (lookat->bucket != 0) {
252: lookat->retval = lookat->bucket->ahname;
253: *** _awk.h Mon Oct 23 16:18:23 1989
254: --- awk.h Tue Mar 6 14:19:04 1990
255: ***************
256: *** 62,68 ****
257: #endif
258:
259: #ifdef __STDC__
260: ! extern void *malloc(unsigned), *realloc(void *, unsigned);
261: extern void free(char *);
262: extern char *getenv(char *);
263:
264: --- 62,68 ----
265: #endif
266:
267: #ifdef __STDC__
268: ! extern char *malloc(unsigned), *realloc(void *, unsigned);
269: extern void free(char *);
270: extern char *getenv(char *);
271:
272: ***************
273: *** 237,242 ****
274: --- 237,245 ----
275:
276: /* Variables */
277: Node_var, /* rnode is value, lnode is array stuff */
278: + #ifdef SNMP
279: + /* magic is pointer to (OT) */
280: + #endif
281: Node_var_array, /* array is ptr to elements, asize num of
282: * eles */
283: Node_val, /* node is a value - type in flags */
284: ***************
285: *** 290,295 ****
286: --- 293,301 ----
287: char *name;
288: short number;
289: unsigned char recase;
290: + #ifdef SNMP
291: + caddr_t cookie;
292: + #endif
293: } nodep;
294: struct {
295: AWKNUM fltnum; /* this is here for optimal packing of
296: ***************
297: *** 333,338 ****
298: --- 339,347 ----
299: #define lnode sub.nodep.l.lptr
300: #define nextp sub.nodep.l.nextnode
301: #define rnode sub.nodep.r.rptr
302: + #ifdef SNMP
303: + #define magic sub.nodep.cookie
304: + #endif
305: #define source_file sub.nodep.name
306: #define source_line sub.nodep.number
307: #define param_cnt sub.nodep.number
308: ***************
309: *** 525,531 ****
310: --- 534,544 ----
311: extern NODE **get_lhs(NODE *, int);
312: extern void do_deref(void );
313: extern struct search *assoc_scan(NODE *);
314: + #ifndef SNMP
315: extern struct search *assoc_next(struct search *);
316: + #else SNMP
317: + extern struct search *assoc_next(NODE *symbol, struct search *lookat);
318: + #endif SNMP
319: extern NODE **assoc_lookup(NODE *, NODE *);
320: extern double r_force_number(NODE *);
321: extern NODE *r_force_string(NODE *);
322: ***************
323: *** 596,598 ****
324: --- 609,640 ----
325: #endif
326:
327: extern char casetable[]; /* for case-independent regexp matching */
328: +
329: +
330: + #ifdef SNMP
331: + extern NODE *AGENT_node,
332: + *COMMUNITY_node,
333: + *DIAGNOSTIC_node,
334: + *ERROR_node,
335: + *RETRIES_node,
336: + *TIMEOUT_node;
337: +
338: + extern NODE *Ndot_string;
339: +
340: + extern int snmp_enabled;
341: + extern char *snmp_file;
342: +
343: +
344: + #ifdef __STDC__
345: + int check_snmp(NODE *r, char *name);
346: + int snmp_get(NODE *ptr, char *instname);
347: + char *snmp_name(NODE *ptr);
348: + struct search *snmp_assoc_scan(NODE *symbol);
349: + struct search *snmp_assoc_next(struct search *lookat, int done);
350: + #else
351: + int check_snmp ();
352: + int snmp_get ();
353: + char *snmp_name ();
354: + struct search *snmp_assoc_scan (), *snmp_assoc_next ();
355: + #endif
356: + #endif
357: *** _awk.tab.c Tue Oct 24 13:37:57 1989
358: --- awk.tab.c Tue Feb 27 17:33:59 1990
359: ***************
360: *** 1930,1935 ****
361: --- 1930,1938 ----
362: *do_split(), *do_system(), *do_int(), *do_close(),
363: *do_atan2(), *do_sin(), *do_cos(), *do_rand(),
364: *do_srand(), *do_match(), *do_tolower(), *do_toupper(),
365: + #ifdef SNMP
366: + *do_band (), *do_bor (),
367: + #endif
368: *do_sub(), *do_gsub();
369:
370: /* Special functions for debugging */
371: ***************
372: *** 1943,1948 ****
373: --- 1946,1955 ----
374: { "BEGIN", Node_illegal, LEX_BEGIN, 0, 0 },
375: { "END", Node_illegal, LEX_END, 0, 0 },
376: { "atan2", Node_builtin, LEX_BUILTIN, 0, do_atan2 },
377: + #ifdef SNMP
378: + { "bit_and", Node_builtin, LEX_BUILTIN, 0, do_band },
379: + { "bit_or", Node_builtin, LEX_BUILTIN, 0, do_bor },
380: + #endif
381: #ifdef DEBUG
382: { "bp", Node_builtin, LEX_BUILTIN, 0, do_bp },
383: #endif
384: ***************
385: *** 2926,2932 ****
386: --- 2933,2947 ----
387: register NODE *r;
388:
389: if ((r = lookup(variables, name)) == NULL)
390: + #ifdef SNMP
391: + {
392: + #endif
393: r = install(variables, name,
394: node(Nnull_string, Node_var, (NODE *) NULL));
395: + #ifdef SNMP
396: + if (snmp_enabled && r)
397: + check_snmp (r, name);
398: + }
399: + #endif
400: return r;
401: }
402: *** _awk.y Wed Oct 18 08:02:07 1989
403: --- awk.y Tue Feb 27 17:33:31 1990
404: ***************
405: *** 684,689 ****
406: --- 684,692 ----
407: *do_split(), *do_system(), *do_int(), *do_close(),
408: *do_atan2(), *do_sin(), *do_cos(), *do_rand(),
409: *do_srand(), *do_match(), *do_tolower(), *do_toupper(),
410: + #ifdef SNMP
411: + *do_band (), *do_bor (),
412: + #endif
413: *do_sub(), *do_gsub();
414:
415: /* Special functions for debugging */
416: ***************
417: *** 697,702 ****
418: --- 700,709 ----
419: { "BEGIN", Node_illegal, LEX_BEGIN, 0, 0 },
420: { "END", Node_illegal, LEX_END, 0, 0 },
421: { "atan2", Node_builtin, LEX_BUILTIN, 0, do_atan2 },
422: + #ifdef SNMP
423: + { "bit_and", Node_builtin, LEX_BUILTIN, 0, do_band },
424: + { "bit_or", Node_builtin, LEX_BUILTIN, 0, do_bor },
425: + #endif
426: #ifdef DEBUG
427: { "bp", Node_builtin, LEX_BUILTIN, 0, do_bp },
428: #endif
429: ***************
430: *** 1680,1686 ****
431: --- 1687,1701 ----
432: register NODE *r;
433:
434: if ((r = lookup(variables, name)) == NULL)
435: + #ifdef SNMP
436: + {
437: + #endif
438: r = install(variables, name,
439: node(Nnull_string, Node_var, (NODE *) NULL));
440: + #ifdef SNMP
441: + if (snmp_enabled && r)
442: + check_snmp (r, name);
443: + }
444: + #endif
445: return r;
446: }
447: *** _builtin.c Wed Oct 18 08:02:08 1989
448: --- builtin.c Tue Feb 27 17:33:32 1990
449: ***************
450: *** 535,540 ****
451: --- 535,608 ----
452: fflush(fp);
453: }
454:
455: + #ifdef SNMP
456: + NODE *do_band (tree)
457: + NODE *tree;
458: + {
459: + #ifdef sun386
460: + long l;
461: + #endif
462: + unsigned long d1,
463: + d2;
464: + NODE *s1,
465: + *s2;
466: +
467: + get_two (tree, &s1, &s2);
468: +
469: + #ifdef sun386
470: + l = force_number (s1);
471: + d1 = (unsigned long) l;
472: + #else
473: + d1 = (unsigned long) force_number (s1);
474: + #endif
475: +
476: + #ifdef sun386
477: + l = force_number (s2);
478: + d2 = (unsigned long) l;
479: + #else
480: + d2 = (unsigned long) force_number (s2);
481: + #endif
482: +
483: + free_temp (s1);
484: + free_temp (s2);
485: +
486: + return tmp_number ((AWKNUM) ((unsigned long) (d1 & d2)));
487: + }
488: +
489: + NODE *do_bor (tree)
490: + NODE *tree;
491: + {
492: + #ifdef sun386
493: + long l;
494: + #endif
495: + unsigned long d1,
496: + d2;
497: + NODE *s1,
498: + *s2;
499: +
500: + get_two (tree, &s1, &s2);
501: +
502: + #ifdef sun386
503: + l = force_number (s1);
504: + d1 = (unsigned long) l;
505: + #else
506: + d1 = (unsigned long) force_number (s1);
507: + #endif
508: +
509: + #ifdef sun386
510: + l = force_number (s2);
511: + d2 = (unsigned long) l;
512: + #else
513: + d2 = (unsigned long) force_number (s2);
514: + #endif
515: +
516: + free_temp (s1);
517: + free_temp (s2);
518: +
519: + return tmp_number ((AWKNUM) ((unsigned long) (d1 | d2)));
520: + }
521: + #endif
522: +
523: NODE *
524: do_sqrt(tree)
525: NODE *tree;
526: *** _debug.c Wed Aug 9 20:06:00 1989
527: --- debug.c Thu Feb 22 16:27:38 1990
528: ***************
529: *** 109,116 ****
530: --- 109,124 ----
531: {
532: struct search *l;
533:
534: + #ifndef SNMP
535: printf("(0x%x Array)\n", ptr);
536: for (l = assoc_scan(ptr); l; l = assoc_next(l)) {
537: + #else
538: + printf("(0x%x Array%s)\n", ptr,
539: + ptr -> magic ? " {SNMP}": "");
540: + if (ptr -> magic)
541: + return;
542: + for (l = assoc_scan(ptr); l; l = assoc_next(ptr, l)) {
543: + #endif
544: printf("\tindex: ");
545: print_parse_tree(l->retval);
546: printf("\tvalue: ");
547: ***************
548: *** 343,348 ****
549: --- 351,360 ----
550: for (buc = variables[n]; buc; buc = buc->hnext) {
551: if (buc->hvalue == ptr) {
552: printf("%.*s", buc->hlength, buc->hname);
553: + #ifdef SNMP
554: + if (ptr -> magic)
555: + printf ("{SNMP}");
556: + #endif
557: n = HASHSIZE;
558: break;
559: }
560: *** _eval.c Wed Oct 18 08:02:09 1989
561: --- eval.c Tue Feb 27 08:33:06 1990
562: ***************
563: *** 302,308 ****
564: --- 302,312 ----
565: if (t->type == Node_param_list)
566: t = stack_ptr[t->param_cnt];
567: stable_tree = tree;
568: + #ifndef SNMP
569: for (l = assoc_scan(t); l; l = assoc_next((struct search *)l)) {
570: + #else
571: + for (l = assoc_scan(t); l; l = assoc_next(t, l)) {
572: + #endif
573: deref = *((NODE **) lhs);
574: do_deref();
575: *lhs = dupnode(l->retval);
576: ***************
577: *** 318,323 ****
578: --- 322,331 ----
579: break;
580:
581: case TAG_BREAK:
582: + #ifdef SNMP
583: + if (t -> magic)
584: + (void) snmp_assoc_next (l, 1);
585: + #endif
586: RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid);
587: field_num = -1;
588: return 1;
589: ***************
590: *** 912,918 ****
591: --- 920,930 ----
592: */
593: if (arg->type == Node_param_list)
594: arg = stack_ptr[arg->param_cnt];
595: + #ifndef SNMP
596: if (arg->type == Node_var_array)
597: + #else
598: + if (arg -> type == Node_var_array && !arg -> magic)
599: + #endif
600: *r = *arg;
601: else {
602: n = tree_eval(arg);
603: ***************
604: *** 980,985 ****
605: --- 992,1002 ----
606: arg = argp->lnode;
607: n = *sp++;
608: if (arg->type == Node_var && n->type == Node_var_array) {
609: + #ifdef SNMP
610: + if (arg -> magic)
611: + fatal ("array assignment to SNMP scalar variable \"%s\"",
612: + snmp_name (arg));
613: + #endif
614: arg->var_array = n->var_array;
615: arg->type = Node_var_array;
616: }
617: ***************
618: *** 1031,1036 ****
619: --- 1048,1062 ----
620: switch (ptr->type) {
621: case Node_var:
622: case Node_var_array:
623: + #ifdef SNMP
624: + if (ptr -> magic)
625: + if (assign)
626: + fatal ("attempt to set SNMP %s variable \"%s\"",
627: + ptr -> type == Node_var ? "scalar" : "array",
628: + snmp_name (ptr));
629: + else
630: + snmp_get (ptr, (char *) NULL);
631: + #endif
632: if (ptr == NF_node && (int) NF_node->var_value->numbr == -1)
633: (void) get_field(HUGE-1, assign); /* parse record */
634: deref = ptr->var_value;
635: ***************
636: *** 1067,1073 ****
637: --- 1093,1107 ----
638: n = ptr->lnode;
639: if (n->type == Node_param_list)
640: n = stack_ptr[n->param_cnt];
641: + #ifdef SNMP
642: + if (n -> magic && assign)
643: + fatal ("attempt to set SNMP array variable \"%s\"",
644: + snmp_name (n));
645: + aptr = assoc_lookup(n,
646: + concat_exp(ptr->rnode, n -> magic ? 1 : 0));
647: + #else
648: aptr = assoc_lookup(n, concat_exp(ptr->rnode));
649: + #endif
650: deref = *aptr;
651: #ifdef DEBUG
652: if (deref->type != Node_val)
653: *** _main.c Tue Oct 17 10:08:24 1989
654: --- main.c Mon Feb 26 17:18:48 1990
655: ***************
656: *** 94,101 ****
657: --- 94,106 ----
658: */
659: #define EXTENSIONS 8 /* where to clear */
660: #ifdef DEBUG
661: + #ifndef SNMP
662: char awk_opts[] = "F:f:v:caeCVdD";
663: #else
664: + char awk_opts[] = "F:f:v:caeCVdDsS";
665: + extern int debug;
666: + #endif
667: + #else
668: char awk_opts[] = "F:f:v:caeCV";
669: #endif
670:
671: ***************
672: *** 189,195 ****
673: --- 194,210 ----
674: debugging++;
675: yydebug = 2;
676: break;
677: +
678: + #ifdef SNMP
679: + case 's':
680: + debug = 1;
681: + break;
682: +
683: + case 'S':
684: + debug = 2;
685: + break;
686: #endif
687: + #endif
688:
689: #ifndef STRICT
690: case 'c':
691: ***************
692: *** 478,483 ****
693: --- 493,506 ----
694: RSTART_node = spc_var("RSTART", make_number(0.0));
695: SUBSEP_node = spc_var("SUBSEP", make_string("\034", 1));
696: IGNORECASE_node = spc_var("IGNORECASE", make_number(0.0));
697: + #ifdef SNMP
698: + AGENT_node = spc_var ("AGENT", make_string ("localhost", 9));
699: + COMMUNITY_node = spc_var ("COMMUNITY", make_string ("public", 6));
700: + DIAGNOSTIC_node = spc_var ("DIAGNOSTIC", Nnull_string);
701: + ERROR_node = spc_var ("ERROR", make_number (0.0));
702: + RETRIES_node = spc_var ("RETRIES", make_number (3.0));
703: + TIMEOUT_node = spc_var ("TIMEOUT", make_number (10.0));
704: + #endif
705:
706: ENVIRON_node = spc_var("ENVIRON", Nnull_string);
707: for (i = 0; environ[i]; i++) {
708: *** _node.c Wed Oct 11 15:57:31 1989
709: --- node.c Fri Feb 23 06:43:17 1990
710: ***************
711: *** 276,281 ****
712: --- 276,284 ----
713: #endif
714: it->type = ty;
715: it->flags = MALLOC;
716: + #ifdef SNMP
717: + it->magic = NULL;
718: + #endif
719: #ifdef MEMDEBUG
720: fprintf(stderr, "node: new: %0x\n", it);
721: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.