1 | /* |
---|
2 | * $Id: fields.h,v 1.1.1.1 1997-09-03 21:08:08 ghudson Exp $ |
---|
3 | * |
---|
4 | * $Log: not supported by cvs2svn $ |
---|
5 | * Revision 1.4 1994/01/05 20:13:43 geoff |
---|
6 | * Add the maxf parameter |
---|
7 | * |
---|
8 | * Revision 1.3 1994/01/04 02:40:22 geoff |
---|
9 | * Add field_line_inc, field_field_inc, and the FLD_NOSHRINK flag. |
---|
10 | * |
---|
11 | * Revision 1.2 1993/09/09 01:11:12 geoff |
---|
12 | * Add a return value to fieldwrite and support for backquotes. |
---|
13 | * |
---|
14 | * Revision 1.1 1993/08/25 21:32:05 geoff |
---|
15 | * Initial revision |
---|
16 | * |
---|
17 | */ |
---|
18 | |
---|
19 | /* |
---|
20 | * Structures used by the field-access package. |
---|
21 | */ |
---|
22 | |
---|
23 | typedef struct |
---|
24 | { |
---|
25 | int nfields; /* Number of fields in the line */ |
---|
26 | int hadnl; /* NZ if line ended with a newline */ |
---|
27 | char * linebuf; /* Malloc'ed buffer containing the line */ |
---|
28 | char ** fields; /* Malloc'ed array of pointers to fields */ |
---|
29 | } |
---|
30 | field_t; |
---|
31 | |
---|
32 | /* |
---|
33 | * Flags to fieldread and fieldmake |
---|
34 | */ |
---|
35 | #define FLD_RUNS 0x0001 /* Consider runs of delimiters same as one */ |
---|
36 | #define FLD_SNGLQUOTES 0x0002 /* Accept single-quoted fields */ |
---|
37 | #define FLD_BACKQUOTES 0x0004 /* Accept back-quoted fields */ |
---|
38 | #define FLD_DBLQUOTES 0x0008 /* Accept double-quoted fields */ |
---|
39 | #define FLD_SHQUOTES 0x0010 /* Use shell-style (embedded) quoting rules */ |
---|
40 | #define FLD_STRIPQUOTES 0x0020 /* Strip quotes from fields */ |
---|
41 | #define FLD_BACKSLASH 0x0040 /* Process C-style backslashes */ |
---|
42 | #define FLD_NOSHRINK 0x0080 /* Don't shrink memory before return */ |
---|
43 | |
---|
44 | #undef P |
---|
45 | #ifdef __STDC__ |
---|
46 | #define P(x) x |
---|
47 | #else /* __STDC__ */ |
---|
48 | #define P(x) () |
---|
49 | #endif /* __STDC__ */ |
---|
50 | |
---|
51 | extern field_t * fieldread P ((FILE * file, char * delims, |
---|
52 | int flags, int maxf)); |
---|
53 | extern field_t * fieldmake P ((char * line, int allocated, |
---|
54 | char * delims, int flags, int maxf)); |
---|
55 | extern int fieldwrite P ((FILE * file, field_t * fieldp, |
---|
56 | int delim)); |
---|
57 | extern void fieldfree P ((field_t * fieldp)); |
---|
58 | |
---|
59 | extern unsigned int field_field_inc; |
---|
60 | /* Increment for expanding fields */ |
---|
61 | extern unsigned int field_line_inc; |
---|
62 | /* Increment for expanding lines */ |
---|