2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
14 /* Include afs installation dir retrieval routines */
15 #include <afs/dirpath.h>
17 /* These macros are return values from extractAddr. They do not represent
18 * any valid IP address and so can indicate a failure.
20 #define AFS_IPINVALID 0xffffffff /* invalid IP address */
21 #define AFS_IPINVALIDIGNORE 0xfffffffe /* no input given to extractAddr */
26 #include <sys/types.h>
27 #include <sys/socket.h>
28 #include <netinet/in.h>
29 #include <arpa/inet.h> /* for inet_ntoa() */
37 extern int mrafsStyleLogs;
39 extern int serverLogSyslog;
40 extern int serverLogSyslogFacility;
41 extern char *serverLogSyslogTag;
43 extern void vFSLog(const char *format, va_list args);
44 extern void SetLogThreadNumProgram(int (*func) (void) );
46 /*@printflike@*/ extern void FSLog(const char *format, ...);
47 #define ViceLog(level, str) do { if ((level) <= LogLevel) (FSLog str); } while (0)
48 #define vViceLog(level, str) do { if ((level) <= LogLevel) (vFSLog str); } while (0)
50 extern int OpenLog(const char *filename);
51 extern int ReOpenLog(const char *fileName);
52 extern void SetupLogSignals(void);
55 afs_vsnprintf( /*@out@ */ char *p, size_t avail, const char *fmt,
57 /*@requires maxSet(p) >= (avail-1)@ */
60 extern /*@printflike@ */ int
61 afs_snprintf( /*@out@ */ char *p, size_t avail,
63 /*@requires maxSet(p) >= (avail-1)@ */
67 afs_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args);
70 afs_vasprintf (char **ret, const char *format, va_list args);
73 afs_asprintf (char **ret, const char *format, ...);
76 afs_asnprintf (char **ret, size_t max_sz, const char *format, ...);
78 /* special version of ctime that clobbers a *different static variable, so
79 * that ViceLog can call ctime and not cause buffer confusion.
81 extern char *vctime(const time_t * atime);
83 /* Need a thead safe ctime for pthread builds. Use std ctime for LWP */
84 #if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
85 #if defined(AFS_SUN5_ENV) && !defined(_POSIX_PTHREAD_SEMANTICS) && (_POSIX_C_SOURCE - 0 < 199506L)
86 #define afs_ctime(C, B, L) ctime_r(C, B, L)
88 /* Cast is for platforms which do not prototype ctime_r */
89 #define afs_ctime(C, B, L) (char*)ctime_r(C, B)
90 #endif /* AFS_SUN5_ENV */
91 #else /* AFS_PTHREAD_ENV && !AFS_NT40_ENV */
93 afs_ctime(const time_t *C, char *B, size_t S) {
94 #if !defined(AFS_NT40_ENV) || (_MSC_VER < 1400)
95 strncpy(B, ctime(C), (S-1));
99 if (ctime_s(buf, sizeof(buf), C) ||
100 strncpy_s(B, S, buf, _TRUNCATE))
105 #endif /* AFS_PTHREAD_ENV && !AFS_NT40_ENV */
108 /* abort the current process. */
110 #define afs_abort() afs_NTAbort()
112 #define afs_abort() abort()
118 #include <winsock2.h>
119 #endif /* _MFC_VER */
121 /* Initialize the windows sockets before calling networking routines. */
122 extern int afs_winsockInit(void);
123 extern void afs_winsockCleanup(void);
126 int tz_minuteswest; /* of Greenwich */
127 int tz_dsttime; /* type of dst correction to apply */
129 #define gettimeofday afs_gettimeofday
130 int afs_gettimeofday(struct timeval *tv, struct timezone *tz);
132 /* Unbuffer output when Un*x would do line buffering. */
133 #define setlinebuf(S) setvbuf(S, NULL, _IONBF, 0)
135 /* Abort on error, possibly trapping to debugger or dumping a trace. */
136 void afs_NTAbort(void);
137 #endif /* AFS_NT40_ENV */
139 #ifndef HAVE_POSIX_REGEX
140 extern char *re_comp(const char *sp);
141 extern int re_exec(const char *p1);
144 typedef char b32_string_t[8];
145 /* b64_string_t is 8 bytes, in stds.h */
146 typedef char lb64_string_t[12];
149 extern size_t strlcat(char *dst, const char *src, size_t siz);
153 extern size_t strlcpy(char *dst, const char *src, size_t siz);
157 #include "afs/ktime.h"
159 #include "afsutil_prototypes.h"
161 #endif /* _AFSUTIL_H_ */