xref: /freebsd/contrib/ntp/include/ntp_stdlib.h (revision 39beb93c)
1 /*
2  * ntp_stdlib.h - Prototypes for NTP lib.
3  */
4 #include <sys/types.h>
5 #include <sys/socket.h>
6 #include "ntp_rfc2553.h"
7 
8 #include "ntp_types.h"
9 #include "ntp_string.h"
10 #include "l_stdlib.h"
11 
12 /*
13  * Handle gcc __attribute__ if available.
14  */
15 #ifndef __attribute__
16 /* This feature is available in gcc versions 2.5 and later.  */
17 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || (defined(__STRICT_ANSI__))
18 #  define __attribute__(Spec) /* empty */
19 # endif
20 /* The __-protected variants of `format' and `printf' attributes
21    are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
22 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
23 #  define __format__ format
24 #  define __printf__ printf
25 # endif
26 #endif
27 
28 #if defined(__STDC__) || defined(HAVE_STDARG_H)
29 # include <stdarg.h>
30 extern	void	msyslog		P((int, const char *, ...))
31 				__attribute__((__format__(__printf__, 2, 3)));
32 extern	void	netsyslog	P((int, const char *, ...))
33 				__attribute__((__format__(__printf__, 2, 3)));
34 #else
35 # include <varargs.h>
36 extern	void msyslog		P(());
37 extern	void netsyslog		P(());
38 #endif
39 
40 extern	void	auth_delkeys	P((void));
41 extern	int	auth_havekey	P((keyid_t));
42 extern	int	authdecrypt	P((keyid_t, u_int32 *, int, int));
43 extern	int	authencrypt	P((keyid_t, u_int32 *, int));
44 extern	int	authhavekey	P((keyid_t));
45 extern	int	authistrusted	P((keyid_t));
46 extern	int	authreadkeys	P((const char *));
47 extern	void	authtrust	P((keyid_t, u_long));
48 extern	int	authusekey	P((keyid_t, int, const u_char *));
49 
50 extern	u_long	calyearstart	P((u_long));
51 extern	const char *clockname	P((int));
52 extern	int	clocktime	P((int, int, int, int, int, u_long, u_long *, u_int32 *));
53 #if defined SYS_WINNT && defined DEBUG
54 # define emalloc(_c) debug_emalloc(_c, __FILE__, __LINE__)
55 extern	void *	debug_emalloc		P((u_int, char *, int));
56 #else
57 extern	void *	emalloc		P((u_int));
58 #endif
59 extern	int	ntp_getopt	P((int, char **, const char *));
60 extern	void	init_auth	P((void));
61 extern	void	init_lib	P((void));
62 extern	struct savekey *auth_findkey P((keyid_t));
63 extern	int	auth_moremem	P((void));
64 extern	int	ymd2yd		P((int, int, int));
65 
66 extern	int	MD5authdecrypt	P((u_char *, u_int32 *, int, int));
67 extern	int	MD5authencrypt	P((u_char *, u_int32 *, int));
68 extern	void	MD5auth_setkey	P((keyid_t, const u_char *, const int));
69 extern	u_int32	addr2refid	P((struct sockaddr_storage *));
70 
71 extern	int	atoint		P((const char *, long *));
72 extern	int	atouint		P((const char *, u_long *));
73 extern	int	hextoint	P((const char *, u_long *));
74 extern	char *	humandate	P((u_long));
75 extern	char *	humanlogtime	P((void));
76 extern	char *	inttoa		P((long));
77 extern	char *	mfptoa		P((u_long, u_long, short));
78 extern	char *	mfptoms		P((u_long, u_long, short));
79 extern	const char * modetoa	P((int));
80 extern  const char * eventstr   P((int));
81 extern  const char * ceventstr  P((int));
82 extern	char *	statustoa	P((int, int));
83 extern  const char * sysstatstr P((int));
84 extern  const char * peerstatstr P((int));
85 extern  const char * clockstatstr P((int));
86 extern	struct sockaddr_storage* netof P((struct sockaddr_storage*));
87 extern	char *	numtoa		P((u_int32));
88 extern	char *	numtohost	P((u_int32));
89 extern char * socktoa           P((struct sockaddr_storage *));
90 extern char * socktohost        P((struct sockaddr_storage *));
91 extern	int	octtoint	P((const char *, u_long *));
92 extern	u_long	ranp2		P((int));
93 extern	char *	refnumtoa	P((struct sockaddr_storage *));
94 extern	int	tsftomsu	P((u_long, int));
95 extern	char *	uinttoa		P((u_long));
96 
97 extern	int	decodenetnum	P((const char *, struct sockaddr_storage *));
98 
99 extern	const char *	FindConfig	P((const char *));
100 
101 extern	void	signal_no_reset P((int, RETSIGTYPE (*func)(int)));
102 
103 extern	void	getauthkeys 	P((const char *));
104 extern	void	auth_agekeys	P((void));
105 extern	void	rereadkeys	P((void));
106 
107 /*
108  * Variable declarations for libntp.
109  */
110 
111 /*
112  * Defined by any program.
113  */
114 extern volatile int debug;		/* debugging flag */
115 
116 /* authkeys.c */
117 extern u_long	authkeynotfound;	/* keys not found */
118 extern u_long	authkeylookups;		/* calls to lookup keys */
119 extern u_long	authnumkeys;		/* number of active keys */
120 extern u_long	authkeyexpired;		/* key lifetime expirations */
121 extern u_long	authkeyuncached;	/* cache misses */
122 extern u_long	authencryptions;	/* calls to encrypt */
123 extern u_long	authdecryptions;	/* calls to decrypt */
124 
125 extern int	authnumfreekeys;
126 
127 /*
128  * The key cache. We cache the last key we looked at here.
129  */
130 extern keyid_t	cache_keyid;		/* key identifier */
131 extern u_char *	cache_key;		/* key pointer */
132 extern u_int	cache_keylen;		/* key length */
133 
134 /* getopt.c */
135 extern char *	ntp_optarg;		/* global argument pointer */
136 extern int	ntp_optind;		/* global argv index */
137 
138 /* machines.c */
139 extern const char *set_tod_using;
140 
141 /* mexit.c */
142 #if defined SYS_WINNT || defined SYS_CYGWIN32
143 extern HANDLE	hServDoneEvent;
144 #endif
145 
146 /* systime.c */
147 extern double	sys_tick;		/* adjtime() resolution */
148 
149 /* version.c */
150 extern const char *Version;		/* version declaration */
151