File size: 2,527 Bytes
1e94262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/*
   +----------------------------------------------------------------------+
   | Copyright (c) The PHP Group                                          |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
   | https://www.php.net/license/3_01.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.               |
   +----------------------------------------------------------------------+
   | Authors: Niels Dossche <nielsdos@php.net>                            |
   |          Mate Kocsis <kocsismate@php.net>                            |
   +----------------------------------------------------------------------+
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "php.h"
#include "zend_globals.h"
#include "ext/standard/info.h"
#include "lexbor/core/types.h"
#include "lexbor/core/lexbor.h"

#ifdef HAVE_LEXBOR

#include "php_lexbor.h"

static void *php_lexbor_malloc(size_t size)
{
	return emalloc(size);
}

static void *php_lexbor_realloc(void *dst, size_t size)
{
	return erealloc(dst, size);
}

static void *php_lexbor_calloc(size_t num, size_t size)
{
	return ecalloc(num, size);
}

static void php_lexbor_free(void *ptr)
{
	efree(ptr);
}

static PHP_MINFO_FUNCTION(lexbor)
{
	php_info_print_table_start();
	php_info_print_table_row(2, "Lexbor support", "active");
	php_info_print_table_row(2, "Lexbor version", LEXBOR_VERSION);
	php_info_print_table_end();
}

static PHP_MINIT_FUNCTION(lexbor)
{
	lexbor_memory_setup(php_lexbor_malloc, php_lexbor_realloc, php_lexbor_calloc, php_lexbor_free);
	return SUCCESS;
}

zend_module_entry lexbor_module_entry = {
	STANDARD_MODULE_HEADER,
	"lexbor",                   /* extension name */
	NULL,                       /* extension function list */
	PHP_MINIT(lexbor),          /* extension-wide startup function */
	NULL,                       /* extension-wide shutdown function */
	NULL,                       /* per-request startup function */
	NULL,                       /* per-request shutdown function */
	PHP_MINFO(lexbor),          /* information function */
	NULL,
	STANDARD_MODULE_PROPERTIES
};

#endif