/** * @file ncd_tokenizer_test.c * @author Ambroz Bizjak * * @section LICENSE * * This file is part of BadVPN. * * BadVPN is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * BadVPN is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include #include #include int error; int main (int argc, char **argv) { if (argc < 1) { return 1; } if (argc != 2) { printf("Usage: %s \n", argv[0]); return 1; } // parse struct NCDConfig_interfaces *ast; if (!NCDConfigParser_Parse(argv[1], strlen(argv[1]), &ast)) { DEBUG("NCDConfigParser_Parse failed"); return 1; } // print struct NCDConfig_interfaces *iface = ast; while (iface) { printf("Interface %s\n", iface->name); struct NCDConfig_statements *st = iface->statements; while (st) { struct NCDConfig_strings *name = st->names; ASSERT(name) printf(" %s", name->value); name = name->next; while (name) { printf(".%s", name->value); name = name->next; } printf("\n"); struct NCDConfig_strings *arg = st->args; while (arg) { printf(" %s\n", arg->value); arg = arg->next; } st = st->next; } iface = iface->next; } NCDConfig_free_interfaces(ast); return 0; }