--- embedtools/src/pceng.c 2011/07/23 23:41:00 1.1.2.7 +++ embedtools/src/pceng.c 2011/07/25 09:13:34 1.1.2.8 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ - * $Id: pceng.c,v 1.1.2.7 2011/07/23 23:41:00 misho Exp $ + * $Id: pceng.c,v 1.1.2.8 2011/07/25 09:13:34 misho Exp $ * ************************************************************************* The ELWIX and AITNET software is distributed under the following @@ -58,7 +58,7 @@ Usage() { printf( "-= PCEngines =- events managment tool\n" "=== %s === %s@%s ===\n\n" - " Syntax: pceng [options] [[led_no <0|1>] ...]\n" + " Syntax: pceng [options] [led_no[=<0|1>] ...]\n" "\n" "\t-v\t\tVerbose ...\n" "\t-D\t\tRun in background mode ...\n" @@ -93,7 +93,7 @@ sigHand(int sig) int main(int argc, char **argv) { - char ch, ledno; + char ch, ledno, *pos; int i, ret = 0, mode = 1; struct sigaction sact; #ifdef HAVE_IO @@ -118,10 +118,6 @@ main(int argc, char **argv) } argc -= optind; argv += optind; - if (argc && argc % 2) { - printf("Error:: not enough parameters ...\n"); - return 1; - } if (!mode) openlog("pceng", LOG_CONS | LOG_PID, LOG_DAEMON); @@ -145,9 +141,15 @@ main(int argc, char **argv) if (argc) { VERB(1) syslog(LOG_WARNING, "LED client ..."); - for (i = 0; !ret && i < argc; i += 2) { - ledno = (char) strtol(argv[i], NULL, 0); - ch = (char) strtol(argv[i + 1], NULL, 0); + for (i = 0; !ret && i < argc; pos = NULL, i++) { + if ((pos = strchr(argv[i], '='))) { + *pos++ = 0; + ledno = (char) strtol(argv[i], NULL, 0); + ch = (char) strtol(pos, NULL, 0); + } else { + ledno = (char) strtol(argv[i], NULL, 0); + ch = -1; + } ret = LED((u_char) ledno, (u_char) ch); } goto end;