LTP GCOV extension - code coverage report
Current view: directory - ext/standard - ftok.c
Test: PHP Code Coverage
Date: 2007-04-10 Instrumented lines: 17
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: Andrew Sitnikov <sitnikov@infonet.ee>                        |
      16                 :    +----------------------------------------------------------------------+
      17                 : */
      18                 : 
      19                 : /* $Id: ftok.c,v 1.16.2.1.2.1 2007/01/01 09:36:08 sebastian Exp $ */
      20                 : 
      21                 : #include "php.h"
      22                 : 
      23                 : #include <sys/types.h>                                                                                                        
      24                 : 
      25                 : #ifdef HAVE_SYS_IPC_H
      26                 : #include <sys/ipc.h>
      27                 : #endif
      28                 : 
      29                 : #if HAVE_FTOK
      30                 : /* {{{ proto int ftok(string pathname, string proj)
      31                 :    Convert a pathname and a project identifier to a System V IPC key */
      32                 : PHP_FUNCTION(ftok)
      33               0 : {
      34                 :         zval **pathname, **proj;
      35                 :         key_t k;
      36                 : 
      37               0 :         if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &pathname, &proj) == FAILURE) {
      38               0 :                 WRONG_PARAM_COUNT;
      39                 :         }
      40                 : 
      41               0 :         convert_to_string_ex(pathname);
      42               0 :         convert_to_string_ex(proj);
      43                 : 
      44               0 :         if (Z_STRLEN_PP(pathname)==0){
      45               0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Pathname is invalid");
      46               0 :                 RETURN_LONG(-1);
      47                 :         }
      48                 : 
      49               0 :         if (Z_STRLEN_PP(proj)!=1){
      50               0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Project identifier is invalid");
      51               0 :                 RETURN_LONG(-1);
      52                 :     }
      53                 : 
      54               0 :         if ((PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(pathname), NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(Z_STRVAL_PP(pathname) TSRMLS_CC)) {
      55               0 :                 RETURN_LONG(-1);
      56                 :         }
      57                 : 
      58               0 :         k = ftok(Z_STRVAL_PP(pathname),Z_STRVAL_PP(proj)[0]);
      59               0 :         if (k == -1) {
      60               0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "ftok() failed - %s", strerror(errno));
      61                 :         }
      62                 : 
      63               0 :         RETURN_LONG(k);
      64                 : }
      65                 : /* }}} */
      66                 : #endif
      67                 : 
      68                 : /*
      69                 :  * Local variables:
      70                 :  * tab-width: 4
      71                 :  * c-basic-offset: 4
      72                 :  * End:
      73                 :  */

Generated by: LTP GCOV extension version 1.5