File: php_r3.c

package info (click to toggle)
libr3 1.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, stretch
  • size: 1,084 kB
  • ctags: 1,086
  • sloc: ansic: 13,117; cpp: 175; makefile: 112; sh: 64; ruby: 52
file content (106 lines) | stat: -rw-r--r-- 2,446 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "php.h"
#include "string.h"
#include "main/php_main.h"
#include "Zend/zend_API.h"
#include "Zend/zend_variables.h"
#include "zend_exceptions.h"
#include "zend_interfaces.h"
#include "zend_object_handlers.h"
#include "ext/standard/php_string.h"

#include "php_r3.h"
// #include "ct_helper.h"
#include "r3_functions.h"
// #include "r3_mux.h"
// #include "php_expandable_mux.h"
// #include "r3_controller.h"

ZEND_DECLARE_MODULE_GLOBALS(r3);


// persistent list entry type for HashTable
int le_mux_hash_table;

// persistent list entry type for boolean
int le_mux_bool;

// persistent list entry type for int
int le_mux_int;

// persistent list entry type for string
int le_mux_string;

zend_class_entry *ce_r3_exception;


// #define DEBUG 1
static const zend_function_entry r3_functions[] = {
    PHP_FE(r3_match, NULL)
    PHP_FE_END
};

void r3_init_exception(TSRMLS_D) {
  zend_class_entry e;
  INIT_CLASS_ENTRY(e, "R3Exception", NULL);
  ce_r3_exception = zend_register_internal_class_ex(&e, (zend_class_entry*)zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC);
}

void r3_mux_le_hash_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
    HashTable *h = (HashTable*) rsrc->ptr;
    if (h) {
        // zend_hash_destroy(h);
        // pefree(h, 1);
    }
}

zend_module_entry r3_module_entry = {
    STANDARD_MODULE_HEADER,
    PHP_R3_EXTNAME,
    r3_functions,
    PHP_MINIT(r3),
    PHP_MSHUTDOWN(r3),
    PHP_RINIT(r3),
    NULL,
    NULL,
    PHP_R3_VERSION,
    STANDARD_MODULE_PROPERTIES
};

PHP_INI_BEGIN()
    PHP_INI_ENTRY("r3.fstat", "0", PHP_INI_ALL, NULL)
    // STD_PHP_INI_ENTRY("r3.direction", "1", PHP_INI_ALL, OnUpdateBool, direction, zend_hello_globals, hello_globals)
PHP_INI_END()

#ifdef COMPILE_DL_R3
ZEND_GET_MODULE(r3)
#endif

static void php_r3_init_globals(zend_r3_globals *r3_globals)
{
    // r3_globals->persistent_list = (HashTable*) 
    // array_init(r3_globals->persistent_list);
}

PHP_MINIT_FUNCTION(r3) {
  ZEND_INIT_MODULE_GLOBALS(r3, php_r3_init_globals, NULL);
  REGISTER_INI_ENTRIES();
  // r3_init_mux(TSRMLS_C);
  // r3_init_expandable_mux(TSRMLS_C);
  // r3_init_controller(TSRMLS_C);
  le_mux_hash_table = zend_register_list_destructors_ex(NULL, r3_mux_le_hash_dtor, "hash table", module_number);
  return SUCCESS;
}

PHP_MSHUTDOWN_FUNCTION(r3) {
  UNREGISTER_INI_ENTRIES();
  return SUCCESS;
}

PHP_RINIT_FUNCTION(r3) {
  return SUCCESS;
}