home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / m / mawk11as.zip / MAWK.H < prev    next >
C/C++ Source or Header  |  1992-01-09  |  4KB  |  176 lines

  1.  
  2. /********************************************
  3. mawk.h
  4. copyright 1991, 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.3  92/01/09  08:46:58  brennan
  16.  * cell destroy macro
  17.  * 
  18.  * Revision 5.2  92/01/06  08:08:56  brennan
  19.  * binmode() proto for MSDOS
  20.  * 
  21.  * Revision 5.1  91/12/05  07:59:26  brennan
  22.  * 1.1 pre-release
  23.  * 
  24. */
  25.  
  26.  
  27. /*  mawk.h  */
  28.  
  29. #ifndef  MAWK_H
  30. #define  MAWK_H   
  31.  
  32. #include  "config.h"
  33.  
  34. #ifdef   DEBUG
  35. #define  YYDEBUG  1
  36. extern  int   yydebug ;  /* print parse if on */
  37. extern  int   dump_RE ;
  38. #endif
  39. extern  int   dump_code ;
  40. extern  int   posix_space_flag ; 
  41.  
  42. #include <stdio.h>
  43.  
  44. #if  HAVE_STRING_H
  45. #include <string.h>
  46. #else
  47. char *strchr() ;
  48. char *strcpy() ;
  49. char *strrchr() ;
  50. #endif
  51.  
  52. #if  HAVE_STDLIB_H
  53. #include <stdlib.h>
  54. #endif
  55.  
  56. #include "types.h"
  57.  
  58.  
  59. /*----------------
  60.  *  GLOBAL VARIABLES
  61.  *----------------*/
  62.  
  63. /* a well known string */
  64. extern STRING  null_str ;
  65.  
  66. #ifndef TEMPBUFF_GOES_HERE
  67. #define EXTERN    extern
  68. #else
  69. #define EXTERN   /* empty */
  70. #endif
  71.  
  72. /* a useful scratch area */
  73. EXTERN  union {
  74. STRING  *_split_buff[MAX_SPLIT] ;
  75. char    _string_buff[MIN_SPRINTF] ;
  76. } tempbuff ;
  77.  
  78. /* anonymous union */
  79. #define  string_buff    tempbuff._string_buff
  80. #define  split_buff    tempbuff._split_buff
  81.  
  82. #define  SPRINTF_SZ    sizeof(tempbuff)
  83.  
  84. /* help with casts */
  85. extern int pow2[] ;
  86.  
  87.  
  88.  /* these are used by the parser, scanner and error messages
  89.     from the compile  */
  90.  
  91. extern  char *pfile_name ; /* program input file */
  92. extern  int current_token ;
  93. extern  unsigned  token_lineno ; /* lineno of current token */
  94. extern  unsigned  compile_error_count ;
  95. extern  int  paren_cnt, brace_cnt ;
  96. extern  int  print_flag, getline_flag ;
  97. extern  short mawk_state ;
  98. #define EXECUTION       1  /* other state is 0 compiling */
  99.  
  100. /*---------*/
  101.  
  102. #ifndef MSDOS_MSC
  103. extern  int  errno ;     
  104. #endif
  105. extern  char *progname ; /* for error messages */
  106.  
  107. /* macro to test the type of two adjacent cells */
  108. #define TEST2(cp)  (pow2[(cp)->type]+pow2[((cp)+1)->type])
  109.  
  110. /* macro to get at the string part of a CELL */
  111. #define string(cp) ((STRING *)(cp)->ptr)
  112.  
  113. #ifdef   DEBUG
  114. #define cell_destroy(cp)  DB_cell_destroy(cp)
  115. #else
  116.  
  117. #define cell_destroy(cp)   if ( (cp)->type >= C_STRING &&\
  118.                            -- string(cp)->ref_cnt == 0 )\
  119.                         zfree(string(cp),string(cp)->len+STRING_OH);else
  120. #endif
  121.  
  122. /*  prototypes  */
  123.  
  124. void  PROTO( cast1_to_s, (CELL *) ) ;
  125. void  PROTO( cast1_to_d, (CELL *) ) ;
  126. void  PROTO( cast2_to_s, (CELL *) ) ;
  127. void  PROTO( cast2_to_d, (CELL *) ) ;
  128. void  PROTO( cast_to_RE, (CELL *) ) ;
  129. void  PROTO( cast_for_split, (CELL *) ) ;
  130. void  PROTO( check_strnum, (CELL *) ) ;
  131. void  PROTO( cast_to_REPL, (CELL *) ) ;
  132.  
  133. int   PROTO( test, (CELL *) ) ; /* test for null non-null */
  134. CELL *PROTO( cellcpy, (CELL *, CELL *) ) ;
  135. CELL *PROTO( repl_cpy, (CELL *, CELL *) ) ;
  136. void  PROTO( DB_cell_destroy, (CELL *) ) ;
  137. void  PROTO( overflow, (char *, unsigned) ) ;
  138. void  PROTO( rt_overflow, (char *, unsigned) ) ;
  139. void  PROTO( rt_error, ( char *, ...) ) ;
  140. void  PROTO( mawk_exit, (int) ) ;
  141. void PROTO( da, (INST *, FILE *)) ;
  142. char *PROTO( str_str, (char*, char*, unsigned) ) ;
  143. char *PROTO( rm_escape, (char *) ) ;
  144. int   PROTO( re_split, (char *, PTR) ) ;
  145. char *PROTO( re_pos_match, (char *, PTR, unsigned *) ) ;
  146. int   PROTO( binmode, (void)) ;
  147.  
  148. void  PROTO( exit, (int) ) ;
  149. #ifdef THINK_C
  150. #include <unix.h>
  151. #else
  152. int   PROTO( close, (int) ) ;
  153. int   PROTO( open, (char *,int, int) ) ;
  154. int   PROTO( read, (int , PTR, unsigned) ) ;
  155. #endif
  156.  
  157. int  PROTO ( parse, (void) ) ;
  158. int  PROTO ( yylex, (void) ) ;
  159. int  PROTO( yyparse, (void) ) ;
  160. void PROTO( yyerror, (char *) ) ;
  161.  
  162. void PROTO( bozo, (char *) ) ;
  163. void PROTO( errmsg , (int, char*, ...) ) ;
  164. void PROTO( compile_error, ( char *, ...) ) ;
  165.  
  166. void  PROTO( execute, (INST *, CELL *, CELL *) ) ;
  167. char *PROTO( find_kw_str, (int) ) ;
  168.  
  169. #if ! HAVE_STDLIB_H
  170. double strtod() ;
  171. #endif
  172.  
  173. double fmod() ;
  174.  
  175. #endif  /* MAWK_H */
  176.