package.xml0000644000175000001440000000626413554523006012052 0ustar mikeusers raphf pecl.php.net Resource and persistent handles factory A reusable split-off of pecl_http's persistent handle and resource factory API. Michael Wallner mike mike@php.net yes 2019-10-25 2.0.1 2.0.0 stable stable BSD-2-Clause * Fixed pointless initialization of persistent handles lists on cleanup * Fixed Windows build (Jan Ehrhardt) 7.0.0 1.4.0 raphf raphf-2.0.1/src/php_raphf_api.h0000644000175000001440000003115613554523006015227 0ustar mikeusers/* +--------------------------------------------------------------------+ | PECL :: raphf | +--------------------------------------------------------------------+ | Redistribution and use in source and binary forms, with or without | | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ | Copyright (c) 2013, Michael Wallner | +--------------------------------------------------------------------+ */ #ifndef PHP_RAPHF_API_H #define PHP_RAPHF_API_H #include "php_raphf.h" /** * A resource constructor. * * @param opaque is the \a data from php_persistent_handle_provide() * @param init_arg is the \a init_arg from php_resource_factory_init() * @return the created (persistent) handle */ typedef void *(*php_resource_factory_handle_ctor_t)(void *opaque, void *init_arg); /** * The copy constructor of a resource. * * @param opaque the factory's data * @param handle the (persistent) handle to copy */ typedef void *(*php_resource_factory_handle_copy_t)(void *opaque, void *handle); /** * The destructor of a resource. * * @param opaque the factory's data * @param handle the handle to destroy */ typedef void (*php_resource_factory_handle_dtor_t)(void *opaque, void *handle); /** * The resource ops consisting of a ctor, a copy ctor and a dtor. * * Define this ops and register them with php_persistent_handle_provide() * in MINIT. */ typedef struct php_resource_factory_ops { /** The resource constructor */ php_resource_factory_handle_ctor_t ctor; /** The resource's copy constructor */ php_resource_factory_handle_copy_t copy; /** The resource's destructor */ php_resource_factory_handle_dtor_t dtor; } php_resource_factory_ops_t; /** * The resource factory. */ typedef struct php_resource_factory { /** The resource ops */ php_resource_factory_ops_t fops; /** Opaque user data */ void *data; /** User data destructor */ void (*dtor)(void *data); /** How often this factory is referenced */ unsigned refcount; } php_resource_factory_t; /** * Initialize a resource factory. * * If you register a \a dtor for a resource factory used with a persistent * handle provider, be sure to call php_persistent_handle_cleanup() for your * registered provider in MSHUTDOWN, else the dtor will point to no longer * available memory if the extension has already been unloaded. * * @param f the factory to initialize; if NULL allocated on the heap * @param fops the resource ops to assign to the factory * @param data opaque user data; may be NULL * @param dtor a destructor for the data; may be NULL * @return \a f or an allocated resource factory */ PHP_RAPHF_API php_resource_factory_t *php_resource_factory_init( php_resource_factory_t *f, php_resource_factory_ops_t *fops, void *data, void (*dtor)(void *data)); /** * Increase the refcount of the resource factory. * * @param rf the resource factory * @return the new refcount */ PHP_RAPHF_API unsigned php_resource_factory_addref(php_resource_factory_t *rf); /** * Destroy the resource factory. * * If the factory's refcount reaches 0, the \a dtor for \a data is called. * * @param f the resource factory */ PHP_RAPHF_API void php_resource_factory_dtor(php_resource_factory_t *f); /** * Destroy and free the resource factory. * * Calls php_resource_factory_dtor() and frees \a f if the factory's refcount * reached 0. * * @param f the resource factory */ PHP_RAPHF_API void php_resource_factory_free(php_resource_factory_t **f); /** * Construct a resource by the resource factory \a f * * @param f the resource factory * @param init_arg for the resource constructor * @return the new resource */ PHP_RAPHF_API void *php_resource_factory_handle_ctor(php_resource_factory_t *f, void *init_arg); /** * Create a copy of the resource \a handle * * @param f the resource factory * @param handle the resource to copy * @return the copy */ PHP_RAPHF_API void *php_resource_factory_handle_copy(php_resource_factory_t *f, void *handle); /** * Destroy (and free) the resource * * @param f the resource factory * @param handle the resource to destroy */ PHP_RAPHF_API void php_resource_factory_handle_dtor(php_resource_factory_t *f, void *handle); /** * Persistent handles storage */ typedef struct php_persistent_handle_list { /** Storage of free resources */ HashTable free; /** Count of acquired resources */ unsigned long used; } php_persistent_handle_list_t; /** * Definition of a persistent handle provider. * Holds a resource factory an a persistent handle list. */ typedef struct php_persistent_handle_provider { /** * The list of free handles. * Hash of "ident" => array(handles) entries. Persistent handles are * acquired out of this list. */ php_persistent_handle_list_t list; /** * The resource factory. * New handles are created by this factory. */ php_resource_factory_t rf; } php_persistent_handle_provider_t; typedef struct php_persistent_handle_factory php_persistent_handle_factory_t; /** * Wakeup the persistent handle on re-acquisition. */ typedef void (*php_persistent_handle_wakeup_t)( php_persistent_handle_factory_t *f, void **handle); /** * Retire the persistent handle on release. */ typedef void (*php_persistent_handle_retire_t)( php_persistent_handle_factory_t *f, void **handle); /** * Definition of a persistent handle factory. * * php_persistent_handle_concede() will return a pointer to a * php_persistent_handle_factory if a provider for the \a name has * been registered with php_persistent_handle_provide(). */ struct php_persistent_handle_factory { /** The persistent handle provider */ php_persistent_handle_provider_t *provider; /** The persistent handle wakeup routine; may be NULL */ php_persistent_handle_wakeup_t wakeup; /** The persistent handle retire routine; may be NULL */ php_persistent_handle_retire_t retire; /** The ident for which this factory manages resources */ zend_string *ident; /** Whether it has to be free'd on php_persistent_handle_abandon() */ unsigned free_on_abandon:1; }; /** * Register a persistent handle provider in MINIT. * * Registers a factory provider for \a name_str with \a fops resource factory * ops. Call this in your MINIT. * * A php_resource_factory will be created with \a fops, \a data and \a dtor * and will be stored together with a php_persistent_handle_list in the global * raphf hash. * * A php_persistent_handle_factory can then be retrieved by * php_persistent_handle_concede() at runtime. * * @param name the provider name, e.g. "http\Client\Curl" * @param fops the resource factory ops * @param data opaque user data * @param dtor \a data destructor * @return SUCCESS/FAILURE */ PHP_RAPHF_API ZEND_RESULT_CODE php_persistent_handle_provide( zend_string *name, php_resource_factory_ops_t *fops, void *data, void (*dtor)(void *)); /** * Retrieve a persistent handle factory at runtime. * * If a persistent handle provider has been registered for \a name, a new * php_persistent_handle_factory creating resources in the \a ident * namespace will be constructed. * * The wakeup routine \a wakeup and the retire routine \a retire will be * assigned to the new php_persistent_handle_factory. * * @param a pointer to a factory; allocated on the heap if NULL * @param name the provider name, e.g. "http\Client\Curl" * @param ident the subsidiary namespace, e.g. "php.net:80" * @param wakeup any persistent handle wakeup routine * @param retire any persistent handle retire routine * @return \a a or an allocated persistent handle factory */ PHP_RAPHF_API php_persistent_handle_factory_t *php_persistent_handle_concede( php_persistent_handle_factory_t *a, zend_string *name, zend_string *ident, php_persistent_handle_wakeup_t wakeup, php_persistent_handle_retire_t retire); /** * Abandon the persistent handle factory. * * Destroy a php_persistent_handle_factory created by * php_persistent_handle_concede(). If the memory for the factory was allocated, * it will automatically be free'd. * * @param a the persistent handle factory to destroy */ PHP_RAPHF_API void php_persistent_handle_abandon( php_persistent_handle_factory_t *a); /** * Acquire a persistent handle. * * That is, either re-use a resource from the free list or create a new handle. * * If a handle is acquired from the free list, the * php_persistent_handle_factory::wakeup callback will be executed for that * handle. * * @param a the persistent handle factory * @param init_arg the \a init_arg for php_resource_factory_handle_ctor() * @return the acquired resource */ PHP_RAPHF_API void *php_persistent_handle_acquire( php_persistent_handle_factory_t *a, void *init_arg); /** * Release a persistent handle. * * That is, either put it back into the free list for later re-use or clean it * up with php_resource_factory_handle_dtor(). * * If a handle is put back into the free list, the * php_persistent_handle_factory::retire callback will be executed for that * handle. * * @param a the persistent handle factory * @param handle the handle to release */ PHP_RAPHF_API void php_persistent_handle_release( php_persistent_handle_factory_t *a, void *handle); /** * Copy a persistent handle. * * Let the underlying resource factory copy the \a handle. * * @param a the persistent handle factory * @param handle the resource to accrete */ PHP_RAPHF_API void *php_persistent_handle_accrete( php_persistent_handle_factory_t *a, void *handle); /** * Retrieve persistent handle resource factory ops. * * These ops can be used to mask a persistent handle factory as * resource factory itself, so you can transparently use the * resource factory API, both for persistent and non-persistent * ressources. * * Example: * \code{.c} * php_resource_factory_t *create_my_rf(zend_string *persistent_id) * { * php_resource_factory_t *rf; * * if (persistent_id) { * php_persistent_handle_factory_t *pf; * php_resource_factory_ops_t *ops; * zend_string *ns = zend_string_init("my", 2, 1); * * ops = php_persistent_handle_get_resource_factory_ops(); * pf = php_persistent_handle_concede(NULL, ns, persistent_id, NULL, NULL); * rf = php_persistent_handle_resource_factory_init(NULL, pf); * zend_string_release(ns); * } else { * rf = php_resource_factory_init(NULL, &myops, NULL, NULL); * } * return rf; * } * \endcode */ PHP_RAPHF_API php_resource_factory_ops_t * php_persistent_handle_get_resource_factory_ops(void); /** * Create a resource factory for persistent handles. * * This will create a resource factory with persistent handle ops, which wraps * the provided reource factory \a pf. * * @param a the persistent handle resource factory to initialize * @param pf the resource factory to wrap */ PHP_RAPHF_API php_resource_factory_t * php_persistent_handle_resource_factory_init(php_resource_factory_t *a, php_persistent_handle_factory_t *pf); /** * Check whether a resource factory is a persistent handle resource factory. * * @param a the resource factory to check */ PHP_RAPHF_API zend_bool php_resource_factory_is_persistent( php_resource_factory_t *a); /** * Clean persistent handles up. * * Destroy persistent handles of provider \a name and in subsidiary * namespace \a ident. * * If \a name is NULL, all persistent handles of all providers with a * matching \a ident will be cleaned up. * * If \a identr is NULL all persistent handles of the provider will be * cleaned up. * * Ergo, if both, \a name and \a ident are NULL, then all * persistent handles will be cleaned up. * * You must call this in MSHUTDOWN, if your resource factory ops hold a * registered php_resource_factory::dtor, else the dtor will point to * memory not any more available if the extension has already been unloaded. * * @param name the provider name; may be NULL * @param ident the subsidiary namespace name; may be NULL */ PHP_RAPHF_API void php_persistent_handle_cleanup(zend_string *name, zend_string *ident); /** * Retrieve statistics about the current process/thread's persistent handles. * * @return a HashTable like: * \code * [ * "name" => [ * "ident" => [ * "used" => 1, * "free" => 0, * ] * ] * ] * \endcode */ PHP_RAPHF_API HashTable *php_persistent_handle_statall(HashTable *ht); #endif /* PHP_RAPHF_API_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 */ raphf-2.0.1/src/php_raphf_api.c0000644000175000001440000004266613554523006015232 0ustar mikeusers/* +--------------------------------------------------------------------+ | PECL :: raphf | +--------------------------------------------------------------------+ | Redistribution and use in source and binary forms, with or without | | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ | Copyright (c) 2013, Michael Wallner | +--------------------------------------------------------------------+ */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" #include "php_raphf.h" #ifndef PHP_RAPHF_TEST # define PHP_RAPHF_TEST 0 #endif struct php_persistent_handle_globals { unsigned long limit; HashTable hash; }; ZEND_BEGIN_MODULE_GLOBALS(raphf) struct php_persistent_handle_globals persistent_handle; ZEND_END_MODULE_GLOBALS(raphf) #ifdef ZTS # define PHP_RAPHF_G ((zend_raphf_globals *) \ (*((void ***) tsrm_get_ls_cache()))[TSRM_UNSHUFFLE_RSRC_ID(raphf_globals_id)]) #else # define PHP_RAPHF_G (&raphf_globals) #endif ZEND_DECLARE_MODULE_GLOBALS(raphf) #ifndef PHP_RAPHF_DEBUG_PHANDLES # define PHP_RAPHF_DEBUG_PHANDLES 0 #endif #if PHP_RAPHF_DEBUG_PHANDLES # undef inline # define inline #endif php_resource_factory_t *php_resource_factory_init(php_resource_factory_t *f, php_resource_factory_ops_t *fops, void *data, void (*dtor)(void *data)) { if (!f) { f = emalloc(sizeof(*f)); } memset(f, 0, sizeof(*f)); memcpy(&f->fops, fops, sizeof(*fops)); f->data = data; f->dtor = dtor; f->refcount = 1; return f; } unsigned php_resource_factory_addref(php_resource_factory_t *rf) { return ++rf->refcount; } void php_resource_factory_dtor(php_resource_factory_t *f) { if (!--f->refcount) { if (f->dtor) { f->dtor(f->data); } } } void php_resource_factory_free(php_resource_factory_t **f) { if (*f) { php_resource_factory_dtor(*f); if (!(*f)->refcount) { efree(*f); *f = NULL; } } } void *php_resource_factory_handle_ctor(php_resource_factory_t *f, void *init_arg) { if (f->fops.ctor) { return f->fops.ctor(f->data, init_arg); } return NULL; } void *php_resource_factory_handle_copy(php_resource_factory_t *f, void *handle) { if (f->fops.copy) { return f->fops.copy(f->data, handle); } return NULL; } void php_resource_factory_handle_dtor(php_resource_factory_t *f, void *handle) { if (f->fops.dtor) { f->fops.dtor(f->data, handle); } } php_resource_factory_t *php_persistent_handle_resource_factory_init( php_resource_factory_t *a, php_persistent_handle_factory_t *pf) { return php_resource_factory_init(a, php_persistent_handle_get_resource_factory_ops(), pf, (void(*)(void*)) php_persistent_handle_abandon); } zend_bool php_resource_factory_is_persistent(php_resource_factory_t *a) { return a->dtor == (void(*)(void *)) php_persistent_handle_abandon; } static inline php_persistent_handle_list_t *php_persistent_handle_list_init( php_persistent_handle_list_t *list) { if (!list) { list = pemalloc(sizeof(*list), 1); } list->used = 0; zend_hash_init(&list->free, 0, NULL, NULL, 1); return list; } static int php_persistent_handle_apply_stat(zval *p, int argc, va_list argv, zend_hash_key *key) { php_persistent_handle_list_t *list = Z_PTR_P(p); zval zsubentry, *zentry = va_arg(argv, zval *); array_init(&zsubentry); add_assoc_long_ex(&zsubentry, ZEND_STRL("used"), list->used); add_assoc_long_ex(&zsubentry, ZEND_STRL("free"), zend_hash_num_elements(&list->free)); if (key->key) { add_assoc_zval_ex(zentry, key->key->val, key->key->len, &zsubentry); } else { add_index_zval(zentry, key->h, &zsubentry); } return ZEND_HASH_APPLY_KEEP; } static int php_persistent_handle_apply_statall(zval *p, int argc, va_list argv, zend_hash_key *key) { php_persistent_handle_provider_t *provider = Z_PTR_P(p); HashTable *ht = va_arg(argv, HashTable *); zval zentry; array_init(&zentry); zend_hash_apply_with_arguments(&provider->list.free, php_persistent_handle_apply_stat, 1, &zentry); if (key->key) { zend_hash_update(ht, key->key, &zentry); } else { zend_hash_index_update(ht, key->h, &zentry); } return ZEND_HASH_APPLY_KEEP; } static int php_persistent_handle_apply_cleanup_ex(zval *p, void *arg) { php_resource_factory_t *rf = arg; void *handle = Z_PTR_P(p); #if PHP_RAPHF_DEBUG_PHANDLES fprintf(stderr, "DESTROY: %p\n", handle); #endif php_resource_factory_handle_dtor(rf, handle); return ZEND_HASH_APPLY_REMOVE; } static int php_persistent_handle_apply_cleanup(zval *p, void *arg) { php_resource_factory_t *rf = arg; php_persistent_handle_list_t *list = Z_PTR_P(p); zend_hash_apply_with_argument(&list->free, php_persistent_handle_apply_cleanup_ex, rf); if (list->used) { return ZEND_HASH_APPLY_KEEP; } zend_hash_destroy(&list->free); #if PHP_RAPHF_DEBUG_PHANDLES fprintf(stderr, "LSTFREE: %p\n", list); #endif pefree(list, 1); return ZEND_HASH_APPLY_REMOVE; } static inline void php_persistent_handle_list_dtor( php_persistent_handle_list_t *list, php_persistent_handle_provider_t *provider) { #if PHP_RAPHF_DEBUG_PHANDLES fprintf(stderr, "LSTDTOR: %p\n", list); #endif zend_hash_apply_with_argument(&list->free, php_persistent_handle_apply_cleanup_ex, &provider->rf); zend_hash_destroy(&list->free); } static inline void php_persistent_handle_list_free( php_persistent_handle_list_t **list, php_persistent_handle_provider_t *provider) { php_persistent_handle_list_dtor(*list, provider); #if PHP_RAPHF_DEBUG_PHANDLES fprintf(stderr, "LSTFREE: %p\n", *list); #endif pefree(*list, 1); *list = NULL; } static int php_persistent_handle_list_apply_dtor(zval *p, void *provider) { php_persistent_handle_list_t *list = Z_PTR_P(p); php_persistent_handle_list_free(&list, provider ); ZVAL_PTR(p, NULL); return ZEND_HASH_APPLY_REMOVE; } static inline php_persistent_handle_list_t *php_persistent_handle_list_find( php_persistent_handle_provider_t *provider, zend_string *ident, zend_bool create) { php_persistent_handle_list_t *list; zval *zlist = zend_symtable_find(&provider->list.free, ident); if (zlist && (list = Z_PTR_P(zlist))) { #if PHP_RAPHF_DEBUG_PHANDLES fprintf(stderr, "LSTFIND: %p\n", list); #endif return list; } if (create && (list = php_persistent_handle_list_init(NULL))) { zval p, *rv; zend_string *id; ZVAL_PTR(&p, list); id = zend_string_init(ident->val, ident->len, 1); rv = zend_symtable_update(&provider->list.free, id, &p); zend_string_release(id); if (rv) { #if PHP_RAPHF_DEBUG_PHANDLES fprintf(stderr, "LSTFIND: %p (new)\n", list); #endif return list; } php_persistent_handle_list_free(&list, provider); } return NULL; } static int php_persistent_handle_apply_cleanup_all(zval *p, int argc, va_list argv, zend_hash_key *key) { php_persistent_handle_provider_t *provider = Z_PTR_P(p); zend_string *ident = va_arg(argv, zend_string *); php_persistent_handle_list_t *list; if (ident && ident->len) { if ((list = php_persistent_handle_list_find(provider, ident, 0))) { zend_hash_apply_with_argument(&list->free, php_persistent_handle_apply_cleanup_ex, &provider->rf); } } else { zend_hash_apply_with_argument(&provider->list.free, php_persistent_handle_apply_cleanup, &provider->rf); } return ZEND_HASH_APPLY_KEEP; } static void php_persistent_handle_hash_dtor(zval *p) { php_persistent_handle_provider_t *provider = Z_PTR_P(p); zend_hash_apply_with_argument(&provider->list.free, php_persistent_handle_list_apply_dtor, provider); zend_hash_destroy(&provider->list.free); php_resource_factory_dtor(&provider->rf); pefree(provider, 1); } ZEND_RESULT_CODE php_persistent_handle_provide(zend_string *name, php_resource_factory_ops_t *fops, void *data, void (*dtor)(void *)) { php_persistent_handle_provider_t *provider = pemalloc(sizeof(*provider), 1); if (php_persistent_handle_list_init(&provider->list)) { if (php_resource_factory_init(&provider->rf, fops, data, dtor)) { zval p, *rv; zend_string *ns; #if PHP_RAPHF_DEBUG_PHANDLES fprintf(stderr, "PROVIDE: %p %s\n", PHP_RAPHF_G, name_str); #endif ZVAL_PTR(&p, provider); ns = zend_string_init(name->val, name->len, 1); rv = zend_symtable_update(&PHP_RAPHF_G->persistent_handle.hash, ns, &p); zend_string_release(ns); if (rv) { return SUCCESS; } php_resource_factory_dtor(&provider->rf); } } return FAILURE; } php_persistent_handle_factory_t *php_persistent_handle_concede( php_persistent_handle_factory_t *a, zend_string *name, zend_string *ident, php_persistent_handle_wakeup_t wakeup, php_persistent_handle_retire_t retire) { zval *zprovider = zend_symtable_find(&PHP_RAPHF_G->persistent_handle.hash, name); if (zprovider) { zend_bool free_a = 0; if ((free_a = !a)) { a = emalloc(sizeof(*a)); } memset(a, 0, sizeof(*a)); a->provider = Z_PTR_P(zprovider); a->ident = zend_string_copy(ident); a->wakeup = wakeup; a->retire = retire; a->free_on_abandon = free_a; } else { a = NULL; } #if PHP_RAPHF_DEBUG_PHANDLES fprintf(stderr, "CONCEDE: %p %p (%s) (%s)\n", PHP_RAPHF_G, a ? a->provider : NULL, name->val, ident->val); #endif return a; } void php_persistent_handle_abandon(php_persistent_handle_factory_t *a) { zend_bool f = a->free_on_abandon; #if PHP_RAPHF_DEBUG_PHANDLES fprintf(stderr, "ABANDON: %p\n", a->provider); #endif zend_string_release(a->ident); memset(a, 0, sizeof(*a)); if (f) { efree(a); } } void *php_persistent_handle_acquire(php_persistent_handle_factory_t *a, void *init_arg) { int key; zval *p; zend_ulong index; void *handle = NULL; php_persistent_handle_list_t *list; list = php_persistent_handle_list_find(a->provider, a->ident, 1); if (list) { zend_hash_internal_pointer_end(&list->free); key = zend_hash_get_current_key(&list->free, NULL, &index); p = zend_hash_get_current_data(&list->free); if (p && HASH_KEY_NON_EXISTENT != key) { handle = Z_PTR_P(p); if (a->wakeup) { a->wakeup(a, &handle); } zend_hash_index_del(&list->free, index); } else { handle = php_resource_factory_handle_ctor(&a->provider->rf, init_arg); } #if PHP_RAPHF_DEBUG_PHANDLES fprintf(stderr, "CREATED: %p\n", handle); #endif if (handle) { ++a->provider->list.used; ++list->used; } } return handle; } void *php_persistent_handle_accrete(php_persistent_handle_factory_t *a, void *handle) { void *new_handle = NULL; php_persistent_handle_list_t *list; new_handle = php_resource_factory_handle_copy(&a->provider->rf, handle); if (handle) { list = php_persistent_handle_list_find(a->provider, a->ident, 1); if (list) { ++list->used; } ++a->provider->list.used; } return new_handle; } void php_persistent_handle_release(php_persistent_handle_factory_t *a, void *handle) { php_persistent_handle_list_t *list; list = php_persistent_handle_list_find(a->provider, a->ident, 1); if (list) { if (a->provider->list.used >= PHP_RAPHF_G->persistent_handle.limit) { #if PHP_RAPHF_DEBUG_PHANDLES fprintf(stderr, "DESTROY: %p\n", handle); #endif php_resource_factory_handle_dtor(&a->provider->rf, handle); } else { if (a->retire) { a->retire(a, &handle); } zend_hash_next_index_insert_ptr(&list->free, handle); } --a->provider->list.used; --list->used; } } void php_persistent_handle_cleanup(zend_string *name, zend_string *ident) { php_persistent_handle_provider_t *provider; php_persistent_handle_list_t *list; if (name) { zval *zprovider = zend_symtable_find(&PHP_RAPHF_G->persistent_handle.hash, name); if (zprovider && (provider = Z_PTR_P(zprovider))) { if (ident) { list = php_persistent_handle_list_find(provider, ident, 0); if (list) { zend_hash_apply_with_argument(&list->free, php_persistent_handle_apply_cleanup_ex, &provider->rf); } } else { zend_hash_apply_with_argument(&provider->list.free, php_persistent_handle_apply_cleanup, &provider->rf); } } } else { zend_hash_apply_with_arguments( &PHP_RAPHF_G->persistent_handle.hash, php_persistent_handle_apply_cleanup_all, 1, ident); } } HashTable *php_persistent_handle_statall(HashTable *ht) { if (zend_hash_num_elements(&PHP_RAPHF_G->persistent_handle.hash)) { if (!ht) { ALLOC_HASHTABLE(ht); zend_hash_init(ht, 0, NULL, ZVAL_PTR_DTOR, 0); } zend_hash_apply_with_arguments( &PHP_RAPHF_G->persistent_handle.hash, php_persistent_handle_apply_statall, 1, ht); } else if (ht) { ht = NULL; } return ht; } static php_resource_factory_ops_t php_persistent_handle_resource_factory_ops = { (php_resource_factory_handle_ctor_t) php_persistent_handle_acquire, (php_resource_factory_handle_copy_t) php_persistent_handle_accrete, (php_resource_factory_handle_dtor_t) php_persistent_handle_release }; php_resource_factory_ops_t *php_persistent_handle_get_resource_factory_ops(void) { return &php_persistent_handle_resource_factory_ops; } ZEND_BEGIN_ARG_INFO_EX(ai_raphf_stat_persistent_handles, 0, 0, 0) ZEND_END_ARG_INFO(); static PHP_FUNCTION(raphf_stat_persistent_handles) { if (SUCCESS == zend_parse_parameters_none()) { object_init(return_value); if (php_persistent_handle_statall(HASH_OF(return_value))) { return; } zval_dtor(return_value); } RETURN_FALSE; } ZEND_BEGIN_ARG_INFO_EX(ai_raphf_clean_persistent_handles, 0, 0, 0) ZEND_ARG_INFO(0, name) ZEND_ARG_INFO(0, ident) ZEND_END_ARG_INFO(); static PHP_FUNCTION(raphf_clean_persistent_handles) { zend_string *name = NULL, *ident = NULL; if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|S!S!", &name, &ident)) { php_persistent_handle_cleanup(name, ident); } } #if PHP_RAPHF_TEST # include "php_raphf_test.c" #endif static const zend_function_entry raphf_functions[] = { ZEND_NS_FENTRY("raphf", stat_persistent_handles, ZEND_FN(raphf_stat_persistent_handles), ai_raphf_stat_persistent_handles, 0) ZEND_NS_FENTRY("raphf", clean_persistent_handles, ZEND_FN(raphf_clean_persistent_handles), ai_raphf_clean_persistent_handles, 0) #if PHP_RAPHF_TEST ZEND_NS_FENTRY("raphf", provide, ZEND_FN(raphf_provide), NULL, 0) ZEND_NS_FENTRY("raphf", conceal, ZEND_FN(raphf_conceal), NULL, 0) ZEND_NS_FENTRY("raphf", concede, ZEND_FN(raphf_concede), NULL, 0) ZEND_NS_FENTRY("raphf", dispute, ZEND_FN(raphf_dispute), NULL, 0) ZEND_NS_FENTRY("raphf", handle_ctor, ZEND_FN(raphf_handle_ctor), NULL, 0) ZEND_NS_FENTRY("raphf", handle_copy, ZEND_FN(raphf_handle_copy), NULL, 0) ZEND_NS_FENTRY("raphf", handle_dtor, ZEND_FN(raphf_handle_dtor), NULL, 0) #endif {0} }; PHP_INI_BEGIN() STD_PHP_INI_ENTRY("raphf.persistent_handle.limit", "-1", PHP_INI_SYSTEM, OnUpdateLong, persistent_handle.limit, zend_raphf_globals, raphf_globals) PHP_INI_END() static HashTable *php_persistent_handles_global_hash; static PHP_GINIT_FUNCTION(raphf) { raphf_globals->persistent_handle.limit = -1; zend_hash_init(&raphf_globals->persistent_handle.hash, 0, NULL, php_persistent_handle_hash_dtor, 1); if (php_persistent_handles_global_hash) { zend_hash_copy(&raphf_globals->persistent_handle.hash, php_persistent_handles_global_hash, NULL); } } static PHP_GSHUTDOWN_FUNCTION(raphf) { zend_hash_destroy(&raphf_globals->persistent_handle.hash); } PHP_MINIT_FUNCTION(raphf) { php_persistent_handles_global_hash = &PHP_RAPHF_G->persistent_handle.hash; #if PHP_RAPHF_TEST PHP_MINIT(raphf_test)(INIT_FUNC_ARGS_PASSTHRU); #endif REGISTER_INI_ENTRIES(); return SUCCESS; } PHP_MSHUTDOWN_FUNCTION(raphf) { #if PHP_RAPHF_TEST PHP_MSHUTDOWN(raphf_test)(SHUTDOWN_FUNC_ARGS_PASSTHRU); #endif UNREGISTER_INI_ENTRIES(); php_persistent_handles_global_hash = NULL; return SUCCESS; } static int php_persistent_handle_apply_info_ex(zval *p, int argc, va_list argv, zend_hash_key *key) { php_persistent_handle_list_t *list = Z_PTR_P(p); zend_hash_key *super_key = va_arg(argv, zend_hash_key *); char used[21], free[21]; slprintf(used, sizeof(used), "%u", list->used); slprintf(free, sizeof(free), "%d", zend_hash_num_elements(&list->free)); php_info_print_table_row(4, super_key->key->val, key->key->val, used, free); return ZEND_HASH_APPLY_KEEP; } static int php_persistent_handle_apply_info(zval *p, int argc, va_list argv, zend_hash_key *key) { php_persistent_handle_provider_t *provider = Z_PTR_P(p); zend_hash_apply_with_arguments(&provider->list.free, php_persistent_handle_apply_info_ex, 1, key); return ZEND_HASH_APPLY_KEEP; } PHP_MINFO_FUNCTION(raphf) { php_info_print_table_start(); php_info_print_table_header(2, "Resource and persistent handle factory support", "enabled"); php_info_print_table_row(2, "Extension version", PHP_RAPHF_VERSION); php_info_print_table_end(); php_info_print_table_start(); php_info_print_table_colspan_header(4, "Persistent handles in this " #ifdef ZTS "thread" #else "process" #endif ); php_info_print_table_header(4, "Provider", "Ident", "Used", "Free"); zend_hash_apply_with_arguments( &PHP_RAPHF_G->persistent_handle.hash, php_persistent_handle_apply_info, 0); php_info_print_table_end(); DISPLAY_INI_ENTRIES(); } zend_module_entry raphf_module_entry = { STANDARD_MODULE_HEADER, "raphf", raphf_functions, PHP_MINIT(raphf), PHP_MSHUTDOWN(raphf), NULL, NULL, PHP_MINFO(raphf), PHP_RAPHF_VERSION, ZEND_MODULE_GLOBALS(raphf), PHP_GINIT(raphf), PHP_GSHUTDOWN(raphf), NULL, STANDARD_MODULE_PROPERTIES_EX }; /* }}} */ #ifdef COMPILE_DL_RAPHF ZEND_GET_MODULE(raphf) #endif /* * 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 */ raphf-2.0.1/scripts/gen_travis_yml.php0000755000175000001440000000155513554523006016714 0ustar mikeusers#!/usr/bin/env php # autogenerated file; do not edit sudo: false language: c dist: xenial addons: apt: packages: - php-cli - php-pear env: ["7.0", "7.1", "7.2", "7.4", "master"], "enable_debug" => "yes", "enable_maintainer_zts" => "yes", ], [ "PHP" => $cur, "enable_debug", "enable_maintainer_zts" ]); foreach ($env as $grp) { foreach ($grp as $e) { printf(" - %s\n", $e); } } ?> matrix: fast_finish: true allow_failures: before_script: - make -f travis/pecl/Makefile php - make -f travis/pecl/Makefile ext PECL=raphf script: - make -f travis/pecl/Makefile test raphf-2.0.1/tests/http001.phpt0000644000175000001440000000300713554523006014720 0ustar mikeusers--TEST-- pecl/http-v2 - general and stat --SKIPIF-- --FILE-- enqueue(new http\Client\Request("GET", "http://php.net")); } while (count($c) < 3); $h = (array) raphf\stat_persistent_handles(); var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h))))); unset($c); $h = (array) raphf\stat_persistent_handles(); var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h))))); ?> Done --EXPECTF-- Test array(2) { ["http\Client\Curl"]=> array(0) { } ["http\Client\Curl\Request"]=> array(0) { } } array(2) { ["http\Client\Curl"]=> array(1) { ["PHP"]=> array(2) { ["used"]=> int(1) ["free"]=> int(0) } } ["http\Client\Curl\Request"]=> array(1) { ["PHP:php.net:80"]=> array(2) { ["used"]=> int(3) ["free"]=> int(0) } } } array(2) { ["http\Client\Curl"]=> array(1) { ["PHP"]=> array(2) { ["used"]=> int(0) ["free"]=> int(1) } } ["http\Client\Curl\Request"]=> array(1) { ["PHP:php.net:80"]=> array(2) { ["used"]=> int(0) ["free"]=> int(3) } } } Done raphf-2.0.1/tests/http002.phpt0000644000175000001440000000251213554523006014721 0ustar mikeusers--TEST-- pecl/http-v2 - clean with name and id --SKIPIF-- --FILE-- enqueue(new http\Client\Request("GET", "http://php.net")); } while (count($c) < 3); unset($c); $h = (array) raphf\stat_persistent_handles(); var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h))))); raphf\clean_persistent_handles("http\\Client\\Curl"); raphf\clean_persistent_handles("http\\Client\\Curl\\Request", "PHP:php.net:80"); $h = (array) raphf\stat_persistent_handles(); var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h))))); ?> Done --EXPECTF-- Test array(2) { ["http\Client\Curl"]=> array(1) { ["PHP"]=> array(2) { ["used"]=> int(0) ["free"]=> int(1) } } ["http\Client\Curl\Request"]=> array(1) { ["PHP:php.net:80"]=> array(2) { ["used"]=> int(0) ["free"]=> int(3) } } } array(2) { ["http\Client\Curl"]=> array(0) { } ["http\Client\Curl\Request"]=> array(1) { ["PHP:php.net:80"]=> array(2) { ["used"]=> int(0) ["free"]=> int(0) } } } Done raphf-2.0.1/tests/http003.phpt0000644000175000001440000000260213554523006014722 0ustar mikeusers--TEST-- pecl/http-v2 - clean with id only --SKIPIF-- --FILE-- enqueue(new http\Client\Request("GET", "http://php.net")); } while (count($c) < 3); unset($c); $h = (array) raphf\stat_persistent_handles(); var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h))))); raphf\clean_persistent_handles(null, "PHP"); raphf\clean_persistent_handles(null, "PHP:php.net:80"); $h = (array) raphf\stat_persistent_handles(); var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h))))); ?> Done --EXPECTF-- Test array(2) { ["http\Client\Curl"]=> array(1) { ["PHP"]=> array(2) { ["used"]=> int(0) ["free"]=> int(1) } } ["http\Client\Curl\Request"]=> array(1) { ["PHP:php.net:80"]=> array(2) { ["used"]=> int(0) ["free"]=> int(3) } } } array(2) { ["http\Client\Curl"]=> array(1) { ["PHP"]=> array(2) { ["used"]=> int(0) ["free"]=> int(0) } } ["http\Client\Curl\Request"]=> array(1) { ["PHP:php.net:80"]=> array(2) { ["used"]=> int(0) ["free"]=> int(0) } } } Done raphf-2.0.1/tests/http004.phpt0000644000175000001440000000410413554523006014722 0ustar mikeusers--TEST-- pecl/http-v2 - partial clean --SKIPIF-- --FILE-- enqueue(new http\Client\Request("GET", "http://php.net")); $c2->enqueue(new http\Client\Request("GET", "http://php.net")); } while (count($c) < 3); $h = (array) raphf\stat_persistent_handles(); var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h))))); unset($c); $h = (array) raphf\stat_persistent_handles(); var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h))))); raphf\clean_persistent_handles(); $h = (array) raphf\stat_persistent_handles(); var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h))))); ?> Done --EXPECTF-- Test array(2) { ["http\Client\Curl"]=> array(0) { } ["http\Client\Curl\Request"]=> array(0) { } } array(2) { ["http\Client\Curl"]=> array(1) { ["PHP"]=> array(2) { ["used"]=> int(2) ["free"]=> int(0) } } ["http\Client\Curl\Request"]=> array(1) { ["PHP:php.net:80"]=> array(2) { ["used"]=> int(6) ["free"]=> int(0) } } } array(2) { ["http\Client\Curl"]=> array(1) { ["PHP"]=> array(2) { ["used"]=> int(1) ["free"]=> int(1) } } ["http\Client\Curl\Request"]=> array(1) { ["PHP:php.net:80"]=> array(2) { ["used"]=> int(3) ["free"]=> int(3) } } } array(2) { ["http\Client\Curl"]=> array(1) { ["PHP"]=> array(2) { ["used"]=> int(1) ["free"]=> int(0) } } ["http\Client\Curl\Request"]=> array(1) { ["PHP:php.net:80"]=> array(2) { ["used"]=> int(3) ["free"]=> int(0) } } } Done raphf-2.0.1/AUTHORS0000644000175000001440000000003713554523006012531 0ustar mikeusersMichael Wallner raphf-2.0.1/BUGS0000644000175000001440000000005213554523006012141 0ustar mikeusersYay, now known and unresolved issues yet! raphf-2.0.1/CONTRIBUTING.md0000644000175000001440000000361613554523006013720 0ustar mikeusers# Contributor Code of Conduct As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality. Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery * Personal attacks * Trolling or insulting/derogatory comments * Public or private harassment * Publishing other's private information, such as physical or electronic addresses, without explicit permission * Other unethical or unprofessional conduct. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team. This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at http://contributor-covenant.org/version/1/2/0/. raphf-2.0.1/CREDITS0000644000175000001440000000002613554523006012477 0ustar mikeusersraphf Michael Wallner raphf-2.0.1/LICENSE0000644000175000001440000000250113554523006012464 0ustar mikeusersCopyright (c) 2013, Michael Wallner . All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. raphf-2.0.1/README.md0000644000175000001440000000244113554523006012741 0ustar mikeusers# ext-raphf [![Build Status](https://travis-ci.org/m6w6/ext-raphf.svg?branch=master)](https://travis-ci.org/m6w6/ext-raphf) The "Resource and Persistent Handle Factory" extension provides facilities to manage those in a convenient manner. ## Documentation See the [online markdown reference](https://mdref.m6w6.name/raphf). Known issues are listed in [BUGS](./BUGS) and future ideas can be found in [TODO](./TODO). ## Installing ### PECL pecl install raphf ### PHARext Watch out for [PECL replicates](https://replicator.pharext.org?raphf) and pharext packages attached to [releases](https://github.com/m6w6/ext-raphf/releases). ### Checkout git clone github.com:m6w6/ext-raphf cd ext-raphf /path/to/phpize ./configure --with-php-config=/path/to/php-config make sudo make install ## ChangeLog A comprehensive list of changes can be obtained from the [PECL website](https://pecl.php.net/package-changelog.php?package=raphf). ## License ext-raphf is licensed under the 2-Clause-BSD license, which can be found in the accompanying [LICENSE](./LICENSE) file. ## Contributing All forms of contribution are welcome! Please see the bundled [CONTRIBUTING](./CONTRIBUTING.md) note for the general principles followed. The list of past and current contributors is maintained in [THANKS](./THANKS). raphf-2.0.1/THANKS0000644000175000001440000000014413554523006012373 0ustar mikeusersThanks go to the following people, who have contributed to this project: Anatol Belski Remi Collet raphf-2.0.1/TODO0000644000175000001440000000000613554523006012145 0ustar mikeusers* TTL raphf-2.0.1/Doxyfile0000644000175000001440000002632313554523006013175 0ustar mikeusers# Doxyfile 1.8.10 #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- DOXYFILE_ENCODING = UTF-8 PROJECT_NAME = "Resource and persistent handle factory API" PROJECT_NUMBER = PROJECT_BRIEF = "A facility to manage possibly persistent resources with a comprehensible API. Provides simliar functionality like the zend_list API, but with more flexiblity and freedom." PROJECT_LOGO = raphf.png OUTPUT_DIRECTORY = CREATE_SUBDIRS = NO ALLOW_UNICODE_NAMES = NO OUTPUT_LANGUAGE = English BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ABBREVIATE_BRIEF = ALWAYS_DETAILED_SEC = NO INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = YES STRIP_FROM_PATH = STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = YES QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO INHERIT_DOCS = YES SEPARATE_MEMBER_PAGES = NO TAB_SIZE = 4 ALIASES = TCL_SUBST = OPTIMIZE_OUTPUT_FOR_C = YES OPTIMIZE_OUTPUT_JAVA = NO OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO EXTENSION_MAPPING = no_extension=md MARKDOWN_SUPPORT = YES AUTOLINK_SUPPORT = YES BUILTIN_STL_SUPPORT = NO CPP_CLI_SUPPORT = NO SIP_SUPPORT = NO IDL_PROPERTY_SUPPORT = YES DISTRIBUTE_GROUP_DOC = NO GROUP_NESTED_COMPOUNDS = NO SUBGROUPING = YES INLINE_GROUPED_CLASSES = NO INLINE_SIMPLE_STRUCTS = YES TYPEDEF_HIDES_STRUCT = NO LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- EXTRACT_ALL = YES EXTRACT_PRIVATE = NO EXTRACT_PACKAGE = NO EXTRACT_STATIC = NO EXTRACT_LOCAL_CLASSES = NO EXTRACT_LOCAL_METHODS = NO EXTRACT_ANON_NSPACES = NO HIDE_UNDOC_MEMBERS = NO HIDE_UNDOC_CLASSES = NO HIDE_FRIEND_COMPOUNDS = NO HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO CASE_SENSE_NAMES = YES HIDE_SCOPE_NAMES = NO HIDE_COMPOUND_REFERENCE= NO SHOW_INCLUDE_FILES = YES SHOW_GROUPED_MEMB_INC = NO FORCE_LOCAL_INCLUDES = NO INLINE_INFO = YES SORT_MEMBER_DOCS = YES SORT_BRIEF_DOCS = NO SORT_MEMBERS_CTORS_1ST = NO SORT_GROUP_NAMES = NO SORT_BY_SCOPE_NAME = NO STRICT_PROTO_MATCHING = NO GENERATE_TODOLIST = YES GENERATE_TESTLIST = YES GENERATE_BUGLIST = YES GENERATE_DEPRECATEDLIST= YES ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES SHOW_FILES = YES SHOW_NAMESPACES = YES FILE_VERSION_FILTER = LAYOUT_FILE = CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages #--------------------------------------------------------------------------- QUIET = NO WARNINGS = YES WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = NO WARN_FORMAT = "$file:$line: $text" WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files #--------------------------------------------------------------------------- INPUT = README.md CONTRIBUTING.md php_raphf.h src INPUT_ENCODING = UTF-8 FILE_PATTERNS = RECURSIVE = NO EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = EXCLUDE_SYMBOLS = EXAMPLE_PATH = EXAMPLE_PATTERNS = EXAMPLE_RECURSIVE = NO IMAGE_PATH = INPUT_FILTER = FILTER_PATTERNS = FILTER_SOURCE_FILES = NO FILTER_SOURCE_PATTERNS = USE_MDFILE_AS_MAINPAGE = README.md #--------------------------------------------------------------------------- # Configuration options related to source browsing #--------------------------------------------------------------------------- SOURCE_BROWSER = NO INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES REFERENCED_BY_RELATION = YES REFERENCES_RELATION = NO REFERENCES_LINK_SOURCE = YES SOURCE_TOOLTIPS = YES USE_HTAGS = NO VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = YES COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the HTML output #--------------------------------------------------------------------------- GENERATE_HTML = YES HTML_OUTPUT = . HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = HTML_STYLESHEET = HTML_EXTRA_STYLESHEET = HTML_EXTRA_FILES = BUGS CONTRIBUTING.md LICENSE THANKS TODO HTML_COLORSTYLE_HUE = 220 HTML_COLORSTYLE_SAT = 100 HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = NO HTML_DYNAMIC_SECTIONS = NO HTML_INDEX_NUM_ENTRIES = 100 GENERATE_DOCSET = NO DOCSET_FEEDNAME = "Doxygen generated docs" DOCSET_BUNDLE_ID = org.doxygen.Project DOCSET_PUBLISHER_ID = org.doxygen.Publisher DOCSET_PUBLISHER_NAME = Publisher GENERATE_HTMLHELP = NO CHM_FILE = HHC_LOCATION = GENERATE_CHI = NO CHM_INDEX_ENCODING = BINARY_TOC = NO TOC_EXPAND = NO GENERATE_QHP = NO QCH_FILE = QHP_NAMESPACE = org.doxygen.Project QHP_VIRTUAL_FOLDER = doc QHP_CUST_FILTER_NAME = QHP_CUST_FILTER_ATTRS = QHP_SECT_FILTER_ATTRS = QHG_LOCATION = GENERATE_ECLIPSEHELP = NO ECLIPSE_DOC_ID = org.doxygen.Project DISABLE_INDEX = NO GENERATE_TREEVIEW = YES ENUM_VALUES_PER_LINE = 4 TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES USE_MATHJAX = NO MATHJAX_FORMAT = HTML-CSS MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest MATHJAX_EXTENSIONS = MATHJAX_CODEFILE = SEARCHENGINE = YES SERVER_BASED_SEARCH = NO EXTERNAL_SEARCH = NO SEARCHENGINE_URL = SEARCHDATA_FILE = searchdata.xml EXTERNAL_SEARCH_ID = EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- # Configuration options related to the LaTeX output #--------------------------------------------------------------------------- GENERATE_LATEX = NO LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO PAPER_TYPE = a4 EXTRA_PACKAGES = LATEX_HEADER = LATEX_FOOTER = LATEX_EXTRA_STYLESHEET = LATEX_EXTRA_FILES = PDF_HYPERLINKS = YES USE_PDFLATEX = YES LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO LATEX_SOURCE_CODE = NO LATEX_BIB_STYLE = plain #--------------------------------------------------------------------------- # Configuration options related to the RTF output #--------------------------------------------------------------------------- GENERATE_RTF = NO RTF_OUTPUT = rtf COMPACT_RTF = NO RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = RTF_EXTENSIONS_FILE = RTF_SOURCE_CODE = NO #--------------------------------------------------------------------------- # Configuration options related to the man page output #--------------------------------------------------------------------------- GENERATE_MAN = NO MAN_OUTPUT = man MAN_EXTENSION = .3 MAN_SUBDIR = MAN_LINKS = NO #--------------------------------------------------------------------------- # Configuration options related to the XML output #--------------------------------------------------------------------------- GENERATE_XML = NO XML_OUTPUT = xml XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # Configuration options related to the DOCBOOK output #--------------------------------------------------------------------------- GENERATE_DOCBOOK = NO DOCBOOK_OUTPUT = docbook DOCBOOK_PROGRAMLISTING = NO #--------------------------------------------------------------------------- # Configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # Configuration options related to the Perl module output #--------------------------------------------------------------------------- GENERATE_PERLMOD = NO PERLMOD_LATEX = NO PERLMOD_PRETTY = YES PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- ENABLE_PREPROCESSING = YES MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = PREDEFINED = DOXYGEN \ TSRMLS_C= \ TSRMLS_D= \ TSRMLS_CC= \ TSRMLS_DC= \ PHP_RAPHF_API= EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration options related to external references #--------------------------------------------------------------------------- TAGFILES = GENERATE_TAGFILE = ALLEXTERNALS = NO EXTERNAL_GROUPS = YES EXTERNAL_PAGES = YES PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- CLASS_DIAGRAMS = YES MSCGEN_PATH = DIA_PATH = HIDE_UNDOC_RELATIONS = YES HAVE_DOT = YES DOT_NUM_THREADS = 0 DOT_FONTNAME = Helvetica DOT_FONTSIZE = 10 DOT_FONTPATH = CLASS_GRAPH = NO COLLABORATION_GRAPH = YES GROUP_GRAPHS = YES UML_LOOK = NO UML_LIMIT_NUM_FIELDS = 10 TEMPLATE_RELATIONS = NO INCLUDE_GRAPH = YES INCLUDED_BY_GRAPH = YES CALL_GRAPH = YES CALLER_GRAPH = YES GRAPHICAL_HIERARCHY = YES DIRECTORY_GRAPH = YES DOT_IMAGE_FORMAT = png INTERACTIVE_SVG = NO DOT_PATH = DOTFILE_DIRS = MSCFILE_DIRS = DIAFILE_DIRS = PLANTUML_JAR_PATH = PLANTUML_INCLUDE_PATH = DOT_GRAPH_MAX_NODES = 50 MAX_DOT_GRAPH_DEPTH = 0 DOT_TRANSPARENT = NO DOT_MULTI_TARGETS = NO GENERATE_LEGEND = YES DOT_CLEANUP = YES raphf-2.0.1/config.m40000644000175000001440000000002513554523006013165 0ustar mikeuserssinclude(config0.m4) raphf-2.0.1/config0.m40000644000175000001440000000134513554523006013253 0ustar mikeusersPHP_ARG_ENABLE(raphf, whether to enable raphf support, [ --enable-raphf Enable resource and persistent handles factory support]) if test "$PHP_RAPHF" != "no"; then PHP_RAPHF_SRCDIR=PHP_EXT_SRCDIR(raphf) PHP_RAPHF_BUILDDIR=PHP_EXT_BUILDDIR(raphf) PHP_ADD_INCLUDE($PHP_RAPHF_SRCDIR/src) PHP_ADD_BUILD_DIR($PHP_RAPHF_BUILDDIR/src) PHP_RAPHF_HEADERS=`(cd $PHP_RAPHF_SRCDIR/src && echo *.h)` PHP_RAPHF_SOURCES=`(cd $PHP_RAPHF_SRCDIR && echo src/*.c)` PHP_NEW_EXTENSION(raphf, $PHP_RAPHF_SOURCES, $ext_shared) PHP_INSTALL_HEADERS(ext/raphf, php_raphf.h $PHP_RAPHF_HEADERS) PHP_SUBST(PHP_RAPHF_HEADERS) PHP_SUBST(PHP_RAPHF_SOURCES) PHP_SUBST(PHP_RAPHF_SRCDIR) PHP_SUBST(PHP_RAPHF_BUILDDIR) PHP_ADD_MAKEFILE_FRAGMENT fi raphf-2.0.1/config.w320000644000175000001440000000170013554523006013261 0ustar mikeusersARG_ENABLE("raphf", "for raphf support", "no"); if (PHP_RAPHF == "yes") { var PHP_RAPHF_HEADERS=glob(configure_module_dirname + "/src/*.h"); var PHP_RAPHF_SRC_ARRAY=glob(configure_module_dirname + "/src/*.c"); var PHP_RAPHF_SOURCES=""; for (var i=0; i$@ <$< $(all_targets): raphf-build-headers clean: raphf-clean-headers .PHONY: raphf-build-headers raphf-build-headers: $(PHP_RAPHF_HEADERS) .PHONY: raphf-clean-headers raphf-clean-headers: -rm -f $(PHP_RAPHF_HEADERS) raphf-2.0.1/php_raphf.h0000644000175000001440000000241713554523006013605 0ustar mikeusers/* +--------------------------------------------------------------------+ | PECL :: raphf | +--------------------------------------------------------------------+ | Redistribution and use in source and binary forms, with or without | | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ | Copyright (c) 2013, Michael Wallner | +--------------------------------------------------------------------+ */ #ifndef PHP_RAPHF_H #define PHP_RAPHF_H extern zend_module_entry raphf_module_entry; #define phpext_raphf_ptr &raphf_module_entry #define PHP_RAPHF_VERSION "2.0.1" #ifdef PHP_WIN32 # define PHP_RAPHF_API __declspec(dllexport) #elif defined(__GNUC__) && __GNUC__ >= 4 # define PHP_RAPHF_API extern __attribute__ ((visibility("default"))) #else # define PHP_RAPHF_API extern #endif #ifdef ZTS # include "TSRM.h" #endif #include "php_raphf_api.h" #endif /* PHP_RAPHF_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 */