- ifh = xfopen(fname, "r");
-
- while ((line = get_line_from_file(ifh)) != NULL) {
- struct ether_addr *mac;
- mactable_t *ch;
- char *line_ptr;
- unsigned short name_length;
-
- line_ptr = line + strspn(line, " \t");
- if ((line_ptr[0] == '#') || (line_ptr[0] == '\n'))
- continue;
- name_length = strcspn(line_ptr, " \t");
- if (name_length > IF_NAMESIZE) {
- serror_msg_and_die(use_syslog, "interface name `%s' too long", argv[optind]);
- }
- ch = xcalloc(1, sizeof(mactable_t));
- ch->ifname = strndup(line_ptr, name_length);
- line_ptr += name_length;
- line_ptr += strspn(line_ptr, " \t");
- name_length = strspn(line_ptr, "0123456789ABCDEFabcdef:");
- line_ptr[name_length] = '\0';
- mac = ether_aton(line_ptr);
- if (mac == NULL) {
- serror_msg_and_die(use_syslog, "cannot parse MAC %s", argv[optind]);
- }
- ch->mac = xcalloc(1, ETH_ALEN);
- memcpy(ch->mac, mac, ETH_ALEN);
- if (clist)
- clist->pprev = &ch->next;
- ch->next = clist;
- ch->pprev = &clist;
- clist = ch;
- free(line);
- }
- fclose(ifh);
+ parser = config_open(fname);
+ while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL))
+ prepend_new_eth_table(&clist, token[0], token[1]);
+ config_close(parser);