]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/misc-progs/qosctrl.c
Ended core 5 and started core 6
[people/pmueller/ipfire-2.x.git] / src / misc-progs / qosctrl.c
index 8a8f07ebc099eb5c17613bf4c89f1bfc5a8a1a06..5e1420b9d28f06cc224811e4210327db949b3acd 100644 (file)
 
 int main(int argc, char *argv[]) {
 
-       int fd = -1;
-
-       if (!(initsetuid()))
-               exit(1);
-
-       if (argc < 2) {
-               fprintf(stderr, "\nNo argument given.\n\nqosctrl (start|stop|restart|status|generate)\n\n");
-               exit(1);
-       }
-       
-       if ((fd = open("/var/ipfire/qos/bin/qos.sh", O_RDONLY)) != -1) {
-               close(fd);
-       } else {
-               // If there is no qos.sh do nothing.
-               exit(0);
-       }
-       
-       safe_system("chmod 755 /var/ipfire/qos/bin/qos.sh &>/dev/null");
-       if (strcmp(argv[1], "start") == 0) {
-               safe_system("/var/ipfire/qos/bin/qos.sh start");        
-       } else if (strcmp(argv[1], "stop") == 0) {
-               safe_system("/var/ipfire/qos/bin/qos.sh clear");
-       } else if (strcmp(argv[1], "status") == 0) {
-               safe_system("/var/ipfire/qos/bin/qos.sh status");
-       } else if (strcmp(argv[1], "restart") == 0) {
-               safe_system("/var/ipfire/qos/bin/qos.sh restart");
-       } else if (strcmp(argv[1], "generate") == 0) {
-               safe_system("/usr/bin/perl /var/ipfire/qos/bin/makeqosscripts.pl > /var/ipfire/qos/bin/qos.sh");
-       } else {
-               fprintf(stderr, "\nBad argument given.\n\nqosctrl (start|stop|restart|status|generate)\n\n");
-               exit(1);
-       }
-
-       return 0;
+        int fd = -1;
+
+        if (!(initsetuid()))
+                exit(1);
+
+        if (argc < 2) {
+                fprintf(stderr, "\nNo argument given.\n\nqosctrl (start|stop|restart|status|generate)\n\n");
+                exit(1);
+        }
+
+        if (strcmp(argv[1], "generate") == 0) {
+                safe_system("/usr/bin/perl /var/ipfire/qos/bin/makeqosscripts.pl > /var/ipfire/qos/bin/qos.sh");
+        }
+
+        if ((fd = open("/var/ipfire/qos/bin/qos.sh", O_RDONLY)) != -1) {
+                close(fd);
+        } else {
+                // If there is no qos.sh do nothing.
+                exit(0);
+        }
+
+        safe_system("chmod 755 /var/ipfire/qos/bin/qos.sh &>/dev/null");
+        if (strcmp(argv[1], "start") == 0) {
+                safe_system("/var/ipfire/qos/bin/qos.sh start");
+        } else if (strcmp(argv[1], "stop") == 0) {
+                safe_system("/var/ipfire/qos/bin/qos.sh clear");
+        } else if (strcmp(argv[1], "status") == 0) {
+                safe_system("/var/ipfire/qos/bin/qos.sh status");
+        } else if (strcmp(argv[1], "restart") == 0) {
+                safe_system("/var/ipfire/qos/bin/qos.sh restart");
+        } else {
+                if (strcmp(argv[1], "generate") == 0) {exit(0);}
+                fprintf(stderr, "\nBad argument given.\n\nqosctrl (start|stop|restart|status|generate)\n\n");
+                exit(1);
+        }
+
+        return 0;
 }