home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / MAWK113.ZIP / mawk113 / mawk.h < prev    next >
C/C++ Source or Header  |  1993-01-22  |  5KB  |  203 lines

  1.  
  2. /********************************************
  3. mawk.h
  4. copyright 1991 1992, Michael D. Brennan
  5.  
  6. This is a source file for mawk, an implementation of
  7. the AWK programming language.
  8.  
  9. Mawk is distributed without warranty under the terms of
  10. the GNU General Public License, version 2, 1991.
  11. ********************************************/
  12.  
  13.  
  14. /*   $Log: mawk.h,v $
  15.  * Revision 5.5.1.3  1993/01/22  15:04:50  mike
  16.  * pow2->mpow2 for linux
  17.  *
  18.  * Revision 5.5.1.2  1993/01/20  12:53:10  mike
  19.  * d_to_l()
  20.  *
  21.  * Revision 5.5.1.1  1993/01/15  03:33:46  mike
  22.  * patch3: safer double to int conversion
  23.  *
  24.  * Revision 5.5  1992/07/06  20:15:49  brennan
  25.  * DONT_PROTO_OPEN macro
  26.  *
  27.  * Revision 5.4  1992/03/03  16:34:41  brennan
  28.  * conditional around open() proto
  29.  *
  30.  * Revision 5.3  92/01/09  08:46:58  brennan
  31.  * cell destroy macro
  32.  * 
  33.  * Revision 5.2  92/01/06  08:08:56  brennan
  34.  * binmode() proto for MSDOS
  35.  * 
  36.  * Revision 5.1  91/12/05  07:59:26  brennan
  37.  * 1.1 pre-release
  38.  * 
  39. */
  40.  
  41.  
  42. /*  mawk.h  */
  43.  
  44. #ifndef  MAWK_H
  45. #define  MAWK_H   
  46.  
  47. #include  "config.h"
  48.  
  49. #ifdef   DEBUG
  50. #define  YYDEBUG  1
  51. extern  int   yydebug ;  /* print parse if on */
  52. extern  int   dump_RE ;
  53. #endif
  54. extern  int   dump_code ;
  55. extern  int   posix_space_flag ; 
  56.  
  57. #include <stdio.h>
  58.  
  59. #if  HAVE_STRING_H
  60. #include <string.h>
  61. #else
  62. char *strchr() ;
  63. char *strcpy() ;
  64. char *strrchr() ;
  65. #endif
  66.  
  67. #if  HAVE_STDLIB_H
  68. #include <stdlib.h>
  69. #endif
  70.  
  71. #include "types.h"
  72.  
  73.  
  74.  
  75.  
  76. /*----------------
  77.  *  GLOBAL VARIABLES
  78.  *----------------*/
  79.  
  80. /* a well known string */
  81. extern STRING  null_str ;
  82.  
  83. #ifndef TEMPBUFF_GOES_HERE
  84. #define EXTERN    extern
  85. #else
  86. #define EXTERN   /* empty */
  87. #endif
  88.  
  89. /* a useful scratch area */
  90. EXTERN  union {
  91. STRING  *_split_buff[MAX_SPLIT] ;
  92. char    _string_buff[MIN_SPRINTF] ;
  93. } tempbuff ;
  94.  
  95. /* anonymous union */
  96. #define  string_buff    tempbuff._string_buff
  97. #define  split_buff    tempbuff._split_buff
  98.  
  99. #define  SPRINTF_SZ    sizeof(tempbuff)
  100.  
  101. /* help with casts */
  102. extern int mpow2[] ;
  103.  
  104.  
  105.  /* these are used by the parser, scanner and error messages
  106.     from the compile  */
  107.  
  108. extern  char *pfile_name ; /* program input file */
  109. extern  int current_token ;
  110. extern  unsigned  token_lineno ; /* lineno of current token */
  111. extern  unsigned  compile_error_count ;
  112. extern  int  paren_cnt, brace_cnt ;
  113. extern  int  print_flag, getline_flag ;
  114. extern  short mawk_state ;
  115. #define EXECUTION       1  /* other state is 0 compiling */
  116.  
  117. /*---------*/
  118.  
  119. #ifndef MSDOS_MSC
  120. extern  int  errno ;     
  121. #endif
  122. extern  char *progname ; /* for error messages */
  123.  
  124. /* macro to test the type of two adjacent cells */
  125. #define TEST2(cp)  (mpow2[(cp)->type]+mpow2[((cp)+1)->type])
  126.  
  127. /* macro to get at the string part of a CELL */
  128. #define string(cp) ((STRING *)(cp)->ptr)
  129.  
  130. #ifdef   DEBUG
  131. #define cell_destroy(cp)  DB_cell_destroy(cp)
  132. #else
  133.  
  134. #define cell_destroy(cp)   if ( (cp)->type >= C_STRING &&\
  135.                            -- string(cp)->ref_cnt == 0 )\
  136.                         zfree(string(cp),string(cp)->len+STRING_OH);else
  137. #endif
  138.  
  139. /*  prototypes  */
  140.  
  141. void  PROTO( cast1_to_s, (CELL *) ) ;
  142. void  PROTO( cast1_to_d, (CELL *) ) ;
  143. void  PROTO( cast2_to_s, (CELL *) ) ;
  144. void  PROTO( cast2_to_d, (CELL *) ) ;
  145. void  PROTO( cast_to_RE, (CELL *) ) ;
  146. void  PROTO( cast_for_split, (CELL *) ) ;
  147. void  PROTO( check_strnum, (CELL *) ) ;
  148. void  PROTO( cast_to_REPL, (CELL *) ) ;
  149. long  PROTO( d_to_l, (double)) ;
  150.  
  151. #define d_to_i(d)    ((int)d_to_l(d))
  152.  
  153. int   PROTO( test, (CELL *) ) ; /* test for null non-null */
  154. CELL *PROTO( cellcpy, (CELL *, CELL *) ) ;
  155. CELL *PROTO( repl_cpy, (CELL *, CELL *) ) ;
  156. void  PROTO( DB_cell_destroy, (CELL *) ) ;
  157. void  PROTO( overflow, (char *, unsigned) ) ;
  158. void  PROTO( rt_overflow, (char *, unsigned) ) ;
  159. void  PROTO( rt_error, ( char *, ...) ) ;
  160. void  PROTO( mawk_exit, (int) ) ;
  161. void PROTO( da, (INST *, FILE *)) ;
  162. char *PROTO( str_str, (char*, char*, unsigned) ) ;
  163. char *PROTO( rm_escape, (char *) ) ;
  164. int   PROTO( re_split, (char *, PTR) ) ;
  165. char *PROTO( re_pos_match, (char *, PTR, unsigned *) ) ;
  166. int   PROTO( binmode, (void)) ;
  167.  
  168. void  PROTO( exit, (int) ) ;
  169.  
  170. #ifdef THINK_C
  171. #include <unix.h>
  172. #else
  173. int   PROTO( close, (int) ) ;
  174.  
  175. /* ANSI compilers won't like open() if they've ever seen open as
  176.    int open(char *,int, ...).  If so , 
  177.    #define DONT_PROTO_OPEN
  178. */
  179.  
  180. #ifndef DONT_PROTO_OPEN
  181. int   PROTO( open, (char *,int, int) ) ;
  182. #endif
  183.  
  184. int   PROTO( read, (int , PTR, unsigned) ) ;
  185. #endif
  186.  
  187. int  PROTO ( parse, (void) ) ;
  188. int  PROTO ( yylex, (void) ) ;
  189. int  PROTO( yyparse, (void) ) ;
  190. void PROTO( yyerror, (char *) ) ;
  191.  
  192. void PROTO( bozo, (char *) ) ;
  193. void PROTO( errmsg , (int, char*, ...) ) ;
  194. void PROTO( compile_error, ( char *, ...) ) ;
  195.  
  196. void  PROTO( execute, (INST *, CELL *, CELL *) ) ;
  197. char *PROTO( find_kw_str, (int) ) ;
  198.  
  199. double strtod() ;
  200. double fmod() ;
  201.  
  202. #endif  /* MAWK_H */
  203.