Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 137 lines (120 sloc) 3.888 kb
aceaabce »
1999-04-07 PHP 4.0
1 /*
2 * This file modified from sources for imap4 for use
3 * in PHP 3
4 */
5 /*
6 * Program: Unix compatibility routines
7 *
8 * Author: Mark Crispin
9 * Networks and Distributed Computing
10 * Computing & Communications
11 * University of Washington
12 * Administration Building, AG-44
13 * Seattle, WA 98195
14 * Internet: MRC@CAC.Washington.EDU
15 *
16 * Date: 14 September 1996
17 * Last Edited: 22 October 1996
18 *
19 * Copyright 1996 by the University of Washington
20 *
21 * Permission to use, copy, modify, and distribute this software and its
22 * documentation for any purpose and without fee is hereby granted, provided
23 * that the above copyright notice appears in all copies and that both the
24 * above copyright notice and this permission notice appear in supporting
25 * documentation, and that the name of the University of Washington not be
26 * used in advertising or publicity pertaining to distribution of the software
27 * without specific, written prior permission. This software is made available
28 * "as is", and
29 * THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
30 * WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION ALL IMPLIED
31 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND IN
32 * NO EVENT SHALL THE UNIVERSITY OF WASHINGTON BE LIABLE FOR ANY SPECIAL,
33 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
34 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT
35 * (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION
36 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
37 *
38 */
39
40
41 /* DEDICATION
42
43 * This file is dedicated to my dog, Unix, also known as Yun-chan and
44 * Unix J. Terwilliker Jehosophat Aloysius Monstrosity Animal Beast. Unix
45 * passed away at the age of 11 1/2 on September 14, 1996, 12:18 PM PDT, after
46 * a two-month bout with cirrhosis of the liver.
47 *
48 * He was a dear friend, and I miss him terribly.
49 *
50 * Lift a leg, Yunie. Luv ya forever!!!!
51 */
52
53 #include "php.h" /*php specific */
54 #include "syslog.h"
55 #include <stdio.h>
56 #include <fcntl.h>
57 #include <process.h>
58
cde7423c »
2004-07-29 Misc. win32 thread safety fixes.
59 #include "php_win32_globals.h"
2c9d87c2 »
2004-07-31 Fix bug #8314: sane syslog output to the WinNT event log.
60 #include "wsyslog.h"
aceaabce »
1999-04-07 PHP 4.0
61
62 void closelog(void)
63 {
cde7423c »
2004-07-29 Misc. win32 thread safety fixes.
64 TSRMLS_FETCH();
bc410c38 »
2006-01-16 Fixed first-chance exception during request shutdown
65 if (PW32G(log_source)) {
66 DeregisterEventSource(PW32G(log_source));
67 PW32G(log_source) = NULL;
68 }
69 if (PW32G(log_header)) {
70 STR_FREE(PW32G(log_header));
71 PW32G(log_header) = NULL;
72 }
aceaabce »
1999-04-07 PHP 4.0
73 }
74
75 /* Emulator for BSD syslog() routine
76 * Accepts: priority
77 * message
78 * parameters
79 */
80
1c4532dc »
2000-02-19 *** empty log message ***
81 void syslog(int priority, const char *message, ...)
aceaabce »
1999-04-07 PHP 4.0
82 {
83 va_list args;
84 LPTSTR strs[2];
85 unsigned short etype;
cde7423c »
2004-07-29 Misc. win32 thread safety fixes.
86 char *tmp = NULL;
2c9d87c2 »
2004-07-31 Fix bug #8314: sane syslog output to the WinNT event log.
87 DWORD evid;
cde7423c »
2004-07-29 Misc. win32 thread safety fixes.
88 TSRMLS_FETCH();
89
aceaabce »
1999-04-07 PHP 4.0
90 /* default event source */
cde7423c »
2004-07-29 Misc. win32 thread safety fixes.
91 if (!PW32G(log_source))
92 openlog("php", LOG_PID, LOG_SYSLOG);
93
aceaabce »
1999-04-07 PHP 4.0
94 switch (priority) { /* translate UNIX type into NT type */
95 case LOG_ALERT:
96 etype = EVENTLOG_ERROR_TYPE;
2c9d87c2 »
2004-07-31 Fix bug #8314: sane syslog output to the WinNT event log.
97 evid = PHP_SYSLOG_ERROR_TYPE;
aceaabce »
1999-04-07 PHP 4.0
98 break;
99 case LOG_INFO:
100 etype = EVENTLOG_INFORMATION_TYPE;
2c9d87c2 »
2004-07-31 Fix bug #8314: sane syslog output to the WinNT event log.
101 evid = PHP_SYSLOG_INFO_TYPE;
aceaabce »
1999-04-07 PHP 4.0
102 break;
103 default:
104 etype = EVENTLOG_WARNING_TYPE;
2c9d87c2 »
2004-07-31 Fix bug #8314: sane syslog output to the WinNT event log.
105 evid = PHP_SYSLOG_WARNING_TYPE;
aceaabce »
1999-04-07 PHP 4.0
106 }
107 va_start(args, message); /* initialize vararg mechanism */
cde7423c »
2004-07-29 Misc. win32 thread safety fixes.
108 vspprintf(&tmp, 0, message, args); /* build message */
109 strs[0] = PW32G(log_header); /* write header */
aceaabce »
1999-04-07 PHP 4.0
110 strs[1] = tmp; /* then the message */
111 /* report the event */
2c9d87c2 »
2004-07-31 Fix bug #8314: sane syslog output to the WinNT event log.
112 ReportEvent(PW32G(log_source), etype, (unsigned short) priority, evid, NULL, 2, 0, strs, NULL);
aceaabce »
1999-04-07 PHP 4.0
113 va_end(args);
cde7423c »
2004-07-29 Misc. win32 thread safety fixes.
114 efree(tmp);
aceaabce »
1999-04-07 PHP 4.0
115 }
116
117
118 /* Emulator for BSD openlog() routine
119 * Accepts: identity
120 * options
121 * facility
122 */
123
124 void openlog(const char *ident, int logopt, int facility)
125 {
cde7423c »
2004-07-29 Misc. win32 thread safety fixes.
126 TSRMLS_FETCH();
aceaabce »
1999-04-07 PHP 4.0
127
cde7423c »
2004-07-29 Misc. win32 thread safety fixes.
128 if (PW32G(log_source)) {
aceaabce »
1999-04-07 PHP 4.0
129 closelog();
130 }
cde7423c »
2004-07-29 Misc. win32 thread safety fixes.
131
132 STR_FREE(PW32G(log_header));
133
2c9d87c2 »
2004-07-31 Fix bug #8314: sane syslog output to the WinNT event log.
134 PW32G(log_source) = RegisterEventSource(NULL, "PHP-" PHP_VERSION);
cde7423c »
2004-07-29 Misc. win32 thread safety fixes.
135 spprintf(&PW32G(log_header), 0, (logopt & LOG_PID) ? "%s[%d]" : "%s", ident, getpid());
aceaabce »
1999-04-07 PHP 4.0
136 }
Something went wrong with that request. Please try again.