Commit | Line | Data |
---|---|---|
8d063cd8 LW |
1 | /* $Header: perl.h,v 1.0 87/12/18 13:05:38 root Exp $ |
2 | * | |
3 | * $Log: perl.h,v $ | |
4 | * Revision 1.0 87/12/18 13:05:38 root | |
5 | * Initial revision | |
6 | * | |
7 | */ | |
8 | ||
9 | #define DEBUGGING | |
10 | #define STDSTDIO /* eventually should be in config.h */ | |
11 | ||
12 | #define VOIDUSED 1 | |
13 | #include "config.h" | |
14 | ||
15 | #ifndef BCOPY | |
16 | # define bcopy(s1,s2,l) memcpy(s2,s1,l); | |
17 | # define bzero(s,l) memset(s,0,l); | |
18 | #endif | |
19 | ||
20 | #include <stdio.h> | |
21 | #include <ctype.h> | |
22 | #include <setjmp.h> | |
23 | #include <sys/types.h> | |
24 | #include <sys/stat.h> | |
25 | #include <time.h> | |
26 | #include <sys/times.h> | |
27 | ||
28 | typedef struct arg ARG; | |
29 | typedef struct cmd CMD; | |
30 | typedef struct formcmd FCMD; | |
31 | typedef struct scanpat SPAT; | |
32 | typedef struct stab STAB; | |
33 | typedef struct stio STIO; | |
34 | typedef struct string STR; | |
35 | typedef struct atbl ARRAY; | |
36 | typedef struct htbl HASH; | |
37 | ||
38 | #include "str.h" | |
39 | #include "form.h" | |
40 | #include "stab.h" | |
41 | #include "spat.h" | |
42 | #include "arg.h" | |
43 | #include "cmd.h" | |
44 | #include "array.h" | |
45 | #include "hash.h" | |
46 | ||
47 | /* A string is TRUE if not "" or "0". */ | |
48 | #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1]))) | |
49 | EXT char *Yes INIT("1"); | |
50 | EXT char *No INIT(""); | |
51 | ||
52 | #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 ))) | |
53 | ||
54 | #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" ))) | |
55 | #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str))) | |
56 | #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str))) | |
57 | EXT STR *Str; | |
58 | ||
59 | #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len) | |
60 | ||
61 | CMD *add_label(); | |
62 | CMD *block_head(); | |
63 | CMD *append_line(); | |
64 | CMD *make_acmd(); | |
65 | CMD *make_ccmd(); | |
66 | CMD *invert(); | |
67 | CMD *addcond(); | |
68 | CMD *addloop(); | |
69 | CMD *wopt(); | |
70 | ||
71 | SPAT *stab_to_spat(); | |
72 | ||
73 | STAB *stabent(); | |
74 | ||
75 | ARG *stab_to_arg(); | |
76 | ARG *op_new(); | |
77 | ARG *make_op(); | |
78 | ARG *make_lval(); | |
79 | ARG *make_match(); | |
80 | ARG *make_split(); | |
81 | ARG *flipflip(); | |
82 | ||
83 | STR *arg_to_str(); | |
84 | STR *str_new(); | |
85 | STR *stab_str(); | |
86 | STR *eval(); | |
87 | ||
88 | FCMD *load_format(); | |
89 | ||
90 | char *scanpat(); | |
91 | char *scansubst(); | |
92 | char *scantrans(); | |
93 | char *scanstr(); | |
94 | char *scanreg(); | |
95 | char *reg_get(); | |
96 | char *str_append_till(); | |
97 | char *str_gets(); | |
98 | ||
99 | bool do_match(); | |
100 | bool do_open(); | |
101 | bool do_close(); | |
102 | bool do_print(); | |
103 | ||
104 | int do_subst(); | |
105 | ||
106 | void str_free(); | |
107 | void freearg(); | |
108 | ||
109 | EXT int line INIT(0); | |
110 | EXT int arybase INIT(0); | |
111 | ||
112 | struct outrec { | |
113 | int o_lines; | |
114 | char *o_str; | |
115 | int o_len; | |
116 | }; | |
117 | ||
118 | EXT struct outrec outrec; | |
119 | EXT struct outrec toprec; | |
120 | ||
121 | EXT STAB *last_in_stab INIT(Nullstab); | |
122 | EXT STAB *defstab INIT(Nullstab); | |
123 | EXT STAB *argvstab INIT(Nullstab); | |
124 | EXT STAB *envstab INIT(Nullstab); | |
125 | EXT STAB *sigstab INIT(Nullstab); | |
126 | EXT STAB *defoutstab INIT(Nullstab); | |
127 | EXT STAB *curoutstab INIT(Nullstab); | |
128 | EXT STAB *argvoutstab INIT(Nullstab); | |
129 | ||
130 | EXT STR *freestrroot INIT(Nullstr); | |
131 | ||
132 | EXT FILE *rsfp; | |
133 | EXT char buf[1024]; | |
134 | EXT char *bufptr INIT(buf); | |
135 | ||
136 | EXT STR *linestr INIT(Nullstr); | |
137 | ||
138 | EXT char record_separator INIT('\n'); | |
139 | EXT char *ofs INIT(Nullch); | |
140 | EXT char *ors INIT(Nullch); | |
141 | EXT char *ofmt INIT(Nullch); | |
142 | EXT char *inplace INIT(Nullch); | |
143 | ||
144 | EXT char tokenbuf[256]; | |
145 | EXT int expectterm INIT(TRUE); | |
146 | EXT int lex_newlines INIT(FALSE); | |
147 | ||
148 | FILE *popen(); | |
149 | /* char *str_get(); */ | |
150 | STR *interp(); | |
151 | void free_arg(); | |
152 | STIO *stio_new(); | |
153 | ||
154 | EXT struct stat statbuf; | |
155 | EXT struct tms timesbuf; | |
156 | ||
157 | #ifdef DEBUGGING | |
158 | EXT int debug INIT(0); | |
159 | EXT int dlevel INIT(0); | |
160 | EXT char debname[40]; | |
161 | EXT char debdelim[40]; | |
162 | #define YYDEBUG; | |
163 | extern int yydebug; | |
164 | #endif | |
165 | ||
166 | EXT STR str_no; | |
167 | EXT STR str_yes; | |
168 | ||
169 | /* runtime control stuff */ | |
170 | ||
171 | EXT struct loop { | |
172 | char *loop_label; | |
173 | jmp_buf loop_env; | |
174 | } loop_stack[32]; | |
175 | ||
176 | EXT int loop_ptr INIT(-1); | |
177 | ||
178 | EXT jmp_buf top_env; | |
179 | ||
180 | EXT char *goto_targ INIT(Nullch); /* cmd_exec gets strange when set */ | |
181 | ||
182 | double atof(); | |
183 | long time(); | |
184 | struct tm *gmtime(), *localtime(); | |
185 | ||
186 | #ifdef CHARSPRINTF | |
187 | char *sprintf(); | |
188 | #else | |
189 | int sprintf(); | |
190 | #endif | |
191 | ||
192 | #ifdef EUNICE | |
193 | #define UNLINK(f) while (unlink(f) >= 0) | |
194 | #else | |
195 | #define UNLINK unlink | |
196 | #endif |