Changeset 5718

Show
Ignore:
Timestamp:
05/13/09 18:03:23 (4 years ago)
Author:
andy
Message:

sensord: Remove the hidden commandline interface.

Location:
lm-sensors/trunk/prog/sensord
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/prog/sensord/args.c

    r5679 r5718  
    4444int rrdNoAverage = 0; 
    4545int syslogFacility = LOG_LOCAL4; 
    46 int doScan = 0; 
    47 int doSet = 0; 
    4846int doCGI = 0; 
    4947int doLoad = 0; 
     
    128126        "your configuration changes, delete the old RRD file and restart sensord.\n"; 
    129127 
    130 static const char *appSyntax = 
    131         "  -a, --alarm-scan          -- only scan for alarms\n" 
    132         "  -s, --set                 -- execute set statements (root only)\n" 
    133         "  -r, --rrd-file <file>     -- only update RRD file\n" 
    134         "  -c, --config-file <file>  -- configuration file\n" 
    135         "  -d, --debug               -- display some debug information\n" 
    136         "  -v, --version             -- display version and exit\n" 
    137         "  -h, --help                -- display help and exit\n" 
    138         "\n" 
    139         "Specify the filename `-' to read the config file from stdin.\n" 
    140         "\n" 
    141         "If no chips are specified, all chip info will be printed.\n"; 
    142  
    143 static const char *daemonShortOptions = "i:l:t:Tf:r:c:p:advhg:"; 
    144  
    145 static const struct option daemonLongOptions[] = { 
     128static const char *shortOptions = "i:l:t:Tf:r:c:p:advhg:"; 
     129 
     130static const struct option longOptions[] = { 
    146131        { "interval", required_argument, NULL, 'i' }, 
    147132        { "log-interval", required_argument, NULL, 'l' }, 
     
    160145}; 
    161146 
    162 static const char *appShortOptions = "asr:c:dvh"; 
    163  
    164 static const struct option appLongOptions[] = { 
    165         { "alarm-scan", no_argument, NULL, 'a' }, 
    166         { "set", no_argument, NULL, 's' }, 
    167         { "rrd-file", required_argument, NULL, 'r' }, 
    168         { "config-file", required_argument, NULL, 'c' }, 
    169         { "debug", no_argument, NULL, 'd' }, 
    170         { "version", no_argument, NULL, 'v' }, 
    171         { "help", no_argument, NULL, 'h' }, 
    172         { NULL, 0, NULL, 0 } 
    173 }; 
    174  
    175147int parseArgs(int argc, char **argv) 
    176148{ 
    177149        int c; 
    178         const char *shortOptions; 
    179         const struct option *longOptions; 
    180150 
    181151        isDaemon = (argv[0][strlen (argv[0]) - 1] == 'd'); 
    182         shortOptions = isDaemon ? daemonShortOptions : appShortOptions; 
    183         longOptions = isDaemon ? daemonLongOptions : appLongOptions; 
     152        if (!isDaemon) { 
     153                fprintf(stderr, "Sensord no longer runs as an commandline" 
     154                        " application.\n"); 
     155                return -1; 
     156        } 
    184157 
    185158        while ((c = getopt_long(argc, argv, shortOptions, longOptions, NULL)) 
     
    206179                        break; 
    207180                case 'a': 
    208                         if (isDaemon) 
    209                                 doLoad = 1; 
    210                         else 
    211                                 doScan = 1; 
    212                         break; 
    213                 case 's': 
    214                         doSet = 1; 
     181                        doLoad = 1; 
    215182                        break; 
    216183                case 'c': 
     
    236203                case 'h': 
    237204                        printf("Syntax: %s {options} {chips}\n%s", argv[0], 
    238                                isDaemon ? daemonSyntax : appSyntax); 
     205                               daemonSyntax); 
    239206                        exit(EXIT_SUCCESS); 
    240207                        break; 
     
    251218                        break; 
    252219                } 
    253         } 
    254  
    255         if (doScan && doSet) { 
    256                 fprintf(stderr, 
    257                         "Error: Incompatible --set and --alarm-scan.\n"); 
    258                 return -1; 
    259         } 
    260  
    261         if (rrdFile && doSet) { 
    262                 fprintf(stderr, 
    263                         "Error: Incompatible --set and --rrd-file.\n"); 
    264                 return -1; 
    265         } 
    266  
    267         if (doScan && rrdFile) { 
    268                 fprintf(stderr, 
    269                         "Error: Incompatible --rrd-file and --alarm-scan.\n"); 
    270                 return -1; 
    271220        } 
    272221 
  • lm-sensors/trunk/prog/sensord/sensord.c

    r5678 r5718  
    213213                exit(EXIT_FAILURE); 
    214214 
    215         if (isDaemon) 
    216                 openLog(); 
    217         if (rrdFile) 
     215        openLog(); 
     216 
     217        if (rrdFile) { 
    218218                ret = rrdInit(); 
    219  
    220         if (ret) { 
    221         } else if (doCGI) { 
     219                if (ret) 
     220                        exit(EXIT_FAILURE); 
     221        } 
     222 
     223        if (doCGI) { 
    222224                ret = rrdCGI(); 
    223         } else if (isDaemon) { 
     225        } else { 
    224226                daemonize(); 
    225227                ret = sensord(); 
    226228                undaemonize(); 
    227         } else { 
    228                 if (doSet) 
    229                         ret = setChips(); 
    230                 else if (doScan) 
    231                         ret = scanChips(); 
    232                 else if (rrdFile) 
    233                         ret = rrdUpdate(); 
    234                 else 
    235                         ret = readChips(); 
    236229        } 
    237230 
  • lm-sensors/trunk/prog/sensord/sensord.h

    r5678 r5718  
    3838extern int rrdNoAverage; 
    3939extern int syslogFacility; 
    40 extern int doScan; 
    41 extern int doSet; 
    4240extern int doCGI; 
    4341extern int doLoad;