2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2018-03-12 11:22:06 +01:00
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
\
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2018-03-12 11:22:06 +01:00
|
|
|
#include "cw/ktv.h"
|
2016-03-03 19:51:42 +01:00
|
|
|
#include "cw/dbg.h"
|
2018-03-12 11:22:06 +01:00
|
|
|
#include "cw/log.h"
|
|
|
|
#include "cw/msgset.h"
|
2016-03-11 18:16:13 +01:00
|
|
|
|
2018-03-12 11:22:06 +01:00
|
|
|
struct bootcfg{
|
|
|
|
const char * modname;
|
|
|
|
const char * modpath;
|
|
|
|
const char * cfgfilename;
|
|
|
|
};
|
2016-03-11 18:16:13 +01:00
|
|
|
|
2018-03-12 11:22:06 +01:00
|
|
|
static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg)
|
2016-03-11 18:16:13 +01:00
|
|
|
{
|
2018-03-12 11:22:06 +01:00
|
|
|
int c;
|
|
|
|
opterr = 1;
|
|
|
|
|
|
|
|
bootcfg->modname = "cisco";
|
|
|
|
bootcfg->cfgfilename = "config.ktv";
|
|
|
|
|
|
|
|
while ( (c = getopt (argc, argv, "p:d:vc:m:h")) != -1) {
|
2016-03-11 18:16:13 +01:00
|
|
|
|
2018-03-12 11:22:06 +01:00
|
|
|
switch (c) {
|
|
|
|
case 'v':
|
|
|
|
printf("WFAT version 0.0.1\n");
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
break;
|
|
|
|
case 'd':{
|
|
|
|
int b = cw_strlist_get_id(cw_dbg_strings, optarg);
|
|
|
|
if (b==-1){
|
|
|
|
fprintf(stderr,"Invalid debug option: %s\n",optarg);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
cw_dbg_set_level(b, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'm':
|
|
|
|
bootcfg->modname = optarg;
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
cw_mod_set_path(optarg);
|
|
|
|
break;
|
|
|
|
case 'c':
|
|
|
|
bootcfg->cfgfilename = optarg;
|
|
|
|
case '?':
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
default:
|
|
|
|
case 'h':
|
|
|
|
printf("%s: -vcmh\n",argv[0]);
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
break;
|
|
|
|
}
|
2016-03-11 18:16:13 +01:00
|
|
|
}
|
2018-03-12 11:22:06 +01:00
|
|
|
return 0;
|
2016-03-11 18:16:13 +01:00
|
|
|
}
|
|
|
|
|
2015-04-14 07:42:23 +02:00
|
|
|
|
2018-03-12 11:22:06 +01:00
|
|
|
int main (int argc, char **argv)
|
2014-07-11 22:12:11 +02:00
|
|
|
{
|
2018-03-12 11:22:06 +01:00
|
|
|
mavl_t types;
|
|
|
|
mavliter_t it;
|
|
|
|
struct bootcfg bootcfg;
|
|
|
|
struct cw_Mod * mod;
|
|
|
|
struct cw_MsgSet * msgset;
|
|
|
|
|
|
|
|
parse_args(argc,argv, &bootcfg);
|
|
|
|
|
2016-03-11 18:16:13 +01:00
|
|
|
|
2018-03-12 11:22:06 +01:00
|
|
|
msgset = cw_msgset_create();
|
|
|
|
if (msgset==NULL){
|
|
|
|
cw_log(LOG_ERR, "Error creating msgset: %s", strerror(errno));
|
|
|
|
exit(EXIT_FAILURE);
|
2016-03-02 19:27:54 +01:00
|
|
|
}
|
2018-03-12 11:22:06 +01:00
|
|
|
mod = cw_mod_load(bootcfg.modname);
|
|
|
|
if (mod == NULL){
|
|
|
|
exit (EXIT_FAILURE);
|
2016-03-09 09:09:28 +01:00
|
|
|
}
|
2018-03-12 11:22:06 +01:00
|
|
|
|
|
|
|
mod->register_messages(msgset, CW_MOD_MODE_CAPWAP);
|
|
|
|
mod->register_messages(msgset, CW_MOD_MODE_BINDINGS);
|
|
|
|
|
2016-03-09 09:09:28 +01:00
|
|
|
|
2015-04-26 23:52:11 +02:00
|
|
|
|
2018-03-12 11:22:06 +01:00
|
|
|
types = cw_ktv_create_types_tree();
|
|
|
|
if (types == NULL){
|
|
|
|
perror("Error creating types tree");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-26 15:48:40 +02:00
|
|
|
|
2016-03-31 19:23:51 +02:00
|
|
|
|
2018-03-12 11:22:06 +01:00
|
|
|
|
|
|
|
mavl_add_ptr(types,CW_TYPE_BSTR16);
|
|
|
|
mavl_add_ptr(types,CW_TYPE_DWORD);
|
|
|
|
|
|
|
|
mavliter_init(&it,types);
|
2016-03-31 19:23:51 +02:00
|
|
|
mavliter_foreach(&it){
|
2018-03-12 11:22:06 +01:00
|
|
|
struct cw_Type * t = mavliter_get_ptr(&it);
|
|
|
|
printf("The Type is %s\n",t->name);
|
2016-03-31 19:23:51 +02:00
|
|
|
}
|
|
|
|
|
2018-03-12 11:22:06 +01:00
|
|
|
return (EXIT_SUCCESS);
|
2014-07-11 22:12:11 +02:00
|
|
|
}
|