xref: /freebsd/contrib/ntp/libntp/ntp_libopts.c (revision b00ab754)
1 /*
2  * ntp_libopts.c
3  *
4  * Common code interfacing with Autogen's libopts command-line option
5  * processing.
6  */
7 #ifdef HAVE_CONFIG_H
8 # include <config.h>
9 #endif
10 
11 #include <stdio.h>
12 #include <stddef.h>
13 #include "ntp_libopts.h"
14 #include "ntp_stdlib.h"
15 
16 extern const char *Version;	/* version.c for each program */
17 
18 
19 /*
20  * ntpOptionProcess() was a clone of libopts' optionProcess which
21  * overrode the --version output, appending detail from version.c
22  * which was not available at Autogen time.  This is now done via
23  * AutoOpts' version-proc = override in copyright.def, so this
24  * routine is a straightforward wrapper of optionProcess().
25  */
26 int
27 ntpOptionProcess(
28 	tOptions *	pOpts,
29 	int		argc,
30 	char **		argv
31 	)
32 {
33 	return optionProcess(pOpts, argc, argv);
34 }
35 
36 
37 /*
38  * ntpOptionPrintVersion() replaces the stock optionPrintVersion() via
39  * version-proc = ntpOptionPrintVersion; in copyright.def.  It differs
40  * from the stock function by displaying the complete version string,
41  * including compile time which was unknown when Autogen ran.
42  *
43  * Like optionPrintVersion() this function must exit(0) rather than
44  * return.
45  */
46 void
47 ntpOptionPrintVersion(
48 	tOptions *	pOpts,
49 	tOptDesc *	pOD
50 	)
51 {
52 	UNUSED_ARG(pOpts);
53 	UNUSED_ARG(pOD);
54 
55 	printf("%s\n", Version);
56 	fflush(stdout);
57 	exit(EXIT_SUCCESS);
58 }
59