Ignore:
Timestamp:
27/07/06 11:43:56 (14 years ago)
Author:
spascoe
Message:

Added an API hook to use bbftpd_log to log messages from python code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/trunk/src/python_ext/bbftpd.c

    r1259 r1332  
    1515#include "util.h" 
    1616#include <structures.h> 
     17#include <bbftpd_log.h> 
    1718 
    1819extern char **environ; 
     
    200201 */ 
    201202 
     203/* log message to bbftpd logger */ 
     204static PyObject *pybbftpd_log(PyObject *self, PyObject *args) { 
     205  int priority; 
     206  char *message; 
     207 
     208  if (!PyArg_ParseTuple(args, "is", &priority, &message)) { 
     209    return NULL; 
     210  } 
     211 
     212  bbftpd_log(priority, message); 
     213 
     214  Py_RETURN_NONE; 
     215} 
     216 
    202217/* send(string) */ 
    203 static PyObject *bbftpd_send(PyObject *self, PyObject *args) { 
     218static PyObject *pybbftpd_send(PyObject *self, PyObject *args) { 
    204219  char *buffer, logmessage[1024]; 
    205220  int len; 
     
    223238 
    224239/* recv(length) -> string */ 
    225 static PyObject *bbftpd_recv(PyObject *self, PyObject *args) { 
     240static PyObject *pybbftpd_recv(PyObject *self, PyObject *args) { 
    226241  char *buffer, logmessage[1024]; 
    227242  int len; 
     
    253268 * Main entry point for the python module. 
    254269 */ 
    255 static PyObject *bbftpd_run(PyObject *self, PyObject *args) { 
     270static PyObject *pybbftpd_run(PyObject *self, PyObject *args) { 
    256271  int argc, i; 
    257272  char **argv, **arg_p; 
     
    315330static PyMethodDef BbftpdMethods[] = { 
    316331  { 
    317     "run", bbftpd_run, METH_VARARGS,  
     332    "run", pybbftpd_run, METH_VARARGS,  
    318333    "Execute the bbftpd server.\n" 
    319334    "\n" 
     
    325340  }, 
    326341  { 
    327     "send", bbftpd_send, METH_VARARGS, 
     342    "send", pybbftpd_send, METH_VARARGS, 
    328343    "Send an authentication message to the client.\n" 
    329344    "\n" 
     
    334349  }, 
    335350  { 
    336     "recv", bbftpd_recv, METH_VARARGS, 
     351    "recv", pybbftpd_recv, METH_VARARGS, 
    337352    "Receive an authentication message from the client.\n" 
    338353    "\n" 
     
    342357    "@return: A string containing the message\n" 
    343358    "@raise IOError: if bbftpd_private_recv() call fails\n" 
     359  }, 
     360  { 
     361    "log", pybbftpd_log, METH_VARARGS, 
     362    "Send a message to the bbftpd logger.\n" 
     363    "\n" 
     364    "@param priority: as syslog priority\n" 
     365    "@param message: A string containing the message to send\n" 
    344366  }, 
    345367  {NULL, NULL, 0, NULL} 
Note: See TracChangeset for help on using the changeset viewer.