static int32_t snmp_import_top(struct snmp_toolinfo *snmptoolctx, enum tok *tok) { enum snmp_tc tc; struct enum_type *t; if (*tok == '(') return (snmp_import_tree(snmptoolctx, tok)); if (*tok == TOK_TYPEDEF) { if ((*tok = gettoken(snmptoolctx)) != TOK_STR) { warnx("type name expected after typedef - %s", input->fname); return (-1); } t = snmp_enumtc_init(nexttok); *tok = gettoken(snmptoolctx); t->is_enum = (*tok == TOK_ENUM); t->is_bits = (*tok == TOK_BITS); t->syntax = parse_type(snmptoolctx, tok, &tc, &(t->snmp_enum)); snmp_enumtc_insert(snmptoolctx, t); return (1); } if (*tok == TOK_INCLUDE) { int i; *tok = gettoken(snmptoolctx); if (*tok != TOK_FILENAME) { warnx("filename expected in include directive - %s", nexttok); return (-1); } if (( i = add_filename(snmptoolctx, nexttok, NULL, 1)) == 0) { *tok = gettoken(snmptoolctx); return (1); } if (i == -1) return (-1); input_fopen(nexttok); *tok = gettoken(snmptoolctx); return (1); } warnx("'(' or 'typedef' expected - %s", nexttok); return (-1); }
/* * Read a .def file and import oid to string mapping. * Mappings are inserted into a global structure containing list for each OID syntax type. */ int snmp_import_file(struct snmp_toolinfo *tool, struct fname *file) { int idx; snmp_import_init(&(file->cut)); input_fopen(file->name); if ((idx = snmp_import(tool)) < 0) warnx("Failed to read mappings from file %s", file->name); input_close(); return (idx); }