1 /*------------------------------------------------------------* 2 | awka.h | 3 | copyright 1991, Michael D. Brennan | 4 | | 5 | This is a source file for the awka package, a translator | 6 | of the AWK programming language to ANSI C. | 7 | | 8 | The file is a borrowed version of mawk.h from | 9 | Mawk, an implementation of the AWK processing language, | 10 | distributed by Michael Brennan under the GPL. | 11 | | 12 | This program is free software; you can redistribute it | 13 | and/or modify it under the terms of the GNU General Public | 14 | License as published by the Free Software Foundation; | 15 | either version 2 of the License, or any later version. | 16 | | 17 | This program is distributed in the hope that it will be | 18 | useful, but WITHOUT ANY WARRANTY; without even the implied | 19 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | 20 | PURPOSE. See the GNU General Public License for more | 21 | details. | 22 | | 23 | You should have received a copy of the GNU General Public | 24 | License along with this program; if not, write to the | 25 | Free Software Foundation, Inc., 675 Mass Ave, Cambridge, | 26 | MA 02139, USA. | 27 *-----------------------------------------------------------*/ 28 29 30 /* awka.h */ 31 32 #ifndef _AWKA_H 33 #define _AWKA_H 34 35 #include "nstd.h" 36 #include <stdio.h> 37 #include <string.h> 38 #include "types.h" 39 40 #ifndef TRUE 41 # define TRUE 1 42 # define FALSE 0 43 #endif 44 45 #ifdef DEBUG 46 #define YYDEBUG 1 47 extern int yydebug ; /* print parse if on */ 48 extern int dump_RE ; 49 #endif 50 51 extern int dump; 52 extern short posix_space_flag , interactive_flag ; 53 54 /*---------------- 55 * GLOBAL VARIABLES 56 *----------------*/ 57 58 /* a well known string */ 59 extern STRING null_str ; 60 61 #ifndef TEMPBUFF_GOES_HERE 62 #define EXTERN extern 63 #else 64 #define EXTERN /* empty */ 65 #endif 66 67 /* a useful scratch area */ 68 EXTERN union { 69 STRING *_split_buff[MAX_SPLIT] ; 70 char _string_buff[MIN_SPRINTF] ; 71 } tempbuff ; 72 73 /* anonymous union */ 74 #define string_buff tempbuff._string_buff 75 #define split_buff tempbuff._split_buff 76 77 #define SPRINTF_SZ sizeof(tempbuff) 78 79 /* help with casts */ 80 extern int mpow2[] ; 81 82 /* these are used by the parser, scanner and error messages 83 from the compile */ 84 85 extern char *pfile_name ; /* program input file */ 86 extern int current_token ; 87 extern unsigned token_lineno ; /* lineno of current token */ 88 extern unsigned compile_error_count ; 89 extern int paren_cnt, brace_cnt ; 90 extern int print_flag, getline_flag ; 91 extern short mawk_state ; 92 #define EXECUTION 1 /* other state is 0 compiling */ 93 94 95 extern char *progname ; /* for error messages */ 96 extern unsigned rt_nr , rt_fnr ; /* ditto */ 97 98 /* macro to test the type of two adjacent cells */ 99 #define TEST2(cp) (mpow2[(cp)->type]+mpow2[((cp)+1)->type]) 100 101 /* macro to get at the string part of a CELL */ 102 #define string(cp) ((STRING *)(cp)->ptr) 103 104 #define cell_destroy(cp) if ( (cp)->type >= C_STRING &&\ 105 -- string(cp)->ref_cnt == 0 )\ 106 zfree(string(cp),string(cp)->len+STRING_OH);else 107 108 /* prototypes */ 109 110 int PROTO( is_ext_builtin, (char *) ) ; 111 void PROTO( cast1_to_s, (CELL *) ) ; 112 void PROTO( cast1_to_d, (CELL *) ) ; 113 void PROTO( cast2_to_s, (CELL *) ) ; 114 void PROTO( cast2_to_d, (CELL *) ) ; 115 void PROTO( cast_to_RE, (CELL *) ) ; 116 void PROTO( cast_for_split, (CELL *) ) ; 117 void PROTO( check_strnum, (CELL *) ) ; 118 void PROTO( cast_to_REPL, (CELL *) ) ; 119 Int PROTO( d_to_I, (double)) ; 120 121 #define d_to_i(d) ((int)d_to_I(d)) 122 123 124 int PROTO( test, (CELL *) ) ; /* test for null non-null */ 125 CELL *PROTO( cellcpy, (CELL *, CELL *) ) ; 126 CELL *PROTO( repl_cpy, (CELL *, CELL *) ) ; 127 void PROTO( DB_cell_destroy, (CELL *) ) ; 128 void PROTO( overflow, (char *, unsigned) ) ; 129 void PROTO( rt_overflow, (char *, unsigned) ) ; 130 void PROTO( rt_error, ( char *, ...) ) ; 131 void PROTO( da, (INST *, FILE *)) ; 132 char *PROTO( rm_escape, (char *) ) ; 133 char *PROTO( re_pos_match, (char *, PTR, unsigned *) ) ; 134 int PROTO( binmode, (void)) ; 135 136 137 int PROTO( close, (int) ) ; 138 /* int PROTO( read, (int , PTR, unsigned) ) ; */ 139 140 void PROTO ( parse, (void) ) ; 141 int PROTO ( yylex, (void) ) ; 142 int PROTO( yyparse, (void) ) ; 143 void PROTO( yyerror, (char *) ) ; 144 void PROTO( scan_cleanup, (void)) ; 145 146 void PROTO( bozo, (char *) ) ; 147 void PROTO( errmsg , (int, char*, ...) ) ; 148 void PROTO( compile_error, ( char *, ...) ) ; 149 150 void PROTO( execute, (INST *, CELL *, CELL *) ) ; 151 char *PROTO( find_kw_str, (int) ) ; 152 153 #ifdef HAVE_STRTOD_OVF_BUG 154 double PROTO(strtod_with_ovf_bug, (const char*, char**)) ; 155 #define strtod strtod_with_ovf_bug 156 #endif 157 158 #endif /* AWKA_H */ 159