~ubuntu-branches/debian/squeeze/ntp/squeeze-201010051545

« back to all changes in this revision

Viewing changes to ntpdc/ntpdc-opts.c

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2009-01-05 21:10:03 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090105211003-mh6zc3um4k1uhsj7
Tags: 1:4.2.4p4+dfsg-8
It did not properly check the return value of EVP_VerifyFinal
which results in an malformed DSA signature being treated as
a good signature rather than as an error.  (CVE-2009-0021)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*   -*- buffer-read-only: t -*- vi: set ro:
 
2
 *  
 
3
 *  DO NOT EDIT THIS FILE   (ntpdc-opts.c)
 
4
 *  
 
5
 *  It has been AutoGen-ed  Monday September 10, 2007 at 08:37:50 PM EDT
 
6
 *  From the definitions    ntpdc-opts.def
 
7
 *  and the template file   options
 
8
 *
 
9
 * Generated from AutoOpts 29:0:4 templates.
 
10
 */
 
11
 
 
12
/*
 
13
 *  This file was produced by an AutoOpts template.  AutoOpts is a
 
14
 *  copyrighted work.  This source file is not encumbered by AutoOpts
 
15
 *  licensing, but is provided under the licensing terms chosen by the
 
16
 *  ntpdc author or copyright holder.  AutoOpts is licensed under
 
17
 *  the terms of the LGPL.  The redistributable library (``libopts'') is
 
18
 *  licensed under the terms of either the LGPL or, at the users discretion,
 
19
 *  the BSD license.  See the AutoOpts and/or libopts sources for details.
 
20
 *
 
21
 * This source file is copyrighted and licensed under the following terms:
 
22
 *
 
23
 * ntpdc copyright 1970-2007 David L. Mills and/or others - all rights reserved
 
24
 *
 
25
 * see html/copyright.html
 
26
 */
 
27
 
 
28
 
 
29
#include <limits.h>
 
30
 
 
31
#define OPTION_CODE_COMPILE 1
 
32
#include "ntpdc-opts.h"
 
33
 
 
34
#ifdef  __cplusplus
 
