Reopen the correct filename when -logfile is given
[openafs.git] / src / util / afsutil.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
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
8  */
9
10 #ifndef _AFSUTIL_H_
11 #define _AFSUTIL_H_
12
13 #include <time.h>
14 /* Include afs installation dir retrieval routines */
15 #include <afs/dirpath.h>
16
17 /* These macros are return values from extractAddr. They do not represent
18  * any valid IP address and so can indicate a failure.
19  */
20 #define AFS_IPINVALID           0xffffffff      /* invalid IP address */
21 #define AFS_IPINVALIDIGNORE     0xfffffffe      /* no input given to extractAddr */
22
23 /* logging defines
24  */
25 #ifndef AFS_NT40_ENV
26 #include <sys/types.h>
27 #include <sys/socket.h>
28 #include <netinet/in.h>
29 #include <arpa/inet.h> /* for inet_ntoa() */
30 #endif
31
32 #include <stdio.h>
33 #include <stdarg.h>
34 #include <string.h>
35
36 extern int LogLevel;
37 extern int mrafsStyleLogs;
38 #ifndef AFS_NT40_ENV
39 extern int serverLogSyslog;
40 extern int serverLogSyslogFacility;
41 extern char *serverLogSyslogTag;
42 #endif
43 extern void vFSLog(const char *format, va_list args)
44         AFS_ATTRIBUTE_FORMAT(__printf__, 1, 0);
45
46 extern void SetLogThreadNumProgram(int (*func) (void) );
47
48 extern void FSLog(const char *format, ...)
49         AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
50
51 #define ViceLog(level, str)  do { if ((level) <= LogLevel) (FSLog str); } while (0)
52 #define vViceLog(level, str) do { if ((level) <= LogLevel) (vFSLog str); } while (0)
53 #define ViceLogThenPanic(level, str) \
54     do { ViceLog(level, str); osi_Panic str; } while(0);
55
56 extern int OpenLog(const char *filename);
57 extern int ReOpenLog(void);
58 extern void SetupLogSignals(void);
59 extern void CloseLog(void);
60 extern void SetupLogSoftSignals(void);
61
62 #ifdef AFS_NT40_ENV
63 #ifndef _MFC_VER
64 #include <winsock2.h>
65 #endif /* _MFC_VER */
66
67 /* Initialize the windows sockets before calling networking routines. */
68      extern int afs_winsockInit(void);
69      extern void afs_winsockCleanup(void);
70
71 /* Unbuffer output when Un*x would do line buffering. */
72 #define setlinebuf(S) setvbuf(S, NULL, _IONBF, 0)
73
74 #endif /* AFS_NT40_ENV */
75
76 #ifndef HAVE_POSIX_REGEX
77 extern char *re_comp(const char *sp);
78 extern int re_exec(const char *p1);
79 #endif
80
81      typedef char b32_string_t[8];
82 /* b64_string_t is 8 bytes, in stds.h */
83      typedef char lb64_string_t[12];
84
85 #include <afs/ktime.h>
86 #include "afsutil_prototypes.h"
87
88 #endif /* _AFSUTIL_H_ */