Annotation of embedaddon/ntp/include/ntp_stdlib.h, revision 1.1

1.1     ! misho       1: /*
        !             2:  * ntp_stdlib.h - Prototypes for NTP lib.
        !             3:  */
        !             4: #ifndef NTP_STDLIB_H
        !             5: #define NTP_STDLIB_H
        !             6: 
        !             7: #include <sys/types.h>
        !             8: #ifdef HAVE_SYS_SOCKET_H
        !             9: #include <sys/socket.h>
        !            10: #endif
        !            11: 
        !            12: #include "l_stdlib.h"
        !            13: #include "ntp_rfc2553.h"
        !            14: #include "ntp_types.h"
        !            15: #include "ntp_malloc.h"
        !            16: #include "ntp_string.h"
        !            17: #include "ntp_net.h"
        !            18: #include "ntp_syslog.h"
        !            19: 
        !            20: 
        !            21: /*
        !            22:  * Handle gcc __attribute__ if available.
        !            23:  */
        !            24: #ifndef __attribute__
        !            25: /* This feature is available in gcc versions 2.5 and later.  */
        !            26: # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || (defined(__STRICT_ANSI__))
        !            27: #  define __attribute__(Spec) /* empty */
        !            28: # endif
        !            29: /* The __-protected variants of `format' and `printf' attributes
        !            30:    are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
        !            31: # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
        !            32: #  define __format__ format
        !            33: #  define __printf__ printf
        !            34: # endif
        !            35: #endif
        !            36: 
        !            37: extern int     mprintf(const char *, ...)
        !            38:                        __attribute__((__format__(__printf__, 1, 2)));
        !            39: extern int     mfprintf(FILE *, const char *, ...)
        !            40:                        __attribute__((__format__(__printf__, 2, 3)));
        !            41: extern int     mvfprintf(FILE *, const char *, va_list)
        !            42:                        __attribute__((__format__(__printf__, 2, 0)));
        !            43: extern int     mvsnprintf(char *, size_t, const char *, va_list)
        !            44:                        __attribute__((__format__(__printf__, 3, 0)));
        !            45: extern int     msnprintf(char *, size_t, const char *, ...)
        !            46:                        __attribute__((__format__(__printf__, 3, 4)));
        !            47: extern void    msyslog(int, const char *, ...)
        !            48:                                __attribute__((__format__(__printf__, 2, 3)));
        !            49: 
        !            50: /*
        !            51:  * When building without OpenSSL, use a few macros of theirs to
        !            52:  * minimize source differences in NTP.
        !            53:  */
        !            54: #ifndef OPENSSL
        !            55: #define NID_md5        4       /* from openssl/objects.h */
        !            56: /* from openssl/evp.h */
        !            57: #define EVP_MAX_MD_SIZE        64      /* longest known is SHA512 */
        !            58: #endif
        !            59: 
        !            60: /* authkeys.c */
        !            61: extern void    auth_delkeys    (void);
        !            62: extern int     auth_havekey    (keyid_t);
        !            63: extern int     authdecrypt     (keyid_t, u_int32 *, int, int);
        !            64: extern int     authencrypt     (keyid_t, u_int32 *, int);
        !            65: extern int     authhavekey     (keyid_t);
        !            66: extern int     authistrusted   (keyid_t);
        !            67: extern int     authreadkeys    (const char *);
        !            68: extern void    authtrust       (keyid_t, u_long);
        !            69: extern int     authusekey      (keyid_t, int, const u_char *);
        !            70: 
        !            71: extern u_long  calyearstart    (u_long);
        !            72: extern const char *clockname   (int);
        !            73: extern int     clocktime       (int, int, int, int, int, u_long, u_long *, u_int32 *);
        !            74: extern int     ntp_getopt      (int, char **, const char *);
        !            75: extern void    init_auth       (void);
        !            76: extern void    init_lib        (void);
        !            77: extern struct savekey *auth_findkey (keyid_t);
        !            78: extern int     auth_moremem    (void);
        !            79: extern int     ymd2yd          (int, int, int);
        !            80: 
        !            81: /* a_md5encrypt.c */
        !            82: extern int     MD5authdecrypt  (int, u_char *, u_int32 *, int, int);
        !            83: extern int     MD5authencrypt  (int, u_char *, u_int32 *, int);
        !            84: extern void    MD5auth_setkey  (keyid_t, int, const u_char *, const int);
        !            85: extern u_int32 addr2refid      (sockaddr_u *);
        !            86: 
        !            87: /* emalloc.c */
        !            88: #ifndef EREALLOC_CALLSITE      /* ntp_malloc.h defines */
        !            89: extern void *  ereallocz       (void *, size_t, size_t, int);
        !            90: #define        erealloczsite(p, n, o, z, f, l) ereallocz(p, n, o, (z))
        !            91: extern void *  emalloc         (size_t);
        !            92: #define        emalloc_zero(c)         ereallocz(NULL, (c), 0, TRUE)
        !            93: #define        erealloc(p, c)          ereallocz(p, (c), 0, FALSE)
        !            94: #define erealloc_zero(p, n, o) ereallocz(p, n, (o), TRUE)
        !            95: extern char *  estrdup_impl    (const char *);
        !            96: #define        estrdup(s)              estrdup_impl(s)
        !            97: #else
        !            98: extern void *  ereallocz       (void *, size_t, size_t, int,
        !            99:                                 const char *, int);
        !           100: #define erealloczsite          ereallocz
        !           101: #define        emalloc(c)              ereallocz(NULL, (c), 0, FALSE, \
        !           102:                                          __FILE__, __LINE__)
        !           103: #define        emalloc_zero(c)         ereallocz(NULL, (c), 0, TRUE, \
        !           104:                                          __FILE__, __LINE__)
        !           105: #define        erealloc(p, c)          ereallocz(p, (c), 0, FALSE, \
        !           106:                                          __FILE__, __LINE__)
        !           107: #define        erealloc_zero(p, n, o)  ereallocz(p, n, (o), TRUE, \
        !           108:                                          __FILE__, __LINE__)
        !           109: extern char *  estrdup_impl    (const char *, const char *, int);
        !           110: #define        estrdup(s) estrdup_impl((s), __FILE__, __LINE__)
        !           111: #endif
        !           112: 
        !           113: 
        !           114: extern int     atoint          (const char *, long *);
        !           115: extern int     atouint         (const char *, u_long *);
        !           116: extern int     hextoint        (const char *, u_long *);
        !           117: extern char *  humanlogtime    (void);
        !           118: extern char *  inttoa          (long);
        !           119: extern char *  mfptoa          (u_long, u_long, short);
        !           120: extern char *  mfptoms         (u_long, u_long, short);
        !           121: extern const char * modetoa    (int);
        !           122: extern  const char * eventstr  (int);
        !           123: extern  const char * ceventstr (int);
        !           124: extern char *  statustoa       (int, int);
        !           125: extern  const char * sysstatstr (int);
        !           126: extern  const char * peerstatstr (int);
        !           127: extern  const char * clockstatstr (int);
        !           128: extern sockaddr_u * netof      (sockaddr_u *);
        !           129: extern char *  numtoa          (u_int32);
        !           130: extern char *  numtohost       (u_int32);
        !           131: extern char *  socktoa         (const sockaddr_u *);
        !           132: extern char *  socktohost      (const sockaddr_u *);
        !           133: extern int     octtoint        (const char *, u_long *);
        !           134: extern u_long  ranp2           (int);
        !           135: extern char *  refnumtoa       (sockaddr_u *);
        !           136: extern int     tsftomsu        (u_long, int);
        !           137: extern char *  uinttoa         (u_long);
        !           138: 
        !           139: extern int     decodenetnum    (const char *, sockaddr_u *);
        !           140: 
        !           141: extern const char * FindConfig (const char *);
        !           142: 
        !           143: extern void    signal_no_reset (int, RETSIGTYPE (*func)(int));
        !           144: 
        !           145: extern void    getauthkeys     (const char *);
        !           146: extern void    auth_agekeys    (void);
        !           147: extern void    rereadkeys      (void);
        !           148: 
        !           149: /*
        !           150:  * Variable declarations for libntp.
        !           151:  */
        !           152: 
        !           153: /*
        !           154:  * Defined by any program.
        !           155:  */
        !           156: extern volatile int debug;             /* debugging flag */
        !           157: 
        !           158: /* authkeys.c */
        !           159: extern u_long  authkeynotfound;        /* keys not found */
        !           160: extern u_long  authkeylookups;         /* calls to lookup keys */
        !           161: extern u_long  authnumkeys;            /* number of active keys */
        !           162: extern u_long  authkeyexpired;         /* key lifetime expirations */
        !           163: extern u_long  authkeyuncached;        /* cache misses */
        !           164: extern u_long  authencryptions;        /* calls to encrypt */
        !           165: extern u_long  authdecryptions;        /* calls to decrypt */
        !           166: 
        !           167: extern int     authnumfreekeys;
        !           168: 
        !           169: /*
        !           170:  * The key cache. We cache the last key we looked at here.
        !           171:  */
        !           172: extern keyid_t cache_keyid;            /* key identifier */
        !           173: extern u_char *        cache_key;              /* key pointer */
        !           174: extern int     cache_type;             /* key type */
        !           175: extern u_int   cache_keylen;           /* key length */
        !           176: 
        !           177: /* getopt.c */
        !           178: extern char *  ntp_optarg;             /* global argument pointer */
        !           179: extern int     ntp_optind;             /* global argv index */
        !           180: 
        !           181: /* lib_strbuf.c */
        !           182: extern int     ipv4_works;
        !           183: extern int     ipv6_works;
        !           184: 
        !           185: /* machines.c */
        !           186: typedef void (*pset_tod_using)(const char *);
        !           187: extern pset_tod_using  set_tod_using;
        !           188: 
        !           189: /* ssl_init.c */
        !           190: #ifdef OPENSSL
        !           191: extern void    ssl_init                (void);
        !           192: extern void    ssl_check_version       (void);
        !           193: extern int     ssl_init_done;
        !           194: #define        INIT_SSL()                              \
        !           195:        do {                                    \
        !           196:                if (!ssl_init_done)             \
        !           197:                        ssl_init();             \
        !           198:        } while (0)
        !           199: #else  /* !OPENSSL follows */
        !           200: #define        INIT_SSL()              do {} while (0)
        !           201: #endif
        !           202: extern int     keytype_from_text       (const char *,  size_t *);
        !           203: extern const char *keytype_name        (int);
        !           204: extern char *  getpass_keytype         (int);
        !           205: 
        !           206: 
        !           207: /* lib/isc/win32/strerror.c
        !           208:  *
        !           209:  * To minimize Windows-specific changes to the rest of the NTP code,
        !           210:  * particularly reference clocks, we hijack calls to strerror() to deal
        !           211:  * with our mixture of error codes from the  C runtime (open, write)
        !           212:  * and Windows (sockets, serial ports).  This is an ugly hack because
        !           213:  * both use the lowest values differently, but particularly for ntpd,
        !           214:  * it's not a problem.
        !           215:  */
        !           216: #ifdef NTP_REDEFINE_STRERROR
        !           217: #define        strerror(e)     ntp_strerror(e)
        !           218: extern char *  ntp_strerror    (int e);
        !           219: #endif
        !           220: 
        !           221: /* systime.c */
        !           222: extern double  sys_tick;               /* adjtime() resolution */
        !           223: 
        !           224: /* version.c */
        !           225: extern const char *Version;            /* version declaration */
        !           226: 
        !           227: #endif /* NTP_STDLIB_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>