ntpq.h revision 1.2
1/* $NetBSD: ntpq.h,v 1.2 2010/12/04 23:08:36 christos Exp $ */ 2 3/* 4 * ntpq.h - definitions of interest to ntpq 5 */ 6#include "ntp_fp.h" 7#include "ntp.h" 8#include "ntp_control.h" 9#include "ntp_string.h" 10#include "ntp_malloc.h" 11 12/* 13 * Maximum number of arguments 14 */ 15#define MAXARGS 4 16 17/* 18 * Flags for forming descriptors. 19 */ 20/* 21 * Flags for forming descriptors. 22 */ 23#define OPT 0x80 /* this argument is optional, or'd with type */ 24 25#define NO 0x0 26#define NTP_STR 0x1 /* string argument */ 27#define NTP_UINT 0x2 /* unsigned integer */ 28#define NTP_INT 0x3 /* signed integer */ 29#define NTP_ADD 0x4 /* IP network address */ 30#define IP_VERSION 0x5 /* IP version */ 31 32/* 33 * Arguments are returned in a union 34 */ 35typedef union { 36 char *string; 37 long ival; 38 u_long uval; 39 sockaddr_u netnum; 40} arg_v; 41 42/* 43 * Structure for passing parsed command line 44 */ 45struct parse { 46 const char *keyword; 47 arg_v argval[MAXARGS]; 48 size_t nargs; 49}; 50 51/* 52 * ntpdc includes a command parser which could charitably be called 53 * crude. The following structure is used to define the command 54 * syntax. 55 */ 56struct xcmd { 57 const char *keyword; /* command key word */ 58 void (*handler) (struct parse *, FILE *); /* command handler */ 59 u_char arg[MAXARGS]; /* descriptors for arguments */ 60 const char *desc[MAXARGS]; /* descriptions for arguments */ 61 const char *comment; 62}; 63 64/* 65 * Structure to hold association data 66 */ 67struct association { 68 u_short assid; 69 u_short status; 70}; 71 72#define MAXASSOC 1024 73 74/* 75 * Structure for translation tables between text format 76 * variable indices and text format. 77 */ 78struct ctl_var { 79 u_short code; 80 u_short fmt; 81 const char *text; 82}; 83 84extern int interactive; /* are we prompting? */ 85extern int old_rv; /* use old rv behavior? --old-rv */ 86 87extern void asciize (int, char *, FILE *); 88extern int getnetnum (const char *, sockaddr_u *, char *, int); 89extern void sortassoc (void); 90extern int doquery (int, int, int, int, char *, u_short *, int *, char **); 91extern char * nntohost (sockaddr_u *); 92extern int decodets (char *, l_fp *); 93extern int decodeuint (char *, u_long *); 94extern int nextvar (int *, char **, char **, char **); 95extern int decodetime (char *, l_fp *); 96extern void printvars (int, char *, int, int, int, FILE *); 97extern int decodeint (char *, long *); 98extern int findvar (char *, struct ctl_var *, int code); 99