Ignore:
Timestamp:
15/06/06 10:16:37 (14 years ago)
Author:
spascoe
Message:

Auto-generated documentation included for the python-server interface.

Some file clean up prior to alpha. Fixed some confusion between authentication
and authorisation in the API.

The embedded client test case is disabled because it doesn't work :-(.

File:
1 edited

Legend:

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

    r1157 r1187  
    1313#include <stdio.h> 
    1414 
     15#include "util.h" 
     16 
    1517extern char **environ; 
    16 #define TRUE 1 
    17 #define FALSE 0 
    1818 
    1919int bbftpc_main(int argc, char **argv, char **envp); 
    20  
    21 /** 
    22  * Routines for constructing a argc/argv style argument list from a python sequence. 
    23  */ 
    24  
    25 struct ndg_argv { 
    26   int argc;         /// Total number of arguments. 
    27   char **argv;     /// Argument array. 
    28   int next;         /// index of next empty (and unallocated) argument. 
    29 }; 
    30  
    31 /** 
    32  * Initialise a structure. 
    33  * @return TRUE on success or FALSE on a memory error. 
    34  */ 
    35 int ndg_argv_init(struct ndg_argv *argv_s, int argc) { 
    36   argv_s->argc = argc; 
    37  
    38   if ((argv_s->argv = (char **)malloc(sizeof(struct ndg_argv))) == NULL) { 
    39     return FALSE; 
    40   } 
    41  
    42   argv_s->next = 0; 
    43  
    44   return TRUE; 
    45 } 
    46  
    47 /** 
    48  * Free a structure.  \a argv_s should be cleared first with \c ndg_argv_clear(). 
    49  * 
    50  * @return TRUE on success or FALSE if the structure isn't empty. 
    51  */ 
    52 int ndg_argv_free(struct ndg_argv *argv_s) { 
    53   if (argv_s->next != 0) return FALSE; 
    54   free(argv_s->argv); 
    55   return TRUE; 
    56 } 
    57  
    58 /** 
    59  * Clear all arguments from the structure. 
    60  * 
    61  */ 
    62 void ndg_argv_clear(struct ndg_argv *argv_s) { 
    63   char *arg; 
    64   while (argv_s->next > 0) { 
    65     argv_s->next--; 
    66     arg = argv_s->argv[argv_s->next]; 
    67     free(arg); 
    68   } 
    69 } 
    70  
    71 /** 
    72  * Add an argument. 
    73  * 
    74  * @return TRUE on success or FALSE on an error. 
    75  */ 
    76 int ndg_argv_add(struct ndg_argv *argv_s, char *arg) { 
    77   char **arg_p; 
    78  
    79   if (argv_s->argc == argv_s->next) return FALSE; 
    80   arg_p = &(argv_s->argv[argv_s->next]); 
    81   if ((*arg_p = (char *)malloc(strlen(arg))) == NULL) { 
    82     return FALSE; 
    83   } 
    84   strcpy(*arg_p, arg); 
    85   argv_s->next++; 
    86   return TRUE; 
    87 } 
    88  
    89  
    9020 
    9121/** 
     
    10636   * Convert arguments into a standard argv sequence. 
    10737   */ 
    108   argc = PySequence_Size(client_args); 
     38 
     39  if ((argc = PySequence_Size(client_args)) == -1) { 
     40    return NULL; 
     41  } 
    10942  if (!ndg_argv_init(&argv_s, argc + 1)) { 
    11043    PyErr_SetString(PyExc_MemoryError, "malloc failed"); 
     
    13063      PyErr_SetString(PyExc_MemoryError, "ndg_argv_add failed"); 
    13164      ndg_argv_clear(&argv_s); ndg_argv_free(&argv_s); 
     65      Py_DECREF(item); 
    13266      Py_DECREF(client_args); 
    133       Py_DECREF(item); 
     67      return NULL; 
    13468    } 
    13569 
     
    14377  } 
    14478   
    145  
    14679  bbftpc_main(argv_s.argc, argv_s.argv, environ); 
    14780  ndg_argv_clear(&argv_s); ndg_argv_free(&argv_s); 
Note: See TracChangeset for help on using the changeset viewer.