Changeset 1070 for TI05-delivery
- Timestamp:
- 31/05/06 12:57:18 (15 years ago)
- Location:
- TI05-delivery/trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TI05-delivery/trunk/src/bbftp-server-3.2.0/bbftpd/bbftpd.c
r1067 r1070 1085 1085 state = S_PROTWAIT ; 1086 1086 sprintf(logmessage,"bbftpd version %s : OK",VERSION) ; 1087 syslog(BBFTPD_DEBUG, "Lets send the auth reply ...");1088 1087 reply(MSG_OK,logmessage) ; 1089 1088 } else { -
TI05-delivery/trunk/src/bbftp-server-3.2.0/bbftpd/bbftpd_daemon.c
r1065 r1070 139 139 #ifdef NDG_PYTHON_EMBED 140 140 /* Return the daemon's PID */ 141 if (retcode > 0) return retcode; 141 if (retcode > 0) { 142 close(controlsock); 143 return retcode; 144 } 142 145 #else 143 146 /* No need for the parent any more */ -
TI05-delivery/trunk/src/python_ext/bbftpd.c
r1067 r1070 1 /** 2 * NDG python embedded bbftp daemon module. 3 * 4 * @author Stephen Pascoe 5 * 6 * Copyright (C) 2006 CCLRC & NERC 7 * 8 * This software may be distributed under the terms of the Q Public Licence, version 1.0 or later. 9 * 10 */ 11 1 12 #include <Python.h> 2 13 3 14 extern char **environ; 4 /* From bbftpd.c */ 15 /* 16 * variables and prototypes from bbftpd.c 17 */ 18 19 extern int be_daemon; 20 extern int newcontrolport; 21 5 22 int bbftpd_main(int argc, char **argv, char **envp); 6 23 7 /*8 When embedding in python main is replaced by a simple python function call.9 */10 24 static PyObject *bbftpd_run(PyObject *self, PyObject *args) { 11 25 int argc, i; 12 26 char **argv, **arg_p; 13 27 int pid; 28 char preargs[2][20] = { "bbftpd_embedded", "-b" }; 29 PyObject *daemon_args, *item; 30 31 if (!PyArg_ParseTuple(args, "O", &daemon_args)) { 32 return NULL; 33 } 34 Py_INCREF(daemon_args); 14 35 15 36 /* 16 37 * Convert arguments into a standard argv sequence. 17 38 */ 18 argc = Py Tuple_GET_SIZE(args);19 if ((argv = (char* )malloc(argc*sizeof(char*))) == NULL) {39 argc = PySequence_Size(daemon_args); 40 if ((argv = (char**)malloc((argc + 2)*sizeof(char*))) == NULL) { 20 41 PyErr_SetString(PyExc_MemoryError, "malloc failed"); 42 Py_DECREF(daemon_args); 21 43 return NULL; 22 44 } 23 45 46 // Add fixed arguments to daemon's argv 24 47 arg_p = argv; 25 for (i==0; i<argc; i++) { 26 if ((*arg_p = PyString_AsString(PyTuple_GET_ITEM(args, i))) == NULL) { 48 *arg_p = preargs[0]; arg_p++; 49 *arg_p = preargs[1]; arg_p++; 50 51 for (i=0; i<argc; i++) { 52 if ((item = PySequence_GetItem(daemon_args, i)) == NULL) { 53 Py_DECREF(daemon_args); 54 return NULL; 55 } 56 if ((*arg_p = PyString_AsString(item)) == NULL) { 27 57 free(argv); 58 Py_DECREF(item); 59 Py_DECREF(daemon_args); 28 60 return NULL; 29 61 } 30 62 arg_p++; 63 Py_DECREF(item); 31 64 } 32 65 33 pid = bbftpd_main(argc, argv, environ); 66 /* 67 * We must reset some global variables so that bbftpd_run can be executed multiple times. 68 */ 69 be_daemon = 0; 70 71 pid = bbftpd_main(argc+2, argv, environ); 34 72 35 73 free(argv); 74 Py_DECREF(daemon_args); 36 75 return Py_BuildValue("i", pid); 37 76 } 38 77 39 78 static PyMethodDef BbftpdMethods[] = { 40 {"run", bbftpd_run, METH_VARARGS, "Execute the bbftpd server. Returns the PID of the server process"}, 79 { 80 "run", bbftpd_run, METH_VARARGS, 81 "Execute the bbftpd server.\n" 82 "\n" 83 "Forks an embedded bbftpd process as if it were executed\n" 84 "with the command line $ bbftpd -b <args>." 85 "\n" 86 "@param args: command line arguments to pass to the server\n" 87 "@return: the PID of the server process\n" 88 }, 41 89 {NULL, NULL, 0, NULL} 42 90 };
Note: See TracChangeset
for help on using the changeset viewer.