LTP GCOV extension - code coverage report
Current view: directory - ext/session - mod_user.c
Test: PHP Code Coverage
Date: 2007-04-10 Instrumented lines: 50
Code covered: 0.0 % Executed lines: 0
Legend: not executed executed

       1                 : /* 
       2                 :    +----------------------------------------------------------------------+
       3                 :    | PHP Version 5                                                        |
       4                 :    +----------------------------------------------------------------------+
       5                 :    | Copyright (c) 1997-2007 The PHP Group                                |
       6                 :    +----------------------------------------------------------------------+
       7                 :    | This source file is subject to version 3.01 of the PHP license,      |
       8                 :    | that is bundled with this package in the file LICENSE, and is        |
       9                 :    | available through the world-wide-web at the following url:           |
      10                 :    | http://www.php.net/license/3_01.txt                                  |
      11                 :    | If you did not receive a copy of the PHP license and are unable to   |
      12                 :    | obtain it through the world-wide-web, please send a note to          |
      13                 :    | license@php.net so we can mail you a copy immediately.               |
      14                 :    +----------------------------------------------------------------------+
      15                 :    | Author: Sascha Schumann <sascha@schumann.cx>                         |
      16                 :    +----------------------------------------------------------------------+
      17                 :  */
      18                 : 
      19                 : /* $Id: mod_user.c,v 1.29.2.1.2.1 2007/01/01 09:36:05 sebastian Exp $ */
      20                 : 
      21                 : #include "php.h"
      22                 : #include "php_session.h"
      23                 : #include "mod_user.h"
      24                 : 
      25                 : ps_module ps_mod_user = {
      26                 :         PS_MOD(user)
      27                 : };
      28                 : 
      29                 : #define SESS_ZVAL_LONG(val, a)                                  \
      30                 : {                                                                                       \
      31                 :         MAKE_STD_ZVAL(a);                                               \
      32                 :         Z_TYPE_P(a) = IS_LONG;                                          \
      33                 :         Z_LVAL_P(a) = val;                                      \
      34                 : }
      35                 : 
      36                 : #define SESS_ZVAL_STRING(vl, a)                                         \
      37                 : {                                                                                       \
      38                 :         int len = strlen(vl);                                   \
      39                 :         MAKE_STD_ZVAL(a);                                               \
      40                 :         Z_TYPE_P(a) = IS_STRING;                                        \
      41                 :         Z_STRLEN_P(a) = len;                            \
      42                 :         Z_STRVAL_P(a) = estrndup(vl, len);      \
      43                 : }
      44                 : 
      45                 : #define SESS_ZVAL_STRINGN(vl, ln, a)                    \
      46                 : {                                                                                       \
      47                 :         MAKE_STD_ZVAL(a);                                               \
      48                 :         Z_TYPE_P(a) = IS_STRING;                                        \
      49                 :         Z_STRLEN_P(a) = ln;                                     \
      50                 :         Z_STRVAL_P(a) = estrndup(vl, ln);       \
      51                 : }
      52                 : 
      53                 : 
      54                 : static zval *ps_call_handler(zval *func, int argc, zval **argv TSRMLS_DC)
      55               0 : {
      56                 :         int i;
      57               0 :         zval *retval = NULL;
      58                 :         
      59               0 :         MAKE_STD_ZVAL(retval);
      60               0 :         if (call_user_function(EG(function_table), NULL, func, retval, 
      61                 :                                 argc, argv TSRMLS_CC) == FAILURE) {
      62               0 :                 zval_ptr_dtor(&retval);
      63               0 :                 retval = NULL;
      64                 :         }
      65                 : 
      66               0 :         for (i = 0; i < argc; i++) {
      67               0 :                 zval_ptr_dtor(&argv[i]);
      68                 :         }
      69                 : 
      70               0 :         return retval;
      71                 : }
      72                 : 
      73                 : #define STDVARS                                                         \
      74                 :         zval *retval;                                                   \
      75                 :         int ret = FAILURE;                                              \
      76                 :         ps_user *mdata = PS_GET_MOD_DATA();             \
      77                 :         if (!mdata)                                                     \
      78                 :                 return FAILURE
      79                 : 
      80                 : #define PSF(a) mdata->name.ps_##a
      81                 : 
      82                 : #define FINISH                                                          \
      83                 :         if (retval) {                                                   \
      84                 :                 convert_to_long(retval);                        \
      85                 :                 ret = Z_LVAL_P(retval);                 \
      86                 :                 zval_ptr_dtor(&retval);                             \
      87                 :         }                                                                               \
      88                 :         return ret
      89                 : 
      90                 : PS_OPEN_FUNC(user)
      91               0 : {
      92                 :         zval *args[2];
      93               0 :         STDVARS;
      94                 :         
      95               0 :         SESS_ZVAL_STRING(save_path, args[0]);
      96               0 :         SESS_ZVAL_STRING(session_name, args[1]);
      97                 :         
      98               0 :         retval = ps_call_handler(PSF(open), 2, args TSRMLS_CC);
      99                 :         
     100               0 :         FINISH;
     101                 : }
     102                 : 
     103                 : PS_CLOSE_FUNC(user)
     104               0 : {
     105                 :         int i;
     106               0 :         STDVARS;
     107                 : 
     108               0 :         retval = ps_call_handler(PSF(close), 0, NULL TSRMLS_CC);
     109                 : 
     110               0 :         for (i = 0; i < 6; i++)
     111               0 :                 zval_ptr_dtor(&mdata->names[i]);
     112               0 :         efree(mdata);
     113                 : 
     114               0 :         PS_SET_MOD_DATA(NULL);
     115                 : 
     116               0 :         FINISH;
     117                 : }
     118                 : 
     119                 : PS_READ_FUNC(user)
     120               0 : {
     121                 :         zval *args[1];
     122               0 :         STDVARS;
     123                 : 
     124               0 :         SESS_ZVAL_STRING(key, args[0]);
     125                 : 
     126               0 :         retval = ps_call_handler(PSF(read), 1, args TSRMLS_CC);
     127                 :         
     128               0 :         if (retval) {
     129               0 :                 if (Z_TYPE_P(retval) == IS_STRING) {
     130               0 :                         *val = estrndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval));
     131               0 :                         *vallen = Z_STRLEN_P(retval);
     132               0 :                         ret = SUCCESS;
     133                 :                 }
     134               0 :                 zval_ptr_dtor(&retval);
     135                 :         }
     136                 : 
     137               0 :         return ret;
     138                 : }
     139                 : 
     140                 : PS_WRITE_FUNC(user)
     141               0 : {
     142                 :         zval *args[2];
     143               0 :         STDVARS;
     144                 :         
     145               0 :         SESS_ZVAL_STRING(key, args[0]);
     146               0 :         SESS_ZVAL_STRINGN(val, vallen, args[1]);
     147                 : 
     148               0 :         retval = ps_call_handler(PSF(write), 2, args TSRMLS_CC);
     149                 : 
     150               0 :         FINISH;
     151                 : }
     152                 : 
     153                 : PS_DESTROY_FUNC(user)
     154               0 : {
     155                 :         zval *args[1];
     156               0 :         STDVARS;
     157                 : 
     158               0 :         SESS_ZVAL_STRING(key, args[0]);
     159                 : 
     160               0 :         retval = ps_call_handler(PSF(destroy), 1, args TSRMLS_CC);
     161                 : 
     162               0 :         FINISH;
     163                 : }
     164                 : 
     165                 : PS_GC_FUNC(user)
     166               0 : {
     167                 :         zval *args[1];
     168               0 :         STDVARS;
     169                 : 
     170               0 :         SESS_ZVAL_LONG(maxlifetime, args[0]);
     171                 : 
     172               0 :         retval = ps_call_handler(PSF(gc), 1, args TSRMLS_CC);
     173                 : 
     174               0 :         FINISH;
     175                 : }
     176                 : 
     177                 : /*
     178                 :  * Local variables:
     179                 :  * tab-width: 4
     180                 :  * c-basic-offset: 4
     181                 :  * End:
     182                 :  * vim600: sw=4 ts=4 fdm=marker
     183                 :  * vim<600: sw=4 ts=4
     184                 :  */

Generated by: LTP GCOV extension version 1.5