00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _NODE_H_
00026 #define _NODE_H_
00027 #include <stdio.h>
00028 #include <time.h>
00029
00030 #if defined(_WIN32) || defined(__declspec)
00031
00032 # ifdef COMPILE_DLL
00033 # define STORAGE_TYPE __declspec(dllexport)
00034 # else
00035 # define STORAGE_TYPE __declspec(dllimport)
00036 # endif
00037
00038 #else // _WIN32 || __declspec
00039 # define STORAGE_TYPE extern
00040 #endif // _WIN32 || __declspec
00041
00042
00043 #ifdef __cplusplus
00044 extern "C"
00045 {
00046 #endif
00047
00048
00051 typedef enum {
00052
00055 NODE_GLOBAL = 0,
00056
00058 NODE_GENERIC = 1,
00059
00061 NODE_PARSED_INTEGER = 2,
00063 NODE_PARSED_DOUBLE = 3,
00065 NODE_PARSED_DATE = 4,
00066
00067 NODE_EXTERNAL = 5
00068
00069 } NodeType;
00070
00071 #ifdef _WIN32
00072
00073 typedef __int64 word64;
00074 typedef unsigned __int64 uword64;
00075 #else
00076 typedef long long int word64;
00077 typedef unsigned long long int uword64;
00078 #endif
00079 #define NODE_CODE 1131
00080 #define NODE_CHECK(x) ((x)->code == NODE_CODE ? 1 : 0)
00081
00084 typedef struct {
00086 int code;
00088 NodeType type;
00089 union {
00090 long parsed_integer;
00091 double parsed_double;
00092 long parsed_date;
00093 unsigned long id;
00094 };
00096 char *literal;
00097
00099 char *context;
00100 char *instance_of;
00101 time_t start;
00102 time_t end;
00103 } Node;
00104
00105
00106
00107 static Node NODE_NULL = { NODE_CODE, NODE_GLOBAL, 0, 0};
00108
00114 STORAGE_TYPE
00115 Node *node_clone(const Node* src);
00116
00124
00125
00126
00127
00128
00142 STORAGE_TYPE
00143 void node_init_string(Node *node, const char *string);
00144
00148 STORAGE_TYPE
00149 void node_init_integer(Node *node, long value);
00150
00154 STORAGE_TYPE
00155 void node_init_double(Node *node, double value);
00156
00157 STORAGE_TYPE
00158 void node_set_instance_of(Node *node, const Node *context, const Node *instance_of);
00159
00160
00161
00162
00163
00164
00174 STORAGE_TYPE
00175 void node_set_literal(Node *node, const char *literal, long literal_size);
00176
00184 STORAGE_TYPE
00185 const char *node_get_literal(Node *node, long *literal_size);
00186
00187
00189 STORAGE_TYPE
00190 void node_free(Node *node);
00191
00192
00197 STORAGE_TYPE
00198 void node_clear(Node *node);
00199
00206 void node_print(FILE *channel, Node *node);
00207
00217 STORAGE_TYPE
00218 int node_compare(const Node *node1, const Node *node2);
00219
00222 int node_compare_(const Node *node1, const Node *node2);
00223
00224
00225
00226 STORAGE_TYPE
00227 void* kml_malloc(size_t size);
00228
00229 STORAGE_TYPE
00230 void* kml_calloc(size_t num, size_t size);
00231
00232 STORAGE_TYPE
00233 void* kml_realloc(void* memblock, size_t size);
00234
00235 STORAGE_TYPE
00236 void kml_free(void* memblock);
00237
00238 #ifdef __cplusplus
00239 }
00240 #endif
00241
00242 #endif
00243 #ifdef DMALLOC
00244 #include<dmalloc.h>
00245 #endif