2d8932440dc04fd7129fd79ceb0b15262ccd12fc
[ctsim.git] / include / pol.h
1 /*****************************************************************************
2 **  This is part of the CTSim program
3 **  Copyright (C) 1983-2000 Kevin Rosenberg
4 **
5 **  $Id: pol.h,v 1.3 2000/05/07 12:46:19 kevin Exp $
6 **  $Log: pol.h,v $
7 **  Revision 1.3  2000/05/07 12:46:19  kevin
8 **  made c++ compatible
9 **
10 **  Revision 1.2  2000/04/28 14:14:16  kevin
11 **  *** empty log message ***
12 **
13 **
14 **  This program is free software; you can redistribute it and/or modify
15 **  it under the terms of the GNU General Public License (version 2) as
16 **  published by the Free Software Foundation.
17 **
18 **  This program is distributed in the hope that it will be useful,
19 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 **  GNU General Public License for more details.
22 **
23 **  You should have received a copy of the GNU General Public License
24 **  along with this program; if not, write to the Free Software
25 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 ******************************************************************************/
27 #ifndef __H_POL
28 #define __H_POL
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33
34 /* codes for pol_usefile */
35
36 #define P_USE_STR  1            /* use string as input source */
37 #define P_USE_FILE 2            /* use file as input source */
38
39 /* codes for pol_int and pol_float */
40 /* if in reject catagory, get new number from terminal */
41
42 #define P_FLTINT   1    /* get a real or integer number */
43 #define P_BFLTINT  2    /* get a real or integer number, clip against bounds */
44 #define P_CBFLTINT 3    /* get real or int, reject if outside bounds */
45
46 #define P_FLT      4    /* get a real number */
47 #define P_BFLT     5    /* get a real, clip against bounds */
48 #define P_CBFLT    6    /* get a floating, reject if outside bounds */
49
50 #define P_INT      7    /* get a integer number */
51 #define P_BINT     8    /* get a integer, clip against bounds */
52 #define P_CBINT    9    /* get a integer, reject if outside bounds */
53
54 #define LETTER   'a'
55 #define DIGIT    '0'
56
57 #define MAXTOK   200            /* maximum length of a token */
58 #define MAXLINE  255
59 #define MAXIDENT  20
60 #define MAXSKIPWORD 20
61 #define MAXSKIPCHAR 20
62
63 #define MIN_INT -32768
64 #define MAX_INT  32767
65
66 /* token types */
67
68 #define TT_STRING        1              /* string token */
69 #define TT_INT           2              /* integer token */
70 #define TT_REAL          3              /* floating point token */
71 #define TT_ALPHA         4              /* alphabetic token */
72 #define TT_ALPNUM        5              /* alphanumeric token */
73 #define TT_NUMALPHA      6
74 #define TT_SPECLCHAR     7
75
76 #define TT_EOF           8              /* end of file reached */
77 #define TT_ERROR         9              /* error in token, caused by call to wrong */
78                                         /*  type of token reader */
79 #define TT_BLANK        10              /* white space token.  pol_tok() skips these */
80 #define TT_USERTOK      11              /* user defined token */
81
82 struct symlist {
83         char *name;
84         int code;
85         struct symlist *next;
86 };
87
88 typedef struct symlist SYMBOL;
89
90 struct token_st {
91     int ready;                          /* TRUE if token is ready */
92     char tokstr[MAXTOK+1];              /* token string */
93     int type;                           /* type of token 'TT_' */
94     int code;                           /* holds code for user defined tokens */
95     double fnum;                        /* real value of token */
96     int inum;                           /* integer value of token */
97 };
98
99 typedef struct token_st TOKEN;
100
101 /* pol.c */
102 void pol_init(void);
103 void pol_skpword(char *w);
104 void pol_skpchar(char *s);
105 int pol_install(char *str, int code);
106 int pol_word(char *search, int nlet);
107 int pol_usertok(char *str, int *code);
108 int pol_string(char *str);
109 int pol_integer(int *n, int typecode, int boundcode, int bb1, int bb2);
110 int pol_float(double *n, double typecode, double boundcode, double bb1, double bb2);
111 int pol_skip(void);
112 void pol_reader(void);
113 void gettext(char *str, int lim);
114 void pol_usefile(int source, char *fn);
115 void pol_closefile(void);
116 int pol_lookchar(void);
117 int pol_inchar(void);
118 void pol_ungetch(int c);
119 int get_inputline(FILE *fp);
120 void set_inputline(char *line);
121
122 #ifdef __cplusplus
123 }
124 #endif /* __cplusplus */
125
126 #endif