Newer
Older
Jakob Olsson
committed
#include "common.h"
#include "dongle_apn.h"
#include "dongle_pin.h"
#include "dongle_network.h"
struct ubus_context *ctx;
Jakob Olsson
committed
static struct option long_options[] =
{
{"debug", required_argument, NULL, 'd'}
};
int parse_args(int argc, char **argv)
{
while ((ch = getopt_long(argc, argv, ":d:", long_options, NULL)) != -1) {
switch (ch) {
case 'd':
debug_arg = atoi(optarg);
if (debug_arg > 1 || debug_arg < 0) {
debug_print("%s: option '-%c' is invalid.\n", argv[0], optopt);
goto fail;
}
printf("hallå3\n");
//set_debug(debug_arg);
break;
case ':':
debug_print(stderr, "%s: option '-%c' requires an argument\n", argv[0], optopt);
goto fail;
break;
case '?':
debug_print(stderr, "%s: option '-%c' is invalid: ignored\n", argv[0], optopt);
goto fail;
break;
}
}
return 0;
fail:
return -1;
}
Jakob Olsson
committed
void init_ubus(void)
{
ctx = ubus_connect(NULL);
if (!ctx) {
perror("ubus");
exit(1);
}
ubus_add_uloop(ctx);
}
int main(int argc, char **argv)
{
int rv;
rv = parse_args(argc, argv);
if (rv < 0)
goto fail;
Jakob Olsson
committed
uloop_init();
init_ubus();
rv = expose_apn_object(ctx);
if (rv < 0)
goto fail;
rv = expose_pin_object(ctx);
if (rv < 0)
goto fail;
rv = expose_network_object(ctx);
if (rv < 0)
goto fail;
Jakob Olsson
committed
uloop_run();
return 0;