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