• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/uqmi/uqmid/uqmid.c

  1 /*
  2  * uqmid -- implement a daemon based on the uqmi idea
  3  *
  4  * Copyright (C) 2014-2015 Felix Fietkau <nbd@openwrt.org>
  5  * Copyright (C) 2023 Alexander Couzens <lynxis@fe80.eu>
  6  *
  7  * This library is free software; you can redistribute it and/or
  8  * modify it under the terms of the GNU Lesser General Public
  9  * License as published by the Free Software Foundation; either
 10  * version 2 of the License, or (at your option) any later version.
 11  *
 12  * This library is distributed in the hope that it will be useful,
 13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 15  * Lesser General Public License for more details.
 16  *
 17  * You should have received a copy of the GNU Lesser General Public
 18  * License along with this library; if not, write to the
 19  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 20  * Boston, MA 02110-1301 USA.
 21  */
 22 
 23 #include <libubox/uloop.h>
 24 #include <libubox/utils.h>
 25 #include <stdio.h>
 26 #include <stdlib.h>
 27 #include <fcntl.h>
 28 #include <unistd.h>
 29 #include <errno.h>
 30 #include <getopt.h>
 31 #include <signal.h>
 32 
 33 #include "uqmid.h"
 34 #include "ubus.h"
 35 
 36 static const struct option uqmid_getopt[] = {
 37         { NULL, 0, NULL, 0 }
 38 };
 39 #undef __uqmi_command
 40 
 41 static int usage(const char *progname)
 42 {
 43         fprintf(stderr, "Usage: %s <options|actions>\n"
 44                 "\n", progname);
 45         return 1;
 46 }
 47 
 48 static void handle_exit_signal(int signal)
 49 {
 50         uloop_end();
 51 }
 52 
 53 int main(int argc, char **argv)
 54 {
 55         int ch, ret;
 56 
 57         uloop_init();
 58         signal(SIGINT, handle_exit_signal);
 59         signal(SIGTERM, handle_exit_signal);
 60 
 61         while ((ch = getopt_long(argc, argv, "d:", uqmid_getopt, NULL)) != -1) {
 62                 switch(ch) {
 63                 default:
 64                         return usage(argv[0]);
 65                 }
 66         }
 67 
 68         uloop_init();
 69         /* TODO: add option for the ubus path */
 70         ret = uqmid_ubus_init(NULL);
 71         if (ret) {
 72                 fprintf(stderr, "Failed to connect");
 73                 exit(1);
 74         }
 75 
 76         uloop_run();
 77 
 78         return ret;
 79 }
 80 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt