Edinburgh Speech Tools  2.1-release
siod.h
Go to the documentation of this file.
1 /* Scheme In One Defun, but in C this time.
2 
3  * COPYRIGHT (c) 1988-1994 BY *
4  * PARADIGM ASSOCIATES INCORPORATED, CAMBRIDGE, MASSACHUSETTS. *
5  * See the source file SLIB.C for more information. *
6 
7 */
8 
9 /*===========================================================*/
10 /* */
11 /* Public LISP functions */
12 /* */
13 /*===========================================================*/
14 #ifndef __SIOD_H__
15 #define __SIOD_H__
16 
17 #include "EST_String.h"
18 #include "EST_string_aux.h"
19 #include "EST_error.h"
20 #include "EST_Val.h"
21 #include "siod_defs.h"
22 
23 
25 int siod_repl(int interactive);
26 void siod_print_welcome(EST_String extra_info);
27 void siod_print_welcome(void);
28 
29 const char *get_c_string(LISP x);
30 long int get_c_int(LISP x);
31 double get_c_double(LISP x);
32 float get_c_float(LISP x);
33 LISP flocons(double x);
34 FILE *get_c_file(LISP p,FILE *deflt);
35 LISP siod_make_typed_cell(long type, void *s);
36 LISP cintern(const char *name);
37 LISP rintern(const char *name);
38 LISP strintern(const char *data);
39 LISP strcons(long length,const char *data);
40 LISP cstrcons(const char *data);
41 
42 void init_subr(const char *name, long type, SUBR_FUNC fcn, const char *doc);
43 void init_subr_0(const char *name, LISP (*fcn)(void), const char *doc);
44 void init_subr_1(const char *name, LISP (*fcn)(LISP), const char *doc);
45 void init_subr_2(const char *name, LISP (*fcn)(LISP,LISP), const char *doc);
46 void init_subr_3(const char *name, LISP (*fcn)(LISP,LISP,LISP), const char *doc);
47 void init_subr_4(const char *name, LISP (*fcn)(LISP,LISP,LISP,LISP), const char *doc);
48 void init_lsubr(const char *name, LISP (*fcn)(LISP), const char *doc);
49 void init_fsubr(const char *name, LISP (*fcn)(LISP,LISP), const char *doc);
50 void init_msubr(const char *name, LISP (*fcn)(LISP *,LISP *), const char *doc);
51 void setdoc(LISP name,LISP doc);
52 
53 int siod_register_user_type(const char *name);
54 void set_gc_hooks(long type,
55  int gc_free_once,
56  LISP (*rel)(LISP),
57  LISP (*mark)(LISP),
58  void (*scan)(LISP),
59  void (*free)(LISP),
60  void (*clear)(LISP),
61  long *kind);
62 void set_eval_hooks(long type,LISP (*fcn)(LISP, LISP *, LISP *));
63 void set_type_hooks(long type, long (*c_sxhash)(LISP,long), LISP (*equal)(LISP,LISP));
64 void set_print_hooks(long type,void (*prin1)(LISP, FILE *), void (*print_string)(LISP, char *));
65 void set_io_hooks(long type, LISP (*fast_print)(LISP,LISP), LISP (*fast_read)(int,LISP));
66 
67 void set_fatal_exit_hook(void (*fcn)(void));
68 
69 extern long nointerrupt;
70 extern LISP current_env;
71 extern LISP truth;
72 extern int audsp_mode;
73 extern int siod_ctrl_c;
74 extern const char *siod_prog_name;
75 extern const char *siod_primary_prompt;
76 extern const char *siod_secondary_prompt;
77 
78 void siod_reset_prompt(void);
79 
80 LISP siod_get_lval(const char *name,const char *message);
81 LISP siod_set_lval(const char *name,LISP val);
82 LISP siod_assoc_str(const char *key,LISP alist);
83 LISP siod_member_str(const char *key,LISP list);
84 LISP siod_regex_member_str(const EST_String &key,LISP list);
85 EST_Regex &make_regex(const char *r);
86 LISP siod_member_int(const int key,LISP list);
87 LISP siod_nth(int nth,LISP list);
88 LISP siod_last(LISP list);
89 int siod_llength(LISP list);
90 int siod_atomic_list(LISP list);
91 LISP siod_flatten(LISP tree);
92 int siod_eof(LISP item);
93 EST_String siod_sprint(LISP exp);
94 LISP symbol_boundp(LISP x,LISP env);
95 
96 LISP get_param_lisp(const char *name, LISP params, LISP defval);
97 int get_param_int(const char *name, LISP params, int defval);
98 float get_param_float(const char *name, LISP params, float defval);
99 const char *get_param_str(const char *name, LISP params,const char *defval);
100 LISP make_param_int(const char *name, int val);
101 LISP make_param_float(const char *name, float val);
102 LISP make_param_str(const char *name,const char *val);
103 LISP make_param_lisp(const char *name,LISP val);
104 LISP apply_hooks(LISP hook,LISP arg);
105 LISP apply_hooks_right(LISP hook,LISP args);
106 LISP apply(LISP func,LISP args);
107 
108 int parse_url(const EST_String &url,
109  EST_String &protocol,
110  EST_String &host,
111  EST_String &port,
112  EST_String &path);
113 
114 void err(const char *message, LISP x) EST_NORETURN;
115 void err(const char *message, const char *s) EST_NORETURN;
116 void errswitch(void) EST_NORETURN;
117 
118 void siod_list_to_strlist(LISP l, EST_StrList &a);
120 void siod_tidy_up();
121 LISP siod_quit(void);
122 const char *siod_version(void);
123 
124 void gc_protect(LISP *location);
125 void gc_unprotect(LISP *location);
126 void gc_protect_n(LISP *location,long n);
127 void gc_protect_sym(LISP *location,const char *st);
128 LISP user_gc(LISP args);
129 
130 // Siod internal function that lots of people use
131 LISP equal(LISP,LISP);
132 LISP eql(LISP x,LISP y);
133 LISP reverse(LISP obj);
134 LISP append(LISP l1, LISP l2);
135 LISP cons(LISP x,LISP y);
136 LISP car(LISP x);
137 LISP cdr(LISP x);
138 LISP consp(LISP x);
139 LISP numberp(LISP x);
140 LISP atomp(LISP x);
141 LISP assoc(LISP x,LISP alist);
142 LISP setcar(LISP cell, LISP value);
143 LISP setcdr(LISP cell, LISP value);
144 LISP assq(LISP x,LISP alist);
145 LISP delq(LISP elem,LISP l);
146 LISP leval(LISP x,LISP env);
147 LISP symbol_value(LISP x,LISP env);
148 LISP setvar(LISP var,LISP val,LISP env);
149 LISP copy_list(LISP x);
150 LISP quote(LISP item);
151 LISP read_from_lstring(LISP x);
152 LISP symbolexplode(LISP name);
153 
154 LISP fopen_c(const char *name, const char *how);
155 LISP fclose_l(LISP p);
156 LISP lprin1f(LISP exp,FILE *f);
157 void pprint(LISP exp);
158 LISP lprint(LISP exp);
159 void pprint_to_fd(FILE *fd,LISP exp);
160 LISP lread(void);
161 LISP lreadtk(long j);
162 LISP lreadf(FILE *f);
163 #ifdef WIN32
164 LISP lreadwinsock(void);
165 #endif
166 void set_read_hooks(char *all_set,char *end_set,
167  LISP (*fcn1)(int, struct gen_readio *),
168  LISP (*fcn2)(char *,long, int *));
169 LISP vload(const char *fname,long cflag);
170 LISP read_from_string(const char *);
171 long repl_c_string(char *,long want_sigint,long want_init,long want_print);
172 long repl_from_socket(int fd);
173 void init_subrs(void);
174 LISP stringexplode(const char *str);
175 void fput_st(FILE *f,const char *st);
176 LISP get_eof_val(void);
177 
178 
179 #if 0
180 void print_hs_1(void);
181 void print_hs_2(void);
182 void set_repl_hooks(void (*puts_f)(char *),
183  LISP (*read_f)(void),
184  LISP (*eval_f)(LISP),
185  void (*print_f)(LISP));
186 long repl(struct repl_hooks *);
187 LISP lerr(LISP message, LISP x);
188 LISP eq(LISP x,LISP y);
189 LISP symcons(char *pname,LISP vcell);
190 LISP symbol_value_p(LISP x,LISP env,int *set);
191 LISP subrcons(long type, const char *name, SUBR_FUNC f);
192 
194 
195 LISP gc_status(LISP args);
196 
197 /* For user defined types in OBJ */
198 
199 LISP oblistfn(void);
200 LISP save_forms(LISP fname,LISP forms,LISP how);
201 LISP intern(LISP x);
202 void init_trace(void);
203 LISP siod_fdopen_c(int fd,const char *name,char *how);
204 
205 LISP probe_file(LISP fname);
206 
207 LISP fopen_l(LISP name,LISP how);
208 LISP fopen_l(LISP name,const char *how);
209 
210 #endif
211 #define siod_error() (errjmp_ok ? longjmp(*est_errjmp,1) : exit(-1))
212 
213 #include "siod_est.h"
214 
215 #endif
LISP numberp(LISP x)
Definition: slib_math.cc:15
long repl_from_socket(int fd)
Definition: slib_server.cc:92
LISP siod_last(LISP list)
Definition: siod.cc:258
Definition: siod_defs.h:32
LISP siod_set_lval(const char *name, LISP val)
Definition: siod.cc:113
void siod_tidy_up()
Definition: siod.cc:85
LISP get_eof_val(void)
Definition: slib_file.cc:556
LISP siod_make_typed_cell(long type, void *s)
Definition: slib.cc:1953
void set_eval_hooks(long type, LISP(*fcn)(LISP, LISP *, LISP *))
Definition: slib.cc:1373
double get_c_double(LISP x)
Definition: slib.cc:1854
LISP intern(LISP name)
Definition: slib.cc:742
void set_read_hooks(char *all_set, char *end_set, LISP(*fcn1)(int, struct gen_readio *), LISP(*fcn2)(char *, long, int *))
Definition: slib.cc:1615
void init_msubr(const char *name, LISP(*fcn)(LISP *, LISP *), const char *doc)
Definition: slib.cc:910
LISP make_param_float(const char *name, float val)
Definition: siod.cc:351
float get_c_float(LISP x)
Definition: slib.cc:1858
void setdoc(LISP name, LISP doc)
Definition: slib_doc.cc:20
LISP fopen_l(LISP what, const char *r_or_w)
Definition: slib_file.cc:274
#define EST_NORETURN
Definition: EST_common.h:59
long repl_c_string(char *, long want_sigint, long want_init, long want_print)
Definition: slib.cc:392
LISP make_param_str(const char *name, const char *val)
Definition: siod.cc:341
LISP siod_get_lval(const char *name, const char *message)
Definition: siod.cc:94
long heap_size
Definition: slib.cc:116
A Regular expression class to go with the CSTR EST_String class.
Definition: EST_Regex.h:56
LISP lprint(LISP exp)
Definition: slib_file.cc:548
const char * siod_secondary_prompt
Definition: slib.cc:173
LISP stringexplode(const char *str)
Definition: siod.cc:422
void set_io_hooks(long type, LISP(*fast_print)(LISP, LISP), LISP(*fast_read)(int, LISP))
Definition: slib.cc:1496
long int get_c_int(LISP x)
Definition: slib.cc:1850
int siod_llength(LISP list)
Definition: siod.cc:202
LISP symcons(char *pname, LISP vcell)
Definition: slib.cc:686
#define DEFAULT_HEAP_SIZE
Definition: siod_defs.h:29
LISP strintern(const char *data)
Definition: slib_str.cc:22
int nth(EST_String name, EST_TList< EST_String > &lex)
Definition: confusion.cc:46
LISP append(LISP l1, LISP l2)
Definition: slib_list.cc:177
void init_subr_2(const char *name, LISP(*fcn)(LISP, LISP), const char *doc)
Definition: slib.cc:900
LISP strcons(long length, const char *data)
Definition: slib_str.cc:27
void gc_unprotect(LISP *location)
Definition: slib.cc:759
LISP gc_status(LISP args)
Definition: slib.cc:1302
void set_repl_hooks(void(*puts_f)(char *), LISP(*read_f)(void), LISP(*eval_f)(LISP), void(*print_f)(LISP))
Definition: slib.cc:441
LISP siod_flatten(LISP tree)
Definition: slib_list.cc:87
const char * siod_prog_name
Definition: slib.cc:171
void init_fsubr(const char *name, LISP(*fcn)(LISP, LISP), const char *doc)
Definition: slib.cc:908
void init_subr_4(const char *name, LISP(*fcn)(LISP, LISP, LISP, LISP), const char *doc)
Definition: slib.cc:904
LISP user_gc(LISP args)
Definition: slib.cc:1269
void set_fatal_exit_hook(void(*fcn)(void))
Definition: slib.cc:570
LISP siod_assoc_str(const char *key, LISP alist)
Definition: siod.cc:125
void set_print_hooks(long type, void(*prin1)(LISP, FILE *), void(*print_string)(LISP, char *))
Definition: slib.cc:1486
LISP lerr(LISP message, LISP x)
Definition: slib.cc:661
LISP siod_regex_member_str(const EST_String &key, LISP list)
Definition: siod.cc:179
LISP setcdr(LISP cell, LISP value)
Definition: slib_list.cc:58
LISP siod_nth(int nth, LISP list)
Definition: siod.cc:214
LISP equal(LISP, LISP)
Definition: slib_list.cc:133
LISP apply(LISP func, LISP args)
Definition: siod.cc:413
LISP siod_quit(void)
Definition: slib.cc:1817
LISP reverse(LISP obj)
Definition: slib_list.cc:171
FILE * get_c_file(LISP p, FILE *deflt)
Definition: slib_file.cc:349
void err(const char *message, LISP x) EST_NORETURN
Definition: slib.cc:608
LISP vload(const char *fname, long cflag)
Definition: slib_file.cc:632
int siod_register_user_type(const char *name)
Definition: slib.cc:925
LISP symbol_boundp(LISP x, LISP env)
Definition: slib_core.cc:222
LISP lreadf(FILE *f)
Definition: slib.cc:1582
void siod_list_to_strlist(LISP l, EST_StrList &a)
Definition: siod.cc:520
LISP read_from_lstring(LISP x)
Definition: slib_str.cc:62
void pprint(LISP exp)
Definition: slib_file.cc:95
const char * get_c_string(LISP x)
Definition: slib.cc:638
LISP siod_fdopen_c(int fd, const char *name, char *how)
Definition: slib_file.cc:269
void errswitch(void) EST_NORETURN
Definition: slib.cc:618
LISP make_param_lisp(const char *name, LISP val)
Definition: siod.cc:356
const char * siod_primary_prompt
Definition: slib.cc:172
void gc_protect_sym(LISP *location, const char *st)
Definition: slib.cc:811
int siod_atomic_list(LISP list)
Definition: siod.cc:228
EST_Regex & make_regex(const char *r)
Definition: siod.cc:361
EST_String siod_sprint(LISP exp)
Definition: slib_file.cc:208
LISP lreadtk(long j)
Definition: slib.cc:1788
LISP cintern(const char *name)
Definition: slib.cc:728
LISP cons(LISP x, LISP y)
Definition: slib_list.cc:97
void fput_st(FILE *f, const char *st)
Definition: slib.cc:450
int audsp_mode
Definition: slib.cc:266
LISP setvar(LISP var, LISP val, LISP env)
Definition: slib_core.cc:18
LISP subrcons(long type, const char *name, SUBR_FUNC f)
Definition: slib.cc:745
LISP current_env
Definition: slib.cc:132
int siod_repl(int interactive)
Definition: slib_repl.cc:44
void init_storage(int init_heap_size)
Definition: slib.cc:880
void siod_reset_prompt(void)
Definition: slib.cc:321
#define l2
LISP read_from_string(const char *)
Definition: slib_str.cc:65
LISP siod_strlist_to_list(EST_StrList &a)
Definition: siod.cc:532
void gc_protect_n(LISP *location, long n)
Definition: slib.cc:803
LISP assoc(LISP x, LISP alist)
Definition: slib_list.cc:36
LISP symbolexplode(LISP name)
Definition: slib_str.cc:251
void siod_print_welcome(EST_String extra_info)
Definition: slib.cc:239
LISP consp(LISP x)
Definition: slib_list.cc:112
f
Definition: EST_item_aux.cc:48
void init_subr_1(const char *name, LISP(*fcn)(LISP), const char *doc)
Definition: slib.cc:898
LISP setcar(LISP cell, LISP value)
Definition: slib_list.cc:54
void init_trace(void)
Definition: trace.cc:127
LISP symbol_value(LISP x, LISP env)
Definition: slib_core.cc:229
LISP get_param_lisp(const char *name, LISP params, LISP defval)
Definition: siod.cc:327
LISP siod_member_int(const int key, LISP list)
Definition: siod.cc:191
void pprint_to_fd(FILE *fd, LISP exp)
Definition: slib_file.cc:74
LISP fclose_l(LISP p)
Definition: slib_file.cc:329
int siod_eof(LISP item)
Definition: siod.cc:240
const char * siod_version(void)
Definition: slib.cc:111
LISP lread(void)
Definition: slib_file.cc:553
LISP copy_list(LISP x)
Definition: slib_list.cc:69
const char * get_param_str(const char *name, LISP params, const char *defval)
Definition: siod.cc:313
void init_subr_3(const char *name, LISP(*fcn)(LISP, LISP, LISP), const char *doc)
Definition: slib.cc:902
void print_hs_2(void)
Definition: slib.cc:258
LISP(* SUBR_FUNC)(void)
Definition: siod_defs.h:151
void init_lsubr(const char *name, LISP(*fcn)(LISP), const char *doc)
Definition: slib.cc:906
LISP rintern(const char *name)
Definition: slib.cc:734
LISP eql(LISP x, LISP y)
Definition: slib_list.cc:77
LISP quote(LISP item)
Definition: siod.cc:252
LISP leval(LISP x, LISP env)
Definition: slib.cc:1378
void print_hs_1(void)
Definition: slib.cc:252
long nointerrupt
Definition: slib.cc:129
LISP assq(LISP x, LISP alist)
Definition: slib_list.cc:45
LISP cstrcons(const char *data)
Definition: slib_str.cc:40
void init_subr_0(const char *name, LISP(*fcn)(void), const char *doc)
Definition: slib.cc:896
LISP flocons(double x)
Definition: slib.cc:673
int get_param_int(const char *name, LISP params, int defval)
Definition: siod.cc:271
LISP apply_hooks(LISP hook, LISP arg)
Definition: siod.cc:379
void gc_protect(LISP *location)
Definition: slib.cc:791
int siod_init(int heap_size=DEFAULT_HEAP_SIZE)
Definition: siod.cc:58
#define l1
LISP car(LISP x)
Definition: slib_list.cc:115
LISP apply_hooks_right(LISP hook, LISP args)
Definition: siod.cc:395
LISP delq(LISP elem, LISP l)
Definition: slib_list.cc:62
int tree
Definition: rxp.c:21
LISP truth
Definition: slib.cc:135
LISP lprin1f(LISP exp, FILE *f)
Definition: slib_file.cc:471
void set_gc_hooks(long type, int gc_free_once, LISP(*rel)(LISP), LISP(*mark)(LISP), void(*scan)(LISP), void(*free)(LISP), void(*clear)(LISP), long *kind)
Definition: slib.cc:946
LISP make_param_int(const char *name, int val)
Definition: siod.cc:346
LISP atomp(LISP x)
Definition: slib_list.cc:104
float get_param_float(const char *name, LISP params, float defval)
Definition: siod.cc:292
int siod_ctrl_c
Definition: slib.cc:267
LISP fopen_c(const char *name, const char *how)
Definition: slib_file.cc:254
LISP siod_member_str(const char *key, LISP list)
Definition: siod.cc:167
void init_subr(const char *name, long type, SUBR_FUNC fcn, const char *doc)
Definition: slib.cc:890
void init_subrs(void)
Definition: slib.cc:1922
LISP cdr(LISP x)
Definition: slib_list.cc:124
Utility EST_String Functions header file.
int parse_url(const EST_String &url, EST_String &protocol, EST_String &host, EST_String &port, EST_String &path)
Definition: io.cc:80
void set_type_hooks(long type, long(*c_sxhash)(LISP, long), LISP(*equal)(LISP, LISP))
Definition: slib.cc:1506