gawk: Two-way processors

1 
1 16.4.5.6 Customized Two-way Processors
1 ......................................
1 
1 A "two-way processor" combines an input parser and an output wrapper for
1 two-way I/O with the '|&' operator (⇒Redirection).  It makes
1 identical use of the 'awk_input_parser_t' and 'awk_output_buf_t'
1 structures as described earlier.
1 
1    A two-way processor is represented by the following structure:
1 
1      typedef struct awk_two_way_processor {
1          const char *name;   /* name of the two-way processor */
1          awk_bool_t (*can_take_two_way)(const char *name);
1          awk_bool_t (*take_control_of)(const char *name,
1                                        awk_input_buf_t *inbuf,
1                                        awk_output_buf_t *outbuf);
1          awk_const struct awk_two_way_processor *awk_const next;  /* for gawk */
1      } awk_two_way_processor_t;
1 
1    The fields are as follows:
1 
1 'const char *name;'
1      The name of the two-way processor.
1 
1 'awk_bool_t (*can_take_two_way)(const char *name);'
1      The function pointed to by this field should return true if it
1      wants to take over two-way I/O for this file name.  It should not
1      change any state (variable values, etc.)  within 'gawk'.
1 
1 'awk_bool_t (*take_control_of)(const char *name,'
1 '                              awk_input_buf_t *inbuf,'
1 '                              awk_output_buf_t *outbuf);'
1      The function pointed to by this field should fill in the
1      'awk_input_buf_t' and 'awk_output_buf_t' structures pointed to by
1      'inbuf' and 'outbuf', respectively.  These structures were
1      described earlier.
1 
1 'awk_const struct two_way_processor *awk_const next;'
1      This is for use by 'gawk'; therefore it is marked 'awk_const' so
1      that the extension cannot modify it.
1 
1    As with the input parser and output processor, you provide "yes I can
1 take this" and "take over for this" functions, 'XXX_can_take_two_way()'
1 and 'XXX_take_control_of()'.
1 
1    You register your two-way processor with the following function:
1 
1 'void register_two_way_processor(awk_two_way_processor_t *two_way_processor);'
1      Register the two-way processor pointed to by 'two_way_processor'
1      with 'gawk'.
1