Mercurial > cpython-lru_cache-weakref
annotate Modules/syslogmodule.c @ 1944:8e8fddcbdfd2 legacy-trunk
Hopefully the last edits for 1.1
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 06 Oct 1994 16:15:09 +0000 |
| parents | 9dbdb83d4178 |
| children | fd5ab7e828fc |
| 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 |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 /* syslog module */ |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 #include "allobjects.h" |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 #include "modsupport.h" |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 #include <syslog.h> |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
32 #include "rename1.h" |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
33 |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
34 static PyObject * |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 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
|
36 PyObject * self; |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
37 PyObject * args; |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 { |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
39 char *ident = ""; |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
40 PyObject * ident_o; |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 long logopt = LOG_PID; |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 long facility = LOG_USER; |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
43 if (!PyArg_Parse(args, "(Sll);ident string, logoption, facility", &ident_o, &logopt, &facility)) |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
44 if (!PyArg_Parse(args, "(Sl);ident string, logoption", &ident_o, &logopt)) |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
45 if (!PyArg_Parse(args, "S;ident string", &ident_o)) |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
46 return NULL; |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
47 Py_INCREF(ident_o); /* This is needed because openlog() does NOT make a copy |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 and syslog() later uses it.. cannot trash it. */ |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
49 ident = PyString_AsString(ident_o); |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 openlog(ident,logopt,facility); |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
51 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
|
52 return Py_None; |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 } |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
55 static PyObject * |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 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
|
57 PyObject * self; |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
58 PyObject * args; |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
59 { |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 int priority = LOG_INFO; |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 char *message; |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
62 |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
63 if (!PyArg_Parse(args,"(is);priority, message string",&priority,&message)) |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
64 if (!PyArg_Parse(args,"s;message string",&message)) |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 return NULL; |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
66 syslog(priority, message); |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
67 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
|
68 return Py_None; |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
69 } |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
70 |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
71 static PyObject * |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
72 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
|
73 PyObject * self; |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
74 PyObject * args; |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
75 { |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
76 if (!PyArg_NoArgs(args)) |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
77 return NULL; |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
78 closelog(); |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
79 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
|
80 return Py_None; |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
81 } |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
82 |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
83 static PyObject * |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 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
|
85 PyObject * self; |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
86 PyObject * args; |
|
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 long maskpri; |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
89 if (!PyArg_Parse(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
|
90 return NULL; |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
91 setlogmask(maskpri); |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
92 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
|
93 return Py_None; |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
94 } |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
95 |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
96 static PyObject * |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
97 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
|
98 PyObject * self; |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
99 PyObject * args; |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
100 { |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
101 long mask; |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
102 long pri; |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
103 if (!PyArg_Parse(args,"l",&pri)) |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
104 return NULL; |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
105 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
|
106 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
|
107 } |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
108 |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
109 static PyObject * |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
110 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
|
111 PyObject * self; |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
112 PyObject * args; |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
113 { |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
114 long mask; |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
115 long pri; |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
116 if (!PyArg_Parse(args,"l",&pri)) |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
117 return NULL; |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
118 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
|
119 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
|
120 } |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
121 |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
122 /* 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
|
123 |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
124 static PyMethodDef syslog_methods[] = { |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
125 {"openlog", (PyCFunction)syslog_openlog}, |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
126 {"closelog", (PyCFunction)syslog_closelog}, |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
127 {"syslog", (PyCFunction)syslog_syslog}, |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
128 {"setlogmask", (PyCFunction)syslog_setlogmask}, |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
129 {"LOG_MASK", (PyCFunction)syslog_log_mask}, |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
130 {"LOG_UPTO", (PyCFunction)syslog_log_upto}, |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
131 {NULL, NULL} /* sentinel */ |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
132 }; |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
133 |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
134 /* 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
|
135 |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
136 void |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
137 initsyslog() |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
138 { |
|
1855
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
139 PyObject *m, *d, *x; |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
140 |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
141 /* 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
|
142 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
|
143 |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
144 /* 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
|
145 d = PyModule_GetDict(m); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
146 x = PyInt_FromLong(LOG_EMERG); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
147 PyDict_SetItemString(d, "LOG_EMERG", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
148 x = PyInt_FromLong(LOG_ALERT); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
149 PyDict_SetItemString(d, "LOG_ALERT", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
150 x = PyInt_FromLong(LOG_CRIT); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
151 PyDict_SetItemString(d, "LOG_CRIT", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
152 x = PyInt_FromLong(LOG_ERR); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
153 PyDict_SetItemString(d, "LOG_ERR", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
154 x = PyInt_FromLong(LOG_WARNING); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
155 PyDict_SetItemString(d, "LOG_WARNING", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
156 x = PyInt_FromLong(LOG_NOTICE); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
157 PyDict_SetItemString(d, "LOG_NOTICE", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
158 x = PyInt_FromLong(LOG_INFO); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
159 PyDict_SetItemString(d, "LOG_INFO", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
160 x = PyInt_FromLong(LOG_DEBUG); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
161 PyDict_SetItemString(d, "LOG_DEBUG", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
162 x = PyInt_FromLong(LOG_PID); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
163 PyDict_SetItemString(d, "LOG_PID", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
164 x = PyInt_FromLong(LOG_CONS); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
165 PyDict_SetItemString(d, "LOG_CONS", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
166 x = PyInt_FromLong(LOG_NDELAY); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
167 PyDict_SetItemString(d, "LOG_NDELAY", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
168 x = PyInt_FromLong(LOG_NOWAIT); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
169 PyDict_SetItemString(d, "LOG_NOWAIT", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
170 x = PyInt_FromLong(LOG_KERN); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
171 PyDict_SetItemString(d, "LOG_KERN", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
172 x = PyInt_FromLong(LOG_USER); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
173 PyDict_SetItemString(d, "LOG_USER", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
174 x = PyInt_FromLong(LOG_MAIL); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
175 PyDict_SetItemString(d, "LOG_MAIL", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
176 x = PyInt_FromLong(LOG_DAEMON); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
177 PyDict_SetItemString(d, "LOG_DAEMON", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
178 x = PyInt_FromLong(LOG_LPR); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
179 PyDict_SetItemString(d, "LOG_LPR", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
180 x = PyInt_FromLong(LOG_LOCAL0); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
181 PyDict_SetItemString(d, "LOG_LOCAL0", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
182 x = PyInt_FromLong(LOG_LOCAL1); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
183 PyDict_SetItemString(d, "LOG_LOCAL1", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
184 x = PyInt_FromLong(LOG_LOCAL2); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
185 PyDict_SetItemString(d, "LOG_LOCAL2", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
186 x = PyInt_FromLong(LOG_LOCAL3); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
187 PyDict_SetItemString(d, "LOG_LOCAL3", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
188 x = PyInt_FromLong(LOG_LOCAL4); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
189 PyDict_SetItemString(d, "LOG_LOCAL4", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
190 x = PyInt_FromLong(LOG_LOCAL5); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
191 PyDict_SetItemString(d, "LOG_LOCAL5", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
192 x = PyInt_FromLong(LOG_LOCAL6); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
193 PyDict_SetItemString(d, "LOG_LOCAL6", x); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
194 x = PyInt_FromLong(LOG_LOCAL7); |
|
9dbdb83d4178
Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents:
1737
diff
changeset
|
195 PyDict_SetItemString(d, "LOG_LOCAL7", x); |
|
1737
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
196 |
|
ee2f88a4f9e2
Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
197 /* 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
|
198 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
|
199 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
|
200 } |
