Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / bsd / ntp / dist / include / ntp_stdlib.h
blob6417aa5e735fde398c6452a4ce78db107a60585b
1 /* $NetBSD$ */
3 /*
4 * ntp_stdlib.h - Prototypes for NTP lib.
5 */
6 #ifndef NTP_STDLIB_H
7 #define NTP_STDLIB_H
9 #include <sys/types.h>
10 #ifdef HAVE_SYS_SOCKET_H
11 #include <sys/socket.h>
12 #endif
14 #include "l_stdlib.h"
15 #include "ntp_rfc2553.h"
16 #include "ntp_types.h"
17 #include "ntp_string.h"
18 #include "ntp_net.h"
19 #include "ntp_syslog.h"
23 * Handle gcc __attribute__ if available.
25 #ifndef __attribute__
26 /* This feature is available in gcc versions 2.5 and later. */
27 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || (defined(__STRICT_ANSI__))
28 # define __attribute__(Spec) /* empty */
29 # endif
30 /* The __-protected variants of `format' and `printf' attributes
31 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
32 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
33 # define __format__ format
34 # define __printf__ printf
35 # endif
36 #endif
38 extern void msyslog (int, const char *, ...)
39 __attribute__((__format__(__printf__, 2, 3)));
42 * When building without OpenSSL, use a few macros of theirs to
43 * minimize source differences in NTP.
45 #ifndef OPENSSL
46 #define NID_md5 4 /* from openssl/objects.h */
47 /* from openssl/evp.h */
48 #define EVP_MAX_MD_SIZE 64 /* longest known is SHA512 */
49 #endif
51 extern void auth_delkeys (void);
52 extern int auth_havekey (keyid_t);
53 extern int authdecrypt (keyid_t, u_int32 *, int, int);
54 extern int authencrypt (keyid_t, u_int32 *, int);
55 extern int authhavekey (keyid_t);
56 extern int authistrusted (keyid_t);
57 extern int authreadkeys (const char *);
58 extern void authtrust (keyid_t, u_long);
59 extern int authusekey (keyid_t, int, const u_char *);
61 extern u_long calyearstart (u_long);
62 extern const char *clockname (int);
63 extern int clocktime (int, int, int, int, int, u_long, u_long *, u_int32 *);
64 #if !defined(_MSC_VER) || !defined(_DEBUG)
65 extern void * emalloc (size_t);
66 extern void * erealloc (void *, size_t);
67 extern char * estrdup (const char *);
68 #else
69 extern void * debug_erealloc (void *, size_t, const char *, int);
70 #define emalloc(c) debug_erealloc(NULL, (c), __FILE__, __LINE__)
71 #define erealloc(p, c) debug_erealloc((p), (c), __FILE__, __LINE__)
72 extern char * debug_estrdup (const char *, const char *, int);
73 #define estrdup(s) debug_estrdup((s), __FILE__, __LINE__)
74 #endif
75 extern int ntp_getopt (int, char **, const char *);
76 extern void init_auth (void);
77 extern void init_lib (void);
78 extern struct savekey *auth_findkey (keyid_t);
79 extern int auth_moremem (void);
80 extern int ymd2yd (int, int, int);
82 /* a_md5encrypt.c */
83 extern int MD5authdecrypt (int, u_char *, u_int32 *, int, int);
84 extern int MD5authencrypt (int, u_char *, u_int32 *, int);
85 extern void MD5auth_setkey (keyid_t, int, const u_char *, const int);
86 extern u_int32 addr2refid (sockaddr_u *);
89 extern int atoint (const char *, long *);
90 extern int atouint (const char *, u_long *);
91 extern int hextoint (const char *, u_long *);
92 extern char * humanlogtime (void);
93 extern char * inttoa (long);
94 extern char * mfptoa (u_long, u_long, short);
95 extern char * mfptoms (u_long, u_long, short);
96 extern const char * modetoa (int);
97 extern const char * eventstr (int);
98 extern const char * ceventstr (int);
99 extern char * statustoa (int, int);
100 extern const char * sysstatstr (int);
101 extern const char * peerstatstr (int);
102 extern const char * clockstatstr (int);
103 extern sockaddr_u * netof (sockaddr_u *);
104 extern char * numtoa (u_int32);
105 extern char * numtohost (u_int32);
106 extern char * socktoa (sockaddr_u *);
107 extern char * socktohost (sockaddr_u *);
108 extern int octtoint (const char *, u_long *);
109 extern u_long ranp2 (int);
110 extern char * refnumtoa (sockaddr_u *);
111 extern int tsftomsu (u_long, int);
112 extern char * uinttoa (u_long);
114 extern int decodenetnum (const char *, sockaddr_u *);
116 extern const char * FindConfig (const char *);
118 extern void signal_no_reset (int, RETSIGTYPE (*func)(int));
120 extern void getauthkeys (const char *);
121 extern void auth_agekeys (void);
122 extern void rereadkeys (void);
125 * Variable declarations for libntp.
129 * Defined by any program.
131 extern volatile int debug; /* debugging flag */
133 /* authkeys.c */
134 extern u_long authkeynotfound; /* keys not found */
135 extern u_long authkeylookups; /* calls to lookup keys */
136 extern u_long authnumkeys; /* number of active keys */
137 extern u_long authkeyexpired; /* key lifetime expirations */
138 extern u_long authkeyuncached; /* cache misses */
139 extern u_long authencryptions; /* calls to encrypt */
140 extern u_long authdecryptions; /* calls to decrypt */
142 extern int authnumfreekeys;
145 * The key cache. We cache the last key we looked at here.
147 extern keyid_t cache_keyid; /* key identifier */
148 extern u_char * cache_key; /* key pointer */
149 extern u_int cache_keylen; /* key length */
151 /* getopt.c */
152 extern char * ntp_optarg; /* global argument pointer */
153 extern int ntp_optind; /* global argv index */
155 /* lib_strbuf.c */
156 extern int ipv4_works;
157 extern int ipv6_works;
159 /* machines.c */
160 typedef void (*pset_tod_using)(const char *);
161 extern pset_tod_using set_tod_using;
163 /* ssl_init.c */
164 #ifdef OPENSSL
165 extern void ssl_init (void);
166 extern void ssl_check_version (void);
167 extern int ssl_init_done;
168 #define INIT_SSL() \
169 do { \
170 if (!ssl_init_done) \
171 ssl_init(); \
172 } while (0)
173 #else /* !OPENSSL follows */
174 #define INIT_SSL() do {} while (0)
175 #endif
176 extern int keytype_from_text (const char *, size_t *);
177 extern const char *keytype_name (int);
180 /* lib/isc/win32/strerror.c
182 * To minimize Windows-specific changes to the rest of the NTP code,
183 * particularly reference clocks, we hijack calls to strerror() to deal
184 * with our mixture of error codes from the C runtime (open, write)
185 * and Windows (sockets, serial ports). This is an ugly hack because
186 * both use the lowest values differently, but particularly for ntpd,
187 * it's not a problem.
189 #ifdef NTP_REDEFINE_STRERROR
190 #define strerror(e) ntp_strerror(e)
191 extern char * ntp_strerror (int e);
192 #endif
194 /* systime.c */
195 extern double sys_tick; /* adjtime() resolution */
197 /* version.c */
198 extern const char *Version; /* version declaration */
200 #endif /* NTP_STDLIB_H */