2b45e011ca
When the series of commits is complete, things like https://cert.litnet.lt/en/docs/ntp-distributed-reflection-dos-attacks should be fixed. PR: bin/148836 (except that we import a newer version) Asked by: Too many MFC after: 2 weeks
55 lines
1.1 KiB
C
55 lines
1.1 KiB
C
/*
|
|
* ntp_libopts.c
|
|
*
|
|
* Common code interfacing with Autogen's libopts command-line option
|
|
* processing.
|
|
*/
|
|
#ifdef HAVE_CONFIG_H
|
|
# include <config.h>
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
#include <stddef.h>
|
|
#include "ntp_libopts.h"
|
|
#include "ntp_stdlib.h"
|
|
|
|
extern const char *Version; /* version.c for each program */
|
|
|
|
|
|
/*
|
|
* ntpOptionProcess() is a clone of libopts' optionProcess which
|
|
* overrides the --version output, appending detail from version.c
|
|
* which was not available at Autogen time.
|
|
*/
|
|
int
|
|
ntpOptionProcess(
|
|
tOptions * pOpts,
|
|
int argc,
|
|
char ** argv
|
|
)
|
|
{
|
|
char * pchOpts;
|
|
char ** ppzFullVersion;
|
|
char * pzNewFV;
|
|
char * pzAutogenFV;
|
|
size_t octets;
|
|
int rc;
|
|
|
|
pchOpts = (void *)pOpts;
|
|
ppzFullVersion = (char **)(pchOpts + offsetof(tOptions,
|
|
pzFullVersion));
|
|
pzAutogenFV = *ppzFullVersion;
|
|
octets = strlen(pzAutogenFV) +
|
|
1 + /* '\n' */
|
|
strlen(Version) +
|
|
1; /* '\0' */
|
|
pzNewFV = emalloc(octets);
|
|
snprintf(pzNewFV, octets, "%s\n%s", pzAutogenFV, Version);
|
|
*ppzFullVersion = pzNewFV;
|
|
rc = optionProcess(pOpts, argc, argv);
|
|
*ppzFullVersion = pzAutogenFV;
|
|
free(pzNewFV);
|
|
|
|
return rc;
|
|
}
|