]>
git.saurik.com Git - apple/ipsec.git/blob - ipsec-tools/racoon/plog.h
1 /* $Id: plog.h,v 1.5 2004/06/11 16:00:17 ludvigm Exp $ */
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 #include <sys/queue.h>
44 #include <SystemConfiguration/SCPreferences.h>
48 extern u_int32_t loglevel
;
49 extern int f_foreground
;
50 extern int print_location
;
52 extern char logFileStr
[];
54 extern char *gSessType
;
55 extern char *gSessVer
;
56 extern aslclient logRef
;
58 struct sockaddr_storage
;
60 typedef enum clog_err_op
{
66 typedef struct clog_err
{
67 int clog_err_level
; /* will be used for filtering */
68 int clog_err_code
; /* internal code */
76 // add a CFErrorRef for global error code (i.e. number-space)
78 TAILQ_HEAD(_chain_head
, clog_err
) chain_head
;
79 TAILQ_ENTRY(clog_err
) chain
;
82 extern const char *plog_facility
;
83 extern const char *plog_session_id
;
84 extern const char *plog_session_type
;
85 extern const char *plog_session_ver
;
86 extern void clog_func (clog_err_t
*, clog_err_op_t
, int, const char *, const char *, const char *, ...);
87 extern void plogdump_asl (aslmsg
, int, const char *, ...);
88 extern void plogdump_func (int, void *, size_t, const char *, ...);
89 extern void plogcf(int priority
, CFStringRef fmt
, ...);
91 #define clog(cerr, cerr_op, pri, fmt, args...) do { \
92 if (pri <= loglevel) { \
93 clog_func(cerr, cerr_op, pri, __FUNCTION__, __LINE__, fmt, ##args); \
97 #define plog(pri, fmt, args...) do { \
98 if (pri <= loglevel) { \
100 if ((m = asl_new(ASL_TYPE_MSG))) { \
101 asl_set(m, ASL_KEY_FACILITY, plog_facility); \
103 asl_set(m, plog_session_id, gSessId); \
105 asl_set(m, plog_session_type, gSessType); \
107 asl_set(m, plog_session_ver, gSessVer); \
108 asl_log(logRef, m, pri, fmt, ##args); \
114 #define plogdump(pri, buf, len, fmt, args...) do { \
115 if (pri <= loglevel) { \
116 plogdump_func(pri, buf, len, fmt, ##args); \
122 void plogreadprefs (void);
124 void plogsetfile (char *);
126 void plogresetfile (char *);
128 int ploggetlevel(void);
130 void plogsetlevel (int);
132 void plogresetlevel (void);
134 void plogsetlevelstr (char *);
135 void plogsetlevelquotedstr (char *);
137 // Called at the beginning of any dispatch event to initialize the logger with protocol client info
138 void plogsetsessioninfo (const char *session_id
,
139 const char *session_type
,
140 const char *session_ver
);