main: reformat code
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
parent
bacfc8e95a
commit
5807e488e8
36
src/main.c
36
src/main.c
|
@ -229,8 +229,8 @@ static void parse_command_line(int argc, char* argv[], int count,
|
|||
exit(1);
|
||||
}
|
||||
}
|
||||
if( c=='o' || c=='f' || c=='g' || c=='t' || c=='a' || c=='A' || c=='m') {
|
||||
if((strncmp(optarg,"all",strlen("all"))==0)
|
||||
if(strchr("ofgtaAm", c)) {
|
||||
if(!strncmp(optarg,"all", strlen("all"))
|
||||
|| (atoi(optarg) == 7) ) {
|
||||
//use all outlets
|
||||
from=1;
|
||||
|
@ -247,8 +247,7 @@ static void parse_command_line(int argc, char* argv[], int count,
|
|||
} else {
|
||||
from = upto = 0;
|
||||
}
|
||||
if( c=='o' || c=='f' || c=='g' || c=='b' || c=='t' || c=='a' || c=='A'
|
||||
|| c=='m') { //we need a device handle for these commands
|
||||
if(strchr("ofgbtaAm", c)) { //we need a device handle for these commands
|
||||
/* get device-handle/-id if it wasn't done already */
|
||||
if(udev == NULL) {
|
||||
udev = get_handle(dev[devnum]);
|
||||
|
@ -256,14 +255,16 @@ static void parse_command_line(int argc, char* argv[], int count,
|
|||
fprintf(stderr, "No access to Gembird #%d USB device %s\n",
|
||||
devnum, dev[devnum]->filename );
|
||||
exit(1);
|
||||
} else if(verbose) printf("Accessing Gembird #%d USB device %s\n",
|
||||
devnum, dev[devnum]->filename );
|
||||
} else if(verbose) {
|
||||
printf("Accessing Gembird #%d USB device %s\n", devnum,
|
||||
dev[devnum]->filename);
|
||||
}
|
||||
id = get_id(dev[devnum]);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WEBLESS
|
||||
if (c=='l' || c=='L' || c=='i' || c=='p' || c=='u' ) {
|
||||
if (strchr("lLipu", c)) {
|
||||
fprintf(stderr,"Application was compiled without web-interface. "
|
||||
"Feature not available.\n");
|
||||
exit(-100);
|
||||
|
@ -442,8 +443,7 @@ static void parse_command_line(int argc, char* argv[], int count,
|
|||
}
|
||||
switch (opt) {
|
||||
case 'd':
|
||||
plan.actions[actionNo+1].switchOn = (strcmp(optarg, "on")
|
||||
== 0 ? 1 : 0);
|
||||
plan.actions[actionNo+1].switchOn = !strcmp(optarg, "on");
|
||||
break;
|
||||
case 'a':
|
||||
plan.actions[actionNo].timeForNext = atol(optarg);
|
||||
|
@ -456,13 +456,15 @@ static void parse_command_line(int argc, char* argv[], int count,
|
|||
strptime(optarg, "%Y-%m-%d %H:%M", &tm);
|
||||
time4next = mktime(&tm);
|
||||
if (time4next > lastEventTime)
|
||||
plan.actions[actionNo].timeForNext = (time4next - lastEventTime) / 60;
|
||||
plan.actions[actionNo].timeForNext =
|
||||
(time4next - lastEventTime) / 60;
|
||||
else
|
||||
plan.actions[actionNo].timeForNext = 0;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr,"Unknown Option: %s\nTerminating\n",argv[optind-1]);
|
||||
fprintf(stderr, "Unknown Option: %s\nTerminating\n",
|
||||
argv[optind-1]);
|
||||
exit(-7);
|
||||
break;
|
||||
}
|
||||
|
@ -565,12 +567,12 @@ static void parse_command_line(int argc, char* argv[], int count,
|
|||
numeric = 2 - numeric;
|
||||
break;
|
||||
case 'b':
|
||||
if (strncmp(optarg,"on",strlen("on"))==0) {
|
||||
if (!strncmp(optarg, "on", strlen("on"))) {
|
||||
sispm_buzzer_on(udev);
|
||||
if(verbose) printf("Turned buzzer %s\n", onoff[1 + numeric]);
|
||||
} else if (strncmp(optarg,"off",strlen("off"))==0) {
|
||||
} else if (!strncmp(optarg,"off", strlen("off"))) {
|
||||
sispm_buzzer_off(udev);
|
||||
if(verbose) printf("Turned buzzer %s\n",onoff[0+numeric]);
|
||||
if(verbose) printf("Turned buzzer %s\n", onoff[numeric]);
|
||||
}
|
||||
break;
|
||||
case 'v':
|
||||
|
@ -587,7 +589,7 @@ static void parse_command_line(int argc, char* argv[], int count,
|
|||
} // loop through devices
|
||||
} // loop through options
|
||||
|
||||
if (udev!=NULL) {
|
||||
if (udev) {
|
||||
usb_close(udev);
|
||||
udev = NULL;
|
||||
}
|
||||
|
@ -595,7 +597,7 @@ static void parse_command_line(int argc, char* argv[], int count,
|
|||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct usb_bus *bus;
|
||||
struct usb_device *dev, *usbdev[MAXGEMBIRD], *usbdevtemp;
|
||||
|
@ -603,7 +605,7 @@ int main(int argc, char** argv)
|
|||
int count=0, found = 0, i=1;
|
||||
|
||||
#ifndef MSG_NOSIGNAL
|
||||
(void) signal(SIGPIPE, SIG_IGN);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
#endif
|
||||
|
||||
memset(usbdev,0,sizeof(usbdev));
|
||||
|
|
Loading…
Reference in New Issue