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