summaryrefslogtreecommitdiff
path: root/Modules/syslogmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1994-08-30 12:25:20 +0000
committerGuido van Rossum <guido@python.org>1994-08-30 12:25:20 +0000
commitf6971e2958a162298885b6069cc137d973fac356 (patch)
treedf71dbe37937e0eff5089b06860303275fd910a5 /Modules/syslogmodule.c
parent0c4071e69fe71513a453aad1720b289ac6f5ff32 (diff)
downloadcpython-git-f6971e2958a162298885b6069cc137d973fac356.tar.gz
Lance has converted his modules to the new naming conventions, and
contributed a curses interface. Setup.in uses .c instead of .o now.
Diffstat (limited to 'Modules/syslogmodule.c')
-rw-r--r--Modules/syslogmodule.c229
1 files changed, 115 insertions, 114 deletions
diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c
index dd0ba35b31..eea33aabb7 100644
--- a/Modules/syslogmodule.c
+++ b/Modules/syslogmodule.c
@@ -1,6 +1,6 @@
/***********************************************************
-Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
-Amsterdam, The Netherlands.
+Copyright 1994 by Lance Ellinghouse,
+Cathedral City, California Republic, United States of America.
All Rights Reserved
@@ -8,125 +8,126 @@ Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
-supporting documentation, and that the names of Stichting Mathematisch
-Centrum or CWI not be used in advertising or publicity pertaining to
-distribution of the software without specific, written prior permission.
+supporting documentation, and that the name of Lance Ellinghouse
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
-STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
+LANCE ELLINGHOUSE DISCLAIMS ALL WARRANTIES WITH REGARD TO
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
-FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
-OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+FITNESS, IN NO EVENT SHALL LANCE ELLINGHOUSE BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/* syslog module */
-/* (By Lance Ellinghouse) */
#include "allobjects.h"
#include "modsupport.h"
#include <syslog.h>
-static object *
+#include "rename1.h"
+
+static PyObject *
syslog_openlog(self, args)
- object *self;
- object *args;
+ PyObject * self;
+ PyObject * args;
{
char *ident = "";
- object *ident_o;
+ PyObject * ident_o;
long logopt = LOG_PID;
long facility = LOG_USER;
- if (!getargs(args, "(Sll);ident string, logoption, facility", &ident_o, &logopt, &facility))
- if (!getargs(args, "(Sl);ident string, logoption", &ident_o, &logopt))
- if (!getargs(args, "S;ident string", &ident_o))
+ if (!PyArg_Parse(args, "(Sll);ident string, logoption, facility", &ident_o, &logopt, &facility))
+ if (!PyArg_Parse(args, "(Sl);ident string, logoption", &ident_o, &logopt))
+ if (!PyArg_Parse(args, "S;ident string", &ident_o))
return NULL;
- INCREF(ident_o); /* This is needed because openlog() does NOT make a copy
+ Py_INCREF(ident_o); /* This is needed because openlog() does NOT make a copy
and syslog() later uses it.. cannot trash it. */
- ident = getstringvalue(ident_o);
+ ident = PyString_AsString(ident_o);
openlog(ident,logopt,facility);
- INCREF(None);
- return None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
-static object *
+static PyObject *
syslog_syslog(self, args)
- object *self;
- object *args;
+ PyObject * self;
+ PyObject * args;
{
int priority = LOG_INFO;
char *message;
- if (!getargs(args,"(is);priority, message string",&priority,&message))
- if (!getargs(args,"s;message string",&message))
+ if (!PyArg_Parse(args,"(is);priority, message string",&priority,&message))
+ if (!PyArg_Parse(args,"s;message string",&message))
return NULL;
syslog(priority, message);
- INCREF(None);
- return None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
-static object *
+static PyObject *
syslog_closelog(self, args)
- object *self;
- object *args;
+ PyObject * self;
+ PyObject * args;
{
- if (!getnoarg(args))
+ if (!PyArg_NoArgs(args))
return NULL;
closelog();
- INCREF(None);
- return None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
-static object *
+static PyObject *
syslog_setlogmask(self, args)
- object *self;
- object *args;
+ PyObject * self;
+ PyObject * args;
{
long maskpri;
- if (!getargs(args,"l;mask for priority",&maskpri))
+ if (!PyArg_Parse(args,"l;mask for priority",&maskpri))
return NULL;
setlogmask(maskpri);
- INCREF(None);
- return None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
-static object *
+static PyObject *
syslog_log_mask(self, args)
- object *self;
- object *args;
+ PyObject * self;
+ PyObject * args;
{
long mask;
long pri;
- if (!getargs(args,"l",&pri))
+ if (!PyArg_Parse(args,"l",&pri))
return NULL;
mask = LOG_MASK(pri);
- return newintobject(mask);
+ return PyInt_FromLong(mask);
}
-static object *
+static PyObject *
syslog_log_upto(self, args)
- object *self;
- object *args;
+ PyObject * self;
+ PyObject * args;
{
long mask;
long pri;
- if (!getargs(args,"l",&pri))
+ if (!PyArg_Parse(args,"l",&pri))
return NULL;
mask = LOG_UPTO(pri);
- return newintobject(mask);
+ return PyInt_FromLong(mask);
}
/* List of functions defined in the module */
-static struct methodlist syslog_methods[] = {
- {"openlog", syslog_openlog},
- {"closelog", syslog_closelog},
- {"syslog", syslog_syslog},
- {"setlogmask", syslog_setlogmask},
- {"LOG_MASK", syslog_log_mask},
- {"LOG_UPTO", syslog_log_upto},
+static PyMethodDef syslog_methods[] = {
+ {"openlog", (PyCFunction)syslog_openlog},
+ {"closelog", (PyCFunction)syslog_closelog},
+ {"syslog", (PyCFunction)syslog_syslog},
+ {"setlogmask", (PyCFunction)syslog_setlogmask},
+ {"LOG_MASK", (PyCFunction)syslog_log_mask},
+ {"LOG_UPTO", (PyCFunction)syslog_log_upto},
{NULL, NULL} /* sentinel */
};
@@ -135,65 +136,65 @@ static struct methodlist syslog_methods[] = {
void
initsyslog()
{
- object *m, *d, *x;
+ PyObject *m, *d, *x;
/* Create the module and add the functions */
- m = initmodule("syslog", syslog_methods);
+ m = Py_InitModule("syslog", syslog_methods);
/* Add some symbolic constants to the module */
- d = getmoduledict(m);
- x = newintobject(LOG_EMERG);
- dictinsert(d, "LOG_EMERG", x);
- x = newintobject(LOG_ALERT);
- dictinsert(d, "LOG_ALERT", x);
- x = newintobject(LOG_CRIT);
- dictinsert(d, "LOG_CRIT", x);
- x = newintobject(LOG_ERR);
- dictinsert(d, "LOG_ERR", x);
- x = newintobject(LOG_WARNING);
- dictinsert(d, "LOG_WARNING", x);
- x = newintobject(LOG_NOTICE);
- dictinsert(d, "LOG_NOTICE", x);
- x = newintobject(LOG_INFO);
- dictinsert(d, "LOG_INFO", x);
- x = newintobject(LOG_DEBUG);
- dictinsert(d, "LOG_DEBUG", x);
- x = newintobject(LOG_PID);
- dictinsert(d, "LOG_PID", x);
- x = newintobject(LOG_CONS);
- dictinsert(d, "LOG_CONS", x);
- x = newintobject(LOG_NDELAY);
- dictinsert(d, "LOG_NDELAY", x);
- x = newintobject(LOG_NOWAIT);
- dictinsert(d, "LOG_NOWAIT", x);
- x = newintobject(LOG_KERN);
- dictinsert(d, "LOG_KERN", x);
- x = newintobject(LOG_USER);
- dictinsert(d, "LOG_USER", x);
- x = newintobject(LOG_MAIL);
- dictinsert(d, "LOG_MAIL", x);
- x = newintobject(LOG_DAEMON);
- dictinsert(d, "LOG_DAEMON", x);
- x = newintobject(LOG_LPR);
- dictinsert(d, "LOG_LPR", x);
- x = newintobject(LOG_LOCAL0);
- dictinsert(d, "LOG_LOCAL0", x);
- x = newintobject(LOG_LOCAL1);
- dictinsert(d, "LOG_LOCAL1", x);
- x = newintobject(LOG_LOCAL2);
- dictinsert(d, "LOG_LOCAL2", x);
- x = newintobject(LOG_LOCAL3);
- dictinsert(d, "LOG_LOCAL3", x);
- x = newintobject(LOG_LOCAL4);
- dictinsert(d, "LOG_LOCAL4", x);
- x = newintobject(LOG_LOCAL5);
- dictinsert(d, "LOG_LOCAL5", x);
- x = newintobject(LOG_LOCAL6);
- dictinsert(d, "LOG_LOCAL6", x);
- x = newintobject(LOG_LOCAL7);
- dictinsert(d, "LOG_LOCAL7", x);
+ d = PyModule_GetDict(m);
+ x = PyInt_FromLong(LOG_EMERG);
+ PyDict_SetItemString(d, "LOG_EMERG", x);
+ x = PyInt_FromLong(LOG_ALERT);
+ PyDict_SetItemString(d, "LOG_ALERT", x);
+ x = PyInt_FromLong(LOG_CRIT);
+ PyDict_SetItemString(d, "LOG_CRIT", x);
+ x = PyInt_FromLong(LOG_ERR);
+ PyDict_SetItemString(d, "LOG_ERR", x);
+ x = PyInt_FromLong(LOG_WARNING);
+ PyDict_SetItemString(d, "LOG_WARNING", x);
+ x = PyInt_FromLong(LOG_NOTICE);
+ PyDict_SetItemString(d, "LOG_NOTICE", x);
+ x = PyInt_FromLong(LOG_INFO);
+ PyDict_SetItemString(d, "LOG_INFO", x);
+ x = PyInt_FromLong(LOG_DEBUG);
+ PyDict_SetItemString(d, "LOG_DEBUG", x);
+ x = PyInt_FromLong(LOG_PID);
+ PyDict_SetItemString(d, "LOG_PID", x);
+ x = PyInt_FromLong(LOG_CONS);
+ PyDict_SetItemString(d, "LOG_CONS", x);
+ x = PyInt_FromLong(LOG_NDELAY);
+ PyDict_SetItemString(d, "LOG_NDELAY", x);
+ x = PyInt_FromLong(LOG_NOWAIT);
+ PyDict_SetItemString(d, "LOG_NOWAIT", x);
+ x = PyInt_FromLong(LOG_KERN);
+ PyDict_SetItemString(d, "LOG_KERN", x);
+ x = PyInt_FromLong(LOG_USER);
+ PyDict_SetItemString(d, "LOG_USER", x);
+ x = PyInt_FromLong(LOG_MAIL);
+ PyDict_SetItemString(d, "LOG_MAIL", x);
+ x = PyInt_FromLong(LOG_DAEMON);
+ PyDict_SetItemString(d, "LOG_DAEMON", x);
+ x = PyInt_FromLong(LOG_LPR);
+ PyDict_SetItemString(d, "LOG_LPR", x);
+ x = PyInt_FromLong(LOG_LOCAL0);
+ PyDict_SetItemString(d, "LOG_LOCAL0", x);
+ x = PyInt_FromLong(LOG_LOCAL1);
+ PyDict_SetItemString(d, "LOG_LOCAL1", x);
+ x = PyInt_FromLong(LOG_LOCAL2);
+ PyDict_SetItemString(d, "LOG_LOCAL2", x);
+ x = PyInt_FromLong(LOG_LOCAL3);
+ PyDict_SetItemString(d, "LOG_LOCAL3", x);
+ x = PyInt_FromLong(LOG_LOCAL4);
+ PyDict_SetItemString(d, "LOG_LOCAL4", x);
+ x = PyInt_FromLong(LOG_LOCAL5);
+ PyDict_SetItemString(d, "LOG_LOCAL5", x);
+ x = PyInt_FromLong(LOG_LOCAL6);
+ PyDict_SetItemString(d, "LOG_LOCAL6", x);
+ x = PyInt_FromLong(LOG_LOCAL7);
+ PyDict_SetItemString(d, "LOG_LOCAL7", x);
/* Check for errors */
- if (err_occurred())
- fatal("can't initialize module syslog");
+ if (PyErr_Occurred())
+ Py_FatalError("can't initialize module syslog");
}