Lines Matching +full:input +full:- +full:value

2  * Copyright (c) 2001-2003
61 * line: oid '=' value
73 * value: EMPTY | STRING | NUM
77 * Input context for macros and includes
83 struct input { struct
98 LIST_ENTRY(input) link; argument
100 static LIST_HEAD(, input) inputs;
120 struct snmp_value value; member
133 char *value; member
161 # define ERRPOP() ((void)(errstk--))
162 # define ERRNEXT() (longjmp(errjmp[--errstk], 1))
163 # define ERR() (longjmp(errjmp[--errstk], 1))
177 const struct input *input; in report() local
183 LIST_FOREACH(input, &inputs, link) { in report()
184 switch (input->type) { in report()
188 input->input_filename, input->input_lno); in report()
193 input->input_macro, in report()
194 input->input_ptr - input->input_str); in report()
202 * Open a file for input
207 struct input *input; in input_open_file() local
220 col = ptr + strlen(ptr) - 1; in input_open_file()
225 (int)(col - ptr), ptr, fname); in input_open_file()
236 if ((input = malloc(sizeof(*input))) == NULL) { in input_open_file()
238 return (-1); in input_open_file()
240 if ((input->input_filename = malloc(strlen(fname) + 1)) == NULL) { in input_open_file()
242 free(input); in input_open_file()
243 return (-1); in input_open_file()
245 strcpy(input->input_filename, fname); in input_open_file()
246 input->input_fp = fp; in input_open_file()
247 input->input_lno = 1; in input_open_file()
248 input->type = INPUT_FILE; in input_open_file()
249 LIST_INSERT_HEAD(&inputs, input, link); in input_open_file()
254 * Make a macro the next input
259 struct input *input; in input_open_macro() local
261 if ((input = malloc(sizeof(*input))) == NULL) in input_open_macro()
263 input->type = INPUT_STRING; in input_open_macro()
264 input->input_macro = m->name; in input_open_macro()
265 if ((input->input_str = malloc(m->length)) == NULL) { in input_open_macro()
266 free(input); in input_open_macro()
269 memcpy(input->input_str, m->value, m->length); in input_open_macro()
270 input->input_ptr = input->input_str; in input_open_macro()
271 input->input_left = m->length; in input_open_macro()
272 LIST_INSERT_HEAD(&inputs, input, link); in input_open_macro()
276 * Close top input source
281 struct input *input; in input_close() local
283 if ((input = LIST_FIRST(&inputs)) == NULL) in input_close()
285 switch (input->type) { in input_close()
288 fclose(input->input_fp); in input_close()
289 free(input->input_filename); in input_close()
293 free(input->input_str); in input_close()
296 LIST_REMOVE(input, link); in input_close()
297 free(input); in input_close()
325 * Return next character from the input without preprocessing.
331 struct input *input; in input_getc_raw() local
334 c = input_buf[--input_push]; in input_getc_raw()
337 while ((input = LIST_FIRST(&inputs)) != NULL) { in input_getc_raw()
338 switch (input->type) { in input_getc_raw()
341 if ((c = getc(input->input_fp)) == EOF) { in input_getc_raw()
342 if (ferror(input->input_fp)) in input_getc_raw()
348 input->input_lno++; in input_getc_raw()
352 if (input->input_left-- == 0) { in input_getc_raw()
356 c = *input->input_ptr++; in input_getc_raw()
376 * Get character with and \\n -> processing.
426 if (strcmp(m->name, name) == 0) in input_getc()
463 numval = numval * base + (c - '0'); in input_getnum()
466 numval = numval * base + (c - 'a' + 10); in input_getnum()
468 numval = numval * base + (c - 'A' + 10); in input_getnum()
582 strval[strvallen++] = chr[end - esc]; in _gettoken()
606 if (!isalnum(c) && c != '.' && c != '-') in _gettoken()
629 if (!isalnum(c) && c != '_' && c != '-') { in _gettoken()
689 const struct snmp_value *value) in handle_assignment() argument
696 if (node->type == SNMP_NODE_LEAF) { in handle_assignment()
698 if (vindex->len > 1 || (vindex->len == 1 && in handle_assignment()
699 vindex->subs[0] != 0)) in handle_assignment()
701 vindex->len = 1; in handle_assignment()
702 vindex->subs[0] = 0; in handle_assignment()
705 if (node->oid.len + vindex->len > ASN_MAXOIDLEN) in handle_assignment()
715 tp->value = *value; in handle_assignment()
716 tp->node_name = node->name; in handle_assignment()
721 tp->value.var = node->oid; in handle_assignment()
722 for (i = 0; i < vindex->len; i++) in handle_assignment()
723 tp->value.var.subs[tp->value.var.len++] = vindex->subs[i]; in handle_assignment()
731 snprintf(nodename, sizeof(nodename), "%s", node->name); in handle_assignment()
732 snmp_ctx->scratch = &tp->scratch; in handle_assignment()
733 snmp_ctx->var_index = 0; in handle_assignment()
734 err = (*node->op)(snmp_ctx, &tp->value, node->oid.len, node->index, in handle_assignment()
757 /* loading a module - ignore common stuff */ in parse_section()
760 /* global configuration - don't ignore */ in parse_section()
764 /* global configuration - ignore module stuff */ in parse_section()
767 /* loading module - check if it's our section */ in parse_section()
768 ignore = (strcmp(strval, mod->section) != 0); in parse_section()
795 sain = (struct sockaddr_in *)(void *)res->ai_addr; in gethost()
796 sain->sin_addr.s_addr = ntohl(sain->sin_addr.s_addr); in gethost()
797 ip[0] = sain->sin_addr.s_addr >> 24; in gethost()
798 ip[1] = sain->sin_addr.s_addr >> 16; in gethost()
799 ip[2] = sain->sin_addr.s_addr >> 8; in gethost()
800 ip[3] = sain->sin_addr.s_addr >> 0; in gethost()
817 if (strcmp(varname, node->name) == 0) in parse_oid()
822 oid->len = 0; in parse_oid()
828 if (oid->len == ASN_MAXOIDLEN) in parse_oid()
831 oid->subs[oid->len++] = numval; in parse_oid()
840 oid->subs[oid->len++] = str_oid.len; in parse_oid()
845 if (strvallen + oid->len + 1 > ASN_MAXOIDLEN) in parse_oid()
847 oid->subs[oid->len++] = strvallen; in parse_oid()
849 oid->subs[oid->len++] = strval[i]; in parse_oid()
854 if (oid->len + 4 > ASN_MAXOIDLEN) in parse_oid()
857 oid->subs[oid->len++] = ip[i]; in parse_oid()
867 * Parse the value for an assignment.
870 parse_syntax_null(struct snmp_value *value __unused) in parse_syntax_null()
877 parse_syntax_integer(struct snmp_value *value) in parse_syntax_integer() argument
884 value->v.integer = numval; in parse_syntax_integer()
889 parse_syntax_counter64(struct snmp_value *value) in parse_syntax_counter64() argument
894 value->v.counter64 = numval; in parse_syntax_counter64()
899 parse_syntax_octetstring(struct snmp_value *value) in parse_syntax_octetstring() argument
905 value->v.octetstring.len = strvallen; in parse_syntax_octetstring()
906 value->v.octetstring.octets = malloc(strvallen); in parse_syntax_octetstring()
907 (void)memcpy(value->v.octetstring.octets, strval, strvallen); in parse_syntax_octetstring()
913 value->v.octetstring.octets = NULL; in parse_syntax_octetstring()
914 value->v.octetstring.len = 0; in parse_syntax_octetstring()
921 free(value->v.octetstring.octets); in parse_syntax_octetstring()
930 report("byte value too large"); in parse_syntax_octetstring()
931 if (alloc == value->v.octetstring.len) { in parse_syntax_octetstring()
933 noct = realloc(value->v.octetstring.octets, alloc); in parse_syntax_octetstring()
936 value->v.octetstring.octets = noct; in parse_syntax_octetstring()
938 value->v.octetstring.octets[value->v.octetstring.len++] in parse_syntax_octetstring()
948 parse_syntax_oid(struct snmp_value *value) in parse_syntax_oid() argument
950 value->v.oid.len = 0; in parse_syntax_oid()
960 if (value->v.oid.len == ASN_MAXOIDLEN) in parse_syntax_oid()
962 value->v.oid.subs[value->v.oid.len++] = numval; in parse_syntax_oid()
970 parse_syntax_ipaddress(struct snmp_value *value) in parse_syntax_ipaddress() argument
981 value->v.ipaddress[i++] = numval; in parse_syntax_ipaddress()
993 value->v.ipaddress[i] = ip[i]; in parse_syntax_ipaddress()
1001 parse_syntax_uint32(struct snmp_value *value) in parse_syntax_uint32() argument
1008 value->v.uint32 = numval; in parse_syntax_uint32()
1018 struct snmp_value value; in parse_assign() local
1036 switch (value.syntax = node->syntax) { in parse_assign()
1039 parse_syntax_null(&value); in parse_assign()
1043 parse_syntax_integer(&value); in parse_assign()
1047 parse_syntax_counter64(&value); in parse_assign()
1051 parse_syntax_octetstring(&value); in parse_assign()
1055 parse_syntax_oid(&value); in parse_assign()
1059 parse_syntax_ipaddress(&value); in parse_assign()
1065 parse_syntax_uint32(&value); in parse_assign()
1075 snmp_value_free(&value); in parse_assign()
1079 handle_assignment(node, &vindex, &value); in parse_assign()
1086 * We have already seen the := and the input now stands at the character
1087 * after the =. Skip whitespace and then call the input routine directly to
1133 if (strcmp(m->name, varname) == 0) in parse_define()
1139 if ((m->name = malloc(strlen(varname) + 1)) == NULL) { in parse_define()
1143 strcpy(m->name, varname); in parse_define()
1144 m->perm = 0; in parse_define()
1147 m->value = string; in parse_define()
1148 m->length = length; in parse_define()
1151 free(m->value); in parse_define()
1152 m->value = string; in parse_define()
1153 m->length = length; in parse_define()
1174 if (!m->perm) { in macro_free_all()
1175 free(m->name); in macro_free_all()
1176 free(m->value); in macro_free_all()
1204 if (input_open_file(fname, sysdir) == -1) in parse_include()
1254 if (node->name == tp->node_name) { in do_rollback()
1255 snmp_ctx->scratch = &tp->scratch; in do_rollback()
1256 (void)(*node->op)(snmp_ctx, &tp->value, in do_rollback()
1257 node->oid.len, node->index, in do_rollback()
1264 snmp_value_free(&tp->value); in do_rollback()
1281 if (node->name == tp->node_name) { in do_commit()
1282 snmp_ctx->scratch = &tp->scratch; in do_commit()
1283 (void)(*node->op)(snmp_ctx, &tp->value, in do_commit()
1284 node->oid.len, node->index, SNMP_OP_COMMIT); in do_commit()
1289 snmp_value_free(&tp->value); in do_commit()
1312 return (-1); in read_config()
1313 if (input_open_file(fname, 0) == -1) { in read_config()
1315 return (-1); in read_config()
1323 return (-1); in read_config()
1331 return (-1); in read_config()
1338 asn_oid2str_r(&snmp_ctx->dep->obj, objbuf), in read_config()
1339 asn_oid2str_r(&snmp_ctx->dep->idx, idxbuf)); in read_config()
1345 return (-1); in read_config()
1362 define_macro(const char *name, const char *value) in define_macro() argument
1367 return (-1); in define_macro()
1368 if ((m->name = malloc(strlen(name) + 1)) == NULL) { in define_macro()
1370 return (-1); in define_macro()
1372 strcpy(m->name, name); in define_macro()
1373 if ((m->value = malloc(strlen(value) + 1)) == NULL) { in define_macro()
1374 free(m->name); in define_macro()
1376 return (-1); in define_macro()
1378 strcpy(m->value, value); in define_macro()
1379 m->length = strlen(value); in define_macro()
1380 m->perm = 1; in define_macro()