viced: Remove logging duplication
[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(const char *fileName);
58 extern void SetupLogSignals(void);
59
60 /* abort the current process. */
61 #ifdef AFS_NT40_ENV
62 #define afs_abort() afs_NTAbort()
63 #else
64 #define afs_abort() abort()
65 #endif
66
67
68 #ifdef AFS_NT40_ENV
69 #ifndef _MFC_VER
70 #include <winsock2.h>
71 #endif /* _MFC_VER */
72
73 /* Initialize the windows sockets before calling networking routines. */
74      extern int afs_winsockInit(void);
75      extern void afs_winsockCleanup(void);
76
77 /* Unbuffer output when Un*x would do line buffering. */
78 #define setlinebuf(S) setvbuf(S, NULL, _IONBF, 0)
79
80 /* Abort on error, possibly trapping to debugger or dumping a trace. */
81      void afs_NTAbort(void);
82 #endif /* AFS_NT40_ENV */
83
84 #ifndef HAVE_POSIX_REGEX
85 extern char *re_comp(const char *sp);
86 extern int re_exec(const char *p1);
87 #endif
88
89      typedef char b32_string_t[8];
90 /* b64_string_t is 8 bytes, in stds.h */
91      typedef char lb64_string_t[12];
92
93 #include <afs/ktime.h>
94 #include "afsutil_prototypes.h"
95
96 #endif /* _AFSUTIL_H_ */