35
extern "C" {
 
36
#endif
 
37
tSCC zCopyright[] =
 
38
       "ntpdc copyright (c) 1970-2007 David L. Mills and/or others, all rights reserved";
 
39
tSCC zCopyrightNotice[] =
 
40
       
 
41
/* extracted from ../include/copyright.def near line 8 */
 
42
"see html/copyright.html";
 
43
extern tUsageProc optionUsage;
 
44
 
 
45
/*
 
46
 *  global included definitions
 
47
 */
 
48
#ifdef __windows
 
49
  extern int atoi(const char*);
 
50
#else
 
51
# include <stdlib.h>
 
52
#endif
 
53
 
 
54
#ifndef NULL
 
55
#  define NULL 0
 
56
#endif
 
57
#ifndef EXIT_SUCCESS
 
58
#  define  EXIT_SUCCESS 0
 
59
#endif
 
60
#ifndef EXIT_FAILURE
 
61
#  define  EXIT_FAILURE 1
 
62
#endif
 
63
/*
 
64
 *  Ipv4 option description:
 
65
 */
 
66
tSCC    zIpv4Text[] =
 
67
        "Force IPv4 DNS name resolution";
 
68
tSCC    zIpv4_NAME[]               = "IPV4";
 
69
tSCC    zIpv4_Name[]               = "ipv4";
 
70
#define IPV4_FLAGS       (OPTST_DISABLED)
 
71
 
 
72
/*
 
73
 *  Ipv6 option description:
 
74
 */
 
75
tSCC    zIpv6Text[] =
 
76
        "Force IPv6 DNS name resolution";
 
77
tSCC    zIpv6_NAME[]               = "IPV6";
 
78
tSCC    zIpv6_Name[]               = "ipv6";
 
79
#define IPV6_FLAGS       (OPTST_DISABLED)
 
80
 
 
81
/*
 
82
 *  Command option description:
 
83
 */
 
84
tSCC    zCommandText[] =
 
85
        "run a command and exit";
 
86
tSCC    zCommand_NAME[]            = "COMMAND";
 
87
tSCC    zCommand_Name[]            = "command";
 
88
#define COMMAND_FLAGS       (OPTST_DISABLED | OPTST_STACKED \
 
89
        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
 
90
 
 
91
/*
 
92
 *  Listpeers option description with
 
93
 *  "Must also have options" and "Incompatible options":
 
94
 */
 
95
tSCC    zListpeersText[] =
 
96
        "Print a list of the peers";
 
97
tSCC    zListpeers_NAME[]          = "LISTPEERS";
 
98
tSCC    zListpeers_Name[]          = "listpeers";
 
99
static const int
 
100
    aListpeersCantList[] = {
 
101
    INDEX_OPT_COMMAND, NO_EQUIVALENT };
 
102
#define LISTPEERS_FLAGS       (OPTST_DISABLED)
 
103
 
 
104
/*
 
105
 *  Peers option description with
 
106
 *  "Must also have options" and "Incompatible options":
 
107
 */
 
108
tSCC    zPeersText[] =
 
109
        "Print a list of the peers";
 
110
tSCC    zPeers_NAME[]              = "PEERS";
 
111
tSCC    zPeers_Name[]              = "peers";
 
112
static const int
 
113
    aPeersCantList[] = {
 
114
    INDEX_OPT_COMMAND, NO_EQUIVALENT };
 
115
#define PEERS_FLAGS       (OPTST_DISABLED)
 
116
 
 
117
/*
 
118
 *  Showpeers option description with
 
119
 *  "Must also have options" and "Incompatible options":
 
120
 */
 
121
tSCC    zShowpeersText[] =
 
122
        "Show a list of the peers";
 
123
tSCC    zShowpeers_NAME[]          = "SHOWPEERS";
 
124
tSCC    zShowpeers_Name[]          = "showpeers";
 
125
static const int
 
126
    aShowpeersCantList[] = {
 
127
    INDEX_OPT_COMMAND, NO_EQUIVALENT };
 
128
#define SHOWPEERS_FLAGS       (OPTST_DISABLED)
 
129
 
 
130
/*
 
131
 *  Interactive option description with
 
132
 *  "Must also have options" and "Incompatible options":
 
133
 */
 
134
tSCC    zInteractiveText[] =
 
135
        "Force ntpq to operate in interactive mode";
 
136
tSCC    zInteractive_NAME[]        = "INTERACTIVE";
 
137
tSCC    zInteractive_Name[]        = "interactive";
 
138
static const int
 
139
    aInteractiveCantList[] = {
 
140
    INDEX_OPT_COMMAND,
 
141
    INDEX_OPT_LISTPEERS,
 
142
    INDEX_OPT_PEERS,
 
143
    INDEX_OPT_SHOWPEERS, NO_EQUIVALENT };
 
144
#define INTERACTIVE_FLAGS       (OPTST_DISABLED)
 
145
 
 
146
/*
 
147
 *  Debug_Level option description:
 
148
 */
 
149
#ifdef DEBUG
 
150
tSCC    zDebug_LevelText[] =
 
151
        "Increase output debug message level";
 
152
tSCC    zDebug_Level_NAME[]        = "DEBUG_LEVEL";
 
153
tSCC    zDebug_Level_Name[]        = "debug-level";
 
154
#define DEBUG_LEVEL_FLAGS       (OPTST_DISABLED)
 
155
 
 
156
#else   /* disable Debug_Level */
 
157
#define VALUE_OPT_DEBUG_LEVEL NO_EQUIVALENT
 
158
#define DEBUG_LEVEL_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
 
159
#define zDebug_LevelText       NULL
 
160
#define zDebug_Level_NAME      NULL
 
161
#define zDebug_Level_Name      NULL
 
162
#endif  /* DEBUG */
 
163
 
 
164
/*
 
165
 *  Set_Debug_Level option description:
 
166
 */
 
167
#ifdef DEBUG
 
168
tSCC    zSet_Debug_LevelText[] =
 
169
        "Set the output debug message level";
 
170
tSCC    zSet_Debug_Level_NAME[]    = "SET_DEBUG_LEVEL";
 
171
tSCC    zSet_Debug_Level_Name[]    = "set-debug-level";
 
172
#define SET_DEBUG_LEVEL_FLAGS       (OPTST_DISABLED \
 
173
        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
 
174
 
 
175
#else   /* disable Set_Debug_Level */
 
176
#define VALUE_OPT_SET_DEBUG_LEVEL NO_EQUIVALENT
 
177
#define SET_DEBUG_LEVEL_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
 
178
#define zSet_Debug_LevelText       NULL
 
179
#define zSet_Debug_Level_NAME      NULL
 
180
#define zSet_Debug_Level_Name      NULL
 
181
#endif  /* DEBUG */
 
182
 
 
183
/*
 
184
 *  Numeric option description:
 
185
 */
 
186
tSCC    zNumericText[] =
 
187
        "numeric host addresses";
 
188
tSCC    zNumeric_NAME[]            = "NUMERIC";
 
189
tSCC    zNumeric_Name[]            = "numeric";
 
190
#define NUMERIC_FLAGS       (OPTST_DISABLED)
 
191
 
 
192
/*
 
193
 *  Help/More_Help/Version option descriptions:
 
194
 */
 
195
tSCC zHelpText[]       = "Display usage information and exit";
 
196
tSCC zHelp_Name[]      = "help";
 
197
 
 
198
tSCC zMore_HelpText[]  = "Extended usage information passed thru pager";
 
199
tSCC zMore_Help_Name[] = "more-help";
 
200
 
 
201
tSCC zVersionText[]    = "Output version information and exit";
 
202
tSCC zVersion_Name[]   = "version";
 
203
 
 
204
/*
 
205
 *  Save/Load_Opts option description:
 
206
 */
 
207
tSCC zSave_OptsText[]     = "Save the option state to a config file";
 
208
tSCC zSave_Opts_Name[]    = "save-opts";
 
209
 
 
210
tSCC zLoad_OptsText[]     = "Load options from a config file";
 
211
tSCC zLoad_Opts_NAME[]    = "LOAD_OPTS";
 
212
 
 
213
tSCC zNotLoad_Opts_Name[] = "no-load-opts";
 
214
tSCC zNotLoad_Opts_Pfx[]  = "no";
 
215
#define zLoad_Opts_Name   (zNotLoad_Opts_Name + 3)
 
216
/*
 
217
 *  Declare option callback procedures
 
218
 */
 
219
#ifdef DEBUG
 
220
  static tOptProc doOptSet_Debug_Level;
 
221
#else /* not DEBUG */
 
222
# define doOptSet_Debug_Level NULL
 
223
#endif /* def/not DEBUG */
 
224
#if defined(TEST_NTPDC_OPTS)
 
225
/*
 
226
 *  Under test, omit argument processing, or call optionStackArg,
 
227
 *  if multiple copies are allowed.
 
228
 */
 
229
extern tOptProc
 
230
    optionPagedUsage, optionStackArg, optionVersionStderr;
 
231
static tOptProc
 
232
    doUsageOpt;
 
233
 
 
234
/*
 
235
 *  #define map the "normal" callout procs to the test ones...
 
236
 */
 
237
#define SET_DEBUG_LEVEL_OPT_PROC optionStackArg
 
238
 
 
239
 
 
240
#else /* NOT defined TEST_NTPDC_OPTS */
 
241
/*
 
242
 *  When not under test, there are different procs to use
 
243
 */
 
244
extern tOptProc
 
245
    optionPagedUsage, optionPrintVersion, optionStackArg;
 
246
static tOptProc
 
247
    doUsageOpt;
 
248
 
 
249
/*
 
250
 *  #define map the "normal" callout procs
 
251
 */
 
252
#define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
 
253
 
 
254
#define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
 
255
#endif /* defined(TEST_NTPDC_OPTS) */
 
256
#ifdef TEST_NTPDC_OPTS
 
257
# define DOVERPROC optionVersionStderr
 
258
#else
 
259
# define DOVERPROC optionPrintVersion
 
260
#endif /* TEST_NTPDC_OPTS */
 
261
 
 
262
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 
263
 *
 
264
 *  Define the Ntpdc Option Descriptions.
 
265
 */
 
266
static tOptDesc optDesc[ OPTION_CT ] = {
 
267
  {  /* entry idx, value */ 0, VALUE_OPT_IPV4,
 
268
     /* equiv idx, value */ NO_EQUIVALENT, 0,
 
269
     /* equivalenced to  */ NO_EQUIVALENT,
 
270
     /* min, max, act ct */ 0, 1, 0,
 
271
     /* opt state flags  */ IPV4_FLAGS, 0,
 
272
     /* last opt argumnt */ { NULL },
 
273
     /* arg list/cookie  */ NULL,
 
274
     /* must/cannot opts */ NULL, NULL,
 
275
     /* option proc      */ NULL,
 
276
     /* desc, NAME, name */ zIpv4Text, zIpv4_NAME, zIpv4_Name,
 
277
     /* disablement strs */ NULL, NULL },
 
278
 
 
279
  {  /* entry idx, value */ 1, VALUE_OPT_IPV6,
 
280
     /* equiv idx, value */ NOLIMIT, NOLIMIT,
 
281
     /* equivalenced to  */ INDEX_OPT_IPV4,
 
282
     /* min, max, act ct */ 0, 1, 0,
 
283
     /* opt state flags  */ IPV6_FLAGS, 0,
 
284
     /* last opt argumnt */ { NULL },
 
285
     /* arg list/cookie  */ NULL,
 
286
     /* must/cannot opts */ NULL, NULL,
 
287
     /* option proc      */ NULL,
 
288
     /* desc, NAME, name */ zIpv6Text, zIpv6_NAME, zIpv6_Name,
 
289
     /* disablement strs */ NULL, NULL },
 
290
 
 
291
  {  /* entry idx, value */ 2, VALUE_OPT_COMMAND,
 
292
     /* equiv idx, value */ 2, VALUE_OPT_COMMAND,
 
293
     /* equivalenced to  */ NO_EQUIVALENT,
 
294
     /* min, max, act ct */ 0, NOLIMIT, 0,
 
295
     /* opt state flags  */ COMMAND_FLAGS, 0,
 
296
     /* last opt argumnt */ { NULL },
 
297
     /* arg list/cookie  */ NULL,
 
298
     /* must/cannot opts */ NULL, NULL,
 
299
     /* option proc      */ optionStackArg,
 
300
     /* desc, NAME, name */ zCommandText, zCommand_NAME, zCommand_Name,
 
301
     /* disablement strs */ NULL, NULL },
 
302
 
 
303
  {  /* entry idx, value */ 3, VALUE_OPT_LISTPEERS,
 
304
     /* equiv idx, value */ 3, VALUE_OPT_LISTPEERS,
 
305
     /* equivalenced to  */ NO_EQUIVALENT,
 
306
     /* min, max, act ct */ 0, 1, 0,
 
307
     /* opt state flags  */ LISTPEERS_FLAGS, 0,
 
308
     /* last opt argumnt */ { NULL },
 
309
     /* arg list/cookie  */ NULL,
 
310
     /* must/cannot opts */ NULL, aListpeersCantList,
 
311
     /* option proc      */ NULL,
 
312
     /* desc, NAME, name */ zListpeersText, zListpeers_NAME, zListpeers_Name,
 
313
     /* disablement strs */ NULL, NULL },
 
314
 
 
315
  {  /* entry idx, value */ 4, VALUE_OPT_PEERS,
 
316
     /* equiv idx, value */ 4, VALUE_OPT_PEERS,
 
317
     /* equivalenced to  */ NO_EQUIVALENT,
 
318
     /* min, max, act ct */ 0, 1, 0,
 
319
     /* opt state flags  */ PEERS_FLAGS, 0,
 
320
     /* last opt argumnt */ { NULL },
 
321
     /* arg list/cookie  */ NULL,
 
322
     /* must/cannot opts */ NULL, aPeersCantList,
 
323
     /* option proc      */ NULL,
 
324
     /* desc, NAME, name */ zPeersText, zPeers_NAME, zPeers_Name,
 
325
     /* disablement strs */ NULL, NULL },
 
326
 
 
327
  {  /* entry idx, value */ 5, VALUE_OPT_SHOWPEERS,
 
328
     /* equiv idx, value */ 5, VALUE_OPT_SHOWPEERS,
 
329
     /* equivalenced to  */ NO_EQUIVALENT,
 
330
     /* min, max, act ct */ 0, 1, 0,
 
331
     /* opt state flags  */ SHOWPEERS_FLAGS, 0,
 
332
     /* last opt argumnt */ { NULL },
 
333
     /* arg list/cookie  */ NULL,
 
334
     /* must/cannot opts */ NULL, aShowpeersCantList,
 
335
     /* option proc      */ NULL,
 
336
     /* desc, NAME, name */ zShowpeersText, zShowpeers_NAME, zShowpeers_Name,
 
337
     /* disablement strs */ NULL, NULL },
 
338
 
 
339
  {  /* entry idx, value */ 6, VALUE_OPT_INTERACTIVE,
 
340
     /* equiv idx, value */ 6, VALUE_OPT_INTERACTIVE,
 
341
     /* equivalenced to  */ NO_EQUIVALENT,
 
342
     /* min, max, act ct */ 0, 1, 0,
 
343
     /* opt state flags  */ INTERACTIVE_FLAGS, 0,
 
344
     /* last opt argumnt */ { NULL },
 
345
     /* arg list/cookie  */ NULL,
 
346
     /* must/cannot opts */ NULL, aInteractiveCantList,
 
347
     /* option proc      */ NULL,
 
348
     /* desc, NAME, name */ zInteractiveText, zInteractive_NAME, zInteractive_Name,
 
349
     /* disablement strs */ NULL, NULL },
 
350
 
 
351
  {  /* entry idx, value */ 7, VALUE_OPT_DEBUG_LEVEL,
 
352
     /* equiv idx, value */ 7, VALUE_OPT_DEBUG_LEVEL,
 
353
     /* equivalenced to  */ NO_EQUIVALENT,
 
354
     /* min, max, act ct */ 0, NOLIMIT, 0,
 
355
     /* opt state flags  */ DEBUG_LEVEL_FLAGS, 0,
 
356
     /* last opt argumnt */ { NULL },
 
357
     /* arg list/cookie  */ NULL,
 
358
     /* must/cannot opts */ NULL, NULL,
 
359
     /* option proc      */ NULL,
 
360
     /* desc, NAME, name */ zDebug_LevelText, zDebug_Level_NAME, zDebug_Level_Name,
 
361
     /* disablement strs */ NULL, NULL },
 
362
 
 
363
  {  /* entry idx, value */ 8, VALUE_OPT_SET_DEBUG_LEVEL,
 
364
     /* equiv idx, value */ 8, VALUE_OPT_SET_DEBUG_LEVEL,
 
365
     /* equivalenced to  */ NO_EQUIVALENT,
 
366
     /* min, max, act ct */ 0, NOLIMIT, 0,
 
367
     /* opt state flags  */ SET_DEBUG_LEVEL_FLAGS, 0,
 
368
     /* last opt argumnt */ { NULL },
 
369
     /* arg list/cookie  */ NULL,
 
370
     /* must/cannot opts */ NULL, NULL,
 
371
     /* option proc      */ SET_DEBUG_LEVEL_OPT_PROC,
 
372
     /* desc, NAME, name */ zSet_Debug_LevelText, zSet_Debug_Level_NAME, zSet_Debug_Level_Name,
 
373
     /* disablement strs */ NULL, NULL },
 
374
 
 
375
  {  /* entry idx, value */ 9, VALUE_OPT_NUMERIC,
 
376
     /* equiv idx, value */ 9, VALUE_OPT_NUMERIC,
 
377
     /* equivalenced to  */ NO_EQUIVALENT,
 
378
     /* min, max, act ct */ 0, 1, 0,
 
379
     /* opt state flags  */ NUMERIC_FLAGS, 0,
 
380
     /* last opt argumnt */ { NULL },
 
381
     /* arg list/cookie  */ NULL,
 
382
     /* must/cannot opts */ NULL, NULL,
 
383
     /* option proc      */ NULL,
 
384
     /* desc, NAME, name */ zNumericText, zNumeric_NAME, zNumeric_Name,
 
385
     /* disablement strs */ NULL, NULL },
 
386
 
 
387
#ifdef NO_OPTIONAL_OPT_ARGS
 
388
#  define VERSION_OPT_FLAGS     OPTST_IMM | OPTST_NO_INIT
 
389
#else
 
390
#  define VERSION_OPT_FLAGS     OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
 
391
                                OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
 
392
#endif
 
393
 
 
394
  {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
 
395
     /* equiv idx value  */ NO_EQUIVALENT, 0,
 
396
     /* equivalenced to  */ NO_EQUIVALENT,
 
397
     /* min, max, act ct */ 0, 1, 0,
 
398
     /* opt state flags  */ VERSION_OPT_FLAGS, 0,
 
399
     /* last opt argumnt */ { NULL },
 
400
     /* arg list/cookie  */ NULL,
 
401
     /* must/cannot opts */ NULL, NULL,
 
402
     /* option proc      */ DOVERPROC,
 
403
     /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
 
404
     /* disablement strs */ NULL, NULL },
 
405
 
 
406
#undef VERSION_OPT_FLAGS
 
407
 
 
408
 
 
409
  {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
 
410
     /* equiv idx value  */ NO_EQUIVALENT, 0,
 
411
     /* equivalenced to  */ NO_EQUIVALENT,
 
412
     /* min, max, act ct */ 0, 1, 0,
 
413
     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
 
414
     /* last opt argumnt */ { NULL },
 
415
     /* arg list/cookie  */ NULL,
 
416
     /* must/cannot opts */ NULL, NULL,
 
417
     /* option proc      */ doUsageOpt,
 
418
     /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
 
419
     /* disablement strs */ NULL, NULL },
 
420
 
 
421
  {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
 
422
     /* equiv idx value  */ NO_EQUIVALENT, 0,
 
423
     /* equivalenced to  */ NO_EQUIVALENT,
 
424
     /* min, max, act ct */ 0, 1, 0,
 
425
     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
 
426
     /* last opt argumnt */ { NULL },
 
427
     /* arg list/cookie  */ NULL,
 
428
     /* must/cannot opts */ NULL,  NULL,
 
429
     /* option proc      */ optionPagedUsage,
 
430
     /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
 
431
     /* disablement strs */ NULL, NULL },
 
432
 
 
433
  {  /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
 
434
     /* equiv idx value  */ NO_EQUIVALENT, 0,
 
435
     /* equivalenced to  */ NO_EQUIVALENT,
 
436
     /* min, max, act ct */ 0, 1, 0,
 
437
     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
 
438
                          | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
 
439
     /* last opt argumnt */ { NULL },
 
440
     /* arg list/cookie  */ NULL,
 
441
     /* must/cannot opts */ NULL,  NULL,
 
442
     /* option proc      */ NULL,
 
443
     /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
 
444
     /* disablement strs */ NULL, NULL },
 
445
 
 
446
  {  /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
 
447
     /* equiv idx value  */ NO_EQUIVALENT, 0,
 
448
     /* equivalenced to  */ NO_EQUIVALENT,
 
449
     /* min, max, act ct */ 0, NOLIMIT, 0,
 
450
     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) \
 
451
                          | OPTST_DISABLE_IMM, 0,
 
452
     /* last opt argumnt */ { NULL },
 
453
     /* arg list/cookie  */ NULL,
 
454
     /* must/cannot opts */ NULL, NULL,
 
455
     /* option proc      */ optionLoadOpt,
 
456
     /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
 
457
     /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
 
458
};
 
459
 
 
460
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 
461
 *
 
462
 *  Define the Ntpdc Option Environment
 
463
 */
 
464
tSCC   zPROGNAME[]   = "NTPDC";
 
465
tSCC   zUsageTitle[] =
 
466
"ntpdc - vendor-specific NTP query program - Ver. 4.2.4p4\n\
 
467
USAGE:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n";
 
468
tSCC   zRcName[]     = ".ntprc";
 
469
tSCC*  apzHomeList[] = {
 
470
       "$HOME",
 
471
       ".",
 
472
       NULL };
 
473
 
 
474
tSCC   zBugsAddr[]    = "http://bugs.ntp.isc.org, bugs@ntp.org";
 
475
#define zExplain NULL
 
476
tSCC    zDetail[]     = "\n\
 
477
The\n\
 
478
[= prog-name =]\n\
 
479
utility program is used to query an NTP daemon about its\n\
 
480
current state and to request changes in that state.\n\
 
481
It uses NTP mode 7 control message formats described in the source code.\n\
 
482
The program may\n\
 
483
be run either in interactive mode or controlled using command line\n\
 
484
arguments.\n\
 
485
Extensive state and statistics information is available\n\
 
486
through the\n\
 
487
[= prog-name =]\n\
 
488
interface.\n\
 
489
In addition, nearly all the\n\
 
490
configuration options which can be specified at startup using\n\
 
491
ntpd's configuration file may also be specified at run time using\n\
 
492
[= prog-name =] .\n";
 
493
tSCC    zFullVersion[] = NTPDC_FULL_VERSION;
 
494
/* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 408 */
 
495
 
 
496
#if defined(ENABLE_NLS)
 
497
# define OPTPROC_BASE OPTPROC_TRANSLATE
 
498
  static tOptionXlateProc translate_option_strings;
 
499
#else
 
500
# define OPTPROC_BASE OPTPROC_NONE
 
501
# define translate_option_strings NULL
 
502
#endif /* ENABLE_NLS */
 
503
 
 
504
tOptions ntpdcOptions = {
 
505
    OPTIONS_STRUCT_VERSION,
 
506
    0, NULL,                    /* original argc + argv    */
 
507
    ( OPTPROC_BASE
 
508
    + OPTPROC_ERRSTOP
 
509
    + OPTPROC_SHORTOPT
 
510
    + OPTPROC_LONGOPT
 
511
    + OPTPROC_NO_REQ_OPT
 
512
    + OPTPROC_ENVIRON
 
513
    + OPTPROC_HAS_IMMED ),
 
514
    0, NULL,                    /* current option index, current option */
 
515
    NULL,         NULL,         zPROGNAME,
 
516
    zRcName,      zCopyright,   zCopyrightNotice,
 
517
    zFullVersion, apzHomeList,  zUsageTitle,
 
518
    zExplain,     zDetail,      optDesc,
 
519
    zBugsAddr,                  /* address to send bugs to */
 
520
    NULL, NULL,                 /* extensions/saved state  */
 
521
    optionUsage,       /* usage procedure */
 
522
    translate_option_strings,   /* translation procedure */
 
523
    /*
 
524
     *  Indexes to special options
 
525
     */
 
526
    { INDEX_OPT_MORE_HELP,
 
527
      INDEX_OPT_SAVE_OPTS,
 
528
      NO_EQUIVALENT /* index of '-#' option */,
 
529
      NO_EQUIVALENT /* index of default opt */
 
530
    },
 
531
    15 /* full option count */, 10 /* user option count */
 
532
};
 
533
 
 
534
/*
 
535
 *  Create the static procedure(s) declared above.
 
536
 */
 
537
static void
 
538
doUsageOpt(
 
539
    tOptions*   pOptions,
 
540
    tOptDesc*   pOptDesc )
 
541
{
 
542
    USAGE( EXIT_SUCCESS );
 
543
}
 
544
 
 
545
#if ! defined(TEST_NTPDC_OPTS)
 
546
 
 
547
/* * * * * * *
 
548
 *
 
549
 *   For the set-debug-level option, when DEBUG is #define-d.
 
550
 */
 
551
#ifdef DEBUG
 
552
static void
 
553
doOptSet_Debug_Level(
 
554
    tOptions*   pOptions,
 
555
    tOptDesc*   pOptDesc )
 
556
{
 
557
    /* extracted from ../include/debug-opt.def, line 29 */
 
558
DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg );
 
559
}
 
