Skip to content
Snippets Groups Projects
dongle.c 1.38 KiB
Newer Older
  • Learn to ignore specific revisions
  • #include "common.h"
    #include "dongle_apn.h"
    #include "dongle_pin.h"
    #include "dongle_network.h"
    
    struct ubus_context *ctx;
    
    static struct option long_options[] =
    {
        {"debug", required_argument, NULL, 'd'}
    };
    
    int parse_args(int argc, char **argv)
    {
    
    Jakob Olsson's avatar
    Jakob Olsson committed
    	char ch;
    
    
    	printf("hallå1\n");
    
    	while ((ch = getopt_long(argc, argv, ":d:", long_options, NULL)) != -1) {
    
    	int debug_arg;
    		printf("hallå2\n");
    
    			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;
    }
    
    
    
    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;