version 1.1.2.5, 2011/07/22 15:03:30
|
version 1.1.2.10, 2011/10/24 13:41:48
|
Line 58 Usage()
|
Line 58 Usage()
|
{ |
{ |
printf( "-= PCEngines =- events managment tool\n" |
printf( "-= PCEngines =- events managment tool\n" |
"=== %s === %s@%s ===\n\n" |
"=== %s === %s@%s ===\n\n" |
" Syntax: pceng [options] [[led_no <0|1>] ...]\n" | " Syntax: pceng [options] [led_no[=<0|1>] ...]\n" |
"\n" |
"\n" |
"\t-v\t\tVerbose ...\n" |
"\t-v\t\tVerbose ...\n" |
"\t-D\t\tRun in background mode ...\n" |
"\t-D\t\tRun in background mode ...\n" |
Line 93 sigHand(int sig)
|
Line 93 sigHand(int sig)
|
int |
int |
main(int argc, char **argv) |
main(int argc, char **argv) |
{ |
{ |
char ch, ledno; | char ch, ledno, *pos; |
int i, io, ret = 0, mode = 1; | int i, ret = 0, mode = 1; |
struct sigaction sact; |
struct sigaction sact; |
|
#ifdef HAVE_IO |
|
int io; |
|
#endif |
|
|
while ((ch = getopt(argc, argv, "vhDc:")) != -1) |
while ((ch = getopt(argc, argv, "vhDc:")) != -1) |
switch (ch) { |
switch (ch) { |
Line 121 main(int argc, char **argv)
|
Line 124 main(int argc, char **argv)
|
else |
else |
openlog("pceng", LOG_CONS | LOG_PID | LOG_PERROR, LOG_USER); |
openlog("pceng", LOG_CONS | LOG_PID | LOG_PERROR, LOG_USER); |
|
|
io = open(_PATH_DEVIO, O_RDWR); | #ifdef HAVE_IO |
| io = open(_PATH_DEVIO, O_RDONLY); |
if (io == -1) { |
if (io == -1) { |
printf("Error:: in open dev %s #%d - %s\n", _PATH_DEVIO, errno, strerror(errno)); |
printf("Error:: in open dev %s #%d - %s\n", _PATH_DEVIO, errno, strerror(errno)); |
ret = 2; |
ret = 2; |
goto end; |
goto end; |
} |
} |
|
#endif |
|
|
if (argc > 1 && !(argc % 2)) { |
|
for (i = 0; !ret && i < argc; i += 2) { |
|
ledno = (char) strtol(argv[i], NULL, 0); |
|
ch = (char) strtol(argv[i + 1], NULL, 0); |
|
ret = LED(io, (u_char) ledno, (u_char) ch); |
|
} |
|
if (ret) |
|
goto end; |
|
} |
|
|
|
if (LoadConfig(szConf, &cfg)) { |
if (LoadConfig(szConf, &cfg)) { |
printf("Error:: #%d - %s\n", cfg_GetErrno(), cfg_GetError()); |
printf("Error:: #%d - %s\n", cfg_GetErrno(), cfg_GetError()); |
ret = 1; |
ret = 1; |
goto end; |
goto end; |
} |
} |
|
|
|
if (argc) { |
|
VERB(1) syslog(LOG_WARNING, "LED client ..."); |
|
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); |
|
printf("%s:: LED#%d=%d\n", (ch == -1) ? "Get" : "Set", ledno, ret); |
|
} |
|
goto end; |
|
} |
|
|
sact.sa_handler = sigHand; |
sact.sa_handler = sigHand; |
sigemptyset(&sact.sa_mask); |
sigemptyset(&sact.sa_mask); |
sigaction(SIGHUP, &sact, NULL); |
sigaction(SIGHUP, &sact, NULL); |
Line 175 main(int argc, char **argv)
|
Line 187 main(int argc, char **argv)
|
goto end; |
goto end; |
} |
} |
|
|
ret = Run(io); | ret = Run(); |
|
|
end: |
end: |
UnloadConfig(&cfg); |
UnloadConfig(&cfg); |
|
#ifdef HAVE_IO |
if (io > 2) |
if (io > 2) |
close(io); |
close(io); |
|
#endif |
closelog(); |
closelog(); |
return ret; |
return ret; |
} |
} |