Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (16 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/miscutils/adjtimex.c

    r821 r1765  
    1212 */
    1313
    14 #include "busybox.h"
    15 #include <stdio.h>
    16 #include <sys/types.h>
    17 #include <stdlib.h>
    18 #include <unistd.h>
     14#include "libbb.h"
    1915#include <sys/timex.h>
    2016
    21 static const struct {int bit; const char *name;} statlist[] = {
     17static const struct {
     18    int bit;
     19    const char *name;
     20} statlist[] = {
    2221    { STA_PLL,       "PLL"       },
    2322    { STA_PPSFREQ,   "PPSFREQ"   },
     
    3332    { STA_PPSERROR,  "PPSERROR"  },
    3433    { STA_CLOCKERR,  "CLOCKERR"  },
    35     { 0, NULL } };
     34    { 0, NULL }
     35};
    3636
    37 static const char * const ret_code_descript[] = {
     37static const char *const ret_code_descript[] = {
    3838    "clock synchronized",
    3939    "insert leap second",
     
    4141    "leap second in progress",
    4242    "leap second has occurred",
    43     "clock not synchronized" };
     43    "clock not synchronized"
     44};
    4445
     46int adjtimex_main(int argc, char **argv);
    4547int adjtimex_main(int argc, char **argv)
    4648{
     49    enum {
     50        OPT_quiet = 0x1
     51    };
     52    unsigned opt;
     53    char *opt_o, *opt_f, *opt_p, *opt_t;
    4754    struct timex txc;
    48     int quiet=0;
    49     int c, i, ret, sep;
     55    int i, ret, sep;
    5056    const char *descript;
    5157    txc.modes=0;
    52     for (;;) {
    53         c = getopt( argc, argv, "qo:f:p:t:");
    54         if (c == EOF) break;
    55         switch (c) {
    56             case 'q':
    57                 quiet=1;
    58                 break;
    59             case 'o':
    60                 txc.offset = atoi(optarg);
    61                 txc.modes |= ADJ_OFFSET_SINGLESHOT;
    62                 break;
    63             case 'f':
    64                 txc.freq = atoi(optarg);
    65                 txc.modes |= ADJ_FREQUENCY;
    66                 break;
    67             case 'p':
    68                 txc.constant = atoi(optarg);
    69                 txc.modes |= ADJ_TIMECONST;
    70                 break;
    71             case 't':
    72                 txc.tick = atoi(optarg);
    73                 txc.modes |= ADJ_TICK;
    74                 break;
    75             default:
    76                 bb_show_usage();
    77                 exit(1);
    78         }
     58
     59    opt = getopt32(argv, "qo:f:p:t:",
     60            &opt_o, &opt_f, &opt_p, &opt_t);
     61    //if (opt & 0x1) // -q
     62    if (opt & 0x2) { // -o
     63        txc.offset = xatol(opt_o);
     64        txc.modes |= ADJ_OFFSET_SINGLESHOT;
     65    }
     66    if (opt & 0x4) { // -f
     67        txc.freq = xatol(opt_f);
     68        txc.modes |= ADJ_FREQUENCY;
     69    }
     70    if (opt & 0x8) { // -p
     71        txc.constant = xatol(opt_p);
     72        txc.modes |= ADJ_TIMECONST;
     73    }
     74    if (opt & 0x10) { // -t
     75        txc.tick = xatol(opt_t);
     76        txc.modes |= ADJ_TICK;
    7977    }
    8078    if (argc != optind) { /* no valid non-option parameters */
    8179        bb_show_usage();
    82         exit(1);
    8380    }
    8481
     
    8784    if (ret < 0) perror("adjtimex");
    8885
    89     if (!quiet && ret>=0) {
     86    if (!(opt & OPT_quiet) && ret>=0) {
    9087        printf(
    9188            "    mode:         %d\n"
Note: See TracChangeset for help on using the changeset viewer.