2005-11-05 17:54:00 +00:00
|
|
|
/*
|
2006-03-31 16:35:37 +00:00
|
|
|
* $Id: awk.h,v 1.39 2006-03-31 16:35:37 bacon Exp $
|
2005-11-05 17:54:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _XP_AWK_AWK_H_
|
|
|
|
#define _XP_AWK_AWK_H_
|
|
|
|
|
|
|
|
#include <xp/types.h>
|
|
|
|
#include <xp/macros.h>
|
2006-01-18 15:16:01 +00:00
|
|
|
|
2006-03-27 11:43:17 +00:00
|
|
|
typedef struct xp_awk_t xp_awk_t;
|
|
|
|
|
2005-11-05 17:54:00 +00:00
|
|
|
typedef xp_ssize_t (*xp_awk_io_t) (
|
|
|
|
int cmd, void* arg, xp_char_t* data, xp_size_t count);
|
|
|
|
|
2006-01-19 16:28:21 +00:00
|
|
|
/* io function commands */
|
2005-11-05 17:54:00 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
XP_AWK_IO_OPEN,
|
|
|
|
XP_AWK_IO_CLOSE,
|
|
|
|
XP_AWK_IO_DATA
|
|
|
|
};
|
|
|
|
|
2006-01-31 16:57:45 +00:00
|
|
|
/* parse options */
|
2006-01-19 16:28:21 +00:00
|
|
|
enum
|
|
|
|
{
|
2006-02-05 13:45:59 +00:00
|
|
|
XP_AWK_IMPLICIT = (1 << 0), /* allow undeclared variables */
|
|
|
|
XP_AWK_EXPLICIT = (1 << 1), /* variable requires explicit declaration */
|
|
|
|
XP_AWK_UNIQUE = (1 << 2), /* a function name should not coincide to be a variable name */
|
2006-02-08 16:14:31 +00:00
|
|
|
XP_AWK_SHADING = (1 << 3), /* allow variable shading */
|
|
|
|
XP_AWK_SHIFT = (1 << 4) /* support shift operators */
|
2006-01-19 16:28:21 +00:00
|
|
|
};
|
|
|
|
|
2005-11-05 17:54:00 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2006-03-31 16:35:37 +00:00
|
|
|
xp_awk_t* xp_awk_open (void);
|
2005-11-05 17:54:00 +00:00
|
|
|
int xp_awk_close (xp_awk_t* awk);
|
|
|
|
|
2006-01-31 16:57:45 +00:00
|
|
|
int xp_awk_geterrnum (xp_awk_t* awk);
|
|
|
|
const xp_char_t* xp_awk_geterrstr (xp_awk_t* awk);
|
|
|
|
|
2006-01-24 16:14:28 +00:00
|
|
|
void xp_awk_clear (xp_awk_t* awk);
|
2006-03-31 16:35:37 +00:00
|
|
|
void xp_awk_setparseopt (xp_awk_t* awk, int opt);
|
2006-01-24 16:14:28 +00:00
|
|
|
|
2005-12-29 12:04:51 +00:00
|
|
|
int xp_awk_attsrc (xp_awk_t* awk, xp_awk_io_t src, void* arg);
|
|
|
|
int xp_awk_detsrc (xp_awk_t* awk);
|
2006-01-19 16:28:21 +00:00
|
|
|
int xp_awk_attin (xp_awk_t* awk, xp_awk_io_t in, void* arg);
|
|
|
|
int xp_awk_detin (xp_awk_t* awk);
|
|
|
|
int xp_awk_attout (xp_awk_t* awk, xp_awk_io_t out, void* arg);
|
|
|
|
int xp_awk_detout (xp_awk_t* awk);
|
2005-11-07 16:02:44 +00:00
|
|
|
|
2006-01-09 16:03:56 +00:00
|
|
|
int xp_awk_parse (xp_awk_t* awk);
|
2006-01-26 15:35:20 +00:00
|
|
|
int xp_awk_run (xp_awk_t* awk);
|
2006-01-09 16:03:56 +00:00
|
|
|
|
2005-11-05 17:54:00 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|