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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
/*
+----------------------------------------------------------------------+
| PHP HTML Embedded Scripting Language Version 3.0 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2000 PHP Development Team (See Credits file) |
+----------------------------------------------------------------------+
| This program is free software; you can redistribute it and/or modify |
| it under the terms of one of the following licenses: |
| |
| A) the GNU General Public License as published by the Free Software |
| Foundation; either version 2 of the License, or (at your option) |
| any later version. |
| |
| B) the PHP License as published by the PHP Development Team and |
| included in the distribution in the file: LICENSE |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
| |
| You should have received a copy of both licenses referred to here. |
| If you did not, or have any questions about PHP licensing, please |
| contact core@php.net. |
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@vipe.technion.ac.il> |
| Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
/* $Id: token_cache.h,v 1.11 2000/02/07 23:54:50 zeev Exp $ */
#ifndef _TOKEN_CACHE
#define _TOKEN_CACHE
#include "php_alloc.h"
#define uint unsigned int
#define SUCCESS 0
#define FAILURE -1
#define GLOBAL(x) x
#define MAX(a,b) (((a)>(b))?(a):(b))
/* data types */
#define IS_LONG 0x1
#define IS_DOUBLE 0x2
#define IS_STRING 0x4
#define IS_ARRAY 0x8
#define IS_EMPTY 0x10
#define IS_USER_FUNCTION 0x20
#define IS_INTERNAL_FUNCTION 0x40
#define IS_TEMPORARY_INTERNAL_FUNCTION 0x80
#define IS_UNSUPPORTED_FUNCTION 0x100
#define IS_CLASS 0x200
#define IS_OBJECT 0x400
#define IS_NULL 0x800
typedef union {
unsigned char switched;
unsigned char included;
unsigned short function_call_type;
unsigned char array_write;
unsigned char error_reporting;
} control_structure_data; /* control-structure data */
typedef struct _pvalue_struct _pvalue;
#define pval _pvalue
#define YYSTYPE pval
typedef union {
long lval; /* long value */
double dval; /* double value */
char *strval; /* string value */
char chval; /* char value */
void *pvalue_ptr; /* used for implementation of multi-dimensional arrays */
} pvalue_value;
struct _pvalue_struct {
/* Variable information */
unsigned short type; /* active type */
/* Control structures */
control_structure_data cs_data;
unsigned int offset;
unsigned char *func_arg_types; /* optionally used to force passing by reference */
pvalue_value value; /* value */
int strlen; /* string length */
};
typedef struct {
pval phplval;
int token_type;
unsigned int lineno;
} Token;
typedef struct {
Token *tokens; /* tokens array */
int count; /* token count */
int pos; /* current position in the tokens array */
int max_tokens; /* (current) max tokens number (respectively) */
int block_size; /* token block size */
} TokenCache;
typedef struct {
TokenCache *token_caches;
int active;
int max;
int initialized;
} TokenCacheManager;
#define TOKEN_CACHE_BLOCK_SIZE 8192
#define TOKEN_CACHE_EVAL_BLOCK_SIZE 32
#define TOKEN_CACHES_BLOCK_SIZE 4
#define MAX_TOKENS_PER_CACHE 1048576
extern int tcm_init(TokenCacheManager *tcm);
extern int tc_init(TokenCache *tc,int block_size);
extern int read_next_token(TokenCacheManager *tcm, Token **token, pval *phplval);
extern int seek_token(TokenCacheManager *tcm, int offset);
extern int tc_switch(TokenCacheManager *tcm, int start, int end, int middle);
extern int tc_set_switched(TokenCacheManager *tcm, int offset);
extern int tc_set_included(TokenCacheManager *tcm, int offset);
extern int tc_destroy(TokenCache *tc);
extern void tcm_destroy(TokenCacheManager *tcm);
extern int tcm_new(TokenCacheManager *tcm);
extern void tcm_save(TokenCacheManager *tcm);
extern int tcm_load(TokenCacheManager *tcm);
#endif
|