OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [libnetworking/] [rtems_webserver/] [ej.h] - Blame information for rev 507

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *      ej.h -- Ejscript(TM) header
3
 *
4
 *      Copyright (c) Go Ahead Software, Inc., 1992-1999
5
 *
6
 *      See the file "license.txt" for information on usage and redistribution
7
 */
8
 
9
#ifndef _h_EJ
10
#define _h_EJ 1
11
 
12
/******************************** Description *********************************/
13
 
14
/*
15
 *      Go Ahead Ejscript(TM) header. This defines the Ejscript API and internal
16
 *      structures.
17
 */
18
 
19
/********************************* Includes ***********************************/
20
 
21
#include        <ctype.h>
22
#include        <stdarg.h>
23
#include        <stdlib.h>
24
#ifndef CE
25
        #include        <fcntl.h>
26
#endif
27
 
28
#if LYNX
29
        #include        <unistd.h>
30
#endif
31
 
32
#ifdef QNX4
33
        #include        <dirent.h>
34
#endif
35
 
36
#if UEMF
37
        #include        "uemf.h"
38
#else
39
        #include        <param.h>
40
        #include        <stat.h>
41
        #include        "basic/basicInternal.h"
42
        #include        "emf/emf.h"
43
        #include        "webs/webs.h"
44
#endif
45
 
46
/********************************** Defines ***********************************/
47
/*
48
 *      Constants
49
 */
50
#define EJ_INC                          110             /* Growth for tags/tokens */
51
#define EJ_OFFSET                       1               /* hAlloc doesn't like 0 entries */
52
#define EJ_MAX_RECURSE          100             /* Sanity for maximum recursion */
53
 
54
/*
55
 *      Ejscript Lexical analyser tokens
56
 */
57
#define TOK_ERR                         -1              /* Any error */
58
#define TOK_LPAREN                      1               /* ( */
59
#define TOK_RPAREN                      2               /* ) */
60
#define TOK_IF                          3               /* if */
61
#define TOK_ELSE                        4               /* else */
62
#define TOK_LBRACE                      5               /* { */
63
#define TOK_RBRACE                      6               /* } */
64
#define TOK_LOGICAL                     7               /* ||, &&, ! */
65
#define TOK_EXPR                        8               /* +, -, /, % */
66
#define TOK_SEMI                        9               /* ; */
67
#define TOK_LITERAL                     10              /* literal string */
68
#define TOK_FUNCTION            11              /* function name */
69
#define TOK_NEWLINE                     12              /* newline white space */
70
#define TOK_ID                          13              /* function name */
71
#define TOK_EOF                         14              /* End of script */
72
#define TOK_COMMA                       15              /* Comma */
73
#define TOK_VAR                         16              /* var */
74
#define TOK_ASSIGNMENT          17              /* = */
75
#define TOK_FOR                         18              /* for */
76
#define TOK_INC_DEC                     19              /* ++, -- */
77
#define TOK_RETURN                      20              /* return */
78
 
79
/*
80
 *      Expression operators
81
 */
82
#define EXPR_LESS                       1               /* < */
83
#define EXPR_LESSEQ                     2               /* <= */
84
#define EXPR_GREATER            3               /* > */
85
#define EXPR_GREATEREQ          4               /* >= */
86
#define EXPR_EQ                         5               /* == */
87
#define EXPR_NOTEQ                      6               /* != */
88
#define EXPR_PLUS                       7               /* + */
89
#define EXPR_MINUS                      8               /* - */
90
#define EXPR_DIV                        9               /* / */
91
#define EXPR_MOD                        10              /* % */
92
#define EXPR_LSHIFT                     11              /* << */
93
#define EXPR_RSHIFT                     12              /* >> */
94
#define EXPR_MUL                        13              /* * */
95
#define EXPR_ASSIGNMENT         14              /* = */
96
#define EXPR_INC                        15              /* ++ */
97
#define EXPR_DEC                        16              /* -- */
98
 
99
/*
100
 *      Conditional operators
101
 */
102
#define COND_AND                        1               /* && */
103
#define COND_OR                         2               /* || */
104
#define COND_NOT                        3               /* ! */
105
 
106
/*
107
 *      States
108
 */
109
#define STATE_ERR                               -1                      /* Error state */
110
#define STATE_EOF                               1                       /* End of file */
111
#define STATE_COND                              2                       /* Parsing a "(conditional)" stmt */
112
#define STATE_COND_DONE                 3
113
#define STATE_RELEXP                    4                       /* Parsing a relational expr */
114
#define STATE_RELEXP_DONE               5
115
#define STATE_EXPR                              6                       /* Parsing an expression */
116
#define STATE_EXPR_DONE                 7
117
#define STATE_STMT                              8                       /* Parsing General statement */
118
#define STATE_STMT_DONE                 9
119
#define STATE_STMT_BLOCK_DONE   10                      /* End of block "}" */
120
#define STATE_ARG_LIST                  11                      /* Function arg list */
121
#define STATE_ARG_LIST_DONE             12
122
#define STATE_DEC_LIST                  16                      /* Declaration list */
123
#define STATE_DEC_LIST_DONE             17
124
#define STATE_DEC                               18
125
#define STATE_DEC_DONE                  19
126
#define STATE_BEGIN                             STATE_STMT
127
 
128
/*
129
 *      Flags. Used in ej_t and as parameter to parse()
130
 */
