Newer
Older
Jakob Olsson
committed
#include "common.h"
#include "dongle_apn.h"
#include "dongle_pin.h"
#include "dongle_network.h"
#include "dongle_infrastructure.h"
Jakob Olsson
committed
struct ubus_context *ctx;
Jakob Olsson
committed
};
int parse_args(int argc, char **argv)
{
while ((ch = getopt_long(argc, argv, "d:", long_options, NULL)) != -1) {
case 'd':
debug = atoi(optarg);
if (debug > 1 || debug < 0) {
printf("%s: option '-%c' is invalid.\n", argv[0], optopt); //cant exactly do debug print in here...
Jakob Olsson
committed
fprintf(stderr, "%s: option '-%c' requires an argument\n", argv[0], optopt);
Jakob Olsson
committed
fprintf(stderr, "%s: option '-%c' is invalid: ignored\n", argv[0], optopt);
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;
rv = expose_infrastructure_object(ctx);
if (rv < 0)
goto fail;
Jakob Olsson
committed
uloop_run();
return 0;