560
#endif /* defined DEBUG */
 
561
 
 
562
#endif /* defined(TEST_NTPDC_OPTS) */
 
563
 
 
564
/* extracted from /usr/local/gnu/share/autogen/optmain.tpl near line 92 */
 
565
 
 
566
#if defined(TEST_NTPDC_OPTS) /* TEST MAIN PROCEDURE: */
 
567
 
 
568
int
 
569
main( int argc, char** argv )
 
570
{
 
571
    int res = EXIT_SUCCESS;
 
572
    (void)optionProcess( &ntpdcOptions, argc, argv );
 
573
    {
 
574
        void optionPutShell( tOptions* );
 
575
        optionPutShell( &ntpdcOptions );
 
576
    }
 
577
    return res;
 
578
}
 
579
#endif  /* defined TEST_NTPDC_OPTS */
 
580
/* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 514 */
 
581
 
 
582
#if ENABLE_NLS
 
583
#include <stdio.h>
 
584
#include <stdlib.h>
 
585
#include <string.h>
 
586
#include <unistd.h>
 
587
#include <autoopts/usage-txt.h>
 
588
 
 
589
static char* AO_gettext( char const* pz );
 
590
static void  coerce_it(void** s);
 
591
 
 
592
static char*
 
593
AO_gettext( char const* pz )
 
