| 
									
										
										
										
											2005-02-04 15:39:11 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  |  * $Id: lsp.h,v 1.25 2006-10-24 04:22:39 bacon Exp $ | 
					
						
							| 
									
										
										
										
											2005-02-04 15:39:11 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | #ifndef _ASE_LSP_LSP_H_
 | 
					
						
							|  |  |  | #define _ASE_LSP_LSP_H_
 | 
					
						
							| 
									
										
										
										
											2005-09-17 17:50:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | #include <ase/lsp/types.h>
 | 
					
						
							| 
									
										
										
										
											2006-10-23 14:42:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | typedef struct ase_lsp_t ase_lsp_t; | 
					
						
							|  |  |  | typedef struct ase_lsp_obj_t ase_lsp_obj_t; | 
					
						
							|  |  |  | typedef struct ase_lsp_syscas_t ase_lsp_syscas_t; | 
					
						
							| 
									
										
										
										
											2006-10-23 14:42:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | typedef ase_ssize_t (*ase_lsp_io_t) ( | 
					
						
							|  |  |  | 	int cmd, void* arg, ase_char_t* data, ase_size_t count); | 
					
						
							| 
									
										
										
										
											2006-10-23 14:42:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | struct ase_lsp_syscas_t | 
					
						
							| 
									
										
										
										
											2006-10-23 14:42:38 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	/* memory */ | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | 	void* (*malloc) (ase_size_t n, void* custom_data); | 
					
						
							|  |  |  | 	void* (*realloc) (void* ptr, ase_size_t n, void* custom_data); | 
					
						
							| 
									
										
										
										
											2006-10-23 14:42:38 +00:00
										 |  |  | 	void  (*free) (void* ptr, void* custom_data); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* character class */ | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +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-10-23 14:42:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* utilities */ | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | 	void* (*memcpy)  (void* dst, const void* src, ase_size_t n); | 
					
						
							|  |  |  | 	void* (*memset)  (void* dst, int val, ase_size_t n); | 
					
						
							| 
									
										
										
										
											2006-10-23 14:42:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | 	int (*sprintf) (ase_char_t* buf, ase_size_t size, ase_char_t* fmt, ...); | 
					
						
							|  |  |  | 	int (*dprintf) (ase_char_t* fmt, ...); | 
					
						
							| 
									
										
										
										
											2006-10-23 14:42:38 +00:00
										 |  |  | 	void (*abort) (void); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void* custom_data; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* io function commands */ | 
					
						
							|  |  |  | enum  | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | 	ASE_LSP_IO_OPEN   = 0, | 
					
						
							|  |  |  | 	ASE_LSP_IO_CLOSE  = 1, | 
					
						
							|  |  |  | 	ASE_LSP_IO_READ   = 2, | 
					
						
							|  |  |  | 	ASE_LSP_IO_WRITE  = 3 | 
					
						
							| 
									
										
										
										
											2006-10-23 14:42:38 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2005-02-04 15:39:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-23 14:42:38 +00:00
										 |  |  | /* option code */ | 
					
						
							|  |  |  | enum | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | 	ASE_LSP_UNDEFSYMBOL = (1 << 0) | 
					
						
							| 
									
										
										
										
											2006-10-23 14:42:38 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											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-24 04:22:40 +00:00
										 |  |  | 	ASE_LSP_ENOERR, | 
					
						
							|  |  |  | 	ASE_LSP_ENOMEM, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ASE_LSP_ERR_ABORT, | 
					
						
							|  |  |  | 	ASE_LSP_ERR_END, | 
					
						
							|  |  |  | 	ASE_LSP_ERR_INPUT_NOT_ATTACHED, | 
					
						
							|  |  |  | 	ASE_LSP_ERR_INPUT, | 
					
						
							|  |  |  | 	ASE_LSP_ERR_OUTPUT_NOT_ATTACHED, | 
					
						
							|  |  |  | 	ASE_LSP_ERR_OUTPUT, | 
					
						
							|  |  |  | 	ASE_LSP_ERR_SYNTAX, | 
					
						
							|  |  |  | 	ASE_LSP_ERR_BAD_ARG, | 
					
						
							|  |  |  | 	ASE_LSP_ERR_WRONG_ARG, | 
					
						
							|  |  |  | 	ASE_LSP_ERR_TOO_FEW_ARGS, | 
					
						
							|  |  |  | 	ASE_LSP_ERR_TOO_MANY_ARGS, | 
					
						
							|  |  |  | 	ASE_LSP_ERR_UNDEF_FUNC, | 
					
						
							|  |  |  | 	ASE_LSP_ERR_BAD_FUNC, | 
					
						
							|  |  |  | 	ASE_LSP_ERR_DUP_FORMAL, | 
					
						
							|  |  |  | 	ASE_LSP_ERR_BAD_SYMBOL, | 
					
						
							|  |  |  | 	ASE_LSP_ERR_UNDEF_SYMBOL, | 
					
						
							|  |  |  | 	ASE_LSP_ERR_EMPTY_BODY, | 
					
						
							|  |  |  | 	ASE_LSP_ERR_BAD_VALUE, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ASE_LSP_EDIVBYZERO | 
					
						
							| 
									
										
										
										
											2005-09-18 10:18:35 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | typedef ase_lsp_obj_t* (*ase_lsp_prim_t) (ase_lsp_t* lsp, ase_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-24 04:22:40 +00:00
										 |  |  | ase_lsp_t* ase_lsp_open ( | 
					
						
							|  |  |  | 	const ase_lsp_syscas_t* syscas, | 
					
						
							|  |  |  | 	ase_size_t mem_ubound, ase_size_t mem_ubound_inc); | 
					
						
							| 
									
										
										
										
											2005-09-18 10:18:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | void ase_lsp_close (ase_lsp_t* lsp); | 
					
						
							| 
									
										
										
										
											2005-09-17 17:42:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | int ase_lsp_geterrnum (ase_lsp_t* lsp); | 
					
						
							| 
									
										
										
										
											2005-02-04 15:39:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | int ase_lsp_attach_input (ase_lsp_t* lsp, ase_lsp_io_t input, void* arg); | 
					
						
							|  |  |  | int ase_lsp_detach_input (ase_lsp_t* lsp); | 
					
						
							| 
									
										
										
										
											2005-09-18 10:18:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | int ase_lsp_attach_output (ase_lsp_t* lsp, ase_lsp_io_t output, void* arg); | 
					
						
							|  |  |  | int ase_lsp_detach_output (ase_lsp_t* lsp); | 
					
						
							| 
									
										
										
										
											2005-09-18 10:18:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | ase_lsp_obj_t* ase_lsp_read (ase_lsp_t* lsp); | 
					
						
							|  |  |  | ase_lsp_obj_t* ase_lsp_eval (ase_lsp_t* lsp, ase_lsp_obj_t* obj); | 
					
						
							|  |  |  | int ase_lsp_print (ase_lsp_t* lsp, const ase_lsp_obj_t* obj); | 
					
						
							| 
									
										
										
										
											2005-02-04 15:39:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | int ase_lsp_add_prim (ase_lsp_t* lsp, const ase_char_t* name, ase_lsp_prim_t prim); | 
					
						
							|  |  |  | int ase_lsp_remove_prim (ase_lsp_t* lsp, const ase_char_t* name); | 
					
						
							| 
									
										
										
										
											2005-09-18 14:05:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-23 10:57:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-24 04:22:40 +00:00
										 |  |  | const ase_char_t* ase_lsp_geterrstr (int errnum); | 
					
						
							| 
									
										
										
										
											2006-10-23 10:57:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-04 15:39:11 +00:00
										 |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 |