131
#define FLAGS_EXE                               0x1                             /* Execute statements */
132
#define FLAGS_VARIABLES                 0x2                             /* Allocated variables store */
133
#define FLAGS_FUNCTIONS                 0x4                             /* Allocated function store */
134
 
135
/*
136
 *      Function call structure
137
 */
138
typedef struct {
139
        char_t          *fname;                                                 /* Function name */
140
        char_t          **args;                                                 /* Args for function (halloc) */
141
        int                     nArgs;                                                  /* Number of args */
142
} ejfunc_t;
143
 
144
/*
145
 *      EJ evaluation block structure
146
 */
147
typedef struct ejEval {
148
        ringq_t         tokbuf;                                                 /* Current token */
149
        ringq_t         script;                                                 /* Input script for parsing */
150
        char_t          *putBackToken;                                  /* Putback token string */
151
        int                     putBackTokenId;                                 /* Putback token ID */
152
        char_t          *line;                                                  /* Current line */
153
        int                     lineLength;                                             /* Current line length */
154
        int                     lineNumber;                                             /* Parse line number */
155
        int                     lineColumn;                                             /* Column in line */
156
} ejinput_t;
157
 
158
/*
159
 *      Per Ejscript session structure
160
 */
161
typedef struct ej {
162
        ejinput_t       *input;                                                 /* Input evaluation block */
163
        sym_fd_t        functions;                                              /* Symbol table for functions */
164
        sym_fd_t        *variables;                                             /* hAlloc list of variables */
165
        int                     variableMax;                                    /* Number of entries */
166
        ejfunc_t        *func;                                                  /* Current function */
167
        char_t          *result;                                                /* Current expression result */
168
        char_t          *error;                                                 /* Error message */
169
        char_t          *token;                                                 /* Pointer to token string */
170
        int                     tid;                                                    /* Current token id */
171
        int                     eid;                                                    /* Halloc handle */
172
        int                     flags;                                                  /* Flags */
173
        int                     userHandle;                                             /* User defined handle */
174
} ej_t;
175
 
176
/******************************** Prototypes **********************************/
177
 
178
extern int              ejOpenEngine(sym_fd_t variables, sym_fd_t functions);
179
extern void             ejCloseEngine(int eid);
180
extern int              ejOpenBlock(int eid);
181
extern int              ejCloseBlock(int eid, int vid);
182
extern char_t   *ejEval(int eid, char_t *script, char_t **emsg);
183
extern char_t   *ejEvalBlock(int eid, char_t *script, char_t **emsg);
184
extern char_t   *ejEvalFile(int eid, char_t *path, char_t **emsg);
185
extern int              ejSetGlobalFunction(int eid, char_t *name,
186
                                        int (*fn)(int eid, void *handle, int argc, char_t **argv));
187
extern void             *ejGetGlobalFunction(int eid, char_t *name);
188
extern int              ejSetGlobalFunctionDirect(sym_fd_t functions, char_t *name,
189
                                        int (*fn)(int eid, void *handle, int argc, char_t **argv));
190
extern int              ejArgs(int argc, char_t **argv, char_t *fmt, ...);
191
extern void     ejError(ej_t* ep, char_t* fmt, ...);
192
extern void             ejSetUserHandle(int eid, int handle);
193
extern int              ejGetUserHandle(int eid);
194
extern int              ejGetLineNumber(int eid);
195
extern void             ejSetResult(int eid, char_t *s);
196
extern char_t   *ejGetResult(int eid);
197
extern void             ejSetVar(int eid, char_t *var, char_t *value);
198
extern void             ejSetLocalVar(int eid, char_t *var, char_t *value);
199
extern int              ejGetVar(int eid, char_t *var, char_t **value);
200
extern void             ejSetGlobalVar(int eid, char_t *var, char_t *value);
201
 
202
extern int              ejLexOpen(ej_t* ep);
203
extern void     ejLexClose(ej_t* ep);
204
extern int              ejLexOpenScript(ej_t* ep, char_t *script);
205
extern void     ejLexCloseScript(ej_t* ep);
206
extern void     ejLexSaveInputState(ej_t* ep, ejinput_t* state);
207
extern void     ejLexFreeInputState(ej_t* ep, ejinput_t* state);
208
extern void     ejLexRestoreInputState(ej_t* ep, ejinput_t* state);
209
extern int              ejLexGetToken(ej_t* ep, int state);
210
extern void             ejLexPutbackToken(ej_t* ep, int tid, char_t *string);
211
 
212
extern sym_fd_t ejGetVariableTable(int eid);
213
extern sym_fd_t ejGetFunctionTable(int eid);
214
 
215
extern int              ejEmfOpen(int eid);
216
extern void             ejEmfClose(int eid);
217
 
218
extern int ejEmfDbRead(int eid, void *handle, int argc, char_t **argv);
219
extern int ejEmfDbReadKeyed(int eid, void *handle, int argc, char_t **argv);
220
extern int ejEmfDbTableGetNrow(int eid, void *handle, int argc, char_t **argv);
221
extern int ejEmfTrace(int eid, void *handle, int argc, char_t **argv);
222
extern int ejEmfDbWrite(int eid, void *handle, int argc, char_t **argv);
223
 
224
#endif /* _h_EJ */
225
 
226
/*****************************************************************************/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.