Skip to content
Snippets Groups Projects
dongle.c 1.41 KiB
Newer Older
  • Learn to ignore specific revisions
  • #include "common.h"
    #include "dongle_apn.h"
    #include "dongle_pin.h"
    #include "dongle_network.h"
    
    #include "dongle_infrastructure.h"
    
    static struct option long_options[] = {
    
    Jakob Olsson's avatar
    Jakob Olsson committed
    	{"debug", required_argument, NULL, 'd'},
    	{0,	0,	0,	0}
    
    };
    
    int parse_args(int argc, char **argv)
    {
    
    Jakob Olsson's avatar
    Jakob Olsson committed
    	char ch;
    
    
    	while ((ch = getopt_long(argc, argv, "d:", long_options, NULL)) != -1) {
    
    Jakob Olsson's avatar
    Jakob Olsson committed
    		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's avatar
    Jakob Olsson committed
    			}
    			goto done;
    		case ':':
    
    			fprintf(stderr, "%s: option '-%c' requires an argument\n", argv[0], optopt);
    
    Jakob Olsson's avatar
    Jakob Olsson committed
    			goto fail;
    		case '?':
    
    			fprintf(stderr, "%s: option '-%c' is invalid: ignored\n", argv[0], optopt);
    
    Jakob Olsson's avatar
    Jakob Olsson committed
    			goto fail;
    
    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;
    
    
    	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;