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