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