2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2013, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
16 extern zend_module_entry raphf_module_entry
;
17 #define phpext_raphf_ptr &raphf_module_entry
19 #define PHP_RAPHF_VERSION "1.0.2"
22 # define PHP_RAPHF_API __declspec(dllexport)
23 #elif defined(__GNUC__) && __GNUC__ >= 4
24 # define PHP_RAPHF_API __attribute__ ((visibility("default")))
26 # define PHP_RAPHF_API
33 typedef void *(*php_resource_factory_handle_ctor_t
)(void *opaque
,
34 void *init_arg TSRMLS_DC
);
35 typedef void *(*php_resource_factory_handle_copy_t
)(void *opaque
,
36 void *handle TSRMLS_DC
);
37 typedef void (*php_resource_factory_handle_dtor_t
)(void *opaque
,
38 void *handle TSRMLS_DC
);
40 typedef struct php_resource_factory_ops
{
41 php_resource_factory_handle_ctor_t ctor
;
42 php_resource_factory_handle_copy_t copy
;
43 php_resource_factory_handle_dtor_t dtor
;
44 } php_resource_factory_ops_t
;
46 typedef struct php_resource_factory
{
47 php_resource_factory_ops_t fops
;
50 void (*dtor
)(void *data
);
53 } php_resource_factory_t
;
55 PHP_RAPHF_API php_resource_factory_t
*php_resource_factory_init(
56 php_resource_factory_t
*f
, php_resource_factory_ops_t
*fops
, void *data
,
57 void (*dtor
)(void *data
));
58 PHP_RAPHF_API
unsigned php_resource_factory_addref(php_resource_factory_t
*rf
);
59 PHP_RAPHF_API
void php_resource_factory_dtor(php_resource_factory_t
*f
);
60 PHP_RAPHF_API
void php_resource_factory_free(php_resource_factory_t
**f
);
62 PHP_RAPHF_API
void *php_resource_factory_handle_ctor(php_resource_factory_t
*f
,
63 void *init_arg TSRMLS_DC
);
64 PHP_RAPHF_API
void *php_resource_factory_handle_copy(php_resource_factory_t
*f
,
65 void *handle TSRMLS_DC
);
66 PHP_RAPHF_API
void php_resource_factory_handle_dtor(php_resource_factory_t
*f
,
67 void *handle TSRMLS_DC
);
69 typedef struct php_persistent_handle_list
{
72 } php_persistent_handle_list_t
;
74 typedef struct php_persistent_handle_provider
{
75 php_persistent_handle_list_t list
; /* "ident" => array(handles) entries */
76 php_resource_factory_t rf
;
77 } php_persistent_handle_provider_t
;
79 typedef struct php_persistent_handle_factory php_persistent_handle_factory_t
;
81 typedef void (*php_persistent_handle_wakeup_t
)(
82 php_persistent_handle_factory_t
*f
, void **handle TSRMLS_DC
);
83 typedef void (*php_persistent_handle_retire_t
)(
84 php_persistent_handle_factory_t
*f
, void **handle TSRMLS_DC
);
86 struct php_persistent_handle_factory
{
87 php_persistent_handle_provider_t
*provider
;
89 php_persistent_handle_wakeup_t wakeup
;
90 php_persistent_handle_retire_t retire
;
97 unsigned free_on_abandon
:1;
100 struct php_persistent_handle_globals
{
105 PHP_RAPHF_API
int /* SUCCESS|FAILURE */ php_persistent_handle_provide(
106 const char *name_str
, size_t name_len
, php_resource_factory_ops_t
*fops
,
107 void *data
, void (*dtor
)(void *) TSRMLS_DC
);
108 PHP_RAPHF_API php_persistent_handle_factory_t
*php_persistent_handle_concede(
109 php_persistent_handle_factory_t
*a
, const char *name_str
,
110 size_t name_len
, const char *ident_str
, size_t ident_len
,
111 php_persistent_handle_wakeup_t wakeup
,
112 php_persistent_handle_retire_t retire TSRMLS_DC
);
113 PHP_RAPHF_API
void php_persistent_handle_abandon(
114 php_persistent_handle_factory_t
*a
);
115 PHP_RAPHF_API
void *php_persistent_handle_acquire(
116 php_persistent_handle_factory_t
*a
, void *init_arg TSRMLS_DC
);
117 PHP_RAPHF_API
void php_persistent_handle_release(
118 php_persistent_handle_factory_t
*a
, void *handle TSRMLS_DC
);
119 PHP_RAPHF_API
void *php_persistent_handle_accrete(
120 php_persistent_handle_factory_t
*a
, void *handle TSRMLS_DC
);
122 PHP_RAPHF_API php_resource_factory_ops_t
*
123 php_persistent_handle_get_resource_factory_ops(void);
125 PHP_RAPHF_API
void php_persistent_handle_cleanup(const char *name_str
,
126 size_t name_len
, const char *ident_str
, size_t ident_len TSRMLS_DC
);
127 PHP_RAPHF_API HashTable
*php_persistent_handle_statall(HashTable
*ht TSRMLS_DC
);
129 ZEND_BEGIN_MODULE_GLOBALS(raphf
)
130 struct php_persistent_handle_globals persistent_handle
;
131 ZEND_END_MODULE_GLOBALS(raphf
)
134 # define PHP_RAPHF_G ((zend_raphf_globals *) \
135 (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(raphf_globals_id)])
137 # define PHP_RAPHF_G (&raphf_globals)
140 #endif /* PHP_RAPHF_H */
148 * vim600: noet sw=4 ts=4 fdm=marker
149 * vim<600: noet sw=4 ts=4