594
{
 
595
    char* pzRes;
 
596
    if (pz == NULL)
 
597
        return NULL;
 
598
    pzRes = _(pz);
 
599
    if (pzRes == pz)
 
600
        return pzRes;
 
601
    pzRes = strdup( pzRes );
 
602
    if (pzRes == NULL) {
 
603
        fputs( _("No memory for duping translated strings\n"), stderr );
 
604
        exit( EXIT_FAILURE );
 
605
    }
 
606
    return pzRes;
 
607
}
 
608
 
 
609
static void coerce_it(void** s) { *s = AO_gettext(*s); }
 
610
#define COERSION(_f) \
 
611
  coerce_it((void*)&(ntpdcOptions._f))
 
612
 
 
613
/*
 
614
 *  This invokes the translation code (e.g. gettext(3)).
 
615
 */
 
616
static void
 
617
translate_option_strings( void )
 
618
{
 
619
    /*
 
620
     *  Guard against re-translation.  It won't work.  The strings will have
 
621
     *  been changed by the first pass through this code.  One shot only.
 
622
     */
 
623
    if (option_usage_text.field_ct == 0)
 
624
        return;
 
625
    /*
 
626
     *  Do the translations.  The first pointer follows the field count field.
 
627
     *  The field count field is the size of a pointer.
 
628
     */
 
629
    {
 
630
        char** ppz = (char**)(void*)&(option_usage_text);
 
631
        int    ix  = option_usage_text.field_ct;
 
632
 
 
633
        do {
 
634
            ppz++;
 
635
            *ppz = AO_gettext(*ppz);
 
636
        } while (--ix > 0);
 
637
    }
 
638
    option_usage_text.field_ct = 0;
 
639
 
 
640
    {
 
641
        tOptDesc* pOD = ntpdcOptions.pOptDesc;
 
642
        int       ix  = ntpdcOptions.optCt;
 
643
 
 
644
        for (;;) {
 
645
            pOD->pzText           = AO_gettext(pOD->pzText);
 
646
            pOD->pz_NAME          = AO_gettext(pOD->pz_NAME);
 
647
            pOD->pz_Name          = AO_gettext(pOD->pz_Name);
 
648
            pOD->pz_DisableName   = AO_gettext(pOD->pz_DisableName);
 
649
            pOD->pz_DisablePfx    = AO_gettext(pOD->pz_DisablePfx);
 
650
            if (--ix <= 0)
 
651
                break;
 
652
            pOD++;
 
653
        }
 
654
    }
 
655
    COERSION(pzCopyright);
 
656
    COERSION(pzCopyNotice);
 
657
    COERSION(pzFullVersion);
 
658
    COERSION(pzUsageTitle);
 
659
    COERSION(pzExplain);
 
660
    COERSION(pzDetail);
 
661
}
 
662
 
 
663
#endif /* ENABLE_NLS */
 
664
 
 
665
#ifdef  __cplusplus
 
666
}
 
667
#endif
 
668
/* ntpdc-opts.c ends here */