cvs: pecl /tcpwrap CREDITS EXPERIMENTAL config.m4 package.xml php_tcpwrap.h tcpwrap.c tcpwrap.php /tcpwrap/tests 001.phpt

From: Date: Sun, 19 Oct 2003 21:22:37 +0000
Subject: cvs: pecl /tcpwrap CREDITS EXPERIMENTAL config.m4 package.xml php_tcpwrap.h tcpwrap.c tcpwrap.php /tcpwrap/tests 001.phpt
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-492@lists.php.net to get a copy of this message
mg Sun Oct 19 17:22:37 2003 EDT Added files: /pecl/tcpwrap CREDITS EXPERIMENTAL config.m4 package.xml php_tcpwrap.h tcpwrap.c tcpwrap.php /pecl/tcpwrap/tests 001.phpt Log: Initial release.

Index: pecl/tcpwrap/config.m4 +++ pecl/tcpwrap/config.m4 dnl $Id: config.m4,v 1.1 2003/10/19 21:22:37 mg Exp $ dnl config.m4 for extension tcpwrap PHP_ARG_WITH(tcpwrap, for tcpwrap support, [ --with-tcpwrappers Include tcpwrappers support]) if test "$PHP_TCPWRAP" != "no"; then SEARCH_PATH="/usr/local /usr" # you might want to change this SEARCH_FOR="/include/tcpd.h" # you most likely want to change this if test -r $PHP_TCPWRAP/; then # path given as parameter TCPWRAP_DIR=$PHP_TCPWRAP else # search default path list AC_MSG_CHECKING([for tcpwrappers files in default path]) for i in $SEARCH_PATH ; do if test -r $i/$SEARCH_FOR; then TCPWRAP_DIR=$i AC_MSG_RESULT(found in $i) fi done fi if test -z "$TCPWRAP_DIR"; then AC_MSG_RESULT([not found]) AC_MSG_ERROR([Please reinstall the tcpwrappers distribution]) fi PHP_ADD_INCLUDE($TCPWRAP_DIR/include) LIBNAME=wrap # you may want to change this LIBSYMBOL=request_init # you most likely want to change this PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, [ PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $TCPWRAP_DIR/lib, TCPWRAP_SHARED_LIBADD) AC_DEFINE(HAVE_TCPWRAPLIB,1,[ ]) ],[ AC_MSG_ERROR([wrong tcpwrappers lib version or lib not found]) ],[ -L$TCPWRAP_DIR/lib -lm -ldl ]) PHP_SUBST(TCPWRAP_SHARED_LIBADD) PHP_NEW_EXTENSION(tcpwrap, tcpwrap.c, $ext_shared) fi Index: pecl/tcpwrap/package.xml +++ pecl/tcpwrap/package.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <!-- do not use the "Type" attribute here, that one is only for generated package.xml files --> <package> <name>tcpwrap</name> <summary>Provides binding to tcpwrappers</summary> <status>beta</status> <maintainers> <maintainer> <user>mg</user> <name>Marcin Gibula</name> <email>mg@php.net</email> </maintainer> </maintainers> <release> <version>0.1</version> <date>2001-11-30</date> <notes> - First offical PEAR/PECL release </notes> </release> <filelist> <dir role="source" name="/" baseinstalldir="tcpwrap"> <file>CREDITS</file> <file>EXPERIMENTAL</file> <file>TODO</file> <file>Makefile.in</file> <file>config.m4</file> <file>tcpwrap.c</file> <file>tcpwrap.php</file> <file>php_tcpwrap.h</file> </dir> </filelist> </package> Index: pecl/tcpwrap/php_tcpwrap.h +++ pecl/tcpwrap/php_tcpwrap.h /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2003 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.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_tcpwrap.h,v 1.1 2003/10/19 21:22:37 mg Exp $ */ #ifndef PHP_TCPWRAP_H #define PHP_TCPWRAP_H extern zend_module_entry tcpwrap_module_entry; #define phpext_tcpwrap_ptr &tcpwrap_module_entry #ifdef PHP_WIN32 #define PHP_TCPWRAP_API __declspec(dllexport) #else #define PHP_TCPWRAP_API #endif #ifdef ZTS #include "TSRM.h" #endif PHP_MINFO_FUNCTION(tcpwrap); PHP_FUNCTION(tcpwrap_check); #endif /* PHP_TCPWRAP_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: t * End: */ Index: pecl/tcpwrap/tcpwrap.c +++ pecl/tcpwrap/tcpwrap.c /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2003 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.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: | +----------------------------------------------------------------------+ $Id: tcpwrap.c,v 1.1 2003/10/19 21:22:37 mg Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" #include "php_tcpwrap.h" #include <tcpd.h> #include <netinet/in.h> #include <netdb.h> #include <arpa/inet.h> int allow_severity = 0; int deny_severity = 0; /* {{{ tcpwrap_functions[] * * Every user visible function must have an entry in tcpwrap_functions[]. */ function_entry tcpwrap_functions[] = { PHP_FE(tcpwrap_check, NULL) /* For testing, remove later. */ {NULL, NULL, NULL} /* Must be the last line in tcpwrap_functions[] */ }; /* }}} */ /* {{{ tcpwrap_module_entry */ zend_module_entry tcpwrap_module_entry = { #if ZEND_MODULE_API_NO >= 20010901 STANDARD_MODULE_HEADER, #endif "tcpwrap", tcpwrap_functions, NULL, NULL, NULL, NULL, PHP_MINFO(tcpwrap), #if ZEND_MODULE_API_NO >= 20010901 "0.1", /* Replace with version number for your extension */ #endif STANDARD_MODULE_PROPERTIES }; /* }}} */ #ifdef COMPILE_DL_TCPWRAP ZEND_GET_MODULE(tcpwrap) #endif /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(tcpwrap) { php_info_print_table_start(); php_info_print_table_row(2, "tcp wrappers support", "enabled"); php_info_print_table_end(); } /* }}} */ /* {{{ proto bool tcpwrap_check(string daemon, string address [, string user]) Check if client has access according to tcp wrappers table */ PHP_FUNCTION(tcpwrap_check) { int argc, retval; char *daemon, *ip, *address, *user = NULL; int daemon_l, address_l, user_l; struct in_addr tmp; struct hostent *host_entry; argc = ZEND_NUM_ARGS(); switch (argc) { case 2: if (zend_parse_parameters(argc TSRMLS_CC, "ss", &daemon, &daemon_l, &address, &address_l) == FAILURE) { return; } break; case 3: if (zend_parse_parameters(argc TSRMLS_CC, "sss", &daemon, &daemon_l, &address, &address_l, &user, &user_l) == FAILURE) { return; } break; default: WRONG_PARAM_COUNT; } if (!user) { user = STRING_UNKNOWN; } if (inet_aton(address, &tmp)) { ip = address; address = STRING_UNKNOWN; } else { if (!(host_entry = gethostbyname(address))) { php_error(E_WARNING, "%s Host lookup failed", get_active_function_name(TSRMLS_C)); RETURN_FALSE; } memcpy(&tmp.s_addr, *(host_entry->h_addr_list), sizeof(tmp.s_addr)); ip = inet_ntoa(tmp); } retval = hosts_ctl(daemon, address, ip, user); if (!retval) { 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 */ Index: pecl/tcpwrap/tcpwrap.php +++ pecl/tcpwrap/tcpwrap.php <? if(!extension_loaded('tcpwrap')) { dl('tcpwrap.' . PHP_SHLIB_SUFFIX); } $module = 'tcpwrap'; $functions = get_extension_funcs($module); echo "Functions available in the test extension:<br>\n"; foreach($functions as $func) { echo $func."<br>\n"; } echo "<br>\n"; $function = 'confirm_' . $module . '_compiled'; if (extension_loaded($module)) { $str = $function($module); } else { $str = "Module $module is not compiled into PHP"; } echo "$str\n"; ?> Index: pecl/tcpwrap/tests/001.phpt +++ pecl/tcpwrap/tests/001.phpt --TEST-- Check for tcpwrap presence --SKIPIF-- <?php if (!extension_loaded("tcpwrap")) print "skip"; ?> --POST-- --GET-- --INI-- --FILE-- <?php echo "tcpwrap 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 php4/README.TESTING for further information on writing regression tests */ ?> --EXPECT-- tcpwrap extension is available
« previous php.pecl.cvs (#492) next »