util: add CloseLog routine to close the server log
[openafs.git] / src / util / afsutil.h
index 6c3cdd7..90c20fc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
 /* 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 vFSLog(const char *format, va_list args);
-/*@printflike@*/ extern void FSLog(const char *format, ...);
-#define ViceLog(level, str)  if ((level) <= LogLevel) (FSLog str)
-#define vViceLog(level, str) if ((level) <= LogLevel) (vFSLog str)
+extern void vFSLog(const char *format, va_list args)
+       AFS_ATTRIBUTE_FORMAT(__printf__, 1, 0);
 
-extern int OpenLog(const char *filename);
-extern int ReOpenLog(const char *fileName);
-extern void SetupLogSignals(void);
+extern void SetLogThreadNumProgram(int (*func) (void) );
 
+extern void FSLog(const char *format, ...)
+       AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
 
-/* 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);
-
-/* 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
-#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 */
-
-
-/* abort the current process. */
-#ifdef AFS_NT40_ENV
-#define afs_abort() afs_NTAbort()
-#else
-#define afs_abort() abort()
-#endif
+#define ViceLog(level, str)  do { if ((level) <= LogLevel) (FSLog str); } while (0)
+#define vViceLog(level, str) do { if ((level) <= LogLevel) (vFSLog str); } while (0)
+#define ViceLogThenPanic(level, str) \
+    do { ViceLog(level, str); osi_Panic str; } while(0);
 
+extern int OpenLog(const char *filename);
+extern int ReOpenLog(const char *fileName);
+extern void SetupLogSignals(void);
+extern void CloseLog(void);
 
 #ifdef AFS_NT40_ENV
 #ifndef _MFC_VER
@@ -73,33 +64,24 @@ extern char *vctime(const time_t *atime);
 #endif /* _MFC_VER */
 
 /* Initialize the windows sockets before calling networking routines. */
-extern int afs_winsockInit(void);
-
-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);
+     extern int afs_winsockInit(void);
+     extern void afs_winsockCleanup(void);
 
 /* 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);
+#endif /* AFS_NT40_ENV */
 
-/* Abort on error, possibly trapping to debugger or dumping a trace. */
-void afs_NTAbort(void);
-#endif /* NT40 */
+#ifndef HAVE_POSIX_REGEX
+extern char *re_comp(const char *sp);
+extern int re_exec(const char *p1);
+#endif
 
-typedef char b32_string_t[8];
+     typedef char b32_string_t[8];
 /* b64_string_t is 8 bytes, in stds.h */
-typedef char lb64_string_t[12];
+     typedef char lb64_string_t[12];
 
-#ifndef UKERNEL
-#include "afs/ktime.h"
-#endif
+#include <afs/ktime.h>
 #include "afsutil_prototypes.h"
 
 #endif /* _AFSUTIL_H_ */