1*cdfa2a7eSchristos /* $NetBSD: ntp_libopts.c,v 1.5 2020/05/25 20:47:24 christos Exp $ */
2f003fb54Skardel
3f003fb54Skardel /*
4f003fb54Skardel * ntp_libopts.c
5f003fb54Skardel *
6f003fb54Skardel * Common code interfacing with Autogen's libopts command-line option
7f003fb54Skardel * processing.
8f003fb54Skardel */
9f003fb54Skardel #ifdef HAVE_CONFIG_H
10f003fb54Skardel # include <config.h>
11f003fb54Skardel #endif
12f003fb54Skardel
13f003fb54Skardel #include <stdio.h>
14f003fb54Skardel #include <stddef.h>
15f003fb54Skardel #include "ntp_libopts.h"
16f003fb54Skardel #include "ntp_stdlib.h"
17f003fb54Skardel
18f003fb54Skardel extern const char *Version; /* version.c for each program */
19f003fb54Skardel
20f003fb54Skardel
21f003fb54Skardel /*
228585484eSchristos * ntpOptionProcess() was a clone of libopts' optionProcess which
238585484eSchristos * overrode the --version output, appending detail from version.c
248585484eSchristos * which was not available at Autogen time. This is now done via
258585484eSchristos * AutoOpts' version-proc = override in copyright.def, so this
268585484eSchristos * routine is a straightforward wrapper of optionProcess().
27f003fb54Skardel */
28f003fb54Skardel int
ntpOptionProcess(tOptions * pOpts,int argc,char ** argv)29f003fb54Skardel ntpOptionProcess(
30f003fb54Skardel tOptions * pOpts,
31f003fb54Skardel int argc,
32f003fb54Skardel char ** argv
33f003fb54Skardel )
34f003fb54Skardel {
358585484eSchristos return optionProcess(pOpts, argc, argv);
368585484eSchristos }
37f003fb54Skardel
38f003fb54Skardel
398585484eSchristos /*
408585484eSchristos * ntpOptionPrintVersion() replaces the stock optionPrintVersion() via
418585484eSchristos * version-proc = ntpOptionPrintVersion; in copyright.def. It differs
428585484eSchristos * from the stock function by displaying the complete version string,
438585484eSchristos * including compile time which was unknown when Autogen ran.
448585484eSchristos *
458585484eSchristos * Like optionPrintVersion() this function must exit(0) rather than
468585484eSchristos * return.
478585484eSchristos */
488585484eSchristos void
ntpOptionPrintVersion(tOptions * pOpts,tOptDesc * pOD)498585484eSchristos ntpOptionPrintVersion(
508585484eSchristos tOptions * pOpts,
518585484eSchristos tOptDesc * pOD
528585484eSchristos )
538585484eSchristos {
548585484eSchristos UNUSED_ARG(pOpts);
558585484eSchristos UNUSED_ARG(pOD);
568585484eSchristos
578585484eSchristos printf("%s\n", Version);
588585484eSchristos fflush(stdout);
598585484eSchristos exit(EXIT_SUCCESS);
60f003fb54Skardel }
61