From 6959e2ab216aeb1d5d8f07ce73cd8b9894b83006 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Sun, 30 Jun 2013 20:57:03 -0400 Subject: Added first version of select extension and new API hooks needed by it. --- gawkapi.h | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'gawkapi.h') diff --git a/gawkapi.h b/gawkapi.h index cc50bba3..7bb93037 100644 --- a/gawkapi.h +++ b/gawkapi.h @@ -264,7 +264,7 @@ typedef struct awk_two_way_processor { /* Current version of the API. */ enum { GAWK_API_MAJOR_VERSION = 1, - GAWK_API_MINOR_VERSION = 0 + GAWK_API_MINOR_VERSION = 1 }; /* A number of typedefs related to different types of values. */ @@ -665,6 +665,27 @@ typedef struct gawk_api { awk_bool_t (*api_release_flattened_array)(awk_ext_id_t id, awk_array_t a_cookie, awk_flat_array_t *data); + + /* + * Look up a currently open file. If the name is NULL, it returns + * data for the currently open input file corresponding to FILENAME. + * If the file is not found, it returns NULL. + */ + const awk_input_buf_t *(*api_lookup_file)(awk_ext_id_t id, + const char *name, + size_t name_len); + /* + * Look up a file. If the name is NULL, it returns + * data for the currently open input file corresponding to FILENAME. + * If the file is not already open, it tries to open it. + * The "filetype" argument should be one of: + * ">", ">>", "<", "|>", "|<", and "|&" + */ + const awk_input_buf_t *(*api_get_file)(awk_ext_id_t id, + const char *name, + size_t name_len, + const char *filetype, + size_t typelen); } gawk_api_t; #ifndef GAWK /* these are not for the gawk code itself! */ @@ -742,6 +763,12 @@ typedef struct gawk_api { #define release_value(value) \ (api->api_release_value(ext_id, value)) +#define lookup_file(name, namelen) \ + (api->api_lookup_file(ext_id, name, namelen)) + +#define get_file(name, namelen, filetype, typelen) \ + (api->api_get_file(ext_id, name, namelen, filetype, typelen)) + #define register_ext_version(version) \ (api->api_register_ext_version(ext_id, version)) -- cgit v1.2.3 From 6ace1b5a655517a41be7d1633ec7592ad940c0e6 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Tue, 2 Jul 2013 15:59:15 -0400 Subject: Patch gawkapi flatten_array to pass index values as strings in all cases! --- gawkapi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gawkapi.h') diff --git a/gawkapi.h b/gawkapi.h index 7bb93037..81217009 100644 --- a/gawkapi.h +++ b/gawkapi.h @@ -343,7 +343,7 @@ typedef struct awk_element { AWK_ELEMENT_DELETE = 1 /* set by extension if should be deleted */ } flags; - awk_value_t index; + awk_value_t index; /* guaranteed to be a string! */ awk_value_t value; } awk_element_t; -- cgit v1.2.3 From d8bd9f5261761dd4ffca331d9c6055c48a0a332b Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Tue, 2 Jul 2013 20:52:25 -0400 Subject: Remove unused api_lookup_file hook. --- gawkapi.h | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'gawkapi.h') diff --git a/gawkapi.h b/gawkapi.h index 81217009..687147e3 100644 --- a/gawkapi.h +++ b/gawkapi.h @@ -667,15 +667,7 @@ typedef struct gawk_api { awk_flat_array_t *data); /* - * Look up a currently open file. If the name is NULL, it returns - * data for the currently open input file corresponding to FILENAME. - * If the file is not found, it returns NULL. - */ - const awk_input_buf_t *(*api_lookup_file)(awk_ext_id_t id, - const char *name, - size_t name_len); - /* - * Look up a file. If the name is NULL, it returns + * Look up a file. If the name is NULL or name_len is 0, it returns * data for the currently open input file corresponding to FILENAME. * If the file is not already open, it tries to open it. * The "filetype" argument should be one of: @@ -763,9 +755,6 @@ typedef struct gawk_api { #define release_value(value) \ (api->api_release_value(ext_id, value)) -#define lookup_file(name, namelen) \ - (api->api_lookup_file(ext_id, name, namelen)) - #define get_file(name, namelen, filetype, typelen) \ (api->api_get_file(ext_id, name, namelen, filetype, typelen)) -- cgit v1.2.3 From 633bbb9f481cd72edb7c419941a366d0efbf88b6 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Fri, 5 Jul 2013 20:44:49 -0400 Subject: Patch the select extension set_non_blocking function to work with a single "" argument. --- gawkapi.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gawkapi.h') diff --git a/gawkapi.h b/gawkapi.h index 687147e3..51374d9f 100644 --- a/gawkapi.h +++ b/gawkapi.h @@ -668,7 +668,9 @@ typedef struct gawk_api { /* * Look up a file. If the name is NULL or name_len is 0, it returns - * data for the currently open input file corresponding to FILENAME. + * data for the currently open input file corresponding to FILENAME + * (and it will not access the filetype or typelen arguments, so those + * may be undefined). * If the file is not already open, it tries to open it. * The "filetype" argument should be one of: * ">", ">>", "<", "|>", "|<", and "|&" -- cgit v1.2.3 From e3f20c041c078eacf648af94d9f012e4906359bb Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Thu, 6 Nov 2014 14:18:37 -0500 Subject: Enhance get_file API to return info about input and output and to enable extensions to create already-opened files or sockets. --- gawkapi.h | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'gawkapi.h') diff --git a/gawkapi.h b/gawkapi.h index dbe7fdf8..65f1dfc3 100644 --- a/gawkapi.h +++ b/gawkapi.h @@ -679,16 +679,34 @@ typedef struct gawk_api { * Look up a file. If the name is NULL or name_len is 0, it returns * data for the currently open input file corresponding to FILENAME * (and it will not access the filetype or typelen arguments, so those - * may be undefined). + * may be undefined). * If the file is not already open, it tries to open it. * The "filetype" argument should be one of: * ">", ">>", "<", "|>", "|<", and "|&" + * If the file is not already open, and the fd argument is non-negative, + * gawk will use that file descriptor instead of opening the file + * in the usual way. If the fd is non-negative, but the file exists + * already, gawk ignores the fd and returns the existing file. It is + * the caller's responsibility to notice that the fd in the returned + * awk_input_buf_t does not match the requested value. Note that + * supplying a file descriptor is currently NOT supported for pipes. + * It should work for input, output, append, and two-way (coprocess) + * sockets. If the filetype is two-way, we assume that it is a socket! + * Note that in the two-way case, the intput and output file descriptors + * may differ. To check for success, one must check that either of + * them matches. */ - const awk_input_buf_t *(*api_get_file)(awk_ext_id_t id, - const char *name, - size_t name_len, - const char *filetype, - size_t typelen); + awk_bool_t (*api_get_file)(awk_ext_id_t id, + const char *name, + size_t name_len, + const char *filetype, + size_t typelen, int fd, + /* + * Return values (on success, one or both should + * be non-NULL): + */ + const awk_input_buf_t **ibufp, + const awk_output_buf_t **obufp); } gawk_api_t; #ifndef GAWK /* these are not for the gawk code itself! */ @@ -771,8 +789,8 @@ typedef struct gawk_api { #define release_value(value) \ (api->api_release_value(ext_id, value)) -#define get_file(name, namelen, filetype, typelen) \ - (api->api_get_file(ext_id, name, namelen, filetype, typelen)) +#define get_file(name, namelen, filetype, typelen, fd, ibuf, obuf) \ + (api->api_get_file(ext_id, name, namelen, filetype, typelen, fd, ibuf, obuf)) #define register_ext_version(version) \ (api->api_register_ext_version(ext_id, version)) -- cgit v1.2.3 From e36300be4deb7bbdeff17c8e896ac2f727e1477e Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Fri, 2 Jan 2015 16:44:33 -0500 Subject: Remove api_get_file typelen argument. --- gawkapi.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gawkapi.h') diff --git a/gawkapi.h b/gawkapi.h index 65f1dfc3..22b3be3d 100644 --- a/gawkapi.h +++ b/gawkapi.h @@ -678,8 +678,8 @@ typedef struct gawk_api { /* * Look up a file. If the name is NULL or name_len is 0, it returns * data for the currently open input file corresponding to FILENAME - * (and it will not access the filetype or typelen arguments, so those - * may be undefined). + * (and it will not access the filetype argument, so that may be + * undefined). * If the file is not already open, it tries to open it. * The "filetype" argument should be one of: * ">", ">>", "<", "|>", "|<", and "|&" @@ -700,7 +700,7 @@ typedef struct gawk_api { const char *name, size_t name_len, const char *filetype, - size_t typelen, int fd, + int fd, /* * Return values (on success, one or both should * be non-NULL): @@ -789,8 +789,8 @@ typedef struct gawk_api { #define release_value(value) \ (api->api_release_value(ext_id, value)) -#define get_file(name, namelen, filetype, typelen, fd, ibuf, obuf) \ - (api->api_get_file(ext_id, name, namelen, filetype, typelen, fd, ibuf, obuf)) +#define get_file(name, namelen, filetype, fd, ibuf, obuf) \ + (api->api_get_file(ext_id, name, namelen, filetype, fd, ibuf, obuf)) #define register_ext_version(version) \ (api->api_register_ext_version(ext_id, version)) -- cgit v1.2.3 From 903e540568e70f71e0a2911cb5998ac2d82ebbb4 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Sun, 4 Jan 2015 18:24:25 -0500 Subject: Document new user-visible features in gawk.1 and gawktexi.in. --- gawkapi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gawkapi.h') diff --git a/gawkapi.h b/gawkapi.h index 22b3be3d..6893fda0 100644 --- a/gawkapi.h +++ b/gawkapi.h @@ -504,7 +504,7 @@ typedef struct gawk_api { awk_value_t *result); /* - * Convert a paramter that was undefined into an array + * Convert a parameter that was undefined into an array * (provide call-by-reference for arrays). Returns false * if count is too big, or if the argument's type is * not undefined. -- cgit v1.2.3 From a29f6a213fb18c199a4b1358327dc6d21f59eb64 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Sun, 4 Jan 2015 20:18:10 -0500 Subject: Document the new get_file API function in gawktexi.in. --- gawkapi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gawkapi.h') diff --git a/gawkapi.h b/gawkapi.h index 6893fda0..cdf81cc8 100644 --- a/gawkapi.h +++ b/gawkapi.h @@ -692,7 +692,7 @@ typedef struct gawk_api { * supplying a file descriptor is currently NOT supported for pipes. * It should work for input, output, append, and two-way (coprocess) * sockets. If the filetype is two-way, we assume that it is a socket! - * Note that in the two-way case, the intput and output file descriptors + * Note that in the two-way case, the input and output file descriptors * may differ. To check for success, one must check that either of * them matches. */ -- cgit v1.2.3 From 2f49027b6d6b1f03ae07c5cd9625b072465079bd Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Wed, 11 Feb 2015 23:21:28 +0200 Subject: O'Reilly edits, through Chapter 16. --- gawkapi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gawkapi.h') diff --git a/gawkapi.h b/gawkapi.h index d8215450..7a58bd4a 100644 --- a/gawkapi.h +++ b/gawkapi.h @@ -846,7 +846,7 @@ make_number(double num, awk_value_t *result) extern int dl_load(const gawk_api_t *const api_p, awk_ext_id_t id); #if 0 -/* Boiler plate code: */ +/* Boilerplate code: */ int plugin_is_GPL_compatible; static gawk_api_t *const api; -- cgit v1.2.3