Access to facilities within gawk are made available by calling through function pointers passed into your extension.
API function pointers are provided for the following kinds of operations:
ERRNO, or unsetting it.
Some points about using the API:
|C Entity||Header File
Due to portability concerns, especially to systems that are not fully standards-compliant, it is your responsibility to include the correct files in the correct way. This requirement is necessary in order to keep gawkapi.h clean, instead of becoming a portability hodge-podge as can be seen in some parts of the gawk source code.
To pass reasonable integer values for
ERRNO, you will also need to
inlinekeyword. If your compiler does not support this keyword, you should either place ‘-Dinline=''’ on your command line, or use the GNU Autotools and include a config.h file in your extensions.
malloc()and is managed by gawk from then on.
structs that map values as seen from awk. A value can be a
double, a string, or an array (as in multidimensional arrays, or when creating a new array). String values maintain both pointer and length since embedded
NULcharacters are allowed.
NOTE: By intent, strings are maintained using the current multibyte encoding (as defined by LC_xxx environment variables) and not using wide characters. This matches how gawk stores strings internally and also how characters are likely to be input and output from files.
However, if the request and actual type don't match, the access function returns “false” and fills in the type of the actual value that is there, so that the extension can, e.g., print an error message (such as “scalar passed where array expected”).
While you may call the API functions by using the function pointers directly, the interface is not so pretty. To make extension code look more like regular code, the gawkapi.h header file defines several macros that you should use in your code. This section presents the macros as if they were functions.