annotate Modules/syslogmodule.c @ 4439:fb1237bf7022 legacy-trunk

Changed version to plain "1.4".
author Guido van Rossum <guido@python.org>
date Tue, 22 Oct 1996 03:09:46 +0000
parents de0ad7527de7
children d36250aefb82
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 /***********************************************************
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
2 Copyright 1994 by Lance Ellinghouse,
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
3 Cathedral City, California Republic, United States of America.
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 All Rights Reserved
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 Permission to use, copy, modify, and distribute this software and its
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 documentation for any purpose and without fee is hereby granted,
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 provided that the above copyright notice appear in all copies and that
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 both that copyright notice and this permission notice appear in
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
11 supporting documentation, and that the name of Lance Ellinghouse
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
12 not be used in advertising or publicity pertaining to distribution
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
13 of the software without specific, written prior permission.
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
14
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
15 LANCE ELLINGHOUSE DISCLAIMS ALL WARRANTIES WITH REGARD TO
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
17 FITNESS, IN NO EVENT SHALL LANCE ELLINGHOUSE BE LIABLE FOR ANY SPECIAL,
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
18 INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
19 FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
20 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
21 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
22
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 ******************************************************************/
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
24
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
25 /******************************************************************
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
26
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
27 Revision history:
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
28
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
29 95/06/29 (Steve Clift)
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
30 - Changed arg parsing to use PyArg_ParseTuple.
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
31 - Added PyErr_Clear() call(s) where needed.
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
32 - Fix core dumps if user message contains format specifiers.
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
33 - Change openlog arg defaults to match normal syslog behaviour.
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
34 - Plug memory leak in openlog().
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
35 - Fix setlogmask() to return previous mask value.
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
36
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
37 ******************************************************************/
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
38
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 /* syslog module */
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
40
2123
fd5ab7e828fc cosmetic changes so these modules will work with the strict new naming scheme
Guido van Rossum <guido@python.org>
parents: 1855
diff changeset
41 #include "Python.h"
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
42
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 #include <syslog.h>
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
44
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
45 static PyObject *
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 syslog_openlog(self, args)
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
47 PyObject * self;
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
48 PyObject * args;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 {
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
50 long logopt = 0;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 long facility = LOG_USER;
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
52
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
53 static PyObject *ident_o = NULL;
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
54
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
55 Py_XDECREF(ident_o);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
56 if (!PyArg_ParseTuple(args, "S|ll;ident string [, logoption [, facility]]",
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
57 &ident_o, &logopt, &facility)) {
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 return NULL;
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
59 }
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
60 Py_INCREF(ident_o); /* This is needed because openlog() does NOT make a copy
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
61 and syslog() later uses it.. cannot trash it. */
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
62
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
63 openlog(PyString_AsString(ident_o), logopt, facility);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
64
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
65 Py_INCREF(Py_None);
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
66 return Py_None;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 }
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
68
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
69 static PyObject *
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
70 syslog_syslog(self, args)
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
71 PyObject * self;
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
72 PyObject * args;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
73 {
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
74 char *message, *s;
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
75 int priority = LOG_INFO | LOG_USER;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
76
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
77 if (!PyArg_ParseTuple(args, "is;[priority,] message string",
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
78 &priority, &message)) {
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
79 PyErr_Clear();
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
80 if (!PyArg_ParseTuple(args, "s;[priority,] message string", &message)) {
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
81 return NULL;
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
82 }
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
83 }
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
84 syslog(priority, "%s", message);
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
85 Py_INCREF(Py_None);
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
86 return Py_None;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
87 }
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
88
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
89 static PyObject *
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
90 syslog_closelog(self, args)
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
91 PyObject * self;
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
92 PyObject * args;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
93 {
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
94 if (!PyArg_ParseTuple(args, ""))
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
95 return NULL;
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
96 closelog();
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
97 Py_INCREF(Py_None);
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
98 return Py_None;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
99 }
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
100
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
101 static PyObject *
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
102 syslog_setlogmask(self, args)
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
103 PyObject * self;
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
104 PyObject * args;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
105 {
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
106 long maskpri, omaskpri;
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
107
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
108 if (!PyArg_ParseTuple(args,"l;mask for priority",&maskpri))
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
109 return NULL;
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
110 omaskpri = setlogmask(maskpri);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
111 return PyInt_FromLong(omaskpri);
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
112 }
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
113
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
114 static PyObject *
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
115 syslog_log_mask(self, args)
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
116 PyObject * self;
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
117 PyObject * args;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
118 {
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
119 long mask;
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
120 long pri;
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
121 if (!PyArg_ParseTuple(args,"l",&pri))
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
122 return NULL;
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
123 mask = LOG_MASK(pri);
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
124 return PyInt_FromLong(mask);
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
125 }
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
126
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
127 static PyObject *
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
128 syslog_log_upto(self, args)
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
129 PyObject * self;
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
130 PyObject * args;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
131 {
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
132 long mask;
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
133 long pri;
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
134 if (!PyArg_ParseTuple(args,"l",&pri))
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
135 return NULL;
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
136 mask = LOG_UPTO(pri);
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
137 return PyInt_FromLong(mask);
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
138 }
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
139
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
140 /* List of functions defined in the module */
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
141
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
142 static PyMethodDef syslog_methods[] = {
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
143 {"openlog", syslog_openlog, METH_VARARGS},
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
144 {"closelog", syslog_closelog, METH_VARARGS},
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
145 {"syslog", syslog_syslog, METH_VARARGS},
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
146 {"setlogmask", syslog_setlogmask, METH_VARARGS},
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
147 {"LOG_MASK", syslog_log_mask, METH_VARARGS},
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
148 {"LOG_UPTO", syslog_log_upto, METH_VARARGS},
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
149 {NULL, NULL, 0}
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
150 };
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
151
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
152 /* Initialization function for the module */
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
153
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
154 #define DICT_SET_INT(d, s, x) \
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
155 PyDict_SetItemString(d, s, PyInt_FromLong((long) (x)))
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
156
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
157 void
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
158 initsyslog()
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
159 {
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
160 PyObject *m, *d;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
161
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
162 /* Create the module and add the functions */
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
163 m = Py_InitModule("syslog", syslog_methods);
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
164
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
165 /* Add some symbolic constants to the module */
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
166 d = PyModule_GetDict(m);
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
167
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
168 /* Priorities */
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
169 DICT_SET_INT(d, "LOG_EMERG", LOG_EMERG);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
170 DICT_SET_INT(d, "LOG_ALERT", LOG_ALERT);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
171 DICT_SET_INT(d, "LOG_CRIT", LOG_CRIT);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
172 DICT_SET_INT(d, "LOG_ERR", LOG_ERR);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
173 DICT_SET_INT(d, "LOG_WARNING", LOG_WARNING);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
174 DICT_SET_INT(d, "LOG_NOTICE", LOG_NOTICE);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
175 DICT_SET_INT(d, "LOG_INFO", LOG_INFO);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
176 DICT_SET_INT(d, "LOG_DEBUG", LOG_DEBUG);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
177
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
178 /* openlog() option flags */
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
179 DICT_SET_INT(d, "LOG_PID", LOG_PID);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
180 DICT_SET_INT(d, "LOG_CONS", LOG_CONS);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
181 DICT_SET_INT(d, "LOG_NDELAY", LOG_NDELAY);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
182 DICT_SET_INT(d, "LOG_NOWAIT", LOG_NOWAIT);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
183 #ifdef LOG_PERROR
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
184 DICT_SET_INT(d, "LOG_PERROR", LOG_PERROR);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
185 #endif
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
186
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
187 /* Facilities */
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
188 DICT_SET_INT(d, "LOG_KERN", LOG_KERN);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
189 DICT_SET_INT(d, "LOG_USER", LOG_USER);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
190 DICT_SET_INT(d, "LOG_MAIL", LOG_MAIL);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
191 DICT_SET_INT(d, "LOG_DAEMON", LOG_DAEMON);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
192 DICT_SET_INT(d, "LOG_AUTH", LOG_AUTH);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
193 DICT_SET_INT(d, "LOG_LPR", LOG_LPR);
3843
de0ad7527de7 Some NeXT changes (default certain symbols to others)
Guido van Rossum <guido@python.org>
parents: 3197
diff changeset
194 #ifdef LOG_NEWS
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
195 DICT_SET_INT(d, "LOG_NEWS", LOG_NEWS);
3843
de0ad7527de7 Some NeXT changes (default certain symbols to others)
Guido van Rossum <guido@python.org>
parents: 3197
diff changeset
196 #else
de0ad7527de7 Some NeXT changes (default certain symbols to others)
Guido van Rossum <guido@python.org>
parents: 3197
diff changeset
197 DICT_SET_INT(d, "LOG_NEWS", LOG_MAIL);
de0ad7527de7 Some NeXT changes (default certain symbols to others)
Guido van Rossum <guido@python.org>
parents: 3197
diff changeset
198 #endif
de0ad7527de7 Some NeXT changes (default certain symbols to others)
Guido van Rossum <guido@python.org>
parents: 3197
diff changeset
199 #ifdef LOG_UUCP
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
200 DICT_SET_INT(d, "LOG_UUCP", LOG_UUCP);
3843
de0ad7527de7 Some NeXT changes (default certain symbols to others)
Guido van Rossum <guido@python.org>
parents: 3197
diff changeset
201 #else
de0ad7527de7 Some NeXT changes (default certain symbols to others)
Guido van Rossum <guido@python.org>
parents: 3197
diff changeset
202 DICT_SET_INT(d, "LOG_UUCP", LOG_MAIL);
de0ad7527de7 Some NeXT changes (default certain symbols to others)
Guido van Rossum <guido@python.org>
parents: 3197
diff changeset
203 #endif
de0ad7527de7 Some NeXT changes (default certain symbols to others)
Guido van Rossum <guido@python.org>
parents: 3197
diff changeset
204 #ifdef LOG_CRON
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
205 DICT_SET_INT(d, "LOG_CRON", LOG_CRON);
3843
de0ad7527de7 Some NeXT changes (default certain symbols to others)
Guido van Rossum <guido@python.org>
parents: 3197
diff changeset
206 #else
de0ad7527de7 Some NeXT changes (default certain symbols to others)
Guido van Rossum <guido@python.org>
parents: 3197
diff changeset
207 DICT_SET_INT(d, "LOG_CRON", LOG_DAEMON);
de0ad7527de7 Some NeXT changes (default certain symbols to others)
Guido van Rossum <guido@python.org>
parents: 3197
diff changeset
208 #endif
3197
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
209 DICT_SET_INT(d, "LOG_LOCAL0", LOG_LOCAL0);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
210 DICT_SET_INT(d, "LOG_LOCAL1", LOG_LOCAL1);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
211 DICT_SET_INT(d, "LOG_LOCAL2", LOG_LOCAL2);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
212 DICT_SET_INT(d, "LOG_LOCAL3", LOG_LOCAL3);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
213 DICT_SET_INT(d, "LOG_LOCAL4", LOG_LOCAL4);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
214 DICT_SET_INT(d, "LOG_LOCAL5", LOG_LOCAL5);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
215 DICT_SET_INT(d, "LOG_LOCAL6", LOG_LOCAL6);
5d16ecae8ee7 changes by Steve Clift
Guido van Rossum <guido@python.org>
parents: 2123
diff changeset
216 DICT_SET_INT(d, "LOG_LOCAL7", LOG_LOCAL7);
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
217
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
218 /* Check for errors */
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
219 if (PyErr_Occurred())
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
220 Py_FatalError("can't initialize module syslog");
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
221 }