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