Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/miscutils/adjtimex.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/miscutils/adjtimex.c
r821 r1770 12 12 */ 13 13 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" 19 15 #include <sys/timex.h> 20 16 21 static const struct {int bit; const char *name;} statlist[] = { 17 static const struct { 18 int bit; 19 const char *name; 20 } statlist[] = { 22 21 { STA_PLL, "PLL" }, 23 22 { STA_PPSFREQ, "PPSFREQ" }, … … 33 32 { STA_PPSERROR, "PPSERROR" }, 34 33 { STA_CLOCKERR, "CLOCKERR" }, 35 { 0, NULL } }; 34 { 0, NULL } 35 }; 36 36 37 static const char * 37 static const char *const ret_code_descript[] = { 38 38 "clock synchronized", 39 39 "insert leap second", … … 41 41 "leap second in progress", 42 42 "leap second has occurred", 43 "clock not synchronized" }; 43 "clock not synchronized" 44 }; 44 45 46 int adjtimex_main(int argc, char **argv); 45 47 int adjtimex_main(int argc, char **argv) 46 48 { 49 enum { 50 OPT_quiet = 0x1 51 }; 52 unsigned opt; 53 char *opt_o, *opt_f, *opt_p, *opt_t; 47 54 struct timex txc; 48 int quiet=0; 49 int c, i, ret, sep; 55 int i, ret, sep; 50 56 const char *descript; 51 57 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; 79 77 } 80 78 if (argc != optind) { /* no valid non-option parameters */ 81 79 bb_show_usage(); 82 exit(1);83 80 } 84 81 … … 87 84 if (ret < 0) perror("adjtimex"); 88 85 89 if (! quiet&& ret>=0) {86 if (!(opt & OPT_quiet) && ret>=0) { 90 87 printf( 91 88 " mode: %d\n"
Note:
See TracChangeset
for help on using the changeset viewer.