Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
43a476ac
Kaydet (Commit)
43a476ac
authored
Ock 09, 1997
tarafından
Barry Warsaw
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Formatting changes, plus memory management in initsyslog()
üst
73a75eb7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
90 deletions
+102
-90
syslogmodule.c
Modules/syslogmodule.c
+102
-90
No files found.
Modules/syslogmodule.c
Dosyayı görüntüle @
43a476ac
...
...
@@ -44,52 +44,56 @@ Revision history:
static
PyObject
*
syslog_openlog
(
self
,
args
)
PyObject
*
self
;
PyObject
*
args
;
PyObject
*
self
;
PyObject
*
args
;
{
long
logopt
=
0
;
long
facility
=
LOG_USER
;
long
logopt
=
0
;
long
facility
=
LOG_USER
;
static
PyObject
*
ident_o
=
NULL
;
static
PyObject
*
ident_o
=
NULL
;
Py_XDECREF
(
ident_o
);
if
(
!
PyArg_ParseTuple
(
args
,
"S|ll;ident string [, logoption [, facility]]"
,
&
ident_o
,
&
logopt
,
&
facility
))
{
return
NULL
;
}
Py_INCREF
(
ident_o
);
/* This is needed because openlog() does NOT make a copy
and syslog() later uses it.. cannot trash it. */
Py_XDECREF
(
ident_o
);
if
(
!
PyArg_ParseTuple
(
args
,
"S|ll;ident string [, logoption [, facility]]"
,
&
ident_o
,
&
logopt
,
&
facility
))
return
NULL
;
/* This is needed because openlog() does NOT make a copy
* and syslog() later uses it.. cannot trash it.
*/
Py_INCREF
(
ident_o
);
openlog
(
PyString_AsString
(
ident_o
),
logopt
,
facility
);
openlog
(
PyString_AsString
(
ident_o
),
logopt
,
facility
);
Py_INCREF
(
Py_None
);
return
Py_None
;
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
PyObject
*
syslog_syslog
(
self
,
args
)
PyObject
*
self
;
PyObject
*
args
;
PyObject
*
self
;
PyObject
*
args
;
{
char
*
message
;
int
priority
=
LOG_INFO
|
LOG_USER
;
if
(
!
PyArg_ParseTuple
(
args
,
"is;[priority,] message string"
,
&
priority
,
&
message
))
{
PyErr_Clear
();
if
(
!
PyArg_ParseTuple
(
args
,
"s;[priority,] message string"
,
&
message
))
{
return
NULL
;
}
}
syslog
(
priority
,
"%s"
,
message
);
Py_INCREF
(
Py_None
);
return
Py_None
;
char
*
message
;
int
priority
=
LOG_INFO
|
LOG_USER
;
if
(
!
PyArg_ParseTuple
(
args
,
"is;[priority,] message string"
,
&
priority
,
&
message
))
{
PyErr_Clear
();
if
(
!
PyArg_ParseTuple
(
args
,
"s;[priority,] message string"
,
&
message
))
return
NULL
;
}
syslog
(
priority
,
"%s"
,
message
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
PyObject
*
syslog_closelog
(
self
,
args
)
PyObject
*
self
;
PyObject
*
args
;
PyObject
*
self
;
PyObject
*
args
;
{
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
...
...
@@ -100,41 +104,41 @@ syslog_closelog(self, args)
static
PyObject
*
syslog_setlogmask
(
self
,
args
)
PyObject
*
self
;
PyObject
*
args
;
PyObject
*
self
;
PyObject
*
args
;
{
long
maskpri
,
omaskpri
;
long
maskpri
,
omaskpri
;
if
(
!
PyArg_ParseTuple
(
args
,
"l;mask for priority"
,
&
maskpri
))
return
NULL
;
omaskpri
=
setlogmask
(
maskpri
);
return
PyInt_FromLong
(
omaskpri
);
if
(
!
PyArg_ParseTuple
(
args
,
"l;mask for priority"
,
&
maskpri
))
return
NULL
;
omaskpri
=
setlogmask
(
maskpri
);
return
PyInt_FromLong
(
omaskpri
);
}
static
PyObject
*
syslog_log_mask
(
self
,
args
)
PyObject
*
self
;
PyObject
*
args
;
PyObject
*
self
;
PyObject
*
args
;
{
long
mask
;
long
pri
;
if
(
!
PyArg_ParseTuple
(
args
,
"l"
,
&
pri
))
return
NULL
;
mask
=
LOG_MASK
(
pri
);
return
PyInt_FromLong
(
mask
);
long
mask
;
long
pri
;
if
(
!
PyArg_ParseTuple
(
args
,
"l"
,
&
pri
))
return
NULL
;
mask
=
LOG_MASK
(
pri
);
return
PyInt_FromLong
(
mask
);
}
static
PyObject
*
syslog_log_upto
(
self
,
args
)
PyObject
*
self
;
PyObject
*
args
;
PyObject
*
self
;
PyObject
*
args
;
{
long
mask
;
long
pri
;
if
(
!
PyArg_ParseTuple
(
args
,
"l"
,
&
pri
))
return
NULL
;
mask
=
LOG_UPTO
(
pri
);
return
PyInt_FromLong
(
mask
);
long
mask
;
long
pri
;
if
(
!
PyArg_ParseTuple
(
args
,
"l"
,
&
pri
))
return
NULL
;
mask
=
LOG_UPTO
(
pri
);
return
PyInt_FromLong
(
mask
);
}
/* List of functions defined in the module */
...
...
@@ -151,8 +155,16 @@ static PyMethodDef syslog_methods[] = {
/* Initialization function for the module */
#define DICT_SET_INT(d, s, x) \
PyDict_SetItemString(d, s, PyInt_FromLong((long) (x)))
void
ins
(
d
,
s
,
x
)
PyObject
*
d
;
char
*
s
;
long
x
;
{
PyObject
*
xl
=
PyInt_FromLong
(
x
);
PyDict_SetItemString
(
d
,
s
,
xl
);
Py_XDECREF
(
xl
);
}
void
initsyslog
()
...
...
@@ -166,54 +178,54 @@ initsyslog()
d
=
PyModule_GetDict
(
m
);
/* Priorities */
DICT_SET_INT
(
d
,
"LOG_EMERG"
,
LOG_EMERG
);
DICT_SET_INT
(
d
,
"LOG_ALERT"
,
LOG_ALERT
);
DICT_SET_INT
(
d
,
"LOG_CRIT"
,
LOG_CRIT
);
DICT_SET_INT
(
d
,
"LOG_ERR"
,
LOG_ERR
);
DICT_SET_INT
(
d
,
"LOG_WARNING"
,
LOG_WARNING
);
DICT_SET_INT
(
d
,
"LOG_NOTICE"
,
LOG_NOTICE
);
DICT_SET_INT
(
d
,
"LOG_INFO"
,
LOG_INFO
);
DICT_SET_INT
(
d
,
"LOG_DEBUG"
,
LOG_DEBUG
);
ins
(
d
,
"LOG_EMERG"
,
LOG_EMERG
);
ins
(
d
,
"LOG_ALERT"
,
LOG_ALERT
);
ins
(
d
,
"LOG_CRIT"
,
LOG_CRIT
);
ins
(
d
,
"LOG_ERR"
,
LOG_ERR
);
ins
(
d
,
"LOG_WARNING"
,
LOG_WARNING
);
ins
(
d
,
"LOG_NOTICE"
,
LOG_NOTICE
);
ins
(
d
,
"LOG_INFO"
,
LOG_INFO
);
ins
(
d
,
"LOG_DEBUG"
,
LOG_DEBUG
);
/* openlog() option flags */
DICT_SET_INT
(
d
,
"LOG_PID"
,
LOG_PID
);
DICT_SET_INT
(
d
,
"LOG_CONS"
,
LOG_CONS
);
DICT_SET_INT
(
d
,
"LOG_NDELAY"
,
LOG_NDELAY
);
DICT_SET_INT
(
d
,
"LOG_NOWAIT"
,
LOG_NOWAIT
);
ins
(
d
,
"LOG_PID"
,
LOG_PID
);
ins
(
d
,
"LOG_CONS"
,
LOG_CONS
);
ins
(
d
,
"LOG_NDELAY"
,
LOG_NDELAY
);
ins
(
d
,
"LOG_NOWAIT"
,
LOG_NOWAIT
);
#ifdef LOG_PERROR
DICT_SET_INT
(
d
,
"LOG_PERROR"
,
LOG_PERROR
);
ins
(
d
,
"LOG_PERROR"
,
LOG_PERROR
);
#endif
/* Facilities */
DICT_SET_INT
(
d
,
"LOG_KERN"
,
LOG_KERN
);
DICT_SET_INT
(
d
,
"LOG_USER"
,
LOG_USER
);
DICT_SET_INT
(
d
,
"LOG_MAIL"
,
LOG_MAIL
);
DICT_SET_INT
(
d
,
"LOG_DAEMON"
,
LOG_DAEMON
);
DICT_SET_INT
(
d
,
"LOG_AUTH"
,
LOG_AUTH
);
DICT_SET_INT
(
d
,
"LOG_LPR"
,
LOG_LPR
);
ins
(
d
,
"LOG_KERN"
,
LOG_KERN
);
ins
(
d
,
"LOG_USER"
,
LOG_USER
);
ins
(
d
,
"LOG_MAIL"
,
LOG_MAIL
);
ins
(
d
,
"LOG_DAEMON"
,
LOG_DAEMON
);
ins
(
d
,
"LOG_AUTH"
,
LOG_AUTH
);
ins
(
d
,
"LOG_LPR"
,
LOG_LPR
);
#ifdef LOG_NEWS
DICT_SET_INT
(
d
,
"LOG_NEWS"
,
LOG_NEWS
);
ins
(
d
,
"LOG_NEWS"
,
LOG_NEWS
);
#else
DICT_SET_INT
(
d
,
"LOG_NEWS"
,
LOG_MAIL
);
ins
(
d
,
"LOG_NEWS"
,
LOG_MAIL
);
#endif
#ifdef LOG_UUCP
DICT_SET_INT
(
d
,
"LOG_UUCP"
,
LOG_UUCP
);
ins
(
d
,
"LOG_UUCP"
,
LOG_UUCP
);
#else
DICT_SET_INT
(
d
,
"LOG_UUCP"
,
LOG_MAIL
);
ins
(
d
,
"LOG_UUCP"
,
LOG_MAIL
);
#endif
#ifdef LOG_CRON
DICT_SET_INT
(
d
,
"LOG_CRON"
,
LOG_CRON
);
ins
(
d
,
"LOG_CRON"
,
LOG_CRON
);
#else
DICT_SET_INT
(
d
,
"LOG_CRON"
,
LOG_DAEMON
);
ins
(
d
,
"LOG_CRON"
,
LOG_DAEMON
);
#endif
DICT_SET_INT
(
d
,
"LOG_LOCAL0"
,
LOG_LOCAL0
);
DICT_SET_INT
(
d
,
"LOG_LOCAL1"
,
LOG_LOCAL1
);
DICT_SET_INT
(
d
,
"LOG_LOCAL2"
,
LOG_LOCAL2
);
DICT_SET_INT
(
d
,
"LOG_LOCAL3"
,
LOG_LOCAL3
);
DICT_SET_INT
(
d
,
"LOG_LOCAL4"
,
LOG_LOCAL4
);
DICT_SET_INT
(
d
,
"LOG_LOCAL5"
,
LOG_LOCAL5
);
DICT_SET_INT
(
d
,
"LOG_LOCAL6"
,
LOG_LOCAL6
);
DICT_SET_INT
(
d
,
"LOG_LOCAL7"
,
LOG_LOCAL7
);
ins
(
d
,
"LOG_LOCAL0"
,
LOG_LOCAL0
);
ins
(
d
,
"LOG_LOCAL1"
,
LOG_LOCAL1
);
ins
(
d
,
"LOG_LOCAL2"
,
LOG_LOCAL2
);
ins
(
d
,
"LOG_LOCAL3"
,
LOG_LOCAL3
);
ins
(
d
,
"LOG_LOCAL4"
,
LOG_LOCAL4
);
ins
(
d
,
"LOG_LOCAL5"
,
LOG_LOCAL5
);
ins
(
d
,
"LOG_LOCAL6"
,
LOG_LOCAL6
);
ins
(
d
,
"LOG_LOCAL7"
,
LOG_LOCAL7
);
/* Check for errors */
if
(
PyErr_Occurred
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment