Edinburgh Speech Tools  2.4-release
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
siod.h
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 int siod_init(int heap_size=DEFAULT_HEAP_SIZE);
24 int siod_repl(int interactive);
25 void siod_print_welcome(EST_String extra_info);
26 void siod_print_welcome(void);
27 
28 const char *get_c_string(LISP x);
29 int get_c_int(LISP x);
30 double get_c_double(LISP x);
31 float get_c_float(LISP x);
32 LISP flocons(double x);
33 FILE *get_c_file(LISP p,FILE *deflt);
34 LISP siod_make_typed_cell(long type, void *s);
35 LISP cintern(const char *name);
36 LISP rintern(const char *name);
37 LISP strintern(const char *data);
38 LISP strcons(long length,const char *data);
39 LISP cstrcons(const char *data);
40 
41 void init_subr(const char *name, long type, SUBR_FUNC fcn, const char *doc);
42 void init_subr_0(const char *name, LISP (*fcn)(void), const char *doc);
43 void init_subr_1(const char *name, LISP (*fcn)(LISP), const char *doc);
44 void init_subr_2(const char *name, LISP (*fcn)(LISP,LISP), const char *doc);
45 void init_subr_3(const char *name, LISP (*fcn)(LISP,LISP,LISP), const char *doc);
46 void init_subr_4(const char *name, LISP (*fcn)(LISP,LISP,LISP,LISP), const char *doc);
47 void init_lsubr(const char *name, LISP (*fcn)(LISP), const char *doc);
48 void init_fsubr(const char *name, LISP (*fcn)(LISP,LISP), const char *doc);
49 void init_msubr(const char *name, LISP (*fcn)(LISP *,LISP *), const char *doc);
50 void setdoc(LISP name,LISP doc);
51 
52 int siod_register_user_type(const char *name);
53 void set_gc_hooks(long type,
54  int gc_free_once,
55  LISP (*rel)(LISP),
56  LISP (*mark)(LISP),
57  void (*scan)(LISP),
58  void (*free)(LISP),
59  void (*clear)(LISP),
60  long *kind);
61 void set_eval_hooks(long type,LISP (*fcn)(LISP, LISP *, LISP *));
62 void set_type_hooks(long type, long (*c_sxhash)(LISP,long), LISP (*equal)(LISP,LISP));
63 void set_print_hooks(long type,void (*prin1)(LISP, FILE *), void (*print_string)(LISP, char *));
64 void set_io_hooks(long type, LISP (*fast_print)(LISP,LISP), LISP (*fast_read)(int,LISP));
65 
66 void set_fatal_exit_hook(void (*fcn)(void));
67 
68 extern long nointerrupt;
69 extern LISP current_env;
70 extern LISP truth;
71 extern int audsp_mode;
72 extern int siod_ctrl_c;
73 extern const char *siod_prog_name;
74 extern const char *siod_primary_prompt;
75 extern const char *siod_secondary_prompt;
76 
77 void siod_reset_prompt(void);
78 
79 LISP siod_get_lval(const char *name,const char *message);
80 LISP siod_set_lval(const char *name,LISP val);
81 LISP siod_assoc_str(const char *key,LISP alist);
82 LISP siod_member_str(const char *key,LISP list);
83 LISP siod_regex_member_str(const EST_String &key,LISP list);
84 EST_Regex &make_regex(const char *r);
85 LISP siod_member_int(const int key,LISP list);
86 LISP siod_nth(int nth,LISP list);
87 LISP siod_last(LISP list);
88 int siod_llength(LISP list);
89 int siod_atomic_list(LISP list);
90 LISP siod_flatten(LISP tree);
91 int siod_eof(LISP item);
92 EST_String siod_sprint(LISP exp);
93 LISP symbol_boundp(LISP x,LISP env);
94 
95 LISP get_param_lisp(const char *name, LISP params, LISP defval);
96 int get_param_int(const char *name, LISP params, int defval);
97 float get_param_float(const char *name, LISP params, float defval);
98 const char *get_param_str(const char *name, LISP params,const char *defval);
99 LISP make_param_int(const char *name, int val);
100 LISP make_param_float(const char *name, float val);
101 LISP make_param_str(const char *name,const char *val);
102 LISP make_param_lisp(const char *name,LISP val);
103 LISP apply_hooks(LISP hook,LISP arg);
104 LISP apply_hooks_right(LISP hook,LISP args);
105 LISP apply(LISP func,LISP args);
106 
107 int parse_url(const EST_String &url,
108  EST_String &protocol,
109  EST_String &host,
110  EST_String &port,
111  EST_String &path);
112 
113 LISP err(const char *message, LISP x);
114 LISP err(const char *message, const char *s);
115 LISP errswitch(void);
116 
117 void siod_list_to_strlist(LISP l, EST_StrList &a);
118 LISP siod_strlist_to_list(EST_StrList &a);
119 void siod_tidy_up();
120 LISP siod_quit(void);
121 const char *siod_version(void);
122 
123 void gc_protect(LISP *location);
124 void gc_unprotect(LISP *location);
125 void gc_protect_n(LISP *location,long n);
126 void gc_protect_sym(LISP *location,const char *st);
127 LISP user_gc(LISP args);
128 
129 // Siod internal function that lots of people use
130 LISP equal(LISP,LISP);
131 LISP eql(LISP x,LISP y);
132 LISP reverse(LISP obj);
133 LISP append(LISP l1, LISP l2);
134 LISP cons(LISP x,LISP y);
135 LISP car(LISP x);
136 LISP cdr(LISP x);
137 LISP consp(LISP x);
138 LISP numberp(LISP x);
139 LISP atomp(LISP x);
140 LISP assoc(LISP x,LISP alist);
141 LISP setcar(LISP cell, LISP value);
142 LISP setcdr(LISP cell, LISP value);
143 LISP assq(LISP x,LISP alist);
144 LISP delq(LISP elem,LISP l);
145 LISP leval(LISP x,LISP env);
146 LISP symbol_value(LISP x,LISP env);
147 LISP setvar(LISP var,LISP val,LISP env);
148 LISP copy_list(LISP x);
149 LISP quote(LISP item);
150 LISP read_from_lstring(LISP x);
151 LISP symbolexplode(LISP name);
152 
153 LISP fopen_c(const char *name, const char *how);
154 LISP fclose_l(LISP p);
155 LISP lprin1f(LISP exp,FILE *f);
156 void pprint(LISP exp);
157 LISP lprint(LISP exp);
158 void pprint_to_fd(FILE *fd,LISP exp);
159 LISP lread(void);
160 LISP lreadtk(long j);
161 LISP lreadf(FILE *f);
162 #ifdef WIN32
163 LISP lreadwinsock(void);
164 #endif
165 void set_read_hooks(char *all_set,char *end_set,
166  LISP (*fcn1)(int, struct gen_readio *),
167  LISP (*fcn2)(char *,long, int *));
168 LISP vload(const char *fname,long cflag);
169 LISP read_from_string(const char *);
170 long repl_c_string(char *,long want_sigint,long want_init,long want_print);
171 long repl_from_socket(int fd);
172 void init_subrs(void);
173 LISP stringexplode(const char *str);
174 void fput_st(FILE *f,const char *st);
175 LISP get_eof_val(void);
176 
177 
178 #if 0
179 void print_hs_1(void);
180 void print_hs_2(void);
181 void set_repl_hooks(void (*puts_f)(char *),
182  LISP (*read_f)(void),
183  LISP (*eval_f)(LISP),
184  void (*print_f)(LISP));
185 long repl(struct repl_hooks *);
186 LISP lerr(LISP message, LISP x);
187 LISP eq(LISP x,LISP y);
188 LISP symcons(char *pname,LISP vcell);
189 LISP symbol_value_p(LISP x,LISP env,int *set);
190 LISP subrcons(long type, const char *name, SUBR_FUNC f);
191 
192 void init_storage(int heap_size=DEFAULT_HEAP_SIZE);
193 
194 LISP gc_status(LISP args);
195 
196 /* For user defined types in OBJ */
197 
198 LISP oblistfn(void);
199 LISP save_forms(LISP fname,LISP forms,LISP how);
200 LISP intern(LISP x);
201 void init_trace(void);
202 LISP siod_fdopen_c(int fd,const char *name,char *how);
203 
204 LISP probe_file(LISP fname);
205 
206 LISP fopen_l(LISP name,LISP how);
207 LISP fopen_l(LISP name,const char *how);
208 
209 #endif
210 #define siod_error() (errjmp_ok ? longjmp(*est_errjmp,1) : exit(-1))
211 
212 #include "siod_est.h"
213 
214 #endif