xref: /freebsd/contrib/ntp/include/ntp_stdlib.h (revision 1e413cf93298b5b97441a21d9a50fdcd0ee9945e)
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	calleapwhen	P((u_long));
51 extern	u_long	calyearstart	P((u_long));
52 extern	const char *clockname	P((int));
53 extern	int	clocktime	P((int, int, int, int, int, u_long, u_long *, u_int32 *));
54 #if defined SYS_WINNT && defined DEBUG
55 # define emalloc(_c) debug_emalloc(_c, __FILE__, __LINE__)
56 extern	void *	debug_emalloc		P((u_int, char *, int));
57 #else
58 extern	void *	emalloc		P((u_int));
59 #endif
60 extern	int	ntp_getopt	P((int, char **, const char *));
61 extern	void	init_auth	P((void));
62 extern	void	init_lib	P((void));
63 extern	void	init_random	P((void));
64 extern	struct savekey *auth_findkey P((keyid_t));
65 extern	int	auth_moremem	P((void));
66 extern	int	ymd2yd		P((int, int, int));
67 
68 extern	int	MD5authdecrypt	P((u_char *, u_int32 *, int, int));
69 extern	int	MD5authencrypt	P((u_char *, u_int32 *, int));
70 extern	void	MD5auth_setkey	P((keyid_t, const u_char *, const int));
71 extern	u_int32	addr2refid	P((struct sockaddr_storage *));
72 
73 extern	int	atoint		P((const char *, long *));
74 extern	int	atouint		P((const char *, u_long *));
75 extern	int	hextoint	P((const char *, u_long *));
76 extern	char *	humandate	P((u_long));
77 extern	char *	humanlogtime	P((void));
78 extern	char *	inttoa		P((long));
79 extern	char *	mfptoa		P((u_long, u_long, short));
80 extern	char *	mfptoms		P((u_long, u_long, short));
81 extern	const char * modetoa	P((int));
82 extern  const char * eventstr   P((int));
83 extern  const char * ceventstr  P((int));
84 extern	char *	statustoa	P((int, int));
85 extern  const char * sysstatstr P((int));
86 extern  const char * peerstatstr P((int));
87 extern  const char * clockstatstr P((int));
88 extern	struct sockaddr_storage* netof P((struct sockaddr_storage*));
89 extern	char *	numtoa		P((u_int32));
90 extern	char *	numtohost	P((u_int32));
91 extern char * socktoa           P((struct sockaddr_storage *));
92 extern char * socktohost        P((struct sockaddr_storage *));
93 extern	int	octtoint	P((const char *, u_long *));
94 extern	u_long	ranp2		P((int));
95 extern	char *	refnumtoa	P((struct sockaddr_storage *));
96 extern	int	tsftomsu	P((u_long, int));
97 extern	char *	uinttoa		P((u_long));
98 
99 extern	int	decodenetnum	P((const char *, struct sockaddr_storage *));
100 
101 extern	const char *	FindConfig	P((const char *));
102 
103 extern	void	signal_no_reset P((int, RETSIGTYPE (*func)(int)));
104 
105 extern	void	getauthkeys 	P((char *));
106 extern	void	auth_agekeys	P((void));
107 extern	void	rereadkeys	P((void));
108 
109 /*
110  * Variable declarations for libntp.
111  */
112 
113 /*
114  * Defined by any program.
115  */
116 extern volatile int debug;		/* debugging flag */
117 
118 /* authkeys.c */
119 extern u_long	authkeynotfound;	/* keys not found */
120 extern u_long	authkeylookups;		/* calls to lookup keys */
121 extern u_long	authnumkeys;		/* number of active keys */
122 extern u_long	authkeyexpired;		/* key lifetime expirations */
123 extern u_long	authkeyuncached;	/* cache misses */
124 extern u_long	authencryptions;	/* calls to encrypt */
125 extern u_long	authdecryptions;	/* calls to decrypt */
126 
127 extern int	authnumfreekeys;
128 
129 /*
130  * The key cache. We cache the last key we looked at here.
131  */
132 extern keyid_t	cache_keyid;		/* key identifier */
133 extern u_char *	cache_key;		/* key pointer */
134 extern u_int	cache_keylen;		/* key length */
135 
136 /* clocktypes.c */
137 #ifdef NTP_REFCLOCK_H
138 struct clktype;
139 extern struct clktype clktypes[];
140 #endif
141 
142 /* getopt.c */
143 extern char *	ntp_optarg;		/* global argument pointer */
144 extern int	ntp_optind;		/* global argv index */
145 
146 /* machines.c */
147 extern const char *set_tod_using;
148 
149 /* mexit.c */
150 #if defined SYS_WINNT || defined SYS_CYGWIN32
151 extern HANDLE	hServDoneEvent;
152 #endif
153 
154 /* systime.c */
155 extern double	sys_tick;		/* adjtime() resolution */
156 
157 /* version.c */
158 extern const char *Version;		/* version declaration */
159