2
+----------------------------------------------------------------------+
4
+----------------------------------------------------------------------+
5
| Copyright (c) 2006-2011 The PHP Group |
6
+----------------------------------------------------------------------+
7
| This source file is subject to version 3.01 of the PHP license, |
8
| that is bundled with this package in the file LICENSE, and is |
9
| available through the world-wide-web at the following url: |
10
| http://www.php.net/license/3_01.txt |
11
| If you did not receive a copy of the PHP license and are unable to |
12
| obtain it through the world-wide-web, please send a note to |
13
| license@php.net so we can mail you a copy immediately. |
14
+----------------------------------------------------------------------+
15
| Authors: Daniel Cowgill <dcowgill@communityconnect.com> |
16
| George Schlossnagle <george@omniti.com> |
17
| Rasmus Lerdorf <rasmus@php.net> |
18
| Arun C. Murthy <arunc@yahoo-inc.com> |
19
| Gopal Vijayaraghavan <gopalv@yahoo-inc.com> |
20
+----------------------------------------------------------------------+
22
This software was contributed to PHP by Community Connect Inc. in 2002
23
and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1.
24
Future revisions and derivatives of this source code must acknowledge
25
Community Connect Inc. as the original contributor of this module by
26
leaving this note intact in the source code.
28
All other licensing and usage conditions are those of the PHP Group.
32
/* $Id: apc.h 328292 2012-11-09 07:05:17Z laruence $ */
38
* This module defines utilities and helper functions used elsewhere in APC.
41
# define PHP_APCU_API __declspec(dllexport)
42
#elif defined(__GNUC__) && __GNUC__ >= 4
43
# define PHP_APCU_API __attribute__ ((visibility("default")))
48
/* Commonly needed C library headers. */
58
/* UNIX headers (needed for struct stat) */
59
#include <sys/types.h>
70
#include "main/php_streams.h"
72
/* typedefs for extensible memory allocators */
73
typedef void* (*apc_malloc_t)(size_t TSRMLS_DC);
74
typedef void (*apc_free_t) (void * TSRMLS_DC);
76
/* wrappers for memory allocation routines */
77
PHP_APCU_API void* apc_emalloc(size_t n TSRMLS_DC);
78
PHP_APCU_API void* apc_erealloc(void* p, size_t n TSRMLS_DC);
79
PHP_APCU_API void* apc_php_malloc(size_t n TSRMLS_DC);
80
PHP_APCU_API void apc_php_free(void* p TSRMLS_DC);
81
PHP_APCU_API void apc_efree(void* p TSRMLS_DC);
82
PHP_APCU_API char* apc_estrdup(const char* s TSRMLS_DC);
83
PHP_APCU_API void* apc_xstrdup(const char* s, apc_malloc_t f TSRMLS_DC);
84
PHP_APCU_API void* apc_xmemcpy(const void* p, size_t n, apc_malloc_t f TSRMLS_DC);
86
/* console display functions */
87
PHP_APCU_API void apc_error(const char *format TSRMLS_DC, ...);
88
PHP_APCU_API void apc_warning(const char *format TSRMLS_DC, ...);
89
PHP_APCU_API void apc_notice(const char *format TSRMLS_DC, ...);
90
PHP_APCU_API void apc_debug(const char *format TSRMLS_DC, ...);
92
/* string and text manipulation */
93
PHP_APCU_API char* apc_append(const char* s, const char* t TSRMLS_DC);
94
PHP_APCU_API char* apc_substr(const char* s, int start, int length TSRMLS_DC);
95
PHP_APCU_API char** apc_tokenize(const char* s, char delim TSRMLS_DC);
97
/* apc_crc32: returns the CRC-32 checksum of the first len bytes in buf */
98
PHP_APCU_API unsigned int apc_crc32(const unsigned char* buf, unsigned int len);
100
/* apc_flip_hash flips keys and values for faster searching */
101
PHP_APCU_API HashTable* apc_flip_hash(HashTable *hash);
103
#define APC_NEGATIVE_MATCH 1
104
#define APC_POSITIVE_MATCH 2
107
(APCG(use_request_time) ? (time_t) sapi_get_request_time(TSRMLS_C) : time(0));
109
#if defined(__GNUC__)
110
# define APC_UNUSED __attribute__((unused))
111
# define APC_USED __attribute__((used))
112
# define APC_ALLOC __attribute__((malloc))
113
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)
114
# define APC_HOTSPOT __attribute__((hot))
128
#define APC_SERIALIZER_ABI "0"
129
#define APC_SERIALIZER_CONSTANT "\000apc_register_serializer-" APC_SERIALIZER_ABI
131
#define APC_SERIALIZER_NAME(module) module##_apc_serializer
132
#define APC_UNSERIALIZER_NAME(module) module##_apc_unserializer
134
#define APC_SERIALIZER_ARGS unsigned char **buf, size_t *buf_len, const zval *value, void *config TSRMLS_DC
135
#define APC_UNSERIALIZER_ARGS zval **value, unsigned char *buf, size_t buf_len, void *config TSRMLS_DC
137
typedef int (*apc_serialize_t)(APC_SERIALIZER_ARGS);
138
typedef int (*apc_unserialize_t)(APC_UNSERIALIZER_ARGS);
140
/* {{{ struct definition: apc_serializer_t */
141
typedef struct apc_serializer_t {
143
apc_serialize_t serialize;
144
apc_unserialize_t unserialize;
149
/* {{{ _apc_register_serializer
150
registers the serializer using the given name and paramters */
151
PHP_APCU_API int _apc_register_serializer(const char* name,
152
apc_serialize_t serialize,
153
apc_unserialize_t unserialize,
154
void *config TSRMLS_DC); /* }}} */
156
/* {{{ apc_get_serializers
157
fetches the list of serializers */
158
PHP_APCU_API apc_serializer_t* apc_get_serializers(TSRMLS_D); /* }}} */
160
/* {{{ apc_find_serializer
161
finds a previously registered serializer by name */
162
PHP_APCU_API apc_serializer_t* apc_find_serializer(const char* name TSRMLS_DC); /* }}} */
164
/* {{{ default serializers */
165
PHP_APCU_API int APC_SERIALIZER_NAME(php) (APC_SERIALIZER_ARGS);
166
PHP_APCU_API int APC_UNSERIALIZER_NAME(php) (APC_UNSERIALIZER_ARGS); /* }}} */
168
/* {{{ eval serializers */
169
PHP_APCU_API int APC_SERIALIZER_NAME(eval) (APC_SERIALIZER_ARGS);
170
PHP_APCU_API int APC_UNSERIALIZER_NAME(eval) (APC_UNSERIALIZER_ARGS); /* }}} */
179
* vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker
180
* vim<600: expandtab sw=4 ts=4 sts=4