more advanced Nginx settings in GUI
[tomato.git] / release / src-rt-6.x.4708 / router / rc / led.c
blobf60bbebcd9def4fc4a826c467d52694df8167b1f
1 /*
3 Tomato Firmware
4 Copyright (C) 2006-2009 Jonathan Zarate
6 */
8 #include "rc.h"
10 __attribute__ ((noreturn))
11 static void help(void)
13 char s[256];
14 int i;
16 s[0] = 0;
17 for (i = 0; i < LED_COUNT; ++i) {
18 if (led(i, LED_PROBE)) {
19 if (s[0]) strcat(s, "/");
20 strcat(s, led_names[i]);
23 if (s[0] == 0) {
24 fprintf(stderr, "Not supported.\n");
26 else {
27 fprintf(stderr, "led <%s> <on/off> [...]\n", s);
29 exit(1);
32 int led_main(int argc, char *argv[])
35 int i;
36 int j;
37 char *a;
39 if ((argc < 3) || ((argc % 2) != 1)) help();
41 for (j = 1; j < argc; j += 2) {
42 a = argv[j];
43 for (i = 0; i < LED_COUNT; ++i) {
44 if (strncmp(led_names[i], a, 2) == 0) break;
46 a = argv[j + 1];
47 if ((i >= LED_COUNT) || ((strcmp(a, "on") != 0) && (strcmp(a, "off") != 0))) help();
48 if (!led(i, (a[1] == 'n'))) help();
51 return 0;