48 lines
1.6 KiB
Groff
48 lines
1.6 KiB
Groff
|
.title Embedding AWK
|
||
|
|
||
|
To embed the awk interpreter to an application, the developer should provide the following routines.
|
||
|
|
||
|
* System functions including memory management
|
||
|
* Source code I/O functions
|
||
|
* I/O functions to interface with the console, files, and pipes.
|
||
|
|
||
|
ase_awk_open creates an awk object and requires a pointer to a structure holding system functions. The structure is described in ase_awk_prmfns_t.
|
||
|
|
||
|
{{{
|
||
|
struct ase_awk_prmfns_t
|
||
|
{
|
||
|
/* memory */
|
||
|
void* (*malloc) (ase_size_t n, void* custom_data);
|
||
|
void* (*realloc) (void* ptr, ase_size_t n, void* custom_data);
|
||
|
void (*free) (void* ptr, void* custom_data);
|
||
|
|
||
|
/* character class */
|
||
|
ase_bool_t (*is_upper) (ase_cint_t c);
|
||
|
ase_bool_t (*is_lower) (ase_cint_t c);
|
||
|
ase_bool_t (*is_alpha) (ase_cint_t c);
|
||
|
ase_bool_t (*is_digit) (ase_cint_t c);
|
||
|
ase_bool_t (*is_xdigit) (ase_cint_t c);
|
||
|
ase_bool_t (*is_alnum) (ase_cint_t c);
|
||
|
ase_bool_t (*is_space) (ase_cint_t c);
|
||
|
ase_bool_t (*is_print) (ase_cint_t c);
|
||
|
ase_bool_t (*is_graph) (ase_cint_t c);
|
||
|
ase_bool_t (*is_cntrl) (ase_cint_t c);
|
||
|
ase_bool_t (*is_punct) (ase_cint_t c);
|
||
|
ase_cint_t (*to_upper) (ase_cint_t c);
|
||
|
ase_cint_t (*to_lower) (ase_cint_t c);
|
||
|
|
||
|
/* utilities */
|
||
|
void* (*memcpy) (void* dst, const void* src, ase_size_t n);
|
||
|
void* (*memset) (void* dst, int val, ase_size_t n);
|
||
|
ase_real_t (*pow) (ase_real_t x, ase_real_t y);
|
||
|
|
||
|
int (*sprintf) (ase_char_t* buf, ase_size_t size, const ase_char_t* fmt, ...);
|
||
|
void (*aprintf) (const ase_char_t* fmt, ...); /* assertion */
|
||
|
void (*dprintf) (const ase_char_t* fmt, ...); /* debug */
|
||
|
void (*abort) (void);
|
||
|
|
||
|
void* custom_data;
|
||
|
};
|
||
|
}}}
|
||
|
|