154359Sroberto/*
254359Sroberto * ntpdc.h - definitions of interest to ntpdc
354359Sroberto */
454359Sroberto#include "ntp_fp.h"
554359Sroberto#include "ntp.h"
654359Sroberto#include "ntp_request.h"
754359Sroberto#include "ntp_string.h"
854359Sroberto#include "ntp_malloc.h"
954359Sroberto
1054359Sroberto/*
1154359Sroberto * Maximum number of arguments
1254359Sroberto */
1354359Sroberto#define	MAXARGS	4
14182007Sroberto#define	MOREARGS 10
1554359Sroberto
1654359Sroberto/*
1754359Sroberto * Flags for forming descriptors.
1854359Sroberto */
19182007Sroberto#define	OPT		0x80	/* this argument is optional, or'd with type */
2054359Sroberto
21182007Sroberto#define	NO		0x0
22182007Sroberto#define	NTP_STR		0x1	/* string argument */
23182007Sroberto#define	NTP_UINT	0x2	/* unsigned integer */
24182007Sroberto#define	NTP_INT		0x3	/* signed integer */
25182007Sroberto#define	NTP_ADD		0x4	/* IP network address */
26182007Sroberto#define IP_VERSION	0x5	/* IP version */
2754359Sroberto
2854359Sroberto/*
29182007Sroberto * Arguments are returned in a struct - no
30182007Sroberto * union space saving is attempted.
3154359Sroberto */
32182007Srobertotypedef struct {
33182007Sroberto	u_char type;
3454359Sroberto	char *string;
3554359Sroberto	long ival;
3654359Sroberto	u_long uval;
37285612Sdelphij	sockaddr_u netnum;
3854359Sroberto} arg_v;
3954359Sroberto
4054359Sroberto/*
4154359Sroberto * Structure for passing parsed command line
4254359Sroberto */
4354359Srobertostruct parse {
4454359Sroberto	char *keyword;
45182007Sroberto	arg_v argval[MAXARGS + MOREARGS];
46285612Sdelphij	size_t nargs;
4754359Sroberto};
4854359Sroberto
4954359Sroberto/*
5054359Sroberto * ntpdc includes a command parser which could charitably be called
5154359Sroberto * crude.  The following structure is used to define the command
5254359Sroberto * syntax.
5354359Sroberto */
5454359Srobertostruct xcmd {
5554359Sroberto  const char *keyword;		/* command key word */
56285612Sdelphij	void (*handler)	(struct parse *, FILE *);	/* command handler */
5754359Sroberto	u_char arg[MAXARGS];	/* descriptors for arguments */
5854359Sroberto  const char *desc[MAXARGS];	/* descriptions for arguments */
5954359Sroberto  const char *comment;
6054359Sroberto};
6154359Sroberto
62132451Srobertoextern	int impl_ver;
63132451Srobertoextern	int showhostnames;
64132451Srobertoextern	int s_port;
65132451Sroberto
66293650Sglebiusextern	int	doquery	(int, int, int, size_t, size_t, const char *, size_t *, size_t *, const char **, int, int);
67285612Sdelphijextern	const char * nntohost	(sockaddr_u *);
68