pax_global_header00006660000000000000000000000064114310206070014504gustar00rootroot0000000000000052 comment=132cad613fc0181029ab9cebf071653ea7e40244 php5-array2arraymap-sdb-0.12/000075500000000000000000000000001143102060700160015ustar00rootroot00000000000000php5-array2arraymap-sdb-0.12/.gear-rules000064400000000000000000000001101143102060700200400ustar00rootroot00000000000000copy: php-array2arraymap* tar: . name=php5-array2arraymap-sdb-@version@ php5-array2arraymap-sdb-0.12/.gitignore000064400000000000000000000005571143102060700200000ustar00rootroot00000000000000.deps *.lo *.la acinclude.m4 aclocal.m4 autom4te.cache build config.h config.log config.nice config.status config.guess config.h.in config.sub configure configure.in install-sh ltmain.sh libtool .libs Makefile Makefile.fragments Makefile.global Makefile.objects missing mkinstalldirs modules run-tests.php tests/*.diff tests/*.exp tests/*.log tests/*.out tests/*.php php5-array2arraymap-sdb-0.12/C000075500000000000000000000001201143102060700161020ustar00rootroot00000000000000phpize && ./configure&& ln -s /usr/lib64/php/5.*/extensions/suhosin.so modules/ php5-array2arraymap-sdb-0.12/CREDITS000064400000000000000000000000221143102060700170130ustar00rootroot00000000000000array2arraymap_sdbphp5-array2arraymap-sdb-0.12/EXPERIMENTAL000064400000000000000000000000001143102060700176070ustar00rootroot00000000000000php5-array2arraymap-sdb-0.12/R000075500000000000000000000000301143102060700161210ustar00rootroot00000000000000rm -rf `cat .gitignore` php5-array2arraymap-sdb-0.12/array2arraymap_sdb.c000064400000000000000000000411121143102060700217310ustar00rootroot00000000000000 #ifdef HAVE_CONFIG_H #include "config.h" #endif extern "C" { #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" } #include "php_array2arraymap_sdb.h" /* If you declare any globals in php_array2arraymap_sdb.h uncomment this: ZEND_DECLARE_MODULE_GLOBALS(array2arraymap_sdb) */ /* True global resources - no need for thread safety here */ static int le_array2arraymap_sdb; /* {{{ array2arraymap_sdb_functions[] * * Every user visible function must have an entry in array2arraymap_sdb_functions[]. */ zend_function_entry array2arraymap_sdb_functions[] = { PHP_FE(array2arraymap_sdb_open, NULL) PHP_FE(array2arraymap_sdb_type, NULL) PHP_FE(array2arraymap_sdb_get, NULL) PHP_FE(array2arraymap_sdb_find, NULL) PHP_FE(array2arraymap_sdb_find_pair, NULL) PHP_FE(array2arraymap_sdb_find_pair_by_prefix, NULL) PHP_FE(array2arraymap_sdb_exists_at, NULL) PHP_FE(confirm_array2arraymap_sdb_compiled, NULL) /* For testing, remove later. */ {NULL, NULL, NULL} /* Must be the last line in array2arraymap_sdb_functions[] */ }; /* }}} */ /* {{{ array2arraymap_sdb_module_entry */ zend_module_entry array2arraymap_sdb_module_entry = { #if ZEND_MODULE_API_NO >= 20010901 STANDARD_MODULE_HEADER, #endif "array2arraymap_sdb", array2arraymap_sdb_functions, PHP_MINIT(array2arraymap_sdb), PHP_MSHUTDOWN(array2arraymap_sdb), NULL, /* PHP_RINIT(array2arraymap_sdb), /* Replace with NULL if there's nothing to do at request start */ NULL, /* PHP_RSHUTDOWN(array2arraymap_sdb), /* Replace with NULL if there's nothing to do at request end */ PHP_MINFO(array2arraymap_sdb), #if ZEND_MODULE_API_NO >= 20010901 "0.1", /* Replace with version number for your extension */ #endif STANDARD_MODULE_PROPERTIES }; /* }}} */ #ifdef COMPILE_DL_ARRAY2ARRAYMAP_SDB BEGIN_EXTERN_C() ZEND_GET_MODULE(array2arraymap_sdb) END_EXTERN_C() #endif /* {{{ PHP_INI */ /* Remove comments and fill if you need to have entries in php.ini PHP_INI_BEGIN() STD_PHP_INI_ENTRY("array2arraymap_sdb.global_value", "42", PHP_INI_ALL, OnUpdateLong, global_value, zend_array2arraymap_sdb_globals, array2arraymap_sdb_globals) STD_PHP_INI_ENTRY("array2arraymap_sdb.global_string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_array2arraymap_sdb_globals, array2arraymap_sdb_globals) PHP_INI_END() */ /* }}} */ /* {{{ php_array2arraymap_sdb_init_globals */ /* Uncomment this function if you have INI entries static void php_array2arraymap_sdb_init_globals(zend_array2arraymap_sdb_globals *array2arraymap_sdb_globals) { array2arraymap_sdb_globals->global_value = 0; array2arraymap_sdb_globals->global_string = NULL; } */ /* }}} */ /* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION(array2arraymap_sdb) { /* uncomment this line if you have INI entries UNREGISTER_INI_ENTRIES(); */ return SUCCESS; } /* }}} */ /* Remove if there's nothing to do at request start */ /* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION(array2arraymap_sdb) { return SUCCESS; } /* }}} */ /* Remove if there's nothing to do at request end */ /* {{{ PHP_RSHUTDOWN_FUNCTION */ PHP_RSHUTDOWN_FUNCTION(array2arraymap_sdb) { return SUCCESS; } /* }}} */ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(array2arraymap_sdb) { php_info_print_table_start(); php_info_print_table_header(2, "array2arraymap_sdb support", "enabled"); php_info_print_table_end(); /* Remove comments if you have entries in php.ini DISPLAY_INI_ENTRIES(); */ } /* }}} */ /*---------------------------------------------------*/ #include /* Resource struct, not the object :) */ /* Extends zend object */ typedef struct _ze_sdb_object { zend_object zo; SDB *sdb_ptr; } ze_sdb_object; // hack #define sdb_object SDB static zend_class_entry *sdb_class_entry_ce; static void sdb_free_resource_ptr(sdb_object *intern TSRMLS_DC); /* {{{ sdb_object_free_storage */ static void sdb_free_resource_ptr(sdb_object *intern TSRMLS_DC) { if (intern) { delete(intern); } } /* }}} */ #ifdef ZEND_ENGINE_2 /* {{{ SDB_FROM_OBJECT */ #define SDB_FROM_OBJECT(intern, object) \ { \ ze_sdb_object *obj = (ze_sdb_object*) zend_object_store_get_object(object TSRMLS_CC); \ intern = obj->sdb_ptr; \ if (!intern) { \ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid or unitialized SDB object"); \ RETURN_FALSE; \ } \ } /* }}} */ static zend_object_handlers sdb_object_handlers; /* {{{ sdb_object_free_storage */ static void sdb_object_free_storage(void *object TSRMLS_DC) { ze_sdb_object * intern = (ze_sdb_object *) object; if (!intern) { return; } if (intern->sdb_ptr) { sdb_free_resource_ptr(intern->sdb_ptr TSRMLS_CC); } intern->sdb_ptr = NULL; zend_object_std_dtor(&intern->zo TSRMLS_CC); efree(intern); } /* }}} */ /* {{{ sdb_object_new */ static zend_object_value sdb_object_new(zend_class_entry *class_type TSRMLS_DC) { ze_sdb_object *intern; zval *tmp; zend_object_value retval; intern = (ze_sdb_object*) emalloc(sizeof(ze_sdb_object)); memset(&intern->zo, 0, sizeof(zend_object)); intern->sdb_ptr = NULL; zend_object_std_init(&intern->zo, class_type TSRMLS_CC); zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t) sdb_object_free_storage, NULL TSRMLS_CC); retval.handlers = (zend_object_handlers *) & sdb_object_handlers; return retval; } /* }}} */ #endif #ifdef ZEND_ENGINE_2 /* {{{ sdb_class_functions */ static zend_function_entry array2arraymap_sdb_class_functions[] = { PHP_ME_MAPPING(open, array2arraymap_sdb_open, NULL, 0) PHP_ME_MAPPING(type, array2arraymap_sdb_type, NULL, 0) PHP_ME_MAPPING(get, array2arraymap_sdb_get, NULL, 0) PHP_ME_MAPPING(find, array2arraymap_sdb_find, NULL, 0) PHP_ME_MAPPING(find_pair, array2arraymap_sdb_find_pair, NULL, 0) PHP_ME_MAPPING(find_pair_by_prefix, array2arraymap_sdb_find_pair_by_prefix, NULL, 0) PHP_ME_MAPPING(exists_at, array2arraymap_sdb_exists_at, NULL, 0) {NULL, NULL, NULL} }; /* }}} */ #endif /* {{{ proto resource array2arraymap_sdb_open() Create new array2arraymap_sdb from file */ static PHP_FUNCTION(array2arraymap_sdb_open) { sdb_object *intern; zval *php_this = getThis(); ze_sdb_object *ze_obj = NULL; char *name; int name_len; if (php_this) { /* We do not use SDB_FROM_OBJECT, sdb init function here */ ze_obj = (ze_sdb_object*) zend_object_store_get_object(php_this TSRMLS_CC); } else RETURN_FALSE; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { RETURN_NULL(); } //php_printf("Hello %s ", name); //intern = emalloc(sizeof(sdb_object)); try { intern = new SDB(name); if (php_this) { ze_obj->sdb_ptr = intern; RETURN_TRUE; } } catch (sdb_error e) { // todo: some error messaging here std::cerr << e.what() << '\n'; } RETURN_FALSE; } /* }}} */ // C++ hacks //define Z_LVAL_P(zval) (*zval).value.lval /* can't inline; require ZEND_FUNCTION expanded */ /* inline void free_path(zval** parameter_array[]) { if (parameter_array!=NULL) efree(parameter_array); } inline zval** *get_parameter_array(long argument_count) { zval ** *parameter_array = (zval***) ecalloc(argument_count, sizeof(zval **)); if(zend_get_parameters_array_ex(argument_count, parameter_array) != SUCCESS) return NULL; return parameter_array; } */ /* can't inline; require ZEND_FUNCTION expanded */ /* proto: zval** get_path(sdb_object* intern); */ #define get_path(intern) \ zval ** *parameter_array; \ zval ** cur_zval; \ /* get the number of arguments */ \ long argument_count = ZEND_NUM_ARGS(); \ if(argument_count == 0) WRONG_PARAM_COUNT; \ \ /* argument count is correct, now retrieve arguments */ \ parameter_array = (zval***) ecalloc(argument_count, sizeof(zval **)); \ if(zend_get_parameters_array_ex(argument_count, parameter_array) != SUCCESS) \ WRONG_PARAM_COUNT; \ if (parameter_array==NULL) WRONG_PARAM_COUNT; \ intern->reset(); \ if (IS_ARRAY==Z_TYPE_PP(parameter_array[0])) { \ HashPosition pointer; \ HashTable *arr_hash = Z_ARRVAL_PP(parameter_array[0]); \ long array_count = zend_hash_num_elements(arr_hash); \ for(zend_hash_internal_pointer_reset_ex(arr_hash, &pointer); (zend_hash_get_current_data_ex(arr_hash, (void**) &cur_zval, &pointer) == SUCCESS) && (array_count > 1); zend_hash_move_forward_ex(arr_hash, &pointer)) { \ convert_to_long_ex(cur_zval); \ intern->set_next(Z_LVAL_P(*cur_zval)); \ array_count--; \ } \ zend_hash_get_current_data_ex(arr_hash, (void**) &cur_zval, &pointer); \ } else { \ for (int i = 0; i < argument_count-1; i++) { \ cur_zval = parameter_array[i]; \ convert_to_long_ex(cur_zval); \ intern->set_next(Z_LVAL_P(*cur_zval)); \ } \ cur_zval = parameter_array[argument_count-1]; \ } \ // } //return cur_zval; typedef void (ZVAL_CREATOR_NUM)(zval* array, large_int num, const char* top); void creator_iv (zval* array, large_int i, const char* top) { add_next_index_long(array, i); } void creator_pv (zval* array, large_int i, const char* top) { const char *str = top + i; add_next_index_string(array, (char*) str, 1); } inline void wrap_val(table < noid_type,noid_type >& tbl, std::pair p, zval *results, ZVAL_CREATOR_NUM key_creator,ZVAL_CREATOR_NUM val_creator, bool pair = false) { const char* top = tbl.get_data_offset(); for (num_iter cur = p.first; cur !=p.second; ++cur) { if(pair) key_creator(results, cur.get_key(), top); val_creator(results, cur.get_val(), top); } } inline void map_int(table < noid_type,noid_type >& tbl, large_int n, zval *results, ZVAL_CREATOR_NUM key_creator,ZVAL_CREATOR_NUM val_creator, bool pair = false) { wrap_val(tbl, num_iter::map_numeric_key(&tbl, n), results, key_creator, val_creator, pair); } inline void map_str(table < noid_type,noid_type >& tbl, char* str, zval *results, ZVAL_CREATOR_NUM key_creator,ZVAL_CREATOR_NUM val_creator, bool pair = false, NodeConst::comparison_type tt = NodeConst::FULL) { wrap_val(tbl, num_iter::map_string_key(&tbl, str, tt), results, key_creator, val_creator, pair); } ZVAL_CREATOR_NUM* choose_creator(NodeConst::TYPE type) { switch (type) { case NodeConst::INT4: case NodeConst::INT8: return &creator_iv; break; case NodeConst::STRING4: return &creator_pv; break; case NodeConst::CONTEXT4: case NodeConst::CONTEXT8: throw sdb_error_incomplete_path(); default: fprintf(stderr, "can't find value creator for Type %d !\n", type); throw sdb_error("can't find value creator for Type"); } return &creator_iv; } large_int convert_sv_to_num (zval* val, NodeConst::TYPE type) { switch (type) { case NodeConst::INT4: case NodeConst::INT8: return Z_LVAL_P(val); break; case NodeConst::STRING4: default: fprintf(stderr, "internal error: unknown type %d for convert_sv_to_num !\n", type); throw sdb_error("internal error: unknown type for convert_sv_to_num !"); } return 0; } void map_common (table < noid_type,noid_type > tbl, zval* key, zval *results, bool is_pair = false, NodeConst::comparison_type tt = NodeConst::PREFIX) { NodeConst::TYPE keytype = tbl.get_keytype(); NodeConst::TYPE valtype = tbl.get_valtype(); ZVAL_CREATOR_NUM* key_creator = choose_creator(keytype); ZVAL_CREATOR_NUM* val_creator = choose_creator(valtype); switch (keytype) { case NodeConst::INT4: case NodeConst::INT8: map_int(tbl, convert_sv_to_num(key, keytype), results, *key_creator, *val_creator, is_pair); break; case NodeConst::STRING4: map_str(tbl, Z_STRVAL_P(key), results, *key_creator, *val_creator, is_pair, tt); break; default: fprintf(stderr, "Type %d is not supported in map_common!\n", keytype); } } void find_common (SDB *THIS, zval* key, zval *results, bool is_pair = false, NodeConst::comparison_type tt = NodeConst::FULL) { map_common (THIS->current()->get_find_map(), key, results, is_pair, tt); } /* ######################################################################### */ /* {{{ proto string sdb_type(SDB sdb, path[]) generic SDB func template */ static PHP_FUNCTION(array2arraymap_sdb_type) { sdb_object *intern; int retval; zval *php_this = getThis(); if (php_this) { SDB_FROM_OBJECT(intern, php_this); } if (intern) { try { get_path(intern); intern->set_next(Z_LVAL_P(*cur_zval)); RETURN_STRING((char*) NodeConst::get_type_name(intern->current()->get_valtype()), 1); } catch (sdb_error_no_path e) { RETURN_FALSE; } } RETURN_FALSE; } /* }}} */ /* {{{ proto array sdb_bla_bla(SDB sdb, path[]) generic SDB func template */ static PHP_FUNCTION(array2arraymap_sdb_get) { sdb_object *intern; int retval; zval *php_this = getThis(); if (php_this) { SDB_FROM_OBJECT(intern, php_this); } if (intern) { array_init(return_value); try { get_path(intern); map_common (intern->current()->get_get_map(), *cur_zval, return_value); } catch (sdb_error_no_path e) { } catch (sdb_error_incomplete_path e) { std::cerr << e.what() << '\n'; } } } /* }}} */ /* {{{ proto array sdb_bla_bla(SDB sdb, path[]) generic SDB func template */ static PHP_FUNCTION(array2arraymap_sdb_find) { sdb_object *intern; int retval; zval *php_this = getThis(); if (php_this) { SDB_FROM_OBJECT(intern, php_this); } if (intern) { array_init(return_value); try { get_path(intern); find_common (intern, *cur_zval, return_value, false); } catch (sdb_error_no_path e) { } catch (sdb_error_incomplete_path e) { std::cerr << e.what() << '\n'; } } } /* }}} */ /* {{{ proto array sdb_bla_bla(SDB sdb, path[]) generic SDB func template */ static PHP_FUNCTION(array2arraymap_sdb_find_pair) { sdb_object *intern; int retval; zval *php_this = getThis(); if (php_this) { SDB_FROM_OBJECT(intern, php_this); } if (intern) { array_init(return_value); try { get_path(intern); find_common (intern, *cur_zval, return_value, true); } catch (sdb_error_no_path e) { } catch (sdb_error_incomplete_path e) { std::cerr << e.what() << '\n'; } } } /* }}} */ /* {{{ proto array sdb_bla_bla(SDB sdb, path[]) generic SDB func template */ static PHP_FUNCTION(array2arraymap_sdb_find_pair_by_prefix) { sdb_object *intern; int retval; zval *php_this = getThis(); if (php_this) { SDB_FROM_OBJECT(intern, php_this); } if (intern) { array_init(return_value); try { get_path(intern); find_common (intern, *cur_zval, return_value, true, NodeConst::PREFIX); } catch (sdb_error_no_path e) { } catch (sdb_error_incomplete_path e) { std::cerr << e.what() << '\n'; } } } /* }}} */ /* {{{ proto array sdb_bla_bla(SDB sdb, path[]) generic SDB func template */ static PHP_FUNCTION(array2arraymap_sdb_exists_at) { sdb_object *intern; int retval; zval *php_this = getThis(); long noid = 0; int argc = ZEND_NUM_ARGS( ); if (zend_parse_parameters(argc TSRMLS_CC, "l", &noid) == FAILURE) RETURN_FALSE; if (php_this) { SDB_FROM_OBJECT(intern, php_this); } if (intern) { intern->reset(); if (intern->exists_at(noid)) RETURN_TRUE else RETURN_FALSE; } } /* }}} */ /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(array2arraymap_sdb) { zend_class_entry ce; memcpy(&sdb_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); sdb_object_handlers.clone_obj = NULL; INIT_CLASS_ENTRY(ce, "SDB", array2arraymap_sdb_class_functions); ce.create_object = sdb_object_new; sdb_class_entry_ce = zend_register_internal_class(&ce TSRMLS_CC); return SUCCESS; } /* }}} */ /*---------------------------------------------------*/ /* Remove the following function when you have succesfully modified config.m4 so that your module can be compiled into PHP, it exists only for testing purposes. */ /* Every user-visible function in PHP should document itself in the source */ /* {{{ proto string confirm_array2arraymap_sdb_compiled(string arg) Return a string to confirm that the module is compiled in */ PHP_FUNCTION(confirm_array2arraymap_sdb_compiled) { char *arg = NULL; int arg_len, len; char *strg; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { return; } len = spprintf(&strg, 0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "array2arraymap_sdb", arg); RETURN_STRINGL(strg, len, 0); } /* }}} */ /* The previous line is meant for vim and emacs, so it can correctly fold and unfold functions in source code. See the corresponding marks just before function definition, where the functions purpose is also documented. Please follow this convention for the convenience of others editing your code. */ /* * 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 */ php5-array2arraymap-sdb-0.12/array2arraymap_sdb.php000064400000000000000000000010321143102060700222730ustar00rootroot00000000000000"; if(!extension_loaded('array2arraymap_sdb')) { dl('array2arraymap_sdb.' . PHP_SHLIB_SUFFIX); } $module = 'array2arraymap_sdb'; $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"; ?> php5-array2arraymap-sdb-0.12/config.m4000064400000000000000000000050201143102060700175050ustar00rootroot00000000000000dnl $Id$ dnl config.m4 for extension array2arraymap_sdb dnl Comments in this file start with the string 'dnl'. dnl Remove where necessary. This file will not work dnl without editing. dnl If your extension references something external, use with: PHP_ARG_WITH(array2arraymap_sdb, for array2arraymap_sdb support, [ --with-array2arraymap_sdb Include array2arraymap_sdb support]) dnl Otherwise use enable: dnl PHP_ARG_ENABLE(array2arraymap_sdb, whether to enable array2arraymap_sdb support, dnl Make sure that the comment is aligned: dnl [ --enable-array2arraymap_sdb Enable array2arraymap_sdb support]) if test "$PHP_ARRAY2ARRAYMAP_SDB" != "no"; then dnl stdc++ moved from here dnl Write more examples of tests here... dnl # --with-array2arraymap_sdb -> check with-path dnl SEARCH_PATH="/usr/local /usr" # you might want to change this dnl SEARCH_FOR="/include/array2arraymap_sdb.h" # you most likely want to change this dnl if test -r $PHP_ARRAY2ARRAYMAP_SDB/$SEARCH_FOR; then # path given as parameter dnl ARRAY2ARRAYMAP_SDB_DIR=$PHP_ARRAY2ARRAYMAP_SDB dnl else # search default path list dnl AC_MSG_CHECKING([for array2arraymap_sdb files in default path]) dnl for i in $SEARCH_PATH ; do dnl if test -r $i/$SEARCH_FOR; then dnl ARRAY2ARRAYMAP_SDB_DIR=$i dnl AC_MSG_RESULT(found in $i) dnl fi dnl done dnl fi dnl dnl if test -z "$ARRAY2ARRAYMAP_SDB_DIR"; then dnl AC_MSG_RESULT([not found]) dnl AC_MSG_ERROR([Please reinstall the array2arraymap_sdb distribution]) dnl fi dnl # --with-array2arraymap_sdb -> add include path dnl PHP_ADD_INCLUDE($ARRAY2ARRAYMAP_SDB_DIR/include) dnl # --with-array2arraymap_sdb -> check for lib and symbol presence dnl LIBNAME=array2arraymap_sdb # you may want to change this dnl LIBSYMBOL=array2arraymap_sdb # you most likely want to change this dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, dnl [ dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $ARRAY2ARRAYMAP_SDB_DIR/lib, ARRAY2ARRAYMAP_SDB_SHARED_LIBADD) dnl AC_DEFINE(HAVE_ARRAY2ARRAYMAP_SDBLIB,1,[ ]) dnl ],[ dnl AC_MSG_ERROR([wrong array2arraymap_sdb lib version or lib not found]) dnl ],[ dnl -L$ARRAY2ARRAYMAP_SDB_DIR/lib -lm -ldl dnl ]) dnl dnl PHP_SUBST(ARRAY2ARRAYMAP_SDB_SHARED_LIBADD) PHP_REQUIRE_CXX() dnl C++ PHP_ADD_LIBRARY(stdc++, 1, ARRAY2ARRAYMAP_SDB_SHARED_LIBADD) PHP_NEW_EXTENSION(array2arraymap_sdb, array2arraymap_sdb.c, $ext_shared,,,1) PHP_SUBST(ARRAY2ARRAYMAP_SDB_SHARED_LIBADD) dnl PHP_ADD_LIBRARY(stdc++) fi php5-array2arraymap-sdb-0.12/config.w32000064400000000000000000000005711143102060700176060ustar00rootroot00000000000000// $Id$ // vim:ft=javascript // If your extension references something external, use ARG_WITH ARG_WITH("array2arraymap_sdb", "for array2arraymap_sdb support", "no"); // Otherwise, use ARG_ENABLE // ARG_ENABLE("array2arraymap_sdb", "enable array2arraymap_sdb support", "no"); if (PHP_ARRAY2ARRAYMAP_SDB != "no") { EXTENSION("array2arraymap_sdb", "array2arraymap_sdb.c"); } php5-array2arraymap-sdb-0.12/php-array2arraymap-sdb-params.sh000075500000000000000000000000541143102060700241100ustar00rootroot00000000000000file_ini=array2arraymap_sdb.ini exceptions= php5-array2arraymap-sdb-0.12/php-array2arraymap-sdb.ini000064400000000000000000000001111143102060700227630ustar00rootroot00000000000000extension=array2arraymap_sdb.so [array2arraymap_sdb] ; nothing is used. php5-array2arraymap-sdb-0.12/php5-array2arraymap-sdb.spec000064400000000000000000000051401143102060700232320ustar00rootroot00000000000000%define php5_extension array2arraymap-sdb Name: php5-%php5_extension Version: 0.12 Release: alt5.M51.1 Summary: php5 module to access static db (SDB) files. Group: System/Servers License: PHP License Packager: Igor Vlasenko Source0: %name-%version.tar Source1: php-%php5_extension.ini Source2: php-%php5_extension-params.sh BuildRequires(pre): rpm-build-php5 BuildRequires: php5-devel = %php5_version BuildRequires: libmapsdb-devel >= 0.11 gcc-c++ libstdc++-devel # for make test BuildRequires: php5-suhosin %description %{summary} %prep %setup -q %build phpize BUILD_HAVE=`echo %php5_extension | tr '[:lower:]-' '[:upper:]_'` %add_optflags -fPIC -L%_libdir export LDFLAGS=-lphp-%_php5_version ./configure \ --enable-%php5_extension %php5_make CC=g++ %install # hack ... # ln -s %_libdir/php/%_php5_version/extensions/suhosin.so modules/ %php5_make_install install -D -m 644 %SOURCE1 %buildroot/%php5_extconf/%php5_extension/config install -D -m 644 %SOURCE2 %buildroot/%php5_extconf/%php5_extension/params %files %php5_extconf/%php5_extension %php5_extdir/* %doc CREDITS %post %php5_extension_postin %preun %php5_extension_preun %changelog * Thu Aug 12 2010 Dmitriy Kulik 0.12-alt5.M51.1 - Bould for branch 5.1 * Thu Aug 05 2010 Anton Farygin 0.12-alt6 - rebuild with new php5-5.2.14.20100721-alt1 * Tue Mar 09 2010 Anton Farygin 0.12-alt5 - Rebuild with php5-5.2.13.20100205-alt1 * Thu Feb 18 2010 Igor Vlasenko 0.12-alt4 - re-release with win32 fixes * Wed Feb 17 2010 Anton Farygin 0.12-alt3.4 - Rebuild with php5-5.2.12.20091216-alt5 * Mon Feb 01 2010 Anton Farygin 0.12-alt3.3 - Rebuild with php5-5.2.12.20091216-alt4 * Thu Jan 28 2010 Anton Farygin 0.12-alt3.2 - Rebuild with php5-5.2.12.20091216-alt1 * Fri Jul 24 2009 Alexey Gladkov 0.12-alt3.1.1.1 - NMU: Rebuild with php5-5.2.11.20090722-alt1. * Tue Feb 10 2009 Alexey Gladkov 0.12-alt3.1.1 - NMU: Rebuild with php5-5.2.9.20090205-alt1. * Tue Oct 21 2008 Igor Vlasenko 0.12-alt3.1 - rebuild with new php * Tue Sep 16 2008 Igor Vlasenko 0.12-alt3 - rebuild with new php * Wed May 14 2008 Igor Vlasenko 0.12-alt2 - rebuild with new php * Tue Oct 02 2007 Igor Vlasenko 0.12-alt1 - built against libmapsdb 0.12 * Mon Sep 24 2007 Igor Vlasenko 0.11-alt1 - built against libmapsdb 0.11 * Mon Aug 06 2007 Igor Vlasenko 0.10-alt1 - first Sisyphus version; php5-array2arraymap-sdb-0.12/php_array2arraymap_sdb.h000064400000000000000000000037341143102060700226150ustar00rootroot00000000000000 #ifndef PHP_ARRAY2ARRAYMAP_SDB_H #define PHP_ARRAY2ARRAYMAP_SDB_H extern zend_module_entry array2arraymap_sdb_module_entry; #define phpext_array2arraymap_sdb_ptr &array2arraymap_sdb_module_entry #ifdef PHP_WIN32 #define PHP_ARRAY2ARRAYMAP_SDB_API __declspec(dllexport) #else #define PHP_ARRAY2ARRAYMAP_SDB_API #endif #ifdef ZTS #include "TSRM.h" #endif PHP_MINIT_FUNCTION(array2arraymap_sdb); PHP_MSHUTDOWN_FUNCTION(array2arraymap_sdb); //PHP_RINIT_FUNCTION(array2arraymap_sdb); //PHP_RSHUTDOWN_FUNCTION(array2arraymap_sdb); PHP_MINFO_FUNCTION(array2arraymap_sdb); PHP_FUNCTION(confirm_array2arraymap_sdb_compiled); /* For testing, remove later. */ static PHP_FUNCTION(array2arraymap_sdb_open); static PHP_FUNCTION(array2arraymap_sdb_type); static PHP_FUNCTION(array2arraymap_sdb_get); static PHP_FUNCTION(array2arraymap_sdb_find); static PHP_FUNCTION(array2arraymap_sdb_find_pair); static PHP_FUNCTION(array2arraymap_sdb_find_pair_by_prefix); static PHP_FUNCTION(array2arraymap_sdb_exists_at); /* Declare any global variables you may need between the BEGIN and END macros here: ZEND_BEGIN_MODULE_GLOBALS(array2arraymap_sdb) long global_value; char *global_string; ZEND_END_MODULE_GLOBALS(array2arraymap_sdb) */ /* In every utility function you add that needs to use variables in php_array2arraymap_sdb_globals, call TSRMLS_FETCH(); after declaring other variables used by that function, or better yet, pass in TSRMLS_CC after the last function argument and declare your utility function with TSRMLS_DC after the last declared argument. Always refer to the globals in your function as ARRAY2ARRAYMAP_SDB_G(variable). You are encouraged to rename these macros something shorter, see examples in any other php module directory. */ #ifdef ZTS #define ARRAY2ARRAYMAP_SDB_G(v) TSRMG(array2arraymap_sdb_globals_id, zend_array2arraymap_sdb_globals *, v) #else #define ARRAY2ARRAYMAP_SDB_G(v) (array2arraymap_sdb_globals.v) #endif #endif /* PHP_ARRAY2ARRAYMAP_SDB_H */ php5-array2arraymap-sdb-0.12/tests/000075500000000000000000000000001143102060700171435ustar00rootroot00000000000000php5-array2arraymap-sdb-0.12/tests/001.phpt000064400000000000000000000011151143102060700203360ustar00rootroot00000000000000--TEST-- Check for array2arraymap_sdb presence --SKIPIF-- --FILE-- --EXPECT-- array2arraymap_sdb extension is available php5-array2arraymap-sdb-0.12/tests/OO_001.phpt000064400000000000000000000003431143102060700207350ustar00rootroot00000000000000--TEST-- SDB: new (create) --SKIPIF-- --FILE-- ===DONE=== --EXPECT-- created ===DONE=== php5-array2arraymap-sdb-0.12/tests/OO_002.phpt000064400000000000000000000004051143102060700207350ustar00rootroot00000000000000--TEST-- SDB: open --SKIPIF-- --FILE-- open("proba.sdb"); echo "\n"; ?> ===DONE=== --EXPECT-- created 1 ===DONE=== php5-array2arraymap-sdb-0.12/tests/OO_003.phpt000064400000000000000000000006441143102060700207430ustar00rootroot00000000000000--TEST-- SDB: type --SKIPIF-- --FILE-- open("proba.sdb"); echo $sdb->type(100); echo "-"; echo $sdb->type(2026); echo "-"; echo $sdb->type(2028); echo "-"; echo $sdb->type(102); echo "-"; //unset($sdb); echo "\n"; ?> ===DONE=== --EXPECT-- created STRING4-INT4-INT4-- ===DONE=== php5-array2arraymap-sdb-0.12/tests/OO_004.phpt000064400000000000000000000006041143102060700207400ustar00rootroot00000000000000--TEST-- SDB: get --SKIPIF-- --FILE-- open("proba.sdb"); $a=$sdb->get(100,1); echo $a[0]; echo "-"; $a=$sdb->find(2026,4); echo $a[0], ",",$a[1], ",",$a[2]; echo "-"; echo "\n"; ?> ===DONE=== --EXPECT-- created aaagdfbnn-456,555,565- ===DONE=== php5-array2arraymap-sdb-0.12/tests/OO_005.phpt000064400000000000000000000006311143102060700207410ustar00rootroot00000000000000--TEST-- SDB: get(array) --SKIPIF-- --FILE-- open("proba.sdb"); $a=$sdb->get(Array(100,1)); echo $a[0]; echo "-"; $a=$sdb->find(Array(2026,4)); echo $a[0], ",",$a[1], ",",$a[2]; echo "-"; echo "\n"; ?> ===DONE=== --EXPECT-- created aaagdfbnn-456,555,565- ===DONE=== php5-array2arraymap-sdb-0.12/tests/OO_006.phpt000064400000000000000000000005731143102060700207470ustar00rootroot00000000000000--TEST-- SDB: open(non-existent file) --SKIPIF-- --FILE-- open("notexists.sdb")) { echo "open of notexists.sdb failed\n"; } ?> ===DONE=== --EXPECT-- created Can not open file notexists.sdb open of notexists.sdb failed ===DONE===