We should define symlink functions only when HAVE_SYMLINK is defined.

Otherwise, they should be aliased as not available.
This commit is contained in:
Andrei Zmievski 2000-06-13 18:07:19 +00:00
parent 111d36a3c8
commit e5360259a4
3 changed files with 16 additions and 8 deletions

View File

@ -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)

View File

@ -22,6 +22,8 @@
#include "php_filestat.h"
#include "php_globals.h"
#ifdef HAVE_SYMLINK
#include <stdlib.h>
#if HAVE_UNISTD_H
#include <unistd.h>
@ -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:

View File

@ -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 */