~ubuntu-branches/ubuntu/gutsy/ntp/gutsy

« back to all changes in this revision

Viewing changes to ntpdc/ntpdc.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-05-18 22:41:56 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070518224156-563ruqxsxvqvoy8h
Tags: 1:4.2.4p0+dfsg-1ubuntu1
* Merge from Debian unstable.
* Remaining Ubuntu changes:
  - Update version in conflicts/replaces to that which was shipped in edgy,
    which was later than that in Debian (due to the ubuntuX).
  - Change default server to ntp.ubuntu.com.
  - Remove stop links from rc0 and rc6
  - Call dh_installinit with --error-handler
  - Set Ubuntu maintainer address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include "isc/net.h"
18
18
#include "isc/result.h"
19
19
 
 
20
#include "ntpdc-opts.h"
 
21
 
20
22
#ifdef SYS_WINNT
21
 
#include <Mswsock.h>
 
23
# include <Mswsock.h>
22
24
# include <io.h>
23
25
#else
24
26
# define closesocket close
30
32
#endif /* HAVE_LIBREADLINE || HAVE_LIBEDIT */
31
33
 
32
34
#ifdef SYS_VXWORKS
33
 
/* vxWorks needs mode flag -casey*/
34
 
#define open(name, flags)   open(name, flags, 0777)
35
 
#define SERVER_PORT_NUM     123
 
35
                                /* vxWorks needs mode flag -casey*/
 
36
# define open(name, flags)   open(name, flags, 0777)
 
37
# define SERVER_PORT_NUM     123
 
38
#endif
 
39
 
 
40
/* We use COMMAND as an autogen keyword */
 
41
#ifdef COMMAND
 
42
# undef COMMAND
36
43
#endif
37
44
 
38
45
/*
273
280
#ifdef SYS_VXWORKS
274
281
void clear_globals(void)
275
282
{
276
 
    extern int ntp_optind;
277
 
    extern char *ntp_optarg;
278
283
    showhostnames = 0;              /* show host names by default */
279
 
    ntp_optind = 0;
280
 
    ntp_optarg = 0;
281
284
    havehost = 0;                   /* set to 1 when host open */
282
285
    numcmds = 0;
283
286
    numhosts = 0;
293
296
        char *argv[]
294
297
        )
295
298
{
296
 
        int c;
297
 
        int errflg = 0;
298
299
        extern int ntp_optind;
299
 
        extern char *ntp_optarg;
300
300
 
301
301
        delay_time.l_ui = 0;
302
302
        delay_time.l_uf = DEFDELAY;
320
320
        }
321
321
 
322
322
        progname = argv[0];
 
323
 
 
324
        {
 
325
                int optct = optionProcess(&ntpdcOptions, argc, argv);
 
326
                argc -= optct;
 
327
                argv += optct;
 
328
        }
 
329
 
 
330
        switch (WHICH_IDX_IPV4) {
 
331
            case INDEX_OPT_IPV4:
 
332
                ai_fam_templ = AF_INET;
 
333
                break;
 
334
            case INDEX_OPT_IPV6:
 
335
                ai_fam_templ = AF_INET6;
 
336
                break;
 
337
            default:
 
338
                ai_fam_templ = ai_fam_default;
 
339
                break;
 
340
        }
 
341
 
 
342
        if (HAVE_OPT(COMMAND)) {
 
343
                int             cmdct = STACKCT_OPT( COMMAND );
 
344
                const char**    cmds  = STACKLST_OPT( COMMAND );
 
345
 
 
346
                while (cmdct-- > 0) {
 
347
                        ADDCMD(*cmds++);
 
348
                }
 
349
        }
 
350
 
 
351
        debug = DESC(DEBUG_LEVEL).optOccCt;
 
352
 
 
353
        if (HAVE_OPT(INTERACTIVE)) {
 
354
                interactive = 1;
 
355
        }
 
356
 
 
357
        if (HAVE_OPT(NUMERIC)) {
 
358
                showhostnames = 0;
 
359
        }
 
360
 
 
361
        if (HAVE_OPT(LISTPEERS)) {
 
362
                ADDCMD("listpeers");
 
363
        }
 
364
 
 
365
        if (HAVE_OPT(PEERS)) {
 
366
                ADDCMD("peers");
 
367
        }
 
368
 
 
369
        if (HAVE_OPT(SHOWPEERS)) {
 
370
                ADDCMD("dmpeers");
 
371
        }
 
372
 
 
373
        if (ntp_optind == argc) {
 
374
                ADDHOST(DEFHOST);
 
375
        } else {
 
376
                for (; ntp_optind < argc; ntp_optind++)
 
377
                    ADDHOST(argv[ntp_optind]);
 
378
        }
 
379
 
 
380
        if (numcmds == 0 && interactive == 0
 
381
            && isatty(fileno(stdin)) && isatty(fileno(stderr))) {
 
382
                interactive = 1;
 
383
        }
 
384
 
 
385
#if 0
323
386
        ai_fam_templ = ai_fam_default;
324
387
        while ((c = ntp_getopt(argc, argv, "46c:dilnps")) != EOF)
325
388
            switch (c) {
354
417
                    errflg++;
355
418
                    break;
356
419
            }
 
420
 
357
421
        if (errflg) {
358
422
                (void) fprintf(stderr,
359
423
                               "usage: %s [-46dilnps] [-c cmd] host ...\n",
360
424
                               progname);
361
425
                exit(2);
362
426
        }
 
427
 
363
428
        if (ntp_optind == argc) {
364
429
                ADDHOST(DEFHOST);
365
430
        } else {
371
436
            && isatty(fileno(stdin)) && isatty(fileno(stderr))) {
372
437
                interactive = 1;
373
438
        }
 
439
#endif
374
440
 
375
441
#ifndef SYS_WINNT /* Under NT cannot handle SIGINT, WIN32 spawns a handler */
376
442
        if (interactive)
865
931
                qpkt.mbz_itemsize = MBZ_ITEMSIZE(qsize);
866
932
        } else {
867
933
                qpkt.err_nitems = ERR_NITEMS(0, 0);
868
 
                qpkt.mbz_itemsize = MBZ_ITEMSIZE(0);
 
934
                qpkt.mbz_itemsize = MBZ_ITEMSIZE(qsize);  /* allow for optional first item */
869
935
        }
870
936
 
871
937
        if (!auth || (keyid_entered && info_auth_keyid == 0)) {