/* These macros are return values from extractAddr. They do not represent
* any valid IP address and so can indicate a failure.
*/
-#define AFS_IPINVALID 0xffffffff /* invalid IP address */
-#define AFS_IPINVALIDIGNORE 0xfffffffe /* no input given to extractAddr */
+#define AFS_IPINVALID 0xffffffff /* invalid IP address */
+#define AFS_IPINVALIDIGNORE 0xfffffffe /* no input given to extractAddr */
/* logging defines
*/
+#ifndef AFS_NT40_ENV
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h> /* for inet_ntoa() */
+#endif
+
#include <stdio.h>
#include <stdarg.h>
+#include <string.h>
+
extern int LogLevel;
+extern int mrafsStyleLogs;
#ifndef AFS_NT40_ENV
extern int serverLogSyslog;
extern int serverLogSyslogFacility;
+extern char *serverLogSyslogTag;
#endif
-extern void FSLog(const char *format, ...);
-#define ViceLog(level, str) if ((level) <= LogLevel) (FSLog str)
+extern void vFSLog(const char *format, va_list args);
+extern void SetLogThreadNumProgram(int (*func) (void) );
+
+/*@printflike@*/ extern void FSLog(const char *format, ...);
+#define ViceLog(level, str) do { if ((level) <= LogLevel) (FSLog str); } while (0)
+#define vViceLog(level, str) do { if ((level) <= LogLevel) (vFSLog str); } while (0)
extern int OpenLog(const char *filename);
extern int ReOpenLog(const char *fileName);
extern void SetupLogSignals(void);
+extern int
+afs_vsnprintf( /*@out@ */ char *p, size_t avail, const char *fmt,
+ va_list ap)
+ /*@requires maxSet(p) >= (avail-1)@ */
+ /*@modifies p@ */ ;
+
+extern /*@printflike@ */ int
+afs_snprintf( /*@out@ */ char *p, size_t avail,
+ const char *fmt, ...)
+ /*@requires maxSet(p) >= (avail-1)@ */
+ /*@modifies p@ */ ;
+
+extern int
+afs_vasnprintf (char **ret, size_t max_sz, const char *format, va_list args);
+
+extern int
+afs_vasprintf (char **ret, const char *format, va_list args);
+
+extern int
+afs_asprintf (char **ret, const char *format, ...);
+
+extern int
+afs_asnprintf (char **ret, size_t max_sz, const char *format, ...);
/* special version of ctime that clobbers a *different static variable, so
* that ViceLog can call ctime and not cause buffer confusion.
*/
-extern char *vctime(const time_t *atime);
+extern char *vctime(const time_t * atime);
/* Need a thead safe ctime for pthread builds. Use std ctime for LWP */
#if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
-#ifdef AFS_SUN5_ENV
+#if defined(AFS_SUN5_ENV) && !defined(_POSIX_PTHREAD_SEMANTICS) && (_POSIX_C_SOURCE - 0 < 199506L)
#define afs_ctime(C, B, L) ctime_r(C, B, L)
#else
/* Cast is for platforms which do not prototype ctime_r */
#define afs_ctime(C, B, L) (char*)ctime_r(C, B)
#endif /* AFS_SUN5_ENV */
#else /* AFS_PTHREAD_ENV && !AFS_NT40_ENV */
-#define afs_ctime(C, B, S) \
- ((void)strncpy(B, ctime(C), (S-1)), (B)[S-1] = '\0', (B))
-#endif /* AFS_PTHREAD_ENV && !AFS_NT40_ENV */
-
-
-/* Convert a 4 byte integer to a text string. */
-extern char* afs_inet_ntoa(afs_uint32 addr);
-extern char* afs_inet_ntoa_r(afs_uint32 addr);
+static_inline char *
+afs_ctime(const time_t *C, char *B, size_t S) {
+#if !defined(AFS_NT40_ENV) || (_MSC_VER < 1400)
+ strncpy(B, ctime(C), (S-1));
+ B[S-1] = '\0';
+#else
+ char buf[32];
+ if (ctime_s(buf, sizeof(buf), C) ||
+ strncpy_s(B, S, buf, _TRUNCATE))
+ B[0] = '\0';
+#endif
+ return B;
+}
+#endif /* AFS_PTHREAD_ENV && !AFS_NT40_ENV */
-/* copy strings, converting case along the way. */
-extern char *lcstring(char *d, char *s, int n);
-extern char *ucstring(char *d, char *s, int n);
-extern char *strcompose(char *buf, size_t len, ...);
/* abort the current process. */
#ifdef AFS_NT40_ENV
#endif /* _MFC_VER */
/* Initialize the windows sockets before calling networking routines. */
-extern int afs_winsockInit(void);
+ extern int afs_winsockInit(void);
+ extern void afs_winsockCleanup(void);
-struct timezone {
- int tz_minuteswest; /* of Greenwich */
- int tz_dsttime; /* type of dst correction to apply */
-};
+ struct timezone {
+ int tz_minuteswest; /* of Greenwich */
+ int tz_dsttime; /* type of dst correction to apply */
+ };
#define gettimeofday afs_gettimeofday
-int afs_gettimeofday(struct timeval *tv, struct timezone *tz);
+ int afs_gettimeofday(struct timeval *tv, struct timezone *tz);
/* Unbuffer output when Un*x would do line buffering. */
#define setlinebuf(S) setvbuf(S, NULL, _IONBF, 0)
-/* regular expression parser for NT */
-extern char *re_comp(char *sp);
-extern int rc_exec(char *p);
-
/* Abort on error, possibly trapping to debugger or dumping a trace. */
-void afs_NTAbort(void);
-#endif
+ void afs_NTAbort(void);
+#endif /* AFS_NT40_ENV */
-/* get temp dir path */
-char *gettmpdir(void);
+#ifndef HAVE_POSIX_REGEX
+extern char *re_comp(const char *sp);
+extern int re_exec(const char *p1);
+#endif
-/* Base 32 conversions used for NT since directory names are
- * case-insensitive.
- */
-typedef char b32_string_t[8];
-char *int_to_base32(b32_string_t s, int a);
-int base32_to_int(char *s);
+ typedef char b32_string_t[8];
+/* b64_string_t is 8 bytes, in stds.h */
+ typedef char lb64_string_t[12];
-#if defined(AFS_NAMEI_ENV) && !defined(AFS_NT40_ENV)
-/* base 64 converters for namei interface. Flip bits to differences are
- * early in name.
- */
-typedef char lb64_string_t[12];
-#ifdef AFS_64BIT_ENV
-#define int32_to_flipbase64(S, A) int64_to_flipbase64(S, (afs_int64)(A))
-char *int64_to_flipbase64(b64_string_t s, afs_int64 a);
-afs_int64 flipbase64_to_int64(char *s);
-#else
-#define int32_to_flipbase64(S, A) int64_to_flipbase64(S, (u_int64_t)(A))
-char *int64_to_flipbase64(b64_string_t s, u_int64_t a);
-int64_t flipbase64_to_int64(char *s);
-#endif
+#ifndef HAVE_STRLCAT
+extern size_t strlcat(char *dst, const char *src, size_t siz);
#endif
-/* This message preserves our ability to license AFS to the U.S. Government
- * more than once.
- */
+#ifndef HAVE_STRLCPY
+extern size_t strlcpy(char *dst, const char *src, size_t siz);
+#endif
-#define AFS_GOVERNMENT_MESSAGE \
-"===================== U.S. Government Restricted Rights ======================\n\
-If you are licensing the Software on behalf of the U.S. Government\n\
-(\"Government\"), the following provisions apply to you. If the Software is\n\
-supplied to the Department of Defense (\"DoD\"), it is classified as \"Commercial\n\
-Computer Software\" under paragraph 252.227-7014 of the DoD Supplement to the\n\
-Federal Acquisition Regulations (\"DFARS\") (or any successor regulations)\n\
-and the Government is acquiring only the license rights granted herein (the\n\
-license rights customarily provided to non-Government users). If the Software\n\
-is supplied to any unit or agency of the Government other than DoD, it is\n\
-classified as \"Restricted Computer Software\" and the Government's rights in\n\
-the Software are defined in paragraph 52.227-19 of the Federal Acquisition\n\
-Regulations (\"FAR\") (or any successor regulations) or, in the case of NASA,\n\
-in paragraph 18.52.227-86 of the NASA Supplement in the FAR (or any successor\n\
-regulations).\n"
+#ifndef UKERNEL
+#include "afs/ktime.h"
+#endif
+#include "afsutil_prototypes.h"
#endif /* _AFSUTIL_H_ */