"Fossies" - the Fresh Open Source Software Archive

Member "mirrordir-0.10.49/diffie/parse.h" (23 Nov 1999, 2902 Bytes) of package /linux/misc/old/mirrordir-0.10.49.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "parse.h" see the Fossies "Dox" file reference documentation.

    1 /* parse.c - simple C intepretor
    2    This has nothing to do with cryptography.
    3    Copyright (C) 1998 Paul Sheer
    4 
    5    This program is free software; you can redistribute it and/or modify
    6    it under the terms of the GNU General Public License as published by
    7    the Free Software Foundation; either version 2 of the License, or
    8    (at your option) any later version.
    9 
   10    This program is distributed in the hope that it will be useful,
   11    but WITHOUT ANY WARRANTY; without even the implied warranty of
   12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13    GNU General Public License for more details.
   14 
   15    You should have received a copy of the GNU General Public License
   16    along with this program; if not, write to the Free Software
   17    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   18    02111-1307, USA.  
   19  */
   20 
   21 #ifndef _PARSER_H
   22 #define _PARSER_H
   23 
   24 #ifdef WIN32
   25 #define PATH_SEP_STR "\\"
   26 #define PATH_SEP '\\'
   27 #else
   28 #define PATH_SEP_STR "/"
   29 #define PATH_SEP '/'
   30 #endif
   31 
   32 typedef struct {
   33 /* on any sane system, these will all be of 
   34    size equal to or smaller than long int */
   35     union {
   36     char *s;
   37     long i;
   38     long *p;
   39     Huge *h;
   40     } v;
   41 #define VALUE_LEN       (0x000FFFFF)
   42 #define VALUE_LONG      (0x00100000)
   43 #define VALUE_ENDVARARGS    (0x00200000)
   44 #define VALUE_HUGE      (0x00400000)
   45 #define VALUE_STRING        (0x00800000)
   46 #define VALUE_POINTER       (0x0F000000)
   47 #define VALUE_P0        (0x01000000)
   48 #define VALUE_P1        (0x02000000)
   49 #define VALUE_P2        (0x03000000)
   50 #define VALUE_P3        (0x04000000)
   51 #define VALUE_P4        (0x05000000)
   52 #define VALUE_P5        (0x06000000)
   53 #define VALUE_TYPE      (0x0FF00000)
   54 #define VALUE_FREE      (0x10000000)
   55 #define VALUE_END       (0x20000000)
   56     int type;
   57 } Value;
   58 
   59 typedef struct value_stack {
   60     Value value;
   61     struct value_stack *next;
   62 } ValueStack;
   63 
   64 typedef struct {
   65     int len;
   66     char *s;
   67     int priority;
   68 /* predefined constants per instance of the script */
   69 #define OP_PREDEF   40
   70 /* user functions */
   71 #define OP_USER_FUNCTION    90
   72 /* functions */
   73 #define OP_FUNCTION 50
   74 /* builtin constants */
   75 #define OP_CONSTANT 80
   76     int type;
   77     int whole_word;
   78     int (*func) ( /* OpStack **, ValueStack ** */ );
   79     Value *value;       /* for user constants, like strings and numbers */
   80     int nargs;          /* number of args for a function */
   81 } Operator;
   82 
   83 typedef int (*Func) ();
   84 
   85 void parser_shut (void);
   86 void parser_init (void);
   87 int parser_add_operator (Operator * o);
   88 Value parser_value_pop (ValueStack ** s);
   89 void parser_push_int (ValueStack ** s, long i);
   90 void parser_push_string (ValueStack ** s, char *str, int len);
   91 void parser_push_string_free (ValueStack ** s, char *str, int len);
   92 void parser_push_huge_free (ValueStack ** s, Huge * v);
   93 void parser_value_push (ValueStack ** s, Value value);
   94 void parser_value_free (Value v);
   95 
   96 void parser_free (void *s, Value *heap);
   97 void *parser_compile (char *text, Value *heap);
   98 int parser_evaluate (void *s, void *user_data);
   99 
  100 #endif  /* ! _PARSER_H */
  101