2005-02-04 15:39:11 +00:00
|
|
|
/*
|
2006-10-23 14:57:44 +00:00
|
|
|
* $Id: lsp.h,v 1.24 2006-10-23 14:57:44 bacon Exp $
|
2005-02-04 15:39:11 +00:00
|
|
|
*/
|
|
|
|
|
2006-10-22 13:10:46 +00:00
|
|
|
#ifndef _SSE_LSP_LSP_H_
|
|
|
|
#define _SSE_LSP_LSP_H_
|
2005-09-17 17:50:45 +00:00
|
|
|
|
2006-10-23 14:57:44 +00:00
|
|
|
#include <sse/lsp/types.h>
|
2006-10-23 14:42:38 +00:00
|
|
|
|
|
|
|
typedef struct sse_lsp_t sse_lsp_t;
|
|
|
|
typedef struct sse_lsp_obj_t sse_lsp_obj_t;
|
|
|
|
typedef struct sse_lsp_syscas_t sse_lsp_syscas_t;
|
|
|
|
|
|
|
|
typedef sse_ssize_t (*sse_lsp_io_t) (
|
|
|
|
int cmd, void* arg, sse_char_t* data, sse_size_t count);
|
|
|
|
|
|
|
|
struct sse_lsp_syscas_t
|
|
|
|
{
|
|
|
|
/* memory */
|
|
|
|
void* (*malloc) (sse_size_t n, void* custom_data);
|
|
|
|
void* (*realloc) (void* ptr, sse_size_t n, void* custom_data);
|
|
|
|
void (*free) (void* ptr, void* custom_data);
|
|
|
|
|
|
|
|
/* character class */
|
|
|
|
sse_bool_t (*is_upper) (sse_cint_t c);
|
|
|
|
sse_bool_t (*is_lower) (sse_cint_t c);
|
|
|
|
sse_bool_t (*is_alpha) (sse_cint_t c);
|
|
|
|
sse_bool_t (*is_digit) (sse_cint_t c);
|
|
|
|
sse_bool_t (*is_xdigit) (sse_cint_t c);
|
|
|
|
sse_bool_t (*is_alnum) (sse_cint_t c);
|
|
|
|
sse_bool_t (*is_space) (sse_cint_t c);
|
|
|
|
sse_bool_t (*is_print) (sse_cint_t c);
|
|
|
|
sse_bool_t (*is_graph) (sse_cint_t c);
|
|
|
|
sse_bool_t (*is_cntrl) (sse_cint_t c);
|
|
|
|
sse_bool_t (*is_punct) (sse_cint_t c);
|
|
|
|
sse_cint_t (*to_upper) (sse_cint_t c);
|
|
|
|
sse_cint_t (*to_lower) (sse_cint_t c);
|
|
|
|
|
|
|
|
/* utilities */
|
|
|
|
void* (*memcpy) (void* dst, const void* src, sse_size_t n);
|
|
|
|
void* (*memset) (void* dst, int val, sse_size_t n);
|
|
|
|
|
|
|
|
int (*sprintf) (sse_char_t* buf, sse_size_t size, sse_char_t* fmt, ...);
|
|
|
|
int (*dprintf) (sse_char_t* fmt, ...);
|
|
|
|
void (*abort) (void);
|
|
|
|
|
|
|
|
void* custom_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* io function commands */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SSE_LSP_IO_OPEN = 0,
|
|
|
|
SSE_LSP_IO_CLOSE = 1,
|
|
|
|
SSE_LSP_IO_READ = 2,
|
|
|
|
SSE_LSP_IO_WRITE = 3
|
|
|
|
};
|
2005-02-04 15:39:11 +00:00
|
|
|
|
2006-10-23 14:42:38 +00:00
|
|
|
/* option code */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SSE_LSP_UNDEFSYMBOL = (1 << 0)
|
|
|
|
};
|
2005-02-04 15:39:11 +00:00
|
|
|
|
2006-10-23 14:42:38 +00:00
|
|
|
/* error code */
|
2005-09-18 08:10:50 +00:00
|
|
|
enum
|
|
|
|
{
|
2006-10-23 14:42:38 +00:00
|
|
|
SSE_LSP_ENOERR,
|
|
|
|
SSE_LSP_ENOMEM,
|
|
|
|
|
2006-10-22 13:10:46 +00:00
|
|
|
SSE_LSP_ERR_ABORT,
|
|
|
|
SSE_LSP_ERR_END,
|
|
|
|
SSE_LSP_ERR_INPUT_NOT_ATTACHED,
|
|
|
|
SSE_LSP_ERR_INPUT,
|
|
|
|
SSE_LSP_ERR_OUTPUT_NOT_ATTACHED,
|
|
|
|
SSE_LSP_ERR_OUTPUT,
|
|
|
|
SSE_LSP_ERR_SYNTAX,
|
|
|
|
SSE_LSP_ERR_BAD_ARG,
|
|
|
|
SSE_LSP_ERR_WRONG_ARG,
|
|
|
|
SSE_LSP_ERR_TOO_FEW_ARGS,
|
|
|
|
SSE_LSP_ERR_TOO_MANY_ARGS,
|
|
|
|
SSE_LSP_ERR_UNDEF_FUNC,
|
|
|
|
SSE_LSP_ERR_BAD_FUNC,
|
|
|
|
SSE_LSP_ERR_DUP_FORMAL,
|
|
|
|
SSE_LSP_ERR_BAD_SYMBOL,
|
|
|
|
SSE_LSP_ERR_UNDEF_SYMBOL,
|
|
|
|
SSE_LSP_ERR_EMPTY_BODY,
|
|
|
|
SSE_LSP_ERR_BAD_VALUE,
|
2005-09-18 12:20:43 +00:00
|
|
|
|
2006-10-23 14:42:38 +00:00
|
|
|
SSE_LSP_EDIVBYZERO
|
2005-09-18 10:18:35 +00:00
|
|
|
};
|
|
|
|
|
2006-10-22 13:10:46 +00:00
|
|
|
typedef sse_lsp_obj_t* (*sse_lsp_prim_t) (sse_lsp_t* lsp, sse_lsp_obj_t* obj);
|
2005-09-19 03:05:37 +00:00
|
|
|
|
2005-02-04 15:39:11 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2006-10-23 10:57:59 +00:00
|
|
|
sse_lsp_t* sse_lsp_open (
|
2006-10-23 14:42:38 +00:00
|
|
|
const sse_lsp_syscas_t* syscas,
|
|
|
|
sse_size_t mem_ubound, sse_size_t mem_ubound_inc);
|
2005-09-18 10:18:35 +00:00
|
|
|
|
2006-10-22 13:10:46 +00:00
|
|
|
void sse_lsp_close (sse_lsp_t* lsp);
|
2005-09-17 17:42:21 +00:00
|
|
|
|
2006-10-23 14:42:38 +00:00
|
|
|
int sse_lsp_geterrnum (sse_lsp_t* lsp);
|
2005-02-04 15:39:11 +00:00
|
|
|
|
2006-10-22 13:10:46 +00:00
|
|
|
int sse_lsp_attach_input (sse_lsp_t* lsp, sse_lsp_io_t input, void* arg);
|
|
|
|
int sse_lsp_detach_input (sse_lsp_t* lsp);
|
2005-09-18 10:18:35 +00:00
|
|
|
|
2006-10-22 13:10:46 +00:00
|
|
|
int sse_lsp_attach_output (sse_lsp_t* lsp, sse_lsp_io_t output, void* arg);
|
|
|
|
int sse_lsp_detach_output (sse_lsp_t* lsp);
|
2005-09-18 10:18:35 +00:00
|
|
|
|
2006-10-22 13:10:46 +00:00
|
|
|
sse_lsp_obj_t* sse_lsp_read (sse_lsp_t* lsp);
|
|
|
|
sse_lsp_obj_t* sse_lsp_eval (sse_lsp_t* lsp, sse_lsp_obj_t* obj);
|
|
|
|
int sse_lsp_print (sse_lsp_t* lsp, const sse_lsp_obj_t* obj);
|
2005-02-04 15:39:11 +00:00
|
|
|
|
2006-10-22 13:10:46 +00:00
|
|
|
int sse_lsp_add_prim (sse_lsp_t* lsp, const sse_char_t* name, sse_lsp_prim_t prim);
|
|
|
|
int sse_lsp_remove_prim (sse_lsp_t* lsp, const sse_char_t* name);
|
2005-09-18 14:05:16 +00:00
|
|
|
|
2006-10-23 10:57:59 +00:00
|
|
|
|
|
|
|
const sse_char_t* sse_lsp_geterrstr (int errnum);
|
|
|
|
|
2005-02-04 15:39:11 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|