aboutsummaryrefslogtreecommitdiffstats
path: root/gawkapi.h
diff options
context:
space:
mode:
Diffstat (limited to 'gawkapi.h')
-rw-r--r--gawkapi.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/gawkapi.h b/gawkapi.h
index 5071adce..e744a0fc 100644
--- a/gawkapi.h
+++ b/gawkapi.h
@@ -117,6 +117,19 @@ typedef enum awk_bool {
awk_true
} awk_bool_t; /* we don't use <stdbool.h> on purpose */
+/*
+ * If the input parser would like to specify the field positions in the input
+ * record, it may populate an array of awk_input_field_info_t structures
+ * to indicate the location of each field. The 0th array element contains
+ * the information about field $1, and the NFth element should set skip
+ * to a negative value. For both skip and len, the value should be in
+ * bytes, not (potentially multi-byte) characters.
+ */
+typedef struct {
+ int skip; /* # of bytes to skip before field starts */
+ size_t len; /* # of bytes in field */
+} awk_input_field_info_t;
+
/* The information about input files that input parsers need to know: */
typedef struct awk_input {
const char *name; /* filename */
@@ -146,9 +159,22 @@ typedef struct awk_input {
* than zero, gawk will automatically update the ERRNO variable based
* on the value of *errcode (e.g., setting *errcode = errno should do
* the right thing).
+ *
+ * If field_width is non-NULL, then its value will be initialized
+ * to NULL, and the function may set it to point to an array of
+ * structures supplying field width information to override the default
+ * gawk field parsing mechanism. The field_width array should have
+ * at least NF+1 elements, and the value of field_width[NF].skip
+ * must be negative. Note that these values are specified
+ * in bytes, not (potentially multi-byte) characters! And note that this
+ * array will not be copied by gawk; it must persist at least until the
+ * next call to get_record or close_func. Note that field_width will
+ * be NULL when getline is assigning the results to a variable, thus
+ * field parsing is not needed.
*/
int (*get_record)(char **out, struct awk_input *iobuf, int *errcode,
- char **rt_start, size_t *rt_len);
+ char **rt_start, size_t *rt_len,
+ const awk_input_field_info_t **field_width);
/*
* No argument prototype on read_func to allow for older systems