1 /* $NetBSD: ntp_stdlib.h,v 1.5 2007/01/06 19:45:22 kardel Exp $ */
4 * ntp_stdlib.h - Prototypes for NTP lib.
7 #include <sys/socket.h>
8 #include "ntp_rfc2553.h"
10 #include "ntp_types.h"
11 #include "ntp_string.h"
15 * Handle gcc __attribute__ if available.
18 /* This feature is available in gcc versions 2.5 and later. */
19 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || (defined(__STRICT_ANSI__))
20 # define __attribute__(Spec) /* empty */
22 /* The __-protected variants of `format' and `printf' attributes
23 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
24 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
25 # define __format__ format
26 # define __printf__ printf
30 #if defined(__STDC__) || defined(HAVE_STDARG_H)
32 extern void msyslog
P((int, const char *, ...))
33 __attribute__((__format__(__printf__
, 2, 3)));
34 extern void netsyslog
P((int, const char *, ...))
35 __attribute__((__format__(__printf__
, 2, 3)));
38 extern void msyslog
P(());
39 extern void netsyslog
P(());
42 extern void auth_delkeys
P((void));
43 extern int auth_havekey
P((keyid_t
));
44 extern int authdecrypt
P((keyid_t
, u_int32
*, int, int));
45 extern int authencrypt
P((keyid_t
, u_int32
*, int));
46 extern int authhavekey
P((keyid_t
));
47 extern int authistrusted
P((keyid_t
));
48 extern int authreadkeys
P((const char *));
49 extern void authtrust
P((keyid_t
, u_long
));
50 extern int authusekey
P((keyid_t
, int, const u_char
*));
52 extern u_long calyearstart
P((u_long
));
53 extern const char *clockname
P((int));
54 extern int clocktime
P((int, int, int, int, int, u_long
, u_long
*, u_int32
*));
55 #if defined SYS_WINNT && defined DEBUG
56 # define emalloc(_c) debug_emalloc(_c, __FILE__, __LINE__)
57 extern void * debug_emalloc
P((size_t, char *, int));
59 extern void * emalloc
P((size_t));
61 extern int ntp_getopt
P((int, char **, const char *));
62 extern void init_auth
P((void));
63 extern void init_lib
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));
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
*));
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
));
99 extern int decodenetnum
P((const char *, struct sockaddr_storage
*));
101 extern const char * FindConfig
P((const char *));
103 extern void signal_no_reset
P((int, RETSIGTYPE (*func
)(int)));
105 extern void getauthkeys
P((const char *));
106 extern void auth_agekeys
P((void));
107 extern void rereadkeys
P((void));
110 * Variable declarations for libntp.
114 * Defined by any program.
116 extern volatile int debug
; /* debugging flag */
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 */
127 extern int authnumfreekeys
;
130 * The key cache. We cache the last key we looked at here.
132 extern keyid_t cache_keyid
; /* key identifier */
133 extern u_char
* cache_key
; /* key pointer */
134 extern u_int cache_keylen
; /* key length */
137 extern char * ntp_optarg
; /* global argument pointer */
138 extern int ntp_optind
; /* global argv index */
141 extern const char *set_tod_using
;
144 #if defined SYS_WINNT || defined SYS_CYGWIN32
145 extern HANDLE hServDoneEvent
;
149 extern double sys_tick
; /* adjtime() resolution */
152 extern const char *Version
; /* version declaration */