forked from reeze/php-ext-embed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
php_ext_embed.h
89 lines (75 loc) · 3.58 KB
/
php_ext_embed.h
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
/*
+----------------------------------------------------------------------+
| PHP Embedable Ext |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2015 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: |
| http://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: Reeze Xia <reeze@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef _PHP_EXT_EMBED_H_
#define _PHP_EXT_EMBED_H_
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <php.h>
#define PHP_EXT_EMBED_VERSION "1.0.1"
#define PHP_EXT_EMBED_API_NO 10000
#define PHP_EXT_EMBED_PROTO_NAME "extension-embed"
#if PHP_MAJOR_VERSION == 4 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 2)
#error "php_ext_embed only supports PHP 5.2 and higher"
#endif
#ifdef PHP_EXT_EMBED_DEBUG
#define EMBED_DBG(args...) php_error_docref(NULL TSRMLS_CC, E_WARNING, "DEBUG: " ##args)
#else
#define EMBED_DBG(args...)
#endif
/*
* PHP-Ext-Embed register a internal php stream wrapper to
* load php lib from binary. This make the libs can take
* advantage of opcache extension, eg: apc, opcache...
*/
typedef struct _php_ext_embed_wrapper {
php_stream_wrapper wraper; /* should be the first */
const char *extname; /* for debugging */
int api_no; /* to detect future possible incompatible if we change api */
HashTable embeded_entries; /* used to improve speed for entry lookup */
} php_ext_embed_wrapper;
typedef struct php_ext_lib_stat {
size_t offset;
size_t size;
time_t m_time;
} php_ext_lib_stat;
/*
* An entry for a embeded php lib file
*/
typedef struct _php_ext_lib_entry {
const char *extname;
const char *filename; /* relative filename */
const char *dummy_filename; /* internal filename */
const char *section_name; /* the section name of the embed file in so */
int include_on_rinit; /* it allow user embed but not include, yes for future */
php_ext_lib_stat stat; /* basic info for entry */
} php_ext_lib_entry;
/*
* the same naming conversion as your entension, please put the corresponding
* macro to your extension
*/
#define PHP_EXT_EMBED_MINIT(extname) php_embed_minit(#extname, ext_ ## extname ## _embed_files TSRMLS_CC)
#define PHP_EXT_EMBED_RINIT(extname) php_embed_rinit(#extname, ext_ ## extname ## _embed_files TSRMLS_CC)
#define PHP_EXT_EMBED_RSHUTDOWN(extname) php_embed_rshutdown(#extname, ext_ ## extname ## _embed_files TSRMLS_CC)
#define PHP_EXT_EMBED_MSHUTDOWN(extname) php_embed_mshutdown(#extname, ext_ ## extname ## _embed_files TSRMLS_CC)
int php_embed_minit(const char *extname, php_ext_lib_entry *embed_files TSRMLS_DC);
int php_embed_rinit(const char *extname, php_ext_lib_entry *embed_files TSRMLS_DC);
int php_embed_rshutdown(const char *extname, php_ext_lib_entry *embed_files TSRMLS_DC);
int php_embed_mshutdown(const char *extname, php_ext_lib_entry *embed_files TSRMLS_DC);
#endif