From e5360259a4835817008f5181a92897d0ef103be3 Mon Sep 17 00:00:00 2001 From: Andrei Zmievski Date: Tue, 13 Jun 2000 18:07:19 +0000 Subject: [PATCH] We should define symlink functions only when HAVE_SYMLINK is defined. Otherwise, they should be aliased as not available. --- ext/standard/basic_functions.c | 8 ++++++++ ext/standard/link.c | 12 ++++-------- ext/standard/php_link.h | 4 ++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index bcbf92287c8..4e109a32b7d 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -182,11 +182,19 @@ function_entry basic_functions[] = { PHP_FE(rawurlencode, NULL) PHP_FE(rawurldecode, NULL) +#ifdef HAVE_SYMLINK PHP_FE(readlink, NULL) PHP_FE(linkinfo, NULL) PHP_FE(symlink, NULL) PHP_FE(link, NULL) PHP_FE(unlink, NULL) +#else + PHP_FALIAS(readlink, warn_not_available, NULL) + PHP_FALIAS(linkinfo, warn_not_available, NULL) + PHP_FALIAS(symlink, warn_not_available, NULL) + PHP_FALIAS(link, warn_not_available, NULL) + PHP_FALIAS(unlink, warn_not_available, NULL) +#endif PHP_FE(exec, second_and_third_args_force_ref) PHP_FE(system, second_arg_force_ref) diff --git a/ext/standard/link.c b/ext/standard/link.c index 7cb9102b945..dbec5e087b3 100644 --- a/ext/standard/link.c +++ b/ext/standard/link.c @@ -22,6 +22,8 @@ #include "php_filestat.h" #include "php_globals.h" +#ifdef HAVE_SYMLINK + #include #if HAVE_UNISTD_H #include @@ -52,7 +54,6 @@ Return the target of a symbolic link */ PHP_FUNCTION(readlink) { -#if HAVE_SYMLINK pval **filename; char buff[256]; int ret; @@ -70,7 +71,6 @@ PHP_FUNCTION(readlink) /* Append NULL to the end of the string */ buff[ret] = '\0'; RETURN_STRING(buff,1); -#endif } /* }}} */ @@ -78,7 +78,6 @@ PHP_FUNCTION(readlink) Returns the st_dev field of the UNIX C stat structure describing the link */ PHP_FUNCTION(linkinfo) { -#if HAVE_SYMLINK pval **filename; struct stat sb; int ret; @@ -94,7 +93,6 @@ PHP_FUNCTION(linkinfo) RETURN_LONG(-1L); } RETURN_LONG((long) sb.st_dev); -#endif } /* }}} */ @@ -102,7 +100,6 @@ PHP_FUNCTION(linkinfo) Create a symbolic link */ PHP_FUNCTION(symlink) { -#if HAVE_SYMLINK pval **topath, **frompath; int ret; PLS_FETCH(); @@ -127,7 +124,6 @@ PHP_FUNCTION(symlink) RETURN_FALSE; } RETURN_TRUE; -#endif } /* }}} */ @@ -135,7 +131,6 @@ PHP_FUNCTION(symlink) Create a hard link */ PHP_FUNCTION(link) { -#if HAVE_LINK pval **topath, **frompath; int ret; PLS_FETCH(); @@ -160,7 +155,6 @@ PHP_FUNCTION(link) RETURN_FALSE; } RETURN_TRUE; -#endif } /* }}} */ @@ -192,6 +186,8 @@ PHP_FUNCTION(unlink) } /* }}} */ +#endif + /* * Local variables: diff --git a/ext/standard/php_link.h b/ext/standard/php_link.h index e3c1116f257..8d6e113ac57 100644 --- a/ext/standard/php_link.h +++ b/ext/standard/php_link.h @@ -32,10 +32,14 @@ #ifndef _PHP_LINK_H #define _PHP_LINK_H +#ifdef HAVE_SYMLINK + PHP_FUNCTION(link); PHP_FUNCTION(unlink); PHP_FUNCTION(readlink); PHP_FUNCTION(linkinfo); PHP_FUNCTION(symlink); +#endif + #endif /* _PHP_LINK_H */