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