annotate Modules/syslogmodule.c @ 2800:ab3dca97ffbe legacy-trunk

new grammar for 3rd raise arg and keyword parameters
author Guido van Rossum <guido@python.org>
date Fri, 07 Jul 1995 22:26:23 +0000
parents fd5ab7e828fc
children 5d16ecae8ee7
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
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
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
27 #include "Python.h"
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
28
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 #include <syslog.h>
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
30
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
31 static PyObject *
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 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
33 PyObject * self;
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
34 PyObject * args;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 {
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 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
37 PyObject * ident_o;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 long logopt = LOG_PID;
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 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
40 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
41 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
42 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
43 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
44 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
45 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
46 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
47 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
48 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
49 return Py_None;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 }
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
51
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
52 static PyObject *
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 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
54 PyObject * self;
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
55 PyObject * args;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
56 {
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 int priority = LOG_INFO;
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 char *message;
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
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 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
61 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
62 return NULL;
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 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
64 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
65 return Py_None;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 }
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
67
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
68 static PyObject *
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 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
70 PyObject * self;
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
71 PyObject * args;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
72 {
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
73 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
74 return NULL;
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
75 closelog();
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
76 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
77 return Py_None;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
78 }
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
79
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
80 static PyObject *
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
81 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
82 PyObject * self;
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
83 PyObject * args;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
84 {
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
85 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
86 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
87 return NULL;
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
88 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
89 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
90 return Py_None;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
91 }
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
92
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
93 static PyObject *
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
94 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
95 PyObject * self;
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
96 PyObject * args;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
97 {
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
98 long mask;
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
99 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
100 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
101 return NULL;
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
102 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
103 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
104 }
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
105
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
106 static PyObject *
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
107 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
108 PyObject * self;
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
109 PyObject * args;
1737
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
110 {
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
111 long mask;
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
112 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
113 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
114 return NULL;
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
115 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
116 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
117 }
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 /* 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
120
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
121 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
122 {"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
123 {"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
124 {"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
125 {"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
126 {"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
127 {"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
128 {NULL, NULL} /* sentinel */
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
129 };
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
130
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
131 /* 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
132
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
133 void
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
134 initsyslog()
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
135 {
1855
9dbdb83d4178 Lance has converted his modules to the new naming conventions, and
Guido van Rossum <guido@python.org>
parents: 1737
diff changeset
136 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
137
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
138 /* 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
139 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
140
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
141 /* 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
142 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
143 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
144 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
145 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
146 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
147 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
148 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
149 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
150 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
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163 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
164 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
165 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
166 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
167 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
168 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
169 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
170 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
171 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
172 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
173 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
174 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
175 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
176 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
177 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
178 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
179 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
180 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
181 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
182 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
183 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
184 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
185 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
186 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
187 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
188 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
189 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
190 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
191 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
192 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
193
ee2f88a4f9e2 Added some names to Setup.in, and added syslogmodule.c.
Guido van Rossum <guido@python.org>
parents:
diff changeset
194 /* 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
195 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
196 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
197 }