From 088751e5a9f081e4a84ffb14740a68249939e15f Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 4 Aug 2008 08:13:03 +0000 Subject: [PATCH] --- ase/lib/awk/std.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 ase/lib/awk/std.c diff --git a/ase/lib/awk/std.c b/ase/lib/awk/std.c new file mode 100644 index 00000000..4d4cb531 --- /dev/null +++ b/ase/lib/awk/std.c @@ -0,0 +1,57 @@ +#include + +typedef struct ext_t +{ + ase_awk_prmfns_t prmfns; +} +ext_t; + +static ase_real_t custom_awk_pow (void* custom, ase_real_t x, ase_real_t y) +{ + return pow (x, y); +} + +static int custom_awk_sprintf ( + void* custom, ase_char_t* buf, ase_size_t size, + const ase_char_t* fmt, ...) +{ + int n; + + va_list ap; + va_start (ap, fmt); + n = ase_vsprintf (buf, size, fmt, ap); + va_end (ap); + + return n; +} + +static void custom_awk_dprintf (void* custom, const ase_char_t* fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + ase_vfprintf (stderr, fmt, ap); + va_end (ap); +} + +ase_awk_t* ase_awk_openstd (void) +{ + ase_awk_t* awk; + + awk = ase_awk_open (ASE_GETMMGR(), ASE_SIZEOF(ext_t), ASE_NULL); + ase_awk_setccls (ASE_GETCCLS()); + + ext = (ext_t*) ase_awk_getextension (awk); + ext->prmfns.pow = custom_awk_pow; + ext->prmfns.sprintf = custom_awk_sprintf; + ext->prmfns.dprintf = custom_awk_dprintf; + ext->prmfns.custom_data = ASE_NULL; + ase_awk_setprmfns (awk, &ext->prmfns); + + ase_awk_setoption (awk, + ASE_AWK_IMPLICIT | ASE_AWK_EXTIO | ASE_AWK_NEWLINE | + ASE_AWK_BASEONE | ASE_AWK_PABLOCK); + + /*ase_awk_addfunction ();*/ + + return awk; +}