[PHP-CVS] cvs: php4 /ext/standard filestat.c

2001-04-25 Thread Andi Gutmans

andiTue Apr 24 23:30:24 2001 EDT

  Modified files:  
/php4/ext/standard  filestat.c 
  Log:
  - Fix filetype() and lstat() too.
  
  
Index: php4/ext/standard/filestat.c
diff -u php4/ext/standard/filestat.c:1.60 php4/ext/standard/filestat.c:1.61
--- php4/ext/standard/filestat.c:1.60   Tue Apr 24 22:53:45 2001
+++ php4/ext/standard/filestat.cTue Apr 24 23:30:24 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filestat.c,v 1.60 2001/04/25 05:53:45 andi Exp $ */
+/* $Id: filestat.c,v 1.61 2001/04/25 06:30:24 andi Exp $ */
 
 #include php.h
 #include safe_mode.h
@@ -446,6 +446,7 @@
 }
 /* }}} */
 
+#define IS_LINK_OPERATION() (type == 8 /* filetype */ || type == 14 /* is_link */ || 
+type == 16 /* lstat */)
 
 static void php_stat(const char *filename, php_stat_len filename_length, int type, 
pval *return_value)
 {
@@ -469,29 +470,23 @@
BG(lsb).st_mode = 0; /* mark lstat buf invalid */
 #endif
if (V_STAT(BG(CurrentStatFile), BG(sb)) == -1) {
-   if ((type != 14)  (type != 15 || errno != ENOENT)) { /* 
fileexists() test must print no error */
+   if (!IS_LINK_OPERATION()  (type != 15 || errno != ENOENT)) { 
+/* fileexists() test must print no error */
php_error(E_NOTICE,stat failed for %s (errno=%d - 
%s), BG(CurrentStatFile), errno, strerror(errno));
}
efree(BG(CurrentStatFile));
BG(CurrentStatFile) = NULL;
-   if (type != 14) { /* Don't require success for is link */
+   if (!IS_LINK_OPERATION()) { /* Don't require success for link 
+operation */
RETURN_FALSE;
}
}
}
 
 #if HAVE_SYMLINK
-   if (8 == type /* filetype */
-   || 14 == type /* is link */
-   || 16 == type) { /* lstat */
-
+   if (IS_LINK_OPERATION()  !BG(lsb).st_mode) {
/* do lstat if the buffer is empty */
-
-   if (!BG(lsb).st_mode) {
-   if (V_LSTAT(filename, BG(lsb)) == -1) {
-   php_error(E_NOTICE, lstat failed for %s (errno=%d - 
%s), filename, errno, strerror(errno));
-   RETURN_FALSE;
-   }
+   if (V_LSTAT(filename, BG(lsb)) == -1) {
+   php_error(E_NOTICE, lstat failed for %s (errno=%d - %s), 
+filename, errno, strerror(errno));
+   RETURN_FALSE;
}
}
 #endif



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /ext/standard filestat.c

2001-04-24 Thread Andi Gutmans

andiTue Apr 24 21:22:30 2001 EDT

  Modified files:  
/php4/ext/standard  filestat.c 
  Log:
  - Fix problem with is_link(), there seem to be at least another couple of
  - bugs lurking around though.
  - Cleaned up code a bit and optimized it a bit too.
  
  
Index: php4/ext/standard/filestat.c
diff -u php4/ext/standard/filestat.c:1.57 php4/ext/standard/filestat.c:1.58
--- php4/ext/standard/filestat.c:1.57   Tue Apr  3 03:51:16 2001
+++ php4/ext/standard/filestat.cTue Apr 24 21:22:29 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filestat.c,v 1.57 2001/04/03 10:51:16 sniper Exp $ */
+/* $Id: filestat.c,v 1.58 2001/04/25 04:22:29 andi Exp $ */
 
 #include php.h
 #include safe_mode.h
@@ -447,7 +447,7 @@
 /* }}} */
 
 
-static void php_stat(const char *filename, int type, pval *return_value)
+static void php_stat(const char *filename, int filename_length, int type, pval 
+*return_value)
 {
struct stat *stat_sb;
int rmask=S_IROTH,wmask=S_IWOTH,xmask=S_IXOTH; /* access rights defaults to 
other */
@@ -455,25 +455,28 @@
 
stat_sb = BG(sb);
 
-   if (!BG(CurrentStatFile) || strcmp(filename,BG(CurrentStatFile))) {
-   if (!BG(CurrentStatFile)
-   || strlen(filename)  BG(CurrentStatLength)) {
-   if (BG(CurrentStatFile)) efree(BG(CurrentStatFile));
-   BG(CurrentStatLength) = strlen(filename);
-   BG(CurrentStatFile) = estrndup(filename,BG(CurrentStatLength));
+   if (!BG(CurrentStatFile) || strcmp(filename, BG(CurrentStatFile))) {
+   if (!BG(CurrentStatFile) || filename_length  BG(CurrentStatLength)) {
+   if (BG(CurrentStatFile)) {
+   efree(BG(CurrentStatFile));
+   }
+   BG(CurrentStatLength) = filename_length;
+   BG(CurrentStatFile) = estrndup(filename, filename_length);
} else {
-   strcpy(BG(CurrentStatFile),filename);
+   memcpy(BG(CurrentStatFile), filename, filename_length+1);
}
 #if HAVE_SYMLINK
BG(lsb).st_mode = 0; /* mark lstat buf invalid */
 #endif
-   if (V_STAT(BG(CurrentStatFile),BG(sb))==-1) {
-   if (type != 15 || errno != ENOENT) { /* fileexists() test must 
print no error */
-   php_error(E_NOTICE,stat failed for %s (errno=%d - 
%s),BG(CurrentStatFile),errno,strerror(errno));
+   if (V_STAT(BG(CurrentStatFile), BG(sb)) == -1) {
+   if ((type != 14)  (type != 15 || errno != ENOENT)) { /* 
+fileexists() test must print no error */
+   php_error(E_NOTICE,stat failed for %s (errno=%d - 
+%s), BG(CurrentStatFile), errno, strerror(errno));
}
efree(BG(CurrentStatFile));
-   BG(CurrentStatFile)=NULL;
-   RETURN_FALSE;
+   BG(CurrentStatFile) = NULL;
+   if (type != 14) { /* Don't require success for is link */
+   RETURN_FALSE;
+   }
}
}
 
@@ -485,8 +488,8 @@
/* do lstat if the buffer is empty */
 
if (!BG(lsb).st_mode) {
-   if (V_LSTAT(BG(CurrentStatFile),BG(lsb)) == -1) {
-   php_error(E_NOTICE,lstat failed for %s (errno=%d - 
%s),BG(CurrentStatFile),errno,strerror(errno));
+   if (V_LSTAT(BG(CurrentStatFile), BG(lsb)) == -1) {
+   php_error(E_NOTICE, lstat failed for %s (errno=%d - 
+%s), BG(CurrentStatFile), errno, strerror(errno));
RETURN_FALSE;
}
}
@@ -494,35 +497,37 @@
 #endif
 
 
-   if(BG(sb).st_uid==getuid()) {
-   rmask=S_IRUSR;
-   wmask=S_IWUSR;
-   xmask=S_IXUSR;
-   } else if(BG(sb).st_gid==getgid()) {
-   rmask=S_IRGRP;
-   wmask=S_IWGRP;
-   xmask=S_IXGRP;
-   } else {
-   int   groups,n,i;
-   gid_t *gids;
+   if (type = 9  type = 11) {
+   if(BG(sb).st_uid==getuid()) {
+   rmask=S_IRUSR;
+   wmask=S_IWUSR;
+   xmask=S_IXUSR;
+   } else if(BG(sb).st_gid==getgid()) {
+   rmask=S_IRGRP;
+   wmask=S_IWGRP;
+   xmask=S_IXGRP;
+   } else {
+   int   groups,n,i;
+   gid_t *gids;
 
-   groups = getgroups(0,NULL);
-   if(groups) {
-   gids=(gid_t *)emalloc(groups*sizeof(gid_t));
-   

[PHP-CVS] cvs: php4 /ext/standard filestat.c

2001-04-24 Thread Andi Gutmans

andiTue Apr 24 22:43:31 2001 EDT

  Modified files:  
/php4/ext/standard  filestat.c 
  Log:
  - Nuke warning. This signed/unsigned stuff gets really annoying sometimes.
  
  
Index: php4/ext/standard/filestat.c
diff -u php4/ext/standard/filestat.c:1.58 php4/ext/standard/filestat.c:1.59
--- php4/ext/standard/filestat.c:1.58   Tue Apr 24 21:22:29 2001
+++ php4/ext/standard/filestat.cTue Apr 24 22:43:30 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filestat.c,v 1.58 2001/04/25 04:22:29 andi Exp $ */
+/* $Id: filestat.c,v 1.59 2001/04/25 05:43:30 andi Exp $ */
 
 #include php.h
 #include safe_mode.h
@@ -447,7 +447,7 @@
 /* }}} */
 
 
-static void php_stat(const char *filename, int filename_length, int type, pval 
*return_value)
+static void php_stat(const char *filename, php_stat_len filename_length, int type, 
+pval *return_value)
 {
struct stat *stat_sb;
int rmask=S_IROTH,wmask=S_IWOTH,xmask=S_IXOTH; /* access rights defaults to 
other */
@@ -637,7 +637,7 @@
WRONG_PARAM_COUNT; \
} \
convert_to_string_ex(filename); \
-   php_stat(Z_STRVAL_PP(filename), Z_STRLEN_PP(filename), funcnum, return_value); 
\
+   php_stat(Z_STRVAL_PP(filename), (php_stat_len) Z_STRLEN_PP(filename), funcnum, 
+return_value); \
 }
 
 /* {{{ proto int fileperms(string filename)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /ext/standard filestat.c

2001-04-24 Thread Andi Gutmans

andiTue Apr 24 22:53:45 2001 EDT

  Modified files:  
/php4/ext/standard  filestat.c 
  Log:
  - Another fix
  
  
Index: php4/ext/standard/filestat.c
diff -u php4/ext/standard/filestat.c:1.59 php4/ext/standard/filestat.c:1.60
--- php4/ext/standard/filestat.c:1.59   Tue Apr 24 22:43:30 2001
+++ php4/ext/standard/filestat.cTue Apr 24 22:53:45 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filestat.c,v 1.59 2001/04/25 05:43:30 andi Exp $ */
+/* $Id: filestat.c,v 1.60 2001/04/25 05:53:45 andi Exp $ */
 
 #include php.h
 #include safe_mode.h
@@ -488,8 +488,8 @@
/* do lstat if the buffer is empty */
 
if (!BG(lsb).st_mode) {
-   if (V_LSTAT(BG(CurrentStatFile), BG(lsb)) == -1) {
-   php_error(E_NOTICE, lstat failed for %s (errno=%d - 
%s), BG(CurrentStatFile), errno, strerror(errno));
+   if (V_LSTAT(filename, BG(lsb)) == -1) {
+   php_error(E_NOTICE, lstat failed for %s (errno=%d - 
+%s), filename, errno, strerror(errno));
RETURN_FALSE;
}
}



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /ext/standard filestat.c

2001-04-03 Thread Jani Taskinen

sniper  Tue Apr  3 03:51:16 2001 EDT

  Modified files:  
/php4/ext/standard  filestat.c 
  Log:
  SCO (and maybe others) do not have this defined.
  
Index: php4/ext/standard/filestat.c
diff -u php4/ext/standard/filestat.c:1.56 php4/ext/standard/filestat.c:1.57
--- php4/ext/standard/filestat.c:1.56   Sun Feb 25 22:07:17 2001
+++ php4/ext/standard/filestat.cTue Apr  3 03:51:16 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filestat.c,v 1.56 2001/02/26 06:07:17 andi Exp $ */
+/* $Id: filestat.c,v 1.57 2001/04/03 10:51:16 sniper Exp $ */
 
 #include "php.h"
 #include "safe_mode.h"
@@ -551,7 +551,7 @@
case S_IFDIR: RETURN_STRING("dir",1);
case S_IFBLK: RETURN_STRING("block",1);
case S_IFREG: RETURN_STRING("file",1);
-#if !defined(ZEND_WIN32)!defined(__BEOS__)
+#if defined(S_IFSOCK)  !defined(ZEND_WIN32)!defined(__BEOS__)
case S_IFSOCK: RETURN_STRING("socket",1);
 #endif
}



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /ext/standard filestat.c

2001-02-15 Thread Egon Schmid

eschmid Thu Feb 15 12:33:09 2001 EDT

  Modified files:  
/php4/ext/standard  filestat.c 
  Log:
  Small typo.
  
Index: php4/ext/standard/filestat.c
diff -u php4/ext/standard/filestat.c:1.52 php4/ext/standard/filestat.c:1.53
--- php4/ext/standard/filestat.c:1.52   Sun Jan 21 09:26:43 2001
+++ php4/ext/standard/filestat.cThu Feb 15 12:33:09 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filestat.c,v 1.52 2001/01/21 17:26:43 rasmus Exp $ */
+/* $Id: filestat.c,v 1.53 2001/02/15 20:33:09 eschmid Exp $ */
 
 #include "php.h"
 #include "safe_mode.h"
@@ -650,7 +650,7 @@
 FileFunction(PHP_FN(fileowner),3)
 /* }}} */
 
-/* {{{ proto nt filegroup(string filename)
+/* {{{ proto int filegroup(string filename)
Get file group */
 FileFunction(PHP_FN(filegroup),4)
 /* }}} */



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]