cvs: pecl /xattr CREDITS EXPERIMENTAL config.m4 config.w32 php_xattr.h xattr.c /xattr/tests 001.phpt
| From: | Marcin Gibula | Date: | Fri, 13 Aug 2004 20:46:29 +0000 |
| Subject: | cvs: pecl /xattr CREDITS EXPERIMENTAL config.m4 config.w32 php_xattr.h xattr.c /xattr/tests 001.phpt | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-1649@lists.php.net to get a copy of this message | ||
mg Fri Aug 13 16:46:29 2004 EDT
Added files:
/pecl/xattr CREDITS EXPERIMENTAL config.m4 config.w32 php_xattr.h
xattr.c
/pecl/xattr/tests 001.phpt
Log:
Initial upload.
http://cvs.php.net/co.php/pecl/xattr/config.m4?r=1.1&p=1 Index: pecl/xattr/config.m4 +++ pecl/xattr/config.m4 dnl $Id: config.m4,v 1.1 2004/08/13 20:46:29 mg Exp $ dnl config.m4 for extension xattr PHP_ARG_WITH(xattr, for xattr support, Make sure that the comment is aligned: [ --with-xattr Include xattr support]) if test "$PHP_XATTR" != "no"; then SEARCH_PATH="/usr/local /usr" SEARCH_FOR="/include/attr/attributes.h" if test -r $PHP_XATTR/$SEARCH_FOR; then # path given as parameter XATTR_DIR=$PHP_XATTR else # search default path list AC_MSG_CHECKING([for xattr files in default path]) for i in $SEARCH_PATH ; do if test -r $i/$SEARCH_FOR; then XATTR_DIR=$i AC_MSG_RESULT(found in $i) fi done fi if test -z "$XATTR_DIR"; then AC_MSG_RESULT([not found]) AC_MSG_ERROR([Please reinstall the libattr distribution]) fi PHP_ADD_INCLUDE($XATTR_DIR/include) LIBNAME=attr # you may want to change this LIBSYMBOL=attr_get # you most likely want to change this PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, [ PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $XATTR_DIR/lib, XATTR_SHARED_LIBADD) AC_DEFINE(HAVE_XATTRLIB,1,[ ]) ],[ AC_MSG_ERROR([wrong xattr lib version or lib not found]) ],[ -L$XATTR_DIR/lib -lm -ldl ]) PHP_SUBST(XATTR_SHARED_LIBADD) PHP_NEW_EXTENSION(xattr, xattr.c, $ext_shared) fi http://cvs.php.net/co.php/pecl/xattr/config.w32?r=1.1&p=1 Index: pecl/xattr/config.w32 +++ pecl/xattr/config.w32 // $Id: config.w32,v 1.1 2004/08/13 20:46:29 mg Exp $ // vim:ft=javascript // If your extension references something external, use ARG_WITH // ARG_WITH("xattr", "for xattr support", "no"); // Otherwise, use ARG_ENABLE // ARG_ENABLE("xattr", "enable xattr support", "no"); if (PHP_XATTR != "no") { EXTENSION("xattr", "xattr.c"); } http://cvs.php.net/co.php/pecl/xattr/php_xattr.h?r=1.1&p=1 Index: pecl/xattr/php_xattr.h +++ pecl/xattr/php_xattr.h /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Marcin Gibula <mg@iceni.pl> | +----------------------------------------------------------------------+ */ /* $Id: php_xattr.h,v 1.1 2004/08/13 20:46:29 mg Exp $ */ #ifndef PHP_XATTR_H #define PHP_XATTR_H extern zend_module_entry xattr_module_entry; #define phpext_xattr_ptr &xattr_module_entry #ifdef PHP_WIN32 #define PHP_XATTR_API __declspec(dllexport) #else #define PHP_XATTR_API #endif #ifdef ZTS #include "TSRM.h" #endif PHP_MINIT_FUNCTION(xattr); PHP_MINFO_FUNCTION(xattr); PHP_FUNCTION(xattr_set); PHP_FUNCTION(xattr_get); PHP_FUNCTION(xattr_remove); #endif /* PHP_XATTR_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ http://cvs.php.net/co.php/pecl/xattr/xattr.c?r=1.1&p=1 Index: pecl/xattr/xattr.c +++ pecl/xattr/xattr.c /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Marcin Gibula <mg@iceni.pl> | +----------------------------------------------------------------------+ */ /* $Id: xattr.c,v 1.1 2004/08/13 20:46:29 mg Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #define XATTR_BUFFER_SIZE 1024 #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" #include "php_xattr.h" #include <stdlib.h> #include <attr/attributes.h> #include <sys/types.h> #include <attr/xattr.h> /* {{{ xattr_functions[] * * Every user visible function must have an entry in xattr_functions[]. */ function_entry xattr_functions[] = { PHP_FE(xattr_set, NULL) PHP_FE(xattr_get, NULL) PHP_FE(xattr_remove, NULL) {NULL, NULL, NULL} /* Must be the last line in xattr_functions[] */ }; /* }}} */ /* {{{ xattr_module_entry */ zend_module_entry xattr_module_entry = { #if ZEND_MODULE_API_NO >= 20010901 STANDARD_MODULE_HEADER, #endif "xattr", xattr_functions, PHP_MINIT(xattr), NULL, NULL, NULL, PHP_MINFO(xattr), #if ZEND_MODULE_API_NO >= 20010901 "1.0", #endif STANDARD_MODULE_PROPERTIES }; /* }}} */ #ifdef COMPILE_DL_XATTR ZEND_GET_MODULE(xattr) #endif /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(xattr) { REGISTER_LONG_CONSTANT("XATTR_ROOT", ATTR_ROOT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("XATTR_DONTFOLLOW", ATTR_DONTFOLLOW, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("XATTR_CREATE", ATTR_CREATE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("XATTR_REPLACE", ATTR_REPLACE, CONST_CS | CONST_PERSISTENT); return SUCCESS; } /* }}} */ /* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION(xattr) { return SUCCESS; } /* }}} */ /* Remove if there's nothing to do at request start */ /* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION(xattr) { return SUCCESS; } /* }}} */ /* Remove if there's nothing to do at request end */ /* {{{ PHP_RSHUTDOWN_FUNCTION */ PHP_RSHUTDOWN_FUNCTION(xattr) { return SUCCESS; } /* }}} */ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(xattr) { php_info_print_table_start(); php_info_print_table_header(2, "xattr support", "enabled"); php_info_print_table_end(); } /* }}} */ /* {{{ proto bool xattr_set(string path, string name, string value [, int flags]) Set an extended attribute for a file */ PHP_FUNCTION(xattr_set) { char *attr_name = NULL; char *attr_value = NULL; char *path = NULL; int error, tmp, value_len, flags = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|l", &path, &tmp, &attr_name, &tmp, &attr_value, &value_len, &flags) == FAILURE) { return; } /* Ensure that only allowed bits are set */ flags &= ATTR_ROOT | ATTR_DONTFOLLOW | ATTR_CREATE | ATTR_REPLACE; /* Try to set an attribute and give some warning if it fails... */ error = attr_set(path, attr_name, attr_value, value_len, flags); if (error == -1) { switch (errno) { case E2BIG: php_error(E_WARNING, "%s The value of the given attribute is too large", get_active_function_name(TSRMLS_C)); break; case EPERM: case EACCES: php_error(E_WARNING, "%s Permission denied", get_active_function_name(TSRMLS_C)); break; case EOPNOTSUPP: php_error(E_WARNING, "%s Operation not supported", get_active_function_name(TSRMLS_C)); break; case ENOENT: case ENOTDIR: php_error(E_WARNING, "%s File %s doesn't exists", get_active_function_name(TSRMLS_C), path); break; } RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto string xattr_get(string path, string name [, int flags]) Return a value of an extended attribute */ PHP_FUNCTION(xattr_get) { char *attr_name = NULL; char *attr_value = NULL; char *path = NULL; int error, tmp, flags = 0; size_t buffer_size = XATTR_BUFFER_SIZE; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &path, &tmp, &attr_name, &tmp, &flags) == FAILURE) { return; } /* Ensure that only allowed bits are set */ flags &= ATTR_ROOT | ATTR_DONTFOLLOW; /* Allocate a buffer with starting size XATTR_BUFFER_SIZE bytes */ attr_value = emalloc(buffer_size); if (!attr_value) RETURN_FALSE; /* * If buffer is too small then attr_get sets errno to E2BIG and tells us * how many bytes is required by setting buffer_size variable. */ error = attr_get(path, attr_name, attr_value, &buffer_size, flags); /* * Loop is necessary in case that someone edited extended attributes * and our estimated buffer size is no longer correct. */ while (error && errno == E2BIG) { attr_value = erealloc(attr_value, buffer_size); if (!attr_value) RETURN_FALSE; error = attr_get(path, attr_name, attr_value, &buffer_size, flags); } /* Return a string if everything is ok */ if (!error) { attr_value = erealloc(attr_value, buffer_size); RETURN_STRINGL(attr_value, buffer_size, 0); } /* Error handling part */ efree(attr_value); /* Give warning for some common error conditions */ switch (errno) { case ENOATTR: break; case ENOENT: case ENOTDIR: php_error(E_WARNING, "%s File %s doesn't exists", get_active_function_name(TSRMLS_C), path); break; case EPERM: case EACCES: php_error(E_WARNING, "%s Permission denied", get_active_function_name(TSRMLS_C)); break; case EOPNOTSUPP: php_error(E_WARNING, "%s Operation not supported", get_active_function_name(TSRMLS_C)); break; } RETURN_FALSE; } /* }}} */ /* {{{ proto string xattr_get(string path, string name [, int flags]) Return a value of an extended attribute */ PHP_FUNCTION(xattr_remove) { char *attr_name = NULL; char *path = NULL; int error, tmp, flags = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &path, &tmp, &attr_name, &tmp, &flags) == FAILURE) { return; } /* Ensure that only allowed bits are set */ flags &= ATTR_ROOT | ATTR_DONTFOLLOW; /* Try to remove an attribute and give some warning if it fails... */ error = attr_remove(path, attr_name, flags); if (error == -1) { switch (errno) { case E2BIG: php_error(E_WARNING, "%s The value of the given attribute is too large", get_active_function_name(TSRMLS_C)); break; case EPERM: case EACCES: php_error(E_WARNING, "%s Permission denied", get_active_function_name(TSRMLS_C)); break; case EOPNOTSUPP: php_error(E_WARNING, "%s Operation not supported", get_active_function_name(TSRMLS_C)); break; case ENOENT: case ENOTDIR: php_error(E_WARNING, "%s File %s doesn't exists", get_active_function_name(TSRMLS_C), path); break; } RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ http://cvs.php.net/co.php/pecl/xattr/tests/001.phpt?r=1.1&p=1 Index: pecl/xattr/tests/001.phpt +++ pecl/xattr/tests/001.phpt --TEST-- Check for xattr presence --SKIPIF-- <?php if (!extension_loaded("xattr")) print "skip"; ?> --FILE-- <?php echo "xattr extension is available"; /* you can add regression tests for your extension here the output of your test code has to be equal to the text in the --EXPECT-- section below for the tests to pass, differences between the output and the expected text are interpreted as failure see php5/README.TESTING for further information on writing regression tests */ ?> --EXPECT-- xattr extension is available
http://cvs.php.net/co.php/pecl/xattr/config.m4?r=1.1&p=1 Index: pecl/xattr/config.m4 +++ pecl/xattr/config.m4 dnl $Id: config.m4,v 1.1 2004/08/13 20:46:29 mg Exp $ dnl config.m4 for extension xattr PHP_ARG_WITH(xattr, for xattr support, Make sure that the comment is aligned: [ --with-xattr Include xattr support]) if test "$PHP_XATTR" != "no"; then SEARCH_PATH="/usr/local /usr" SEARCH_FOR="/include/attr/attributes.h" if test -r $PHP_XATTR/$SEARCH_FOR; then # path given as parameter XATTR_DIR=$PHP_XATTR else # search default path list AC_MSG_CHECKING([for xattr files in default path]) for i in $SEARCH_PATH ; do if test -r $i/$SEARCH_FOR; then XATTR_DIR=$i AC_MSG_RESULT(found in $i) fi done fi if test -z "$XATTR_DIR"; then AC_MSG_RESULT([not found]) AC_MSG_ERROR([Please reinstall the libattr distribution]) fi PHP_ADD_INCLUDE($XATTR_DIR/include) LIBNAME=attr # you may want to change this LIBSYMBOL=attr_get # you most likely want to change this PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, [ PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $XATTR_DIR/lib, XATTR_SHARED_LIBADD) AC_DEFINE(HAVE_XATTRLIB,1,[ ]) ],[ AC_MSG_ERROR([wrong xattr lib version or lib not found]) ],[ -L$XATTR_DIR/lib -lm -ldl ]) PHP_SUBST(XATTR_SHARED_LIBADD) PHP_NEW_EXTENSION(xattr, xattr.c, $ext_shared) fi http://cvs.php.net/co.php/pecl/xattr/config.w32?r=1.1&p=1 Index: pecl/xattr/config.w32 +++ pecl/xattr/config.w32 // $Id: config.w32,v 1.1 2004/08/13 20:46:29 mg Exp $ // vim:ft=javascript // If your extension references something external, use ARG_WITH // ARG_WITH("xattr", "for xattr support", "no"); // Otherwise, use ARG_ENABLE // ARG_ENABLE("xattr", "enable xattr support", "no"); if (PHP_XATTR != "no") { EXTENSION("xattr", "xattr.c"); } http://cvs.php.net/co.php/pecl/xattr/php_xattr.h?r=1.1&p=1 Index: pecl/xattr/php_xattr.h +++ pecl/xattr/php_xattr.h /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Marcin Gibula <mg@iceni.pl> | +----------------------------------------------------------------------+ */ /* $Id: php_xattr.h,v 1.1 2004/08/13 20:46:29 mg Exp $ */ #ifndef PHP_XATTR_H #define PHP_XATTR_H extern zend_module_entry xattr_module_entry; #define phpext_xattr_ptr &xattr_module_entry #ifdef PHP_WIN32 #define PHP_XATTR_API __declspec(dllexport) #else #define PHP_XATTR_API #endif #ifdef ZTS #include "TSRM.h" #endif PHP_MINIT_FUNCTION(xattr); PHP_MINFO_FUNCTION(xattr); PHP_FUNCTION(xattr_set); PHP_FUNCTION(xattr_get); PHP_FUNCTION(xattr_remove); #endif /* PHP_XATTR_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ http://cvs.php.net/co.php/pecl/xattr/xattr.c?r=1.1&p=1 Index: pecl/xattr/xattr.c +++ pecl/xattr/xattr.c /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Marcin Gibula <mg@iceni.pl> | +----------------------------------------------------------------------+ */ /* $Id: xattr.c,v 1.1 2004/08/13 20:46:29 mg Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #define XATTR_BUFFER_SIZE 1024 #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" #include "php_xattr.h" #include <stdlib.h> #include <attr/attributes.h> #include <sys/types.h> #include <attr/xattr.h> /* {{{ xattr_functions[] * * Every user visible function must have an entry in xattr_functions[]. */ function_entry xattr_functions[] = { PHP_FE(xattr_set, NULL) PHP_FE(xattr_get, NULL) PHP_FE(xattr_remove, NULL) {NULL, NULL, NULL} /* Must be the last line in xattr_functions[] */ }; /* }}} */ /* {{{ xattr_module_entry */ zend_module_entry xattr_module_entry = { #if ZEND_MODULE_API_NO >= 20010901 STANDARD_MODULE_HEADER, #endif "xattr", xattr_functions, PHP_MINIT(xattr), NULL, NULL, NULL, PHP_MINFO(xattr), #if ZEND_MODULE_API_NO >= 20010901 "1.0", #endif STANDARD_MODULE_PROPERTIES }; /* }}} */ #ifdef COMPILE_DL_XATTR ZEND_GET_MODULE(xattr) #endif /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(xattr) { REGISTER_LONG_CONSTANT("XATTR_ROOT", ATTR_ROOT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("XATTR_DONTFOLLOW", ATTR_DONTFOLLOW, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("XATTR_CREATE", ATTR_CREATE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("XATTR_REPLACE", ATTR_REPLACE, CONST_CS | CONST_PERSISTENT); return SUCCESS; } /* }}} */ /* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION(xattr) { return SUCCESS; } /* }}} */ /* Remove if there's nothing to do at request start */ /* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION(xattr) { return SUCCESS; } /* }}} */ /* Remove if there's nothing to do at request end */ /* {{{ PHP_RSHUTDOWN_FUNCTION */ PHP_RSHUTDOWN_FUNCTION(xattr) { return SUCCESS; } /* }}} */ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(xattr) { php_info_print_table_start(); php_info_print_table_header(2, "xattr support", "enabled"); php_info_print_table_end(); } /* }}} */ /* {{{ proto bool xattr_set(string path, string name, string value [, int flags]) Set an extended attribute for a file */ PHP_FUNCTION(xattr_set) { char *attr_name = NULL; char *attr_value = NULL; char *path = NULL; int error, tmp, value_len, flags = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|l", &path, &tmp, &attr_name, &tmp, &attr_value, &value_len, &flags) == FAILURE) { return; } /* Ensure that only allowed bits are set */ flags &= ATTR_ROOT | ATTR_DONTFOLLOW | ATTR_CREATE | ATTR_REPLACE; /* Try to set an attribute and give some warning if it fails... */ error = attr_set(path, attr_name, attr_value, value_len, flags); if (error == -1) { switch (errno) { case E2BIG: php_error(E_WARNING, "%s The value of the given attribute is too large", get_active_function_name(TSRMLS_C)); break; case EPERM: case EACCES: php_error(E_WARNING, "%s Permission denied", get_active_function_name(TSRMLS_C)); break; case EOPNOTSUPP: php_error(E_WARNING, "%s Operation not supported", get_active_function_name(TSRMLS_C)); break; case ENOENT: case ENOTDIR: php_error(E_WARNING, "%s File %s doesn't exists", get_active_function_name(TSRMLS_C), path); break; } RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto string xattr_get(string path, string name [, int flags]) Return a value of an extended attribute */ PHP_FUNCTION(xattr_get) { char *attr_name = NULL; char *attr_value = NULL; char *path = NULL; int error, tmp, flags = 0; size_t buffer_size = XATTR_BUFFER_SIZE; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &path, &tmp, &attr_name, &tmp, &flags) == FAILURE) { return; } /* Ensure that only allowed bits are set */ flags &= ATTR_ROOT | ATTR_DONTFOLLOW; /* Allocate a buffer with starting size XATTR_BUFFER_SIZE bytes */ attr_value = emalloc(buffer_size); if (!attr_value) RETURN_FALSE; /* * If buffer is too small then attr_get sets errno to E2BIG and tells us * how many bytes is required by setting buffer_size variable. */ error = attr_get(path, attr_name, attr_value, &buffer_size, flags); /* * Loop is necessary in case that someone edited extended attributes * and our estimated buffer size is no longer correct. */ while (error && errno == E2BIG) { attr_value = erealloc(attr_value, buffer_size); if (!attr_value) RETURN_FALSE; error = attr_get(path, attr_name, attr_value, &buffer_size, flags); } /* Return a string if everything is ok */ if (!error) { attr_value = erealloc(attr_value, buffer_size); RETURN_STRINGL(attr_value, buffer_size, 0); } /* Error handling part */ efree(attr_value); /* Give warning for some common error conditions */ switch (errno) { case ENOATTR: break; case ENOENT: case ENOTDIR: php_error(E_WARNING, "%s File %s doesn't exists", get_active_function_name(TSRMLS_C), path); break; case EPERM: case EACCES: php_error(E_WARNING, "%s Permission denied", get_active_function_name(TSRMLS_C)); break; case EOPNOTSUPP: php_error(E_WARNING, "%s Operation not supported", get_active_function_name(TSRMLS_C)); break; } RETURN_FALSE; } /* }}} */ /* {{{ proto string xattr_get(string path, string name [, int flags]) Return a value of an extended attribute */ PHP_FUNCTION(xattr_remove) { char *attr_name = NULL; char *path = NULL; int error, tmp, flags = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &path, &tmp, &attr_name, &tmp, &flags) == FAILURE) { return; } /* Ensure that only allowed bits are set */ flags &= ATTR_ROOT | ATTR_DONTFOLLOW; /* Try to remove an attribute and give some warning if it fails... */ error = attr_remove(path, attr_name, flags); if (error == -1) { switch (errno) { case E2BIG: php_error(E_WARNING, "%s The value of the given attribute is too large", get_active_function_name(TSRMLS_C)); break; case EPERM: case EACCES: php_error(E_WARNING, "%s Permission denied", get_active_function_name(TSRMLS_C)); break; case EOPNOTSUPP: php_error(E_WARNING, "%s Operation not supported", get_active_function_name(TSRMLS_C)); break; case ENOENT: case ENOTDIR: php_error(E_WARNING, "%s File %s doesn't exists", get_active_function_name(TSRMLS_C), path); break; } RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ http://cvs.php.net/co.php/pecl/xattr/tests/001.phpt?r=1.1&p=1 Index: pecl/xattr/tests/001.phpt +++ pecl/xattr/tests/001.phpt --TEST-- Check for xattr presence --SKIPIF-- <?php if (!extension_loaded("xattr")) print "skip"; ?> --FILE-- <?php echo "xattr extension is available"; /* you can add regression tests for your extension here the output of your test code has to be equal to the text in the --EXPECT-- section below for the tests to pass, differences between the output and the expected text are interpreted as failure see php5/README.TESTING for further information on writing regression tests */ ?> --EXPECT-- xattr extension is available