aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--miscutils/adjtimex.c57
1 files changed, 26 insertions, 31 deletions
diff --git a/miscutils/adjtimex.c b/miscutils/adjtimex.c
index abd061897..9662bbea9 100644
--- a/miscutils/adjtimex.c
+++ b/miscutils/adjtimex.c
@@ -44,49 +44,44 @@ static const char * const ret_code_descript[] = {
44 44
45int adjtimex_main(int argc, char **argv) 45int adjtimex_main(int argc, char **argv)
46{ 46{
47 enum {
48 OPT_quiet = 0x1
49 };
50 unsigned long opt;
51 char *opt_o, *opt_f, *opt_p, *opt_t;
47 struct timex txc; 52 struct timex txc;
48 int quiet=0; 53 int i, ret, sep;
49 int c, i, ret, sep;
50 const char *descript; 54 const char *descript;
51 txc.modes=0; 55 txc.modes=0;
52 for (;;) { 56
53 c = getopt( argc, argv, "qo:f:p:t:"); 57 opt = bb_getopt_ulflags(argc, argv, "qo:f:p:t:",
54 if (c == EOF) break; 58 &opt_o, &opt_f, &opt_p, &opt_t);
55 switch (c) { 59 //if (opt & 0x1) // -q
56 case 'q': 60 if (opt & 0x2) { // -o
57 quiet=1; 61 txc.offset = atoi(opt_o);
58 break; 62 txc.modes |= ADJ_OFFSET_SINGLESHOT;
59 case 'o': 63 }
60 txc.offset = atoi(optarg); 64 if (opt & 0x4) { // -f
61 txc.modes |= ADJ_OFFSET_SINGLESHOT; 65 txc.freq = atoi(opt_f);
62 break; 66 txc.modes |= ADJ_FREQUENCY;
63 case 'f': 67 }
64 txc.freq = atoi(optarg); 68 if (opt & 0x8) { // -p
65 txc.modes |= ADJ_FREQUENCY; 69 txc.constant = atoi(opt_p);
66 break; 70 txc.modes |= ADJ_TIMECONST;
67 case 'p': 71 }
68 txc.constant = atoi(optarg); 72 if (opt & 0x10) { // -t
69 txc.modes |= ADJ_TIMECONST; 73 txc.tick = atoi(opt_t);
70 break; 74 txc.modes |= ADJ_TICK;
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 }
79 } 75 }
80 if (argc != optind) { /* no valid non-option parameters */ 76 if (argc != optind) { /* no valid non-option parameters */
81 bb_show_usage(); 77 bb_show_usage();
82 exit(1);
83 } 78 }
84 79
85 ret = adjtimex(&txc); 80 ret = adjtimex(&txc);
86 81
87 if (ret < 0) perror("adjtimex"); 82 if (ret < 0) perror("adjtimex");
88 83
89 if (!quiet && ret>=0) { 84 if (!(opt & OPT_quiet) && ret>=0) {
90 printf( 85 printf(
91 " mode: %d\n" 86 " mode: %d\n"
92 "-o offset: %ld\n" 87 "-o offset: %ld\n"