qse/ase/awk/awk.h

464 lines
15 KiB
C
Raw Normal View History

2005-11-05 17:54:00 +00:00
/*
2006-11-24 13:25:12 +00:00
* $Id: awk.h,v 1.151 2006-11-24 13:20:48 bacon Exp $
2005-11-05 17:54:00 +00:00
*/
2006-10-24 04:10:12 +00:00
#ifndef _ASE_AWK_AWK_H_
#define _ASE_AWK_AWK_H_
2005-11-05 17:54:00 +00:00
2006-10-24 04:10:12 +00:00
#include <ase/types.h>
#include <ase/macros.h>
2006-01-18 15:16:01 +00:00
2006-10-24 04:10:12 +00:00
typedef struct ase_awk_t ase_awk_t;
typedef struct ase_awk_run_t ase_awk_run_t;
typedef struct ase_awk_val_t ase_awk_val_t;
typedef struct ase_awk_extio_t ase_awk_extio_t;
2006-08-04 17:36:40 +00:00
2006-10-24 04:10:12 +00:00
typedef struct ase_awk_syscas_t ase_awk_syscas_t;
typedef struct ase_awk_srcios_t ase_awk_srcios_t;
typedef struct ase_awk_runios_t ase_awk_runios_t;
typedef struct ase_awk_runcbs_t ase_awk_runcbs_t;
typedef struct ase_awk_runarg_t ase_awk_runarg_t;
2006-08-04 17:36:40 +00:00
2006-10-24 04:10:12 +00:00
typedef void (*ase_awk_lk_t) (ase_awk_t* awk, void* arg);
typedef ase_ssize_t (*ase_awk_io_t) (
int cmd, void* arg, ase_char_t* data, ase_size_t count);
2006-06-19 04:38:51 +00:00
2006-10-24 04:10:12 +00:00
struct ase_awk_extio_t
2006-06-19 04:38:51 +00:00
{
2006-10-24 04:10:12 +00:00
ase_awk_run_t* run; /* [IN] */
2006-11-21 15:06:51 +00:00
int type; /* [IN] console, file, coproc, pipe */
int mode; /* [IN] read, write, etc */
2006-10-24 04:10:12 +00:00
ase_char_t* name; /* [IN] */
2006-11-21 15:06:51 +00:00
void* custom_data; /* [IN] */
void* handle; /* [OUT] */
2006-10-16 14:39:21 +00:00
2006-11-21 15:06:51 +00:00
/* input */
2006-06-28 14:19:01 +00:00
struct
{
2006-10-24 04:10:12 +00:00
ase_char_t buf[2048];
ase_size_t pos;
ase_size_t len;
ase_bool_t eof;
2006-11-21 15:06:51 +00:00
ase_bool_t eos;
2006-06-28 14:19:01 +00:00
} in;
2006-11-21 15:06:51 +00:00
/* output */
struct
{
ase_bool_t eof;
ase_bool_t eos;
} out;
2006-10-24 04:10:12 +00:00
ase_awk_extio_t* next;
2006-06-19 04:38:51 +00:00
};
2006-10-24 04:10:12 +00:00
struct ase_awk_syscas_t
2006-08-31 04:21:04 +00:00
{
/* memory */
2006-10-24 04:10:12 +00:00
void* (*malloc) (ase_size_t n, void* custom_data);
void* (*realloc) (void* ptr, ase_size_t n, void* custom_data);
2006-08-31 04:21:04 +00:00
void (*free) (void* ptr, void* custom_data);
/* thread lock */
2006-10-24 04:10:12 +00:00
ase_awk_lk_t lock;
ase_awk_lk_t unlock;
2006-08-31 04:21:04 +00:00
2006-09-01 06:23:58 +00:00
/* character class */
2006-10-24 04:10:12 +00:00
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);
2006-09-01 06:23:58 +00:00
2006-09-25 06:17:19 +00:00
/* utilities */
2006-10-31 14:32:50 +00:00
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);
2006-10-12 04:17:58 +00:00
2006-10-24 04:10:12 +00:00
int (*sprintf) (ase_char_t* buf, ase_size_t size, ase_char_t* fmt, ...);
2006-11-18 15:36:57 +00:00
void (*aprintf) (ase_char_t* fmt, ...); /* assertion */
void (*dprintf) (ase_char_t* fmt, ...); /* debug */
2006-10-12 04:17:58 +00:00
void (*abort) (void);
2006-09-22 14:05:30 +00:00
2006-08-31 04:21:04 +00:00
void* custom_data;
};
2006-08-10 16:02:15 +00:00
2006-10-24 04:10:12 +00:00
struct ase_awk_srcios_t
2006-08-04 17:54:52 +00:00
{
2006-10-24 04:10:12 +00:00
ase_awk_io_t in;
ase_awk_io_t out;
2006-08-04 17:54:52 +00:00
void* custom_data;
};
2006-10-24 04:10:12 +00:00
struct ase_awk_runios_t
2006-08-04 17:36:40 +00:00
{
2006-10-24 04:10:12 +00:00
ase_awk_io_t pipe;
ase_awk_io_t coproc;
ase_awk_io_t file;
ase_awk_io_t console;
2006-10-13 10:18:39 +00:00
void* custom_data;
2006-08-04 17:36:40 +00:00
};
2006-10-24 04:10:12 +00:00
struct ase_awk_runcbs_t
2006-08-04 16:31:22 +00:00
{
2006-10-24 04:10:12 +00:00
void (*on_start) (ase_awk_t* awk, void* handle, void* arg);
void (*on_end) (ase_awk_t* awk, void* handle, int errnum, void* arg);
2006-08-04 17:36:40 +00:00
void* custom_data;
2006-08-04 16:31:22 +00:00
};
2006-10-24 04:10:12 +00:00
struct ase_awk_runarg_t
2006-10-10 14:09:23 +00:00
{
2006-10-24 04:10:12 +00:00
const ase_char_t* ptr;
ase_size_t len;
2006-10-10 14:09:23 +00:00
};
2006-08-31 04:21:04 +00:00
2006-01-19 16:28:21 +00:00
/* io function commands */
2005-11-05 17:54:00 +00:00
enum
{
2006-10-24 04:10:12 +00:00
ASE_AWK_IO_OPEN = 0,
ASE_AWK_IO_CLOSE = 1,
ASE_AWK_IO_READ = 2,
ASE_AWK_IO_WRITE = 3,
ASE_AWK_IO_FLUSH = 4,
ASE_AWK_IO_NEXT = 5
2006-06-22 04:25:44 +00:00
};
2006-08-04 17:36:40 +00:00
/* various options */
2006-10-23 14:44:43 +00:00
enum
2006-07-30 15:53:42 +00:00
{
/* allow undeclared variables */
2006-10-24 04:10:12 +00:00
ASE_AWK_IMPLICIT = (1 << 0),
2006-07-30 15:53:42 +00:00
2006-11-19 11:21:06 +00:00
/* allow explicit variable declarations */
2006-10-24 04:10:12 +00:00
ASE_AWK_EXPLICIT = (1 << 1),
2006-07-30 15:53:42 +00:00
/* a function name should not coincide to be a variable name */
2006-10-24 04:10:12 +00:00
ASE_AWK_UNIQUE = (1 << 2),
2006-07-30 15:53:42 +00:00
/* allow variable shading */
2006-10-24 04:10:12 +00:00
ASE_AWK_SHADING = (1 << 3),
2006-07-30 15:53:42 +00:00
/* support shift operators */
2006-10-24 04:10:12 +00:00
ASE_AWK_SHIFT = (1 << 4),
2006-07-30 15:53:42 +00:00
/* support comments by a hash sign */
2006-10-24 04:10:12 +00:00
ASE_AWK_HASHSIGN = (1 << 5),
2006-07-30 15:53:42 +00:00
/* support comments by double slashes */
2006-10-24 04:10:12 +00:00
ASE_AWK_DBLSLASHES = (1 << 6),
2006-07-30 15:53:42 +00:00
/* support string concatenation in tokenization.
* this option can change the behavior of a certain construct.
* getline < "abc" ".def" is treated as if it is getline < "abc.def"
2006-10-22 12:39:30 +00:00
* when this option is on. If this option is off, the same expression
2006-07-30 15:53:42 +00:00
* is treated as if it is (getline < "abc") ".def". */
2006-10-24 04:10:12 +00:00
ASE_AWK_STRCONCAT = (1 << 7),
2006-07-30 15:53:42 +00:00
/* support getline and print */
2006-10-24 04:10:12 +00:00
ASE_AWK_EXTIO = (1 << 8),
2006-08-03 09:54:16 +00:00
/* support blockless patterns */
2006-10-24 04:10:12 +00:00
ASE_AWK_BLOCKLESS = (1 << 9),
2006-01-19 16:28:21 +00:00
2006-08-04 17:36:40 +00:00
/* execution starts from main */
2006-10-24 04:10:12 +00:00
ASE_AWK_RUNMAIN = (1 << 10),
2006-08-13 16:05:04 +00:00
/* use 1 as the start index for string operations */
2006-10-24 04:10:12 +00:00
ASE_AWK_STRINDEXONE = (1 << 11),
2006-09-08 14:51:15 +00:00
/* strip off leading and trailing spaces when splitting a record
2006-10-22 12:39:30 +00:00
* into fields with a regular expression.
2006-09-08 14:57:43 +00:00
*
* Consider the following program.
* BEGIN { FS="[:[:space:]]+"; }
* {
* print "NF=" NF;
* for (i = 0; i < NF; i++) print i " [" $(i+1) "]";
* }
*
* The program splits " a b c " into [a], [b], [c] when this
* option is on while into [], [a], [b], [c], [] when it is off.
*/
2006-10-24 04:10:12 +00:00
ASE_AWK_STRIPSPACES = (1 << 12),
2006-10-15 15:46:14 +00:00
2006-11-23 03:31:58 +00:00
/* enable the nextoutfile keyword */
2006-11-23 14:27:52 +00:00
ASE_AWK_NEXTOFILE = (1 << 13),
2006-11-23 03:31:58 +00:00
2006-10-15 15:46:14 +00:00
/* a newline terminates a statement */
2006-11-23 14:27:52 +00:00
ASE_AWK_NEWLINE = (1 << 14)
2006-04-09 15:31:13 +00:00
};
2006-04-02 12:45:04 +00:00
/* error code */
2006-10-23 14:44:43 +00:00
enum
2006-04-02 12:45:04 +00:00
{
2006-10-24 04:10:12 +00:00
ASE_AWK_ENOERR, /* no error */
ASE_AWK_ENOMEM, /* out of memory */
ASE_AWK_EINVAL, /* invalid parameter */
ASE_AWK_ERUNTIME, /* run-time error */
ASE_AWK_ERUNNING, /* there are running instances */
ASE_AWK_ETOOMANYRUNS, /* too many running instances */
ASE_AWK_ERECURSION, /* recursion too deep */
ASE_AWK_ESRCINOPEN,
ASE_AWK_ESRCINCLOSE,
ASE_AWK_ESRCINREAD,
ASE_AWK_ESRCOUTOPEN,
ASE_AWK_ESRCOUTCLOSE,
ASE_AWK_ESRCOUTWRITE,
ASE_AWK_ECONINOPEN,
ASE_AWK_ECONINCLOSE,
ASE_AWK_ECONINNEXT,
ASE_AWK_ECONINDATA,
ASE_AWK_ECONOUTOPEN,
ASE_AWK_ECONOUTCLOSE,
ASE_AWK_ECONOUTNEXT,
ASE_AWK_ECONOUTDATA,
ASE_AWK_ELXCHR, /* lexer came accross an wrong character */
ASE_AWK_ELXUNG, /* lexer failed to unget a character */
ASE_AWK_EENDSRC, /* unexpected end of source */
ASE_AWK_EENDCOMMENT, /* unexpected end of a comment */
ASE_AWK_EENDSTR, /* unexpected end of a string */
ASE_AWK_EENDREX, /* unexpected end of a regular expression */
ASE_AWK_ELBRACE, /* left brace expected */
ASE_AWK_ELPAREN, /* left parenthesis expected */
ASE_AWK_ERPAREN, /* right parenthesis expected */
ASE_AWK_ERBRACK, /* right bracket expected */
ASE_AWK_ECOMMA, /* comma expected */
ASE_AWK_ESEMICOLON, /* semicolon expected */
ASE_AWK_ECOLON, /* colon expected */
ASE_AWK_EIN, /* keyword 'in' is expected */
ASE_AWK_ENOTVAR, /* not a variable name after 'in' */
ASE_AWK_EEXPRESSION, /* expression expected */
ASE_AWK_EWHILE, /* keyword 'while' is expected */
ASE_AWK_EASSIGNMENT, /* assignment statement expected */
ASE_AWK_EIDENT, /* identifier expected */
ASE_AWK_EBEGINBLOCK, /* BEGIN requires an action block */
ASE_AWK_EENDBLOCK, /* END requires an action block */
ASE_AWK_EDUPBEGIN, /* duplicate BEGIN */
ASE_AWK_EDUPEND, /* duplicate END */
ASE_AWK_EDUPFUNC, /* duplicate function name */
ASE_AWK_EDUPPARAM, /* duplicate parameter name */
ASE_AWK_EDUPVAR, /* duplicate variable name */
ASE_AWK_EDUPNAME, /* duplicate name - function, variable, etc */
ASE_AWK_EUNDEF, /* undefined identifier */
ASE_AWK_ELVALUE, /* l-value required */
ASE_AWK_ETOOFEWARGS, /* too few arguments */
ASE_AWK_ETOOMANYARGS, /* too many arguments */
ASE_AWK_ETOOMANYGLOBALS, /* too many global variables */
ASE_AWK_ETOOMANYLOCALS, /* too many local variables */
ASE_AWK_ETOOMANYPARAMS, /* too many parameters */
ASE_AWK_EBREAK, /* break outside a loop */
ASE_AWK_ECONTINUE, /* continue outside a loop */
ASE_AWK_ENEXT, /* next illegal in BEGIN or END block */
ASE_AWK_ENEXTFILE, /* nextfile illegal in BEGIN or END block */
ASE_AWK_EGETLINE, /* getline expected */
2006-10-31 10:13:15 +00:00
ASE_AWK_EPRINTFARG, /* printf must have one or more arguments */
2006-04-05 15:56:20 +00:00
/* run time error */
2006-11-16 04:44:16 +00:00
ASE_AWK_EINTERNAL, /* internal error */
2006-10-24 04:10:12 +00:00
ASE_AWK_EDIVBYZERO, /* divide by zero */
ASE_AWK_EOPERAND, /* invalid operand */
ASE_AWK_EPOSIDX, /* wrong position index */
ASE_AWK_ENOSUCHFUNC, /* no such function */
ASE_AWK_ENOTASSIGNABLE, /* value not assignable */
ASE_AWK_ENOTINDEXABLE, /* not indexable variable */
ASE_AWK_ENOTDELETABLE, /* not deletable variable */
ASE_AWK_ENOTREFERENCEABLE, /* not referenceable value */
ASE_AWK_EIDXVALASSMAP, /* indexed value cannot be assigned a map */
ASE_AWK_EPOSVALASSMAP, /* a positional cannot be assigned a map */
ASE_AWK_EMAPTOSCALAR, /* cannot change a map to a scalar value */
ASE_AWK_ESCALARTOMAP, /* cannot change a scalar value to a map */
ASE_AWK_EMAPNOTALLOWED, /* a map is not allowed */
ASE_AWK_EVALTYPE, /* wrong value type */
ASE_AWK_EPIPE, /* pipe operation error */
ASE_AWK_ENEXTCALL, /* next called from BEGIN or END */
ASE_AWK_ENEXTFILECALL, /* nextfile called from BEGIN or END */
ASE_AWK_EIOIMPL, /* wrong implementation of user io handler */
ASE_AWK_ENOSUCHIO, /* no such io name found */
ASE_AWK_EIOHANDLER, /* io handler has returned an error */
2006-11-16 04:44:16 +00:00
ASE_AWK_EFMTARG, /* arguments to format string not sufficient */
ASE_AWK_EFMTCONV, /* recursion detected in format conversion */
2006-11-18 12:15:20 +00:00
ASE_AWK_ECONVFMTCHAR, /* an invalid character found in CONVFMT */
ASE_AWK_EOFMTCHAR, /* an invalid character found in OFMT */
2006-10-22 11:34:53 +00:00
2006-10-22 12:39:30 +00:00
/* regular expression error */
2006-10-24 04:10:12 +00:00
ASE_AWK_EREXRPAREN, /* a right parenthesis is expected */
ASE_AWK_EREXRBRACKET, /* a right bracket is expected */
ASE_AWK_EREXRBRACE, /* a right brace is expected */
ASE_AWK_EREXCOLON, /* a colon is expected */
ASE_AWK_EREXCRANGE, /* invalid character range */
ASE_AWK_EREXCCLASS, /* invalid character class */
ASE_AWK_EREXBRANGE, /* invalid boundary range */
ASE_AWK_EREXEND, /* unexpected end of the pattern */
ASE_AWK_EREXGARBAGE /* garbage after the pattern */
2006-04-02 12:45:04 +00:00
};
2006-06-19 09:10:57 +00:00
/* extio types */
2006-11-21 15:06:51 +00:00
enum ase_awk_extio_type_t
2006-06-19 09:10:57 +00:00
{
/* extio types available */
2006-10-24 04:10:12 +00:00
ASE_AWK_EXTIO_PIPE,
ASE_AWK_EXTIO_COPROC,
ASE_AWK_EXTIO_FILE,
ASE_AWK_EXTIO_CONSOLE,
2006-06-19 09:10:57 +00:00
/* reserved for internal use only */
2006-10-24 04:10:12 +00:00
ASE_AWK_EXTIO_NUM
2006-06-19 09:10:57 +00:00
};
2006-11-23 03:31:58 +00:00
enum
{
ASE_AWK_EXTIO_PIPE_READ = 0,
ASE_AWK_EXTIO_PIPE_WRITE = 1,
/*
ASE_AWK_EXTIO_COPROC_READ = 0,
ASE_AWK_EXTIO_COPROC_WRITE = 1,
ASE_AWK_EXTIO_COPROC_RDWR = 2,
*/
ASE_AWK_EXTIO_FILE_READ = 0,
ASE_AWK_EXTIO_FILE_WRITE = 1,
ASE_AWK_EXTIO_FILE_APPEND = 2,
ASE_AWK_EXTIO_CONSOLE_READ = 0,
ASE_AWK_EXTIO_CONSOLE_WRITE = 1
};
2006-10-24 04:48:52 +00:00
/* assertion statement */
#ifdef NDEBUG
2006-10-26 09:31:28 +00:00
#define ASE_AWK_ASSERT(awk,expr) ((void)0)
2006-10-30 14:31:37 +00:00
#define ASE_AWK_ASSERTX(awk,expr,desc) ((void)0)
2006-10-24 04:48:52 +00:00
#else
2006-10-26 09:31:28 +00:00
#define ASE_AWK_ASSERT(awk,expr) (void)((expr) || \
2006-10-30 14:31:37 +00:00
(ase_awk_assertfail (awk, ASE_T(#expr), ASE_NULL, ASE_T(__FILE__), __LINE__), 0))
#define ASE_AWK_ASSERTX(awk,expr,desc) (void)((expr) || \
(ase_awk_assertfail (awk, ASE_T(#expr), ASE_T(desc), ASE_T(__FILE__), __LINE__), 0))
2006-10-24 04:48:52 +00:00
#endif
2005-11-05 17:54:00 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2006-10-24 04:10:12 +00:00
ase_awk_t* ase_awk_open (const ase_awk_syscas_t* syscas);
int ase_awk_close (ase_awk_t* awk);
int ase_awk_clear (ase_awk_t* awk);
2005-11-05 17:54:00 +00:00
2006-10-24 04:10:12 +00:00
int ase_awk_geterrnum (ase_awk_t* awk);
ase_size_t ase_awk_getsrcline (ase_awk_t* awk);
2006-08-13 16:05:04 +00:00
2006-10-24 04:10:12 +00:00
int ase_awk_getopt (ase_awk_t* awk);
void ase_awk_setopt (ase_awk_t* awk, int opt);
2006-08-04 17:36:40 +00:00
2006-10-24 04:10:12 +00:00
int ase_awk_parse (ase_awk_t* awk, ase_awk_srcios_t* srcios);
2006-08-04 17:36:40 +00:00
2006-08-13 05:55:02 +00:00
/*
2006-10-24 04:10:12 +00:00
* ase_awk_run return 0 on success and -1 on failure, generally speaking.
2006-08-13 05:55:02 +00:00
* A runtime context is required for it to start running the program.
* Once the runtime context is created, the program starts to run.
* The context creation failure is reported by the return value -1 of
* this function. however, the runtime error after the context creation
* is reported differently depending on the use of the callback.
2006-10-24 04:10:12 +00:00
* When no callback is specified (i.e. runcbs is ASE_NULL), ase_awk_run
2006-08-13 05:55:02 +00:00
* returns -1 on an error and awk->errnum is set accordingly.
2006-10-24 04:10:12 +00:00
* However, if a callback is specified (i.e. runcbs is not ASE_NULL),
* ase_awk_run returns 0 on both success and failure. Instead, the
2006-08-13 05:55:02 +00:00
* on_end handler of the callback is triggered with the relevant
* error number. The third parameter to on_end denotes this error number.
*/
2006-10-24 04:10:12 +00:00
int ase_awk_run (ase_awk_t* awk,
2006-11-19 15:24:21 +00:00
const ase_char_t* main,
2006-10-24 04:10:12 +00:00
ase_awk_runios_t* runios,
ase_awk_runcbs_t* runcbs,
ase_awk_runarg_t* runarg);
2006-08-04 17:36:40 +00:00
2006-10-24 04:10:12 +00:00
int ase_awk_stop (ase_awk_t* awk, ase_awk_run_t* run);
void ase_awk_stopall (ase_awk_t* awk);
2006-01-09 16:03:56 +00:00
2006-06-20 15:27:50 +00:00
/* functions to access internal stack structure */
2006-10-24 04:10:12 +00:00
ase_size_t ase_awk_getnargs (ase_awk_run_t* run);
ase_awk_val_t* ase_awk_getarg (ase_awk_run_t* run, ase_size_t idx);
ase_awk_val_t* ase_awk_getglobal (ase_awk_run_t* run, ase_size_t idx);
int ase_awk_setglobal (ase_awk_run_t* run, ase_size_t idx, ase_awk_val_t* val);
void ase_awk_setretval (ase_awk_run_t* run, ase_awk_val_t* val);
2006-10-03 14:38:26 +00:00
2006-11-24 13:25:12 +00:00
int ase_awk_setfilename (
ase_awk_run_t* run, const ase_char_t* name, ase_size_t len);
int ase_awk_setofilename (
2006-10-24 04:10:12 +00:00
ase_awk_run_t* run, const ase_char_t* name, ase_size_t len);
2006-10-16 14:39:21 +00:00
2006-10-24 04:10:12 +00:00
int ase_awk_getrunerrnum (ase_awk_run_t* run);
void ase_awk_setrunerrnum (ase_awk_run_t* run, int errnum);
2006-10-10 07:02:38 +00:00
2006-10-03 14:38:26 +00:00
/* record and field functions */
2006-10-24 04:10:12 +00:00
int ase_awk_clrrec (ase_awk_run_t* run, ase_bool_t skip_inrec_line);
int ase_awk_setrec (ase_awk_run_t* run, ase_size_t idx, const ase_char_t* str, ase_size_t len);
2006-10-22 11:34:53 +00:00
2006-10-22 12:39:30 +00:00
/* utility functions exported by awk.h */
2006-10-24 04:10:12 +00:00
ase_long_t ase_awk_strxtolong (
ase_awk_t* awk, const ase_char_t* str, ase_size_t len,
int base, const ase_char_t** endptr);
ase_real_t ase_awk_strxtoreal (
ase_awk_t* awk, const ase_char_t* str, ase_size_t len,
const ase_char_t** endptr);
2006-10-22 11:34:53 +00:00
2006-10-24 04:10:12 +00:00
ase_size_t ase_awk_longtostr (
ase_long_t value, int radix, const ase_char_t* prefix,
ase_char_t* buf, ase_size_t size);
2006-10-22 11:34:53 +00:00
2006-10-22 12:39:30 +00:00
/* string functions exported by awk.h */
2006-10-24 04:10:12 +00:00
ase_char_t* ase_awk_strdup (
ase_awk_t* awk, const ase_char_t* str);
ase_char_t* ase_awk_strxdup (
ase_awk_t* awk, const ase_char_t* str, ase_size_t len);
ase_char_t* ase_awk_strxdup2 (
ase_awk_t* awk,
const ase_char_t* str1, ase_size_t len1,
const ase_char_t* str2, ase_size_t len2);
ase_size_t ase_awk_strlen (const ase_char_t* str);
ase_size_t ase_awk_strcpy (ase_char_t* buf, const ase_char_t* str);
ase_size_t ase_awk_strncpy (ase_char_t* buf, const ase_char_t* str, ase_size_t len);
int ase_awk_strcmp (const ase_char_t* s1, const ase_char_t* s2);
int ase_awk_strxncmp (
const ase_char_t* s1, ase_size_t len1,
const ase_char_t* s2, ase_size_t len2);
int ase_awk_strxncasecmp (
ase_awk_t* awk,
const ase_char_t* s1, ase_size_t len1,
const ase_char_t* s2, ase_size_t len2);
ase_char_t* ase_awk_strxnstr (
const ase_char_t* str, ase_size_t strsz,
const ase_char_t* sub, ase_size_t subsz);
2006-09-01 06:23:58 +00:00
2006-10-26 09:31:28 +00:00
/* abort function for assertion. use ASE_AWK_ASSERT instead */
2006-10-24 04:48:52 +00:00
int ase_awk_assertfail (ase_awk_t* awk,
2006-10-30 14:31:37 +00:00
const ase_char_t* expr, const ase_char_t* desc,
const ase_char_t* file, int line);
2006-10-24 04:48:52 +00:00
2006-08-10 16:02:15 +00:00
/* utility functions to convert an error number ot a string */
2006-10-24 04:10:12 +00:00
const ase_char_t* ase_awk_geterrstr (int errnum);
2006-08-10 16:02:15 +00:00
2005-11-05 17:54:00 +00:00
#ifdef __cplusplus
}
#endif
#endif