PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LTP GCOV extension - code coverage report
Current view: directory - standard - pageinfo.c
Test: PHP Code Coverage
Date: 2009-11-19 Instrumented lines: 45
Code covered: 84.4 % Executed lines: 38
Legend: not executed executed

       1                 : /*
       2                 :    +----------------------------------------------------------------------+
       3                 :    | PHP Version 5                                                        |
       4                 :    +----------------------------------------------------------------------+
       5                 :    | Copyright (c) 1997-2009 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: Jim Winstead <jimw@php.net>                                  |
      16                 :    +----------------------------------------------------------------------+
      17                 : */
      18                 : 
      19                 : /* $Id: pageinfo.c 290179 2009-11-03 18:03:02Z guenter $ */
      20                 : 
      21                 : #include "php.h"
      22                 : #include "pageinfo.h"
      23                 : #include "SAPI.h"
      24                 : 
      25                 : #include <stdio.h>
      26                 : #include <stdlib.h>
      27                 : #if HAVE_PWD_H
      28                 : #ifdef PHP_WIN32
      29                 : #include "win32/pwd.h"
      30                 : #else
      31                 : #include <pwd.h>
      32                 : #endif
      33                 : #endif
      34                 : #if HAVE_GRP_H
      35                 : # ifdef PHP_WIN32
      36                 : #  include "win32/grp.h"
      37                 : # else
      38                 : #  include <grp.h>
      39                 : # endif
      40                 : #endif
      41                 : #ifdef PHP_WIN32
      42                 : #undef getgid
      43                 : #define getgroups(a, b) 0
      44                 : #define getgid() 1
      45                 : #define getuid() 1
      46                 : #endif
      47                 : #if HAVE_UNISTD_H
      48                 : #include <unistd.h>
      49                 : #endif
      50                 : #include <sys/stat.h>
      51                 : #include <sys/types.h>
      52                 : #ifdef PHP_WIN32
      53                 : #include <process.h>
      54                 : #endif
      55                 : 
      56                 : #include "ext/standard/basic_functions.h"
      57                 : 
      58                 : /* {{{ php_statpage
      59                 :  */
      60                 : PHPAPI void php_statpage(TSRMLS_D)
      61              28 : {
      62                 :         struct stat *pstat;
      63                 : 
      64              28 :         pstat = sapi_get_stat(TSRMLS_C);
      65                 : 
      66              28 :         if (BG(page_uid)==-1 || BG(page_gid)==-1) {
      67               6 :                 if(pstat) {
      68               6 :                         BG(page_uid)   = pstat->st_uid;
      69               6 :                         BG(page_gid)   = pstat->st_gid;
      70               6 :                         BG(page_inode) = pstat->st_ino;
      71               6 :                         BG(page_mtime) = pstat->st_mtime;
      72                 :                 } else { /* handler for situations where there is no source file, ex. php -r */
      73               0 :                         BG(page_uid) = getuid();
      74               0 :                         BG(page_gid) = getgid();
      75                 :                 }
      76                 :         }
      77              28 : }
      78                 : /* }}} */
      79                 : 
      80                 : /* {{{ php_getuid
      81                 :  */
      82                 : long php_getuid(void)
      83              25 : {
      84                 :         TSRMLS_FETCH();
      85                 : 
      86              25 :         php_statpage(TSRMLS_C);
      87              25 :         return (BG(page_uid));
      88                 : }
      89                 : /* }}} */
      90                 : 
      91                 : long php_getgid(void)
      92               1 : {
      93                 :         TSRMLS_FETCH();
      94                 : 
      95               1 :         php_statpage(TSRMLS_C);
      96               1 :         return (BG(page_gid));
      97                 : }
      98                 : 
      99                 : /* {{{ proto int getmyuid(void)
     100                 :    Get PHP script owner's UID */
     101                 : PHP_FUNCTION(getmyuid)
     102               1 : {
     103                 :         long uid;
     104                 :         
     105               1 :         uid = php_getuid();
     106               1 :         if (uid < 0) {
     107               0 :                 RETURN_FALSE;
     108                 :         } else {
     109               1 :                 RETURN_LONG(uid);
     110                 :         }
     111                 : }
     112                 : /* }}} */
     113                 : 
     114                 : /* {{{ proto int getmygid(void)
     115                 :    Get PHP script owner's GID */
     116                 : PHP_FUNCTION(getmygid)
     117               1 : {
     118                 :         long gid;
     119                 :         
     120               1 :         gid = php_getgid();
     121               1 :         if (gid < 0) {
     122               0 :                 RETURN_FALSE;
     123                 :         } else {
     124               1 :                 RETURN_LONG(gid);
     125                 :         }
     126                 : }
     127                 : /* }}} */
     128                 : 
     129                 : /* {{{ proto int getmypid(void)
     130                 :    Get current process ID */
     131                 : PHP_FUNCTION(getmypid)
     132               4 : {
     133                 :         int pid;
     134                 :         
     135               4 :         pid = getpid();
     136               4 :         if (pid < 0) {
     137               0 :                 RETURN_FALSE;
     138                 :         } else {
     139               4 :                 RETURN_LONG((long) pid);
     140                 :         }
     141                 : }
     142                 : /* }}} */
     143                 : 
     144                 : /* {{{ proto int getmyinode(void)
     145                 :    Get the inode of the current script being parsed */
     146                 : PHP_FUNCTION(getmyinode)
     147               1 : {
     148               1 :         php_statpage(TSRMLS_C);
     149               1 :         if (BG(page_inode) < 0) {
     150               0 :                 RETURN_FALSE;
     151                 :         } else {
     152               1 :                 RETURN_LONG(BG(page_inode));
     153                 :         }
     154                 : }
     155                 : /* }}} */
     156                 : 
     157                 : PHPAPI long php_getlastmod(TSRMLS_D)
     158               1 : {
     159               1 :         php_statpage(TSRMLS_C);
     160               1 :         return BG(page_mtime);
     161                 : }
     162                 : 
     163                 : /* {{{ proto int getlastmod(void)
     164                 :    Get time of last page modification */
     165                 : PHP_FUNCTION(getlastmod)
     166               1 : {
     167               1 :         long lm = php_getlastmod(TSRMLS_C);
     168               1 :         if (lm < 0) {
     169               0 :                 RETURN_FALSE;
     170                 :         } else {
     171               1 :                 RETURN_LONG(lm);
     172                 :         }
     173                 : }
     174                 : /* }}} */
     175                 : 
     176                 : /*
     177                 :  * Local variables:
     178                 :  * tab-width: 4
     179                 :  * c-basic-offset: 4
     180                 :  * End:
     181                 :  * vim600: sw=4 ts=4 fdm=marker
     182                 :  * vim<600: sw=4 ts=4
     183                 :  */

Generated by: LTP GCOV extension version 1.5

Generated at Thu, 19 Nov 2009 08:20:24 +0000 (5 days ago)

Copyright © 2005-2009 The PHP Group
All rights reserved.