Diff for /embedtools/src/pceng.c between versions 1.1.2.4 and 1.1.2.6

version 1.1.2.4, 2011/07/22 14:45:30 version 1.1.2.6, 2011/07/22 15:10:53
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]\n"                "  Syntax: pceng [options] [[led_no <0|1>] ...]\n"
                 "\n"                  "\n"
                 "\t-v\t\tVerbose ...\n"                  "\t-v\t\tVerbose ...\n"
                "\t-b\t\tRun in batch mode ...\n"                "\t-D\t\tRun in background mode ...\n"
                 "\t-c <conf>\tConfig events file ...\n"                  "\t-c <conf>\tConfig events file ...\n"
                 "\n", compiled, compiledby, compilehost);                  "\n", compiled, compiledby, compilehost);
 }  }
Line 93  sigHand(int sig) Line 93  sigHand(int sig)
 int  int
 main(int argc, char **argv)  main(int argc, char **argv)
 {  {
        char ch;        char ch, ledno;
        int io, ret = 0, mode = 0;        int i, io, ret = 0, mode = 1;
         struct sigaction sact;          struct sigaction sact;
   
        while ((ch = getopt(argc, argv, "vhbc:")) != -1)        while ((ch = getopt(argc, argv, "vhDc:")) != -1)
                 switch (ch) {                  switch (ch) {
                         case 'c':                          case 'c':
                                 strlcpy(szConf, optarg, sizeof szConf);                                  strlcpy(szConf, optarg, sizeof szConf);
                                 break;                                  break;
                        case 'b':                        case 'D':
                                mode = 1;                                mode = 0;
                                 break;                                  break;
                         case 'v':                          case 'v':
                                 Verbose++;                                  Verbose++;
Line 115  main(int argc, char **argv) Line 115  main(int argc, char **argv)
                 }                  }
         argc -= optind;          argc -= optind;
         argv += optind;          argv += optind;
           if (argc && argc % 2) {
                   printf("Error:: not enough parameters ...\n");
                   return 1;
           }
   
        openlog("pceng", LOG_CONS | LOG_PID, LOG_DAEMON);        if (!mode)
                 openlog("pceng", LOG_CONS | LOG_PID, LOG_DAEMON);
         else
                 openlog("pceng", LOG_CONS | LOG_PID | LOG_PERROR, LOG_USER);
   
           io = open(_PATH_DEVIO, O_RDWR);
           if (io == -1) {
                   printf("Error:: in open dev %s #%d - %s\n", _PATH_DEVIO, errno, strerror(errno));
                   ret = 2;
                   goto end;
           }
   
           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);
                           ret = LED(io, (u_char) ledno, (u_char) ch);
                   }
                   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());
                return 1;                ret = 1;
                 goto end;
         }          }
   
         sact.sa_handler = sigHand;          sact.sa_handler = sigHand;
Line 129  main(int argc, char **argv) Line 154  main(int argc, char **argv)
         sigaction(SIGTERM, &sact, NULL);          sigaction(SIGTERM, &sact, NULL);
         sigaction(SIGCHLD, &sact, NULL);          sigaction(SIGCHLD, &sact, NULL);
   
         io = open(_PATH_DEVIO, O_RDWR);  
         if (io == -1) {  
                 printf("Error:: in open dev %s #%d - %s\n", _PATH_DEVIO, errno, strerror(errno));  
                 ret = 2;  
                 goto end;  
         }  
   
         if (!mode)          if (!mode)
                 switch (fork()) {                  switch (fork()) {
                         case -1:                          case -1:
Line 164  main(int argc, char **argv) Line 182  main(int argc, char **argv)
         ret = Run(io);          ret = Run(io);
   
 end:  end:
           UnloadConfig(&cfg);
         if (io > 2)          if (io > 2)
                 close(io);                  close(io);
         UnloadConfig(&cfg);  
         closelog();          closelog();
         return ret;          return ret;
 }  }

Removed from v.1.1.2.4  
changed lines
  Added in v.1.1.2.6


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>