File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / ntp / libntp / ntp_libopts.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:08:38 2012 UTC (12 years, 1 month ago) by misho
Branches: ntp, MAIN
CVS tags: v4_2_6p5p0, v4_2_6p5, HEAD
ntp 4.2.6p5

    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() is a clone of libopts' optionProcess which
   21:  * overrides the --version output, appending detail from version.c
   22:  * which was not available at Autogen time.
   23:  */
   24: int
   25: ntpOptionProcess(
   26: 	tOptions *	pOpts,
   27: 	int		argc,
   28: 	char **		argv
   29: 	)
   30: {
   31: 	char *		pchOpts;
   32: 	char **		ppzFullVersion;
   33: 	char *		pzNewFV;
   34: 	char *		pzAutogenFV;
   35: 	size_t		octets;
   36: 	int		rc;
   37: 
   38: 	pchOpts = (void *)pOpts;
   39: 	ppzFullVersion = (char **)(pchOpts + offsetof(tOptions,
   40: 						      pzFullVersion));
   41: 	pzAutogenFV = *ppzFullVersion;
   42: 	octets = strlen(pzAutogenFV) +
   43: 		 1 +	/* '\n' */
   44: 		 strlen(Version) +
   45: 		 1;	/* '\0' */
   46: 	pzNewFV = emalloc(octets);
   47: 	snprintf(pzNewFV, octets, "%s\n%s", pzAutogenFV, Version);
   48: 	*ppzFullVersion = pzNewFV;
   49: 	rc = optionProcess(pOpts, argc, argv);
   50: 	*ppzFullVersion = pzAutogenFV;
   51: 	free(pzNewFV);
   52: 
   53: 	return rc;
   54: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>