Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

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

    r1765 r2725  
    99 * busyboxed 20 March 2001, Larry Doolittle <ldoolitt@recycle.lbl.gov>
    1010 *
    11  * Licensed under GPLv2 or later, see file License in this tarball for details.
     11 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    1212 */
    1313
     
    1515#include <sys/timex.h>
    1616
    17 static const struct {
    18     int bit;
    19     const char *name;
    20 } statlist[] = {
    21     { STA_PLL,       "PLL"       },
    22     { STA_PPSFREQ,   "PPSFREQ"   },
    23     { STA_PPSTIME,   "PPSTIME"   },
    24     { STA_FLL,       "FFL"       },
    25     { STA_INS,       "INS"       },
    26     { STA_DEL,       "DEL"       },
    27     { STA_UNSYNC,    "UNSYNC"    },
    28     { STA_FREQHOLD,  "FREQHOLD"  },
    29     { STA_PPSSIGNAL, "PPSSIGNAL" },
    30     { STA_PPSJITTER, "PPSJITTER" },
    31     { STA_PPSWANDER, "PPSWANDER" },
    32     { STA_PPSERROR,  "PPSERROR"  },
    33     { STA_CLOCKERR,  "CLOCKERR"  },
    34     { 0, NULL }
     17static const uint16_t statlist_bit[] = {
     18    STA_PLL,
     19    STA_PPSFREQ,
     20    STA_PPSTIME,
     21    STA_FLL,
     22    STA_INS,
     23    STA_DEL,
     24    STA_UNSYNC,
     25    STA_FREQHOLD,
     26    STA_PPSSIGNAL,
     27    STA_PPSJITTER,
     28    STA_PPSWANDER,
     29    STA_PPSERROR,
     30    STA_CLOCKERR,
     31    0
    3532};
     33static const char statlist_name[] =
     34    "PLL"       "\0"
     35    "PPSFREQ"   "\0"
     36    "PPSTIME"   "\0"
     37    "FFL"       "\0"
     38    "INS"       "\0"
     39    "DEL"       "\0"
     40    "UNSYNC"    "\0"
     41    "FREQHOLD"  "\0"
     42    "PPSSIGNAL" "\0"
     43    "PPSJITTER" "\0"
     44    "PPSWANDER" "\0"
     45    "PPSERROR"  "\0"
     46    "CLOCKERR"
     47;
    3648
    37 static const char *const ret_code_descript[] = {
    38     "clock synchronized",
    39     "insert leap second",
    40     "delete leap second",
    41     "leap second in progress",
    42     "leap second has occurred",
     49static const char ret_code_descript[] =
     50    "clock synchronized" "\0"
     51    "insert leap second" "\0"
     52    "delete leap second" "\0"
     53    "leap second in progress" "\0"
     54    "leap second has occurred" "\0"
    4355    "clock not synchronized"
    44 };
     56;
    4557
    46 int adjtimex_main(int argc, char **argv);
    47 int adjtimex_main(int argc, char **argv)
     58int adjtimex_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     59int adjtimex_main(int argc UNUSED_PARAM, char **argv)
    4860{
    4961    enum {
     
    5365    char *opt_o, *opt_f, *opt_p, *opt_t;
    5466    struct timex txc;
    55     int i, ret, sep;
     67    int i, ret;
    5668    const char *descript;
    57     txc.modes=0;
    5869
     70    opt_complementary = "=0"; /* no valid non-option parameters */
    5971    opt = getopt32(argv, "qo:f:p:t:",
    6072            &opt_o, &opt_f, &opt_p, &opt_t);
     73    txc.modes = 0;
    6174    //if (opt & 0x1) // -q
    6275    if (opt & 0x2) { // -o
     
    7689        txc.modes |= ADJ_TICK;
    7790    }
    78     if (argc != optind) { /* no valid non-option parameters */
    79         bb_show_usage();
    80     }
    8191
    8292    ret = adjtimex(&txc);
    8393
    84     if (ret < 0) perror("adjtimex");
     94    if (ret < 0) {
     95        bb_perror_nomsg_and_die();
     96    }
    8597
    86     if (!(opt & OPT_quiet) && ret>=0) {
     98    if (!(opt & OPT_quiet)) {
     99        int sep;
     100        const char *name;
     101
    87102        printf(
    88103            "    mode:         %d\n"
     
    91106            "    maxerror:     %ld\n"
    92107            "    esterror:     %ld\n"
    93             "    status:       %d ( ",
     108            "    status:       %d (",
    94109        txc.modes, txc.offset, txc.freq, txc.maxerror,
    95110        txc.esterror, txc.status);
     
    97112        /* representative output of next code fragment:
    98113           "PLL | PPSTIME" */
    99         sep=0;
    100         for (i=0; statlist[i].name; i++) {
    101             if (txc.status & statlist[i].bit) {
    102                 if (sep) fputs(" | ",stdout);
    103                 fputs(statlist[i].name,stdout);
    104                 sep=1;
     114        name = statlist_name;
     115        sep = 0;
     116        for (i = 0; statlist_bit[i]; i++) {
     117            if (txc.status & statlist_bit[i]) {
     118                if (sep)
     119                    fputs(" | ", stdout);
     120                fputs(name, stdout);
     121                sep = 1;
    105122            }
     123            name += strlen(name) + 1;
    106124        }
    107125
    108126        descript = "error";
    109         if (ret >= 0 && ret <= 5) descript = ret_code_descript[ret];
    110         printf(" )\n"
     127        if (ret <= 5)
     128            descript = nth_string(ret_code_descript, ret);
     129        printf(")\n"
    111130            "-p  timeconstant: %ld\n"
    112131            "    precision:    %ld\n"
     
    120139        (long)txc.time.tv_sec, (long)txc.time.tv_usec, ret, descript);
    121140    }
    122     return (ret<0);
     141
     142    return 0;
    123143}
Note: See TracChangeset for help on using the changeset viewer.