1 
2 /********************************************
3 field.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 /* $Log: field.h,v $
14  * Revision 1.2  1995/06/18  19:42:16  mike
15  * Remove some redundant declarations and add some prototypes
16  *
17  * Revision 1.1.1.1  1993/07/03  18:58:12  mike
18  * move source to cvs
19  *
20  * Revision 5.2  1992/01/06  08:10:24  brennan
21  * set_binmode() proto for MSDOS
22  *
23  * Revision 5.1  91/12/05  07:59:16  brennan
24  * 1.1 pre-release
25  *
26 */
27 
28 /* field.h */
29 
30 
31 #ifndef  FIELD_H
32 #define  FIELD_H   1
33 
34 void  PROTO( set_field0, (char *, unsigned) ) ;
35 void  PROTO( split_field0, (void) ) ;
36 int   PROTO( space_split, (char *, unsigned) ) ;
37 int   PROTO( re_split, (char *, PTR) ) ;
38 int   PROTO( null_split, (char *)) ;
39 char *PROTO( is_string_split, (PTR , unsigned *) ) ;
40 void  PROTO( slow_cell_assign, (CELL*, CELL*)) ;
41 CELL *PROTO( slow_field_ptr, (int)) ;
42 int   PROTO( field_addr_to_index, (CELL*)) ;
43 void  PROTO( set_binmode, (int)) ;
44 
45 
46 #define  NUM_PFIELDS                5
47 extern  CELL  field[FBANK_SZ+NUM_PFIELDS] ;
48         /* $0, $1 ... $(MAX_SPLIT), NF, RS, RS, CONVFMT, OFMT */
49 
50 /* more fields if needed go here */
51 extern CELL *fbank[NUM_FBANK] ; /* fbank[0] == field */
52 
53 /* index to CELL *  for a field */
54 #define field_ptr(i) ((i)<=MAX_SPLIT?field+(i):slow_field_ptr(i))
55 
56 /* the pseudo fields, assignment has side effects */
57 #undef RS  /* quietens hpux */
58 #define  NF     (field+MAX_SPLIT+1)   /* must be first */
59 #define  RS     (field+MAX_SPLIT+2)
60 #define  FS     (field+MAX_SPLIT+3)
61 #define  CONVFMT  (field+MAX_SPLIT+4)
62 #define  OFMT   (field+MAX_SPLIT+5)   /* must be last */
63 
64 #define  LAST_PFIELD        OFMT
65 
66 /* some compilers choke on (NF-field) in a case statement
67    even though it's constant so ...
68 */
69 #define  NF_field    (MAX_SPLIT+1)
70 #define  RS_field    (MAX_SPLIT+2)
71 #define  FS_field    (MAX_SPLIT+3)
72 #define  CONVFMT_field (MAX_SPLIT+4)
73 #define  OFMT_field  (MAX_SPLIT+5)
74 
75 
76 extern  int  nf ; /* shadows NF */
77 
78 /* a shadow type for RS and FS */
79 #define  SEP_SPACE      0
80 #define  SEP_CHAR       1
81 #define  SEP_STR        2
82 #define  SEP_RE         3
83 #define  SEP_MLR        4
84 
85 typedef  struct {
86 char  type ;
87 char  c ;
88 PTR ptr ; /* STRING* or RE machine* */
89 } SEPARATOR ;
90 
91 extern   SEPARATOR  rs_shadow  ;
92 extern   CELL  fs_shadow ;
93 
94 
95 /*  types for splitting overflow */
96 
97 typedef  struct spov {
98 struct spov  *link ;
99 STRING  *sval ;
100 } SPLIT_OV ;
101 
102 extern  SPLIT_OV  *split_ov_list ;
103 
104 
105 #endif   /* FIELD_H  */
106