1 /*-
2  * Copyright (c) 2005-2019 Michael Scholz <mi-scholz@users.sourceforge.net>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * @(#)fth.h	2.4 11/20/19
27  */
28 
29 #if !defined(_FTH_H_)
30 #define _FTH_H_
31 
32 #include "fth-config.h"
33 
34 #if defined(HAVE_SYS_TYPES_H)
35 #include <sys/types.h>
36 #endif
37 #include <stdio.h>
38 #include <ctype.h>
39 #include <math.h>
40 #include <stdlib.h>
41 #include <stddef.h>
42 #if defined(HAVE_STRING_H)
43 #include <string.h>
44 #endif
45 #if defined(HAVE_MEMORY_H)
46 #include <memory.h>
47 #endif
48 #if defined(HAVE_STRINGS_H)
49 #include <strings.h>
50 #endif
51 #if defined(HAVE_UNISTD_H)
52 #include <unistd.h>
53 #endif
54 #if defined(HAVE_ERRNO_H)
55 #include <errno.h>
56 #endif
57 #if defined(HAVE_SETJMP_H)
58 #include <setjmp.h>
59 #endif
60 #if defined(HAVE_STDARG_H)
61 #include <stdarg.h>
62 #endif
63 
64 #include "ficllocal.h"
65 #include "ficl.h"
66 
67 #undef __BEGIN_DECLS
68 #undef __END_DECLS
69 #if defined(__cplusplus)
70 #define __BEGIN_DECLS		extern "C" {
71 #define __END_DECLS		}
72 #else
73 #define __BEGIN_DECLS
74 #define __END_DECLS
75 #endif
76 
77 #include "fth-lib.h"
78 
79 /* from ruby/ruby.h */
80 #if defined(__STDC__)
81 #include <limits.h>
82 #else				/* !__STDC__ */
83 #if !defined(LONG_MAX)
84 #if defined(HAVE_LIMITS_H)
85 #include <limits.h>
86 #else
87 #if (FTH_SIZEOF_LONG == 4)
88 /* assuming 32bit (2's compliment) long */
89 #define LONG_MAX		0x7fffffffL
90 #else
91 #define LONG_MAX		0x7fffffffffffffffL
92 #endif
93 #endif
94 #endif				/* !LONG_MAX */
95 #if !defined(LONG_MIN)
96 #define LONG_MIN		(-LONG_MAX - 1)
97 #endif
98 #if !defined(ULONG_MAX)
99 #if (FTH_SIZEOF_LONG == 4)
100 #define ULONG_MAX		0xffffffffUL
101 #else
102 #define ULONG_MAX		0x7fffffffffffffffUL
103 #endif
104 #endif				/* !ULONG_MAX */
105 #endif				/* __STDC__ */
106 
107 #if defined(HAVE_LONG_LONG)
108 #if !defined(LLONG_MAX)
109 #if defined(LONG_LONG_MAX)
110 #define LLONG_MAX		LONG_LONG_MAX
111 #else
112 #if defined(_I64_MAX)
113 #define LLONG_MAX		_I64_MAX
114 #else
115 /* assuming 64bit (2's complement) long long */
116 #define LLONG_MAX		0x7fffffffffffffffLL
117 #endif				/* _I64_MAX */
118 #endif				/* LONG_LONG_MAX */
119 #endif				/* !LLONG_MAX */
120 #if !defined(LLONG_MIN)
121 #if defined(LONG_LONG_MIN)
122 #define LLONG_MIN		LONG_LONG_MIN
123 #else
124 #if defined(_I64_MIN)
125 #define LLONG_MIN		_I64_MIN
126 #else
127 #define LLONG_MIN		(-LLONG_MAX - 1)
128 #endif				/* _I64_MIN */
129 #endif				/* LONG_LONG_MIN */
130 #endif				/* !LLONG_MIN */
131 #if !defined(ULLONG_MAX)
132 #define ULLONG_MAX		0xffffffffffffffffULL
133 #endif
134 #endif				/* HAVE_LONG_LONG */
135 
136 #if (FTH_SIZEOF_LONG_LONG == FTH_SIZEOF_VOID_P)
137 #define FIXNUM_MAX		(LLONG_MAX >> 1L)
138 #define FIXNUM_MIN		(((SIGNED_FTH)(LLONG_MIN)) >> 1L)
139 #define FIXNUM_UMAX		(ULLONG_MAX >> 1L)
140 #else
141 #define FIXNUM_MAX		(LONG_MAX >> 1L)
142 #define FIXNUM_MIN		(((SIGNED_FTH)(LONG_MIN)) >> 1L)
143 #define FIXNUM_UMAX		(ULONG_MAX >> 1L)
144 #endif
145 
146 #define POSFIXABLE_P(Obj)	((Obj) <= FIXNUM_MAX)
147 #define NEGFIXABLE_P(Obj)	((Obj) >= FIXNUM_MIN)
148 #define FIXABLE_P(Obj)		(POSFIXABLE_P(Obj) && NEGFIXABLE_P(Obj))
149 #define UFIXABLE_P(Obj)		((Obj) <= FIXNUM_UMAX)
150 
151 #define FIXNUM_FLAG		0x01
152 #define FIXNUM_P(Obj)		(((SIGNED_FTH)(Obj)) & FIXNUM_FLAG)
153 
154 #define INT_TO_FIX(Obj)		((FTH)(((FTH)(Obj)) << 1L | FIXNUM_FLAG))
155 #define FIX_TO_INT(Obj)		(((SIGNED_FTH)(Obj)) >> 1L)
156 #define FIX_TO_INT32(Obj)	(int)FIX_TO_INT(Obj)
157 #define UNSIGNED_TO_FIX(Obj)	INT_TO_FIX(Obj)
158 #define FIX_TO_UNSIGNED(Obj)	(((FTH)(Obj)) >> 1L)
159 
160 #define IMMEDIATE_MASK		0x03
161 #define IMMEDIATE_P(Obj)	((FTH)(Obj) & IMMEDIATE_MASK)
162 
163 #define CHAR_TO_FTH(Obj)	INT_TO_FIX(Obj)
164 #define FTH_TO_CHAR(Obj)	((int)FIX_TO_INT(Obj))
165 
166 #if (FTH_SIZEOF_LONG == 4)
167 #define FTH_INT_REF(Obj)	fth_integer_ref(Obj)
168 #else
169 #define FTH_INT_REF(Obj)	FIX_TO_INT(Obj)
170 #endif
171 
172 #define FTH_ARGn 		0L
173 #define FTH_ARG1 		1L
174 #define FTH_ARG2 		2L
175 #define FTH_ARG3 		3L
176 #define FTH_ARG4 		4L
177 #define FTH_ARG5 		5L
178 #define FTH_ARG6 		6L
179 #define FTH_ARG7 		7L
180 #define FTH_ARG8 		8L
181 #define FTH_ARG9 		9L
182 
183 #define FTH_ONE_NEG		INT_TO_FIX(-1)
184 #define FTH_ZERO		INT_TO_FIX(0)
185 #define FTH_ONE			INT_TO_FIX(1)
186 #define FTH_TWO			INT_TO_FIX(2)
187 #define FTH_THREE		INT_TO_FIX(3)
188 #define FTH_FOUR		INT_TO_FIX(4)
189 #define FTH_FIVE		INT_TO_FIX(5)
190 #define FTH_SIX			INT_TO_FIX(6)
191 #define FTH_SEVEN		INT_TO_FIX(7)
192 #define FTH_EIGHT		INT_TO_FIX(8)
193 #define FTH_NINE		INT_TO_FIX(9)
194 
195 #define FTH_FILE_EXTENSION	"fs"
196 
197 enum {
198 	FTH_UNKNOWN,
199 	FTH_OKAY,
200 	FTH_BYE,
201 	FTH_ERROR
202 };
203 
204 typedef struct {
205 	ficlSystem     *system;
206 	ficlVm         *vm;
207 	FTH 		current_file;
208 	ficlInteger 	current_line;
209 	int 		print_length;
210 	FTH 		last_exception;
211 	FTH 		_false;
212 	FTH 		_true;
213 	FTH 		_nil;
214 	FTH 		_undef;
215 	int 		print_p;
216 	int 		eval_p;
217 	int 		hit_error_p;
218 	int 		true_repl_p;
219 	int 		die_on_signal_p;
220 	int 		interactive_p;
221 } Ficl;
222 
223 /* defined in misc.c */
224 extern Ficl    *fth_ficl;
225 
226 #define FTH_FICL_VAR()		fth_ficl
227 #define FTH_FICL_SYSTEM()	FTH_FICL_VAR()->system
228 #define FTH_FICL_VM()		FTH_FICL_VAR()->vm
229 #define FTH_FICL_STACK()	FTH_FICL_VAR()->vm->dataStack
230 #define FTH_FICL_DICT()		FTH_FICL_VAR()->system->dictionary
231 #define FTH_FICL_ENV()		FTH_FICL_VAR()->system->environment
232 
233 #define fth_current_file	FTH_FICL_VAR()->current_file
234 #define fth_current_line	FTH_FICL_VAR()->current_line
235 #define fth_print_length	FTH_FICL_VAR()->print_length
236 
237 #define fth_last_exception	FTH_FICL_VAR()->last_exception
238 
239 #define FTH_FALSE		FTH_FICL_VAR()->_false
240 #define FTH_TRUE		FTH_FICL_VAR()->_true
241 #define FTH_NIL			FTH_FICL_VAR()->_nil
242 #define FTH_UNDEF		FTH_FICL_VAR()->_undef
243 
244 #define fth_print_p		FTH_FICL_VAR()->print_p
245 #define fth_eval_p		FTH_FICL_VAR()->eval_p
246 #define fth_hit_error_p		FTH_FICL_VAR()->hit_error_p
247 #define fth_true_repl_p		FTH_FICL_VAR()->true_repl_p
248 #define fth_die_on_signal_p	FTH_FICL_VAR()->die_on_signal_p
249 #define fth_interactive_p	FTH_FICL_VAR()->interactive_p
250 
251 typedef char   *(*in_cb) (ficlVm *);
252 typedef void    (*out_cb) (ficlVm *, char *);
253 typedef void    (*exit_cb) (int);
254 extern in_cb 	fth_read_hook;
255 extern out_cb 	fth_print_hook;
256 extern out_cb 	fth_error_hook;
257 extern exit_cb 	fth_exit_hook;
258 
259 /* === Predicates === */
260 #define FTH_INSTANCE_FLAG_P(Obj, Type)	fth_instance_flag_p(Obj, Type)
261 #define FTH_INSTANCE_TYPE_P(Obj, Type)	fth_instance_type_p(Obj, Type)
262 
263 #define FTH_CHAR_P(Obj)		fth_char_p(Obj)
264 #define FTH_EXACT_P(Obj)	fth_exact_p(Obj)
265 #define FTH_FIXNUM_P(Obj)	fth_fixnum_p(Obj)
266 #define FTH_INTEGER_P(Obj)	fth_integer_p(Obj)
267 #define FTH_NUMBER_P(Obj)	fth_number_p(Obj)
268 #define FTH_UNSIGNED_P(Obj)	fth_unsigned_p(Obj)
269 #define FTH_ULLONG_P(Obj)	fth_ullong_p(Obj)
270 
271 #define FTH_ARRAY_P(Obj)	FTH_INSTANCE_TYPE_P(Obj, FTH_ARRAY_T)
272 #define FTH_HASH_P(Obj)		FTH_INSTANCE_TYPE_P(Obj, FTH_HASH_T)
273 #define FTH_HOOK_P(Obj)		FTH_INSTANCE_TYPE_P(Obj, FTH_HOOK_T)
274 #define FTH_IO_P(Obj)		FTH_INSTANCE_TYPE_P(Obj, FTH_IO_T)
275 #define FTH_REGEXP_P(Obj)	FTH_INSTANCE_TYPE_P(Obj, FTH_REGEXP_T)
276 #define FTH_STRING_P(Obj)	FTH_INSTANCE_TYPE_P(Obj, FTH_STRING_T)
277 
278 #define FTH_ASSOC_P(Obj)	FTH_ARRAY_P(Obj)
279 #define FTH_CONS_P(Obj)		FTH_ARRAY_P(Obj)
280 #define FTH_LIST_P(Obj)		(FTH_NIL_P(Obj) || FTH_CONS_P(Obj))
281 #define FTH_PAIR_P(Obj)		FTH_CONS_P(Obj)
282 
283 #define FTH_BIGNUM_P(Obj)	FTH_INSTANCE_TYPE_P(Obj, FTH_BIGNUM_T)
284 #define FTH_COMPLEX_P(Obj)	FTH_INSTANCE_TYPE_P(Obj, FTH_COMPLEX_T)
285 #define FTH_FLOAT_T_P(Obj)	FTH_INSTANCE_TYPE_P(Obj, FTH_FLOAT_T)
286 #define FTH_LONG_LONG_P(Obj)	FTH_INTEGER_P(Obj)
287 #define FTH_FLOAT_P(Obj)	FTH_NUMBER_P(Obj)
288 #define FTH_LLONG_P(Obj)	FTH_INSTANCE_TYPE_P(Obj, FTH_LLONG_T)
289 #define FTH_RATIO_P(Obj)	FTH_INSTANCE_TYPE_P(Obj, FTH_RATIO_T)
290 
291 #define N_NUMBER_T		0x01
292 #define N_EXACT_T		0x02
293 #define N_INEXACT_T		0x04
294 
295 #define FTH_EXACT_T_P(Obj)	FTH_INSTANCE_FLAG_P(Obj, N_EXACT_T)
296 #define FTH_INEXACT_P(Obj)	FTH_INSTANCE_FLAG_P(Obj, N_INEXACT_T)
297 #define FTH_NUMBER_T_P(Obj)	FTH_INSTANCE_FLAG_P(Obj, N_NUMBER_T)
298 
299 /* === Word === */
300 
301 #define FICL_WORD_DICT_P(Obj)						\
302 	(FICL_WORD_REF(Obj) >= FICL_WORD_REF(FTH_FICL_DICT()->base) &&	\
303 	FICL_WORD_REF(Obj) <						\
304 	(FICL_WORD_REF(FTH_FICL_DICT()->base + FTH_FICL_DICT()->size)))
305 #define FICL_WORD_DEFINED_P(Obj)					\
306 	((Obj) && FICL_WORD_DICT_P(Obj))
307 
308 #define FICL_WORD_TYPE_P(Obj, Type)					\
309 	(FICL_WORD_DEFINED_P(Obj) && FICL_WORD_TYPE(Obj) == (Type))
310 
311 enum {
312 	FW_WORD,
313 	FW_PROC,
314 	FW_SYMBOL,
315 	FW_KEYWORD,
316 	FW_EXCEPTION,
317 	FW_VARIABLE,
318 	FW_TRACE_VAR
319 };
320 
321 #define FICL_INSTRUCTION_P(Obj)						\
322 	(((ficlInstruction)(Obj)) > ficlInstructionInvalid &&		\
323 	 ((ficlInstruction)(Obj)) < ficlInstructionLast)
324 
325 #define FICL_WORD_P(Obj)						\
326 	(FICL_WORD_DEFINED_P(Obj) &&					\
327 	 ((FICL_WORD_TYPE(Obj) == FW_WORD) ||				\
328 	  (FICL_WORD_TYPE(Obj) == FW_PROC)))
329 
330 #define FICL_SYMBOLS_P(Obj)						\
331 	(FICL_WORD_DEFINED_P(Obj) &&					\
332 	 ((FICL_WORD_TYPE(Obj) == FW_SYMBOL) ||				\
333 	  (FICL_WORD_TYPE(Obj) == FW_KEYWORD) ||			\
334 	  (FICL_WORD_TYPE(Obj) == FW_EXCEPTION)))
335 
336 #define FICL_VARIABLES_P(Obj)						\
337 	(FICL_WORD_DEFINED_P(Obj) &&					\
338 	 ((FICL_WORD_TYPE(Obj) == FW_VARIABLE) ||			\
339 	  (FICL_WORD_TYPE(Obj) == FW_TRACE_VAR)))
340 
341 #define FTH_EXCEPTION_P(Obj)	FICL_WORD_TYPE_P(Obj, FW_EXCEPTION)
342 #define FTH_KEYWORD_P(Obj)	FICL_WORD_TYPE_P(Obj, FW_KEYWORD)
343 #define FTH_PROC_P(Obj)		FICL_WORD_TYPE_P(Obj, FW_PROC)
344 #define FTH_SYMBOL_P(Obj)	FICL_WORD_TYPE_P(Obj, FW_SYMBOL)
345 #define FTH_TRACE_VAR_P(Obj)	FICL_WORD_TYPE_P(Obj, FW_TRACE_VAR)
346 #define FTH_VARIABLE_P(Obj)	FICL_WORD_TYPE_P(Obj, FW_VARIABLE)
347 #define FTH_WORD_P(Obj)		FICL_WORD_TYPE_P(Obj, FW_WORD)
348 
349 /* === Boolean === */
350 #define FTH_BOOLEAN_P(Obj)	FTH_INSTANCE_TYPE_P(Obj, FTH_BOOLEAN_T)
351 #define FTH_NIL_TYPE_P(Obj)	FTH_INSTANCE_TYPE_P(Obj, FTH_NIL_T)
352 #define FTH_BOUND_P(Obj)	((Obj) != FTH_UNDEF)
353 #define FTH_FALSE_P(Obj)	((Obj) == FTH_FALSE)
354 #define FTH_NIL_P(Obj)		((Obj) == FTH_NIL)
355 #define FTH_TRUE_P(Obj)		((Obj) == FTH_TRUE)
356 #define FTH_UNDEF_P(Obj)	((Obj) == FTH_UNDEF)
357 #define FTH_NOT_BOUND_P(Obj)	((Obj) == FTH_UNDEF)
358 #define FTH_NOT_FALSE_P(Obj)	((Obj) != FTH_FALSE)
359 #define FTH_NOT_NIL_P(Obj)	((Obj) != FTH_NIL)
360 #define FTH_NOT_TRUE_P(Obj)	((Obj) != FTH_TRUE)
361 #define BOOL_TO_FTH(Obj)	((FTH)((Obj) ? FTH_TRUE : FTH_FALSE))
362 #define FTH_TO_BOOL(Obj)	((Obj) != FTH_FALSE)
363 
364 #define FTH_CADR(Obj)		fth_cadr(Obj)
365 #define FTH_CADDR(Obj)		fth_caddr(Obj)
366 #define FTH_CADDDR(Obj)		fth_cadddr(Obj)
367 #define FTH_CDDR(Obj)		fth_cddr(Obj)
368 
369 #define FTH_LIST_1(A)		fth_make_list_var(1, A)
370 #define FTH_LIST_2(A, B)	fth_make_list_var(2, A, B)
371 #define FTH_LIST_3(A, B, C)	fth_make_list_var(3, A, B, C)
372 #define FTH_LIST_4(A, B, C, D)	fth_make_list_var(4, A, B, C, D)
373 #define FTH_LIST_5(A, B, C, D, E)					\
374 	fth_make_list_var(5, A, B, C, D, E)
375 #define FTH_LIST_6(A, B, C, D, E, F)					\
376 	fth_make_list_var(6, A, B, C, D, E, F)
377 #define FTH_LIST_7(A, B, C, D, E, F, G)					\
378 	fth_make_list_var(7, A, B, C, D, E, F, G)
379 #define FTH_LIST_8(A, B, C, D, E, F, G, H)				\
380 	fth_make_list_var(8, A, B, C, D, E, F, G, H)
381 #define FTH_LIST_9(A, B, C, D, E, F, G, H, I)				\
382 	fth_make_list_var(9, A, B, C, D, E, F, G, H, I)
383 
384 #define FTH_ASSERT_STRING(Obj)						\
385 	if ((Obj) == 0)							\
386 		fth_throw(FTH_NULL_STRING, "%s: null string", RUNNING_WORD())
387 
388 #define FTH_WRONG_TYPE_ARG_ERROR(Caller, Pos, Arg, Desc)		\
389 	fth_throw(FTH_WRONG_TYPE_ARG,					\
390 	    "%s: wrong type arg %d, %s (%S), wanted %s",		\
391 	    (Caller), 							\
392 	    (Pos),							\
393 	    fth_object_name(Arg),					\
394 	    (Arg),							\
395 	    (Desc))
396 
397 #define FTH_ASSERT_TYPE(Assertion, Arg, Pos, Caller, Desc)		\
398 	if ((Assertion) == 0)						\
399 		FTH_WRONG_TYPE_ARG_ERROR(Caller, Pos, Arg, Desc)
400 
401 #define FTH_ASSERT_ARGS(Assertion, Arg, Pos, Desc)			\
402 	FTH_ASSERT_TYPE(Assertion, Arg, Pos, RUNNING_WORD(), Desc)
403 
404 #define FTH_OUT_OF_BOUNDS_ERROR(Pos, Arg, Desc)				\
405 	fth_throw(FTH_OUT_OF_RANGE,					\
406 	    "%s arg %d: %ld is %s", RUNNING_WORD(), (int)(Pos),		\
407 	    (ficlInteger)(Arg), (Desc))
408 
409 #define FTH_OUT_OF_BOUNDS(Pos, Arg)					\
410 	FTH_OUT_OF_BOUNDS_ERROR(Pos, Arg, "out of range")
411 
412 /*
413  * This is special for Snd:
414  *	(char *Caller, int Pos, FTH Arg, char *Desc)
415  */
416 #define FTH_OUT_OF_RANGE_ERROR(Caller, Pos, Arg, Desc)			\
417 	fth_throw(FTH_OUT_OF_RANGE,					\
418 	    "%s arg %d: %S is out of range (%s)",			\
419 	    (Caller), (int)(Pos), (Arg), (Desc))
420 
421 #define FTH_BAD_ARITY_ERROR(Pos, Arg, Desc)				\
422 	fth_throw(FTH_BAD_ARITY,					\
423 	    "%s arg %d: %S, %s", RUNNING_WORD(), (Pos), (Arg), (Desc))
424 
425 #define FTH_BAD_ARITY_ERROR_ARGS(Pos, Arg, Wr, Wo, Wrst, Gr, Go, Grst)	\
426 	fth_throw(FTH_BAD_ARITY,					\
427 	    "%s arg %d: %S (%d/%d/%s), wanted %d/%d/%s",		\
428 	    RUNNING_WORD(),						\
429 	    (Pos),							\
430 	    (Arg),							\
431 	    (Gr),							\
432 	    (Go),							\
433 	    (Grst) ? "#t" : "#f",					\
434 	    (Wr),							\
435 	    (Wo),							\
436 	    (Wrst) ? "#t" : "#f")
437 
438 #define FTH_ANY_ERROR_THROW(Exc, Func)					\
439 	((errno != 0) ?							\
440 	 fth_throw(Exc,	"%s: %s", #Func, fth_strerror(errno)) :		\
441 	 fth_throw(Exc, "%s", #Func))
442 
443 #define FTH_ANY_ERROR_ARG_THROW(Exc, Func, Desc)			\
444 	((errno != 0) ?							\
445 	 fth_throw(Exc, "%s (%s): %s", #Func, Desc, fth_strerror(errno)) :\
446 	 fth_throw(Exc, "%s: %s", #Func, Desc))
447 
448 #define FTH_SYSTEM_ERROR_THROW(Func)					\
449 	FTH_ANY_ERROR_THROW(FTH_SYSTEM_ERROR, Func)
450 
451 #define FTH_SYSTEM_ERROR_ARG_THROW(Func, Desc)				\
452 	FTH_ANY_ERROR_ARG_THROW(FTH_SYSTEM_ERROR, Func, Desc)
453 
454 #define FTH_NOT_IMPLEMENTED_ERROR(Func)					\
455 	fth_throw(FTH_NOT_IMPLEMENTED,					\
456 	    "%s: %S", #Func, fth_exception_message_ref(FTH_NOT_IMPLEMENTED))
457 
458 #define FTH_BAD_SYNTAX_ERROR(Desc)					\
459 	fth_throw(FTH_BAD_SYNTAX, "%s: %s", RUNNING_WORD(), (Desc))
460 
461 #define FTH_NO_MEMORY_THROW()						\
462 	fth_throw(FTH_NO_MEMORY_ERROR,					\
463 	    "%s: can't allocate memory", RUNNING_WORD())
464 
465 __BEGIN_DECLS
466 
467 /* === array.c === */
468 /* array */
469 FTH		fth_array_append(FTH, FTH);
470 void		fth_array_clear(FTH);
471 FTH		fth_array_compact(FTH);
472 FTH		fth_array_copy(FTH);
473 FTH		fth_array_delete(FTH, ficlInteger);
474 FTH		fth_array_delete_key(FTH, FTH);
475 FTH		fth_array_each(FTH, FTH (*) (FTH, FTH), FTH);
476 FTH		fth_array_each_with_index(FTH,
477 		    FTH (*) (FTH, FTH, ficlInteger), FTH);
478 int		fth_array_equal_p(FTH, FTH);
479 FTH		fth_array_fill(FTH, FTH);
480 FTH		fth_array_find(FTH, FTH);
481 ficlInteger	fth_array_index(FTH, FTH);
482 FTH		fth_array_insert(FTH, ficlInteger, FTH);
483 FTH		fth_array_join(FTH, FTH);
484 ficlInteger	fth_array_length(FTH);
485 FTH		fth_array_map(FTH, FTH (*) (FTH, FTH), FTH);
486 int		fth_array_member_p(FTH, FTH);
487 FTH		fth_array_pop(FTH);
488 FTH		fth_array_push(FTH, FTH);
489 FTH		fth_array_ref(FTH, ficlInteger);
490 FTH		fth_array_reject(FTH, FTH, FTH);
491 FTH		fth_array_reverse(FTH);
492 FTH		fth_array_set(FTH, ficlInteger, FTH);
493 FTH		fth_array_shift(FTH);
494 FTH		fth_array_sort(FTH, FTH);
495 FTH		fth_array_subarray(FTH, ficlInteger, ficlInteger);
496 FTH		fth_array_to_array(FTH);
497 FTH		fth_array_to_list(FTH);
498 FTH		fth_array_uniq(FTH);
499 FTH		fth_array_unshift(FTH, FTH);
500 FTH		fth_make_array_len(ficlInteger);
501 FTH		fth_make_array_var(int,...);
502 FTH		fth_make_array_with_init(ficlInteger, FTH);
503 FTH		fth_make_empty_array(void);
504 /* assoc */
505 FTH		fth_acell_key(FTH);
506 FTH		fth_acell_value(FTH);
507 /* returns => #( key value ) */
508 FTH		fth_array_assoc(FTH, FTH);
509 /* returns => value */
510 FTH		fth_array_assoc_ref(FTH, FTH);
511 FTH		fth_array_assoc_remove(FTH, FTH);
512 FTH		fth_array_assoc_set(FTH, FTH, FTH);
513 FTH		fth_assoc(FTH, FTH, FTH);
514 FTH		fth_make_acell(FTH, FTH);
515 /* list */
516 FTH		fth_acons(FTH, FTH, FTH);
517 FTH		fth_cadddr(FTH);
518 FTH		fth_caddr(FTH);
519 FTH		fth_cadr(FTH);
520 FTH		fth_car(FTH);
521 FTH		fth_cddr(FTH);
522 FTH		fth_cdr(FTH);
523 FTH		fth_cons(FTH, FTH);
524 FTH		fth_cons_2(FTH, FTH, FTH);
525 FTH		fth_list_append(FTH);
526 /* returns => '( key value ) */
527 FTH		fth_list_assoc(FTH, FTH);
528 /* returns => value */
529 FTH		fth_list_assoc_ref(FTH, FTH);
530 FTH		fth_list_assoc_remove(FTH, FTH);
531 FTH		fth_list_assoc_set(FTH, FTH, FTH);
532 FTH		fth_list_copy(FTH);
533 ficlInteger	fth_list_length(FTH);
534 FTH		fth_list_member_p(FTH, FTH);
535 FTH		fth_list_ref(FTH, ficlInteger);
536 FTH		fth_list_reverse(FTH);
537 FTH		fth_list_set(FTH, ficlInteger, FTH);
538 FTH		fth_list_to_array(FTH);
539 FTH		fth_make_empty_list(void);
540 FTH		fth_make_list_len(ficlInteger);
541 FTH		fth_make_list_var(int,...);
542 FTH		fth_make_list_with_init(ficlInteger, FTH);
543 
544 /* === file.c === */
545 /* general file functions */
546 FTH		fth_file_atime(const char *);
547 FTH		fth_file_basename(const char *, const char *);
548 void		fth_file_chmod(const char *, mode_t);
549 void		fth_file_copy(const char *, const char *);
550 FTH		fth_file_ctime(const char *);
551 void		fth_file_delete(const char *);
552 FTH		fth_file_dirname(const char *);
553 int		fth_file_install(const char *, const char *, mode_t);
554 FTH		fth_file_length(const char *);
555 FTH		fth_file_match_dir(FTH, FTH);
556 void		fth_file_mkdir(const char *, mode_t);
557 void		fth_file_mkfifo(const char *, mode_t);
558 FTH		fth_file_mtime(const char *);
559 FTH		fth_file_realpath(const char *);
560 void		fth_file_rename(const char *, const char *);
561 void		fth_file_rmdir(const char *);
562 FTH		fth_file_split(const char *);
563 void		fth_file_symlink(const char *, const char *);
564 /* file test */
565 int		fth_file_block_p(const char *);
566 int		fth_file_character_p(const char *);
567 int		fth_file_directory_p(const char *);
568 int		fth_file_executable_p(const char *);
569 int		fth_file_exists_p(const char *);
570 int		fth_file_fifo_p(const char *);
571 int		fth_file_grpowned_p(const char *);
572 int		fth_file_owned_p(const char *);
573 int		fth_file_readable_p(const char *);
574 int		fth_file_setgid_p(const char *);
575 int		fth_file_setuid_p(const char *);
576 int		fth_file_socket_p(const char *);
577 int		fth_file_sticky_p(const char *);
578 int		fth_file_symlink_p(const char *);
579 int		fth_file_writable_p(const char *);
580 int		fth_file_zero_p(const char *);
581 
582 /* === hash.c === */
583 /* hash */
584 void		fth_hash_clear(FTH);
585 FTH		fth_hash_copy(FTH);
586 FTH		fth_hash_delete(FTH, FTH);
587 FTH		fth_hash_each(FTH, FTH (*) (FTH, FTH, FTH), FTH);
588 int		fth_hash_equal_p(FTH, FTH);
589 FTH		fth_hash_find(FTH, FTH);
590 FTH		fth_hash_keys(FTH);
591 FTH		fth_hash_map(FTH, FTH (*) (FTH, FTH, FTH), FTH);
592 int		fth_hash_member_p(FTH, FTH);
593 FTH		fth_hash_ref(FTH, FTH);
594 void		fth_hash_set(FTH, FTH, FTH);
595 FTH		fth_hash_to_array(FTH);
596 FTH		fth_hash_values(FTH);
597 FTH		fth_make_hash(void);
598 FTH		fth_make_hash_len(int);
599 /* properties */
600 FTH		fth_hash_id(FTH);
601 FTH		fth_object_id(FTH);
602 FTH		fth_object_properties(FTH);
603 FTH		fth_object_property_ref(FTH, FTH);
604 void		fth_object_property_set(FTH, FTH, FTH);
605 FTH		fth_properties(FTH);
606 FTH		fth_property_ref(FTH, FTH);
607 void		fth_property_set(FTH, FTH, FTH);
608 FTH		fth_word_properties(FTH);
609 FTH		fth_word_property_ref(FTH, FTH);
610 void		fth_word_property_set(FTH, FTH, FTH);
611 
612 /* === hook.c === */
613 /* hook */
614 void		fth_add_hook(FTH, FTH);
615 FTH		fth_hook_apply(FTH, FTH, const char *);
616 int		fth_hook_arity(FTH);
617 void		fth_hook_clear(FTH);
618 int		fth_hook_empty_p(FTH);
619 int		fth_hook_equal_p(FTH, FTH);
620 int		fth_hook_member_p(FTH, FTH);
621 FTH		fth_hook_names(FTH);
622 FTH		fth_hook_to_array(FTH);
623 FTH		fth_make_hook(const char *, int, const char *);
624 FTH		fth_make_hook_with_arity(const char *,
625 		    int, int, int, const char *);
626 FTH		fth_make_simple_hook(int);
627 FTH		fth_remove_hook(FTH, FTH);
628 FTH		fth_run_hook(FTH, int,...);
629 FTH		fth_run_hook_again(FTH, int,...);
630 FTH		fth_run_hook_bool(FTH, int,...);
631 
632 /* === io.c === */
633 /* io */
634 void		fth_io_close(FTH);
635 int		fth_io_closed_p(FTH);
636 int		fth_io_eof_p(FTH);
637 int		fth_io_equal_p(FTH, FTH);
638 char           *fth_io_filename(FTH);
639 int		fth_io_fileno(FTH);
640 void		fth_io_flush(FTH);
641 int		fth_io_getc(FTH);
642 int		fth_io_input_p(FTH);
643 ficl2Integer	fth_io_length(FTH);
644 int		fth_io_mode(FTH);
645 FTH		fth_io_nopen(const char *, int, int);
646 FTH		fth_io_open(const char *, int);
647 int		fth_io_output_p(FTH);
648 FTH		fth_io_popen(FTH, int);
649 ficl2Integer	fth_io_pos_ref(FTH);
650 void		fth_io_pos_set(FTH, ficl2Integer);
651 void           *fth_io_ptr(FTH);
652 void		fth_io_putc(FTH, int);
653 char           *fth_io_read(FTH);
654 FTH		fth_io_read_line(FTH);
655 FTH		fth_io_readlines(FTH);
656 void		fth_io_rewind(FTH);
657 FTH		fth_io_sopen(FTH, int);
658 FTH		fth_io_to_string(FTH);
659 void		fth_io_write(FTH, const char *);
660 void		fth_io_write_and_flush(FTH, const char *);
661 void		fth_io_write_format(FTH, FTH, FTH);
662 void		fth_io_writelines(FTH, FTH);
663 FTH		fth_readlines(const char *);
664 int		fth_set_exit_status(int);
665 FTH		fth_set_io_stderr(FTH);
666 FTH		fth_set_io_stdin(FTH);
667 FTH		fth_set_io_stdout(FTH);
668 void		fth_writelines(const char *, FTH);
669 
670 /* === misc.c === */
671 void		fth_exit  (int);
672 void		fth_make_ficl(unsigned, unsigned, unsigned, unsigned);
673 void		fth_reset (void);
674 /* eval */
675 void		fth_add_feature(const char *);
676 int		fth_catch_eval(const char *);
677 int		fth_catch_exec(ficlWord *);
678 FTH		fth_eval(const char *);
679 void		fth_init(void);
680 int		fth_provided_p(const char *);
681 /* load */
682 void		fth_add_load_lib_path(const char *);
683 void		fth_add_load_path(const char *);
684 void		fth_add_loaded_files(const char *);
685 char           *fth_basename(const char *);
686 FTH		fth_dl_load(const char *, const char *);
687 FTH		fth_find_file(FTH);
688 void		fth_install(void);	/* parse word */
689 void		fth_install_file(FTH);
690 FTH		fth_load_file(const char *);
691 FTH		fth_load_global_init_file(void);
692 FTH		fth_load_init_file(const char *);
693 FTH		fth_require_file(const char *);
694 void		fth_unshift_load_lib_path(const char *);
695 void		fth_unshift_load_path(const char *);
696 /* words */
697 FTH		fth_apropos(FTH);
698 void		fth_begin_values_to_obj(ficlVm *, char *, FTH);
699 FTH		fth_find_in_wordlist(const char *);
700 char           *fth_parse_word(void);
701 char           *fth_short_version(void);
702 char           *fth_version(void);
703 FTH		fth_word_ref(const char *);
704 FTH		fth_wordlist_each(int (*) (ficlWord *, FTH), FTH);
705 
706 /* === numbers.c === */
707 int		fth_char_p(FTH);
708 int		fth_exact_p(FTH);
709 int		fth_fixnum_p(FTH);
710 int		fth_integer_p(FTH);
711 int		fth_number_p(FTH);
712 int		fth_ullong_p(FTH);
713 int		fth_unsigned_p(FTH);
714 #if HAVE_COMPLEX
715 ficlComplex	fth_complex_ref(FTH);
716 #endif
717 ficlBignum	fth_bignum_ref(FTH);
718 ficlRatio	fth_ratio_ref(FTH);
719 ficlFloat	fth_float_ref(FTH);
720 ficlFloat	fth_float_ref_or_else(FTH, ficlFloat);
721 ficlInteger	fth_integer_ref(FTH);
722 ficlInteger	fth_int_ref(FTH);
723 ficlInteger	fth_int_ref_or_else(FTH, ficlInteger);
724 int		fth_isinf (ficlFloat);
725 int		fth_isnan (ficlFloat);
726 FTH		fth_llong_copy(FTH);
727 ficl2Integer	fth_long_long_ref(FTH);
728 FTH		fth_make_int(ficlInteger);
729 FTH		fth_make_llong(ficl2Integer);
730 FTH		fth_make_long_long(ficl2Integer);
731 ficlFloat	fth_real_ref(FTH);
732 FTH		fth_make_ullong(ficl2Unsigned);
733 FTH		fth_make_ulong_long(ficl2Unsigned);
734 FTH		fth_make_unsigned(ficlUnsigned);
735 ficl2Unsigned	fth_ulong_long_ref(FTH);
736 ficlUnsigned	fth_unsigned_ref(FTH);
737 /* random */
738 ficlFloat	fth_frandom(ficlFloat);	/* -f...f */
739 ficlFloat	fth_random(ficlFloat);	/* 0...f */
740 void		fth_srand (ficlUnsigned);
741 /* float */
742 FTH		fth_float_copy(FTH);
743 FTH		fth_make_float(ficlFloat);
744 #if HAVE_COMPLEX
745 /* complex */
746 ficlComplex 	ficlStackPopComplex(ficlStack *);
747 void 		ficlStackPushComplex(ficlStack *, ficlComplex);
748 FTH 		fth_make_complex(ficlComplex);
749 FTH 		fth_make_polar(ficlFloat, ficlFloat);
750 FTH 		fth_make_rectangular(ficlFloat, ficlFloat);
751 #endif				/* HAVE_COMPLEX */
752 /* bignum */
753 ficlBignum	ficlStackPopBignum(ficlStack *);
754 void 		ficlStackPushBignum(ficlStack *, ficlBignum);
755 FTH 		fth_make_bignum(ficlBignum);
756 FTH 		fth_make_big(FTH);
757 /* ratio */
758 ficlRatio	ficlStackPopRatio(ficlStack *);
759 void 		ficlStackPushRatio(ficlStack *, ficlRatio);
760 FTH		fth_exact_to_inexact(FTH);
761 FTH		fth_inexact_to_exact(FTH);
762 FTH		fth_denominator(FTH);
763 FTH		fth_numerator(FTH);
764 FTH 		fth_make_ratio(FTH, FTH);
765 FTH 		fth_make_ratio_from_float(ficlFloat);
766 FTH 		fth_make_ratio_from_int(ficlInteger, ficlInteger);
767 FTH 		fth_make_rational(ficlRatio);
768 FTH 		fth_ratio_floor(FTH);
769 FTH 		fth_rationalize(FTH, FTH);
770 FTH		fth_number_add(FTH, FTH);
771 FTH		fth_number_div(FTH, FTH);
772 int		fth_number_equal_p(FTH, FTH);
773 int		fth_number_less_p(FTH, FTH);
774 FTH		fth_number_mul(FTH, FTH);
775 FTH		fth_number_sub(FTH, FTH);
776 
777 /* === object.c === */
778 /* gc */
779 void		fth_gc_mark(FTH);
780 FTH		fth_gc_off(void);
781 FTH		fth_gc_on(void);
782 FTH		fth_gc_permanent(FTH);
783 FTH		fth_gc_protect(FTH);
784 FTH		fth_gc_protect_set(FTH, FTH);
785 void		fth_gc_unmark(FTH);
786 FTH		fth_gc_unprotect(FTH);
787 /* object */
788 FTH		fth_make_object_type(const char *);
789 FTH		fth_make_object_type_from(const char *, FTH);
790 int		fth_object_type_p(FTH);
791 /* instance */
792 int		fth_instance_flag_p(FTH, int);
793 int		fth_instance_p(FTH);
794 void           *fth_instance_ref_gen(FTH);
795 int		fth_instance_type_p(FTH, fobj_t);
796 FTH		fth_make_instance(FTH, void *);
797 int		fth_object_is_instance_of(FTH, FTH);
798 /* object set functions */
799 /* NOSTRICT */
800 FTH		fth_set_object_apply(FTH, void *, int, int, int);
801 FTH		fth_set_object_copy(FTH, FTH (*) (FTH));
802 FTH		fth_set_object_dump(FTH, FTH (*) (FTH));
803 FTH		fth_set_object_equal_p(FTH, FTH (*) (FTH, FTH));
804 FTH		fth_set_object_free(FTH, void (*) (FTH));
805 FTH		fth_set_object_inspect(FTH, FTH (*) (FTH));
806 FTH		fth_set_object_length(FTH, FTH (*) (FTH));
807 FTH		fth_set_object_mark(FTH, void (*) (FTH));
808 FTH		fth_set_object_to_array(FTH, FTH (*) (FTH));
809 FTH		fth_set_object_to_string(FTH, FTH (*) (FTH));
810 FTH		fth_set_object_value_ref(FTH, FTH (*) (FTH, FTH));
811 FTH		fth_set_object_value_set(FTH, FTH (*) (FTH, FTH, FTH));
812 /* object functions */
813 FTH		fth_object_apply(FTH, FTH);
814 FTH		fth_object_copy(FTH);
815 FTH		fth_object_dump(FTH);
816 int		fth_object_empty_p(FTH);
817 int		fth_object_equal_p(FTH, FTH);
818 FTH		fth_object_find(FTH, FTH);
819 FTH		fth_object_index(FTH, FTH);
820 FTH		fth_object_inspect(FTH);
821 ficlInteger	fth_object_length(FTH);
822 int		fth_object_member_p(FTH, FTH);
823 char           *fth_object_name(FTH);
824 int		fth_object_range_p(FTH, ficlInteger);
825 FTH		fth_object_sort(FTH, FTH);
826 FTH		fth_object_to_array(FTH);
827 FTH		fth_object_to_string(FTH);
828 /* Wrap String object type to "string". */
829 FTH		fth_object_to_string_2(FTH);
830 FTH		fth_object_value_ref(FTH, ficlInteger);
831 FTH		fth_object_value_set(FTH, ficlInteger, FTH);
832 char           *fth_to_c_dump(FTH);
833 char           *fth_to_c_inspect(FTH);
834 char           *fth_to_c_string(FTH);
835 /* Wrap String object type to "string". */
836 char           *fth_to_c_string_2(FTH);
837 /* cycle */
838 ficlInteger	fth_cycle_next(FTH);
839 ficlInteger	fth_cycle_pos_0(FTH);
840 ficlInteger	fth_cycle_pos_ref(FTH);
841 ficlInteger	fth_cycle_pos_set(FTH, ficlInteger);
842 FTH		fth_object_cycle_ref(FTH);
843 FTH		fth_object_cycle_set(FTH, FTH);
844 /* stack access */
845 FTH		ficl_to_fth(FTH);
846 FTH		fth_pop_ficl_cell(ficlVm *);
847 void		fth_push_ficl_cell(ficlVm *, FTH);
848 FTH		fth_to_ficl(FTH);
849 
850 /* === port.c === */
851 /* port */
852 void		fth_port_close(FTH);
853 void		fth_port_display(FTH, FTH);
854 void		fth_port_flush(FTH);
855 int		fth_port_getc(FTH);
856 char           *fth_port_gets(FTH);
857 void		fth_port_putc(FTH, int);
858 void		fth_port_puts(FTH, const char *);
859 out_cb		fth_set_error_cb(out_cb);
860 out_cb		fth_set_print_and_error_cb(out_cb);
861 /* output callbacks */
862 /* void (*)(ficlVm *, char *); */
863 out_cb		fth_set_print_cb(out_cb);
864 /* input callback */
865 /* char *(*)(ficlVm *); */
866 in_cb		fth_set_read_cb(in_cb);
867 FTH		fth_port_to_string(FTH);
868 
869 /* === printf.c === */
870 int 		fth_asprintf(char **, const char *,...);
871 int 		fth_debug (const char *,...);
872 int 		fth_errorf(const char *,...);
873 char           *fth_format(const char *,...);
874 int 		fth_fprintf(FILE *, const char *,...);
875 int 		fth_ioprintf(FTH, const char *,...);
876 int 		fth_port_printf(FTH, const char *,...);
877 int 		fth_printf(const char *,...);
878 int 		fth_snprintf(char *, size_t, const char *,...);
879 int 		fth_sprintf(char *, const char *,...);
880 int 		fth_warning(const char *,...);
881 int		fth_port_vprintf(FTH, const char *, va_list);
882 int		fth_print(const char *);
883 int		fth_error(const char *);
884 FTH		fth_string_vformat(const char *, FTH);
885 int		fth_vasprintf(char **, const char *, va_list);
886 int		fth_verrorf(const char *, va_list);
887 char           *fth_vformat(const char *, va_list);
888 int		fth_vfprintf(FILE *, const char *, va_list);
889 int		fth_vioprintf(FTH, const char *, va_list);
890 int		fth_vprintf(const char *, va_list);
891 int		fth_vsnprintf(char *, size_t, const char *, va_list);
892 int		fth_vsprintf(char *, const char *, va_list);
893 
894 /* === proc.c === */
895 int		fth_word_defined_p(FTH);
896 int		fth_word_type_p(FTH, int);
897 /* proc */
898 ficlWord       *fth_define_procedure(const char *,
899 		    FTH (*) (), int, int, int, const char *);
900 ficlWord       *fth_define_void_procedure(const char *,
901 		    void (*) (), int, int, int, const char *);
902 FTH		fth_documentation_ref(FTH);
903 void		fth_documentation_set(FTH, FTH);
904 FTH		fth_get_optarg(ficlInteger, FTH);
905 FTH		fth_get_optkey(FTH, FTH);
906 ficl2Integer	fth_get_optkey_2int(FTH, ficl2Integer);
907 ficlInteger	fth_get_optkey_int(FTH, ficlInteger);
908 int		fth_get_optkey_fix(FTH, int);
909 char           *fth_get_optkey_str(FTH, char *);
910 FTH		fth_make_proc(ficlWord *, int, int, int);
911 FTH		fth_make_proc_from_func(const char *,
912 		    FTH (*) (), int, int, int, int);
913 FTH		fth_proc_apply(FTH, FTH, const char *);
914 int		fth_proc_arity(FTH);
915 FTH		fth_proc_call(FTH, const char *, int,...);
916 char           *fth_proc_name(FTH);
917 FTH		fth_proc_source_ref(FTH);
918 void		fth_proc_source_set(FTH, FTH);
919 ficlWord       *fth_proc_to_xt(FTH);
920 FTH		fth_source_file(FTH);
921 FTH		fth_source_line(FTH);
922 FTH		fth_source_ref(FTH);
923 void		fth_source_set(FTH, FTH);
924 ficlWord       *fth_word_doc_set(ficlWord *, const char *);
925 FTH		fth_xt_apply(const char *, FTH, const char *);
926 FTH		fth_xt_call(const char *, const char *, int,...);
927 FTH		proc_from_proc_or_xt(FTH, int, int, int);
928 /* define, variable */
929 FTH		fth_define (const char *, FTH);
930 FTH		fth_define_constant(const char *, FTH, const char *);
931 FTH		fth_define_variable(const char *, FTH, const char *);
932 int		fth_defined_p(const char *);
933 void		fth_trace_var(FTH, FTH);
934 FTH		fth_trace_var_execute(ficlWord *);
935 void		fth_untrace_var(FTH);
936 FTH		fth_var_ref(FTH);
937 FTH		fth_var_set(FTH, FTH);
938 FTH		fth_variable_ref(const char *);
939 FTH		fth_variable_set(const char *, FTH);
940 
941 /* === regexp.c === */
942 /* regexp */
943 FTH		fth_make_regexp(const char *);
944 int		fth_regexp_find(const char *, const char *);
945 ficlInteger	fth_regexp_match(FTH, FTH);
946 FTH		fth_regexp_replace(FTH, FTH, FTH);
947 ficlInteger	fth_regexp_search(FTH, FTH, ficlInteger, ficlInteger);
948 FTH		fth_regexp_var_ref(ficlInteger);
949 
950 /* === string.c === */
951 /* string */
952 FTH		fth_make_empty_string(void);
953 FTH		fth_make_string(const char *);
954 FTH		fth_make_string_format(const char *,...);
955 FTH		fth_make_string_len(const char *, ficlInteger);
956 FTH		fth_make_string_or_false(const char *);
957 FTH		fth_string_append(FTH, FTH);
958 FTH		fth_string_capitalize(FTH);
959 FTH		fth_string_char_ref(FTH, ficlInteger);
960 FTH		fth_string_char_set(FTH, ficlInteger, FTH);
961 FTH		fth_string_chomp(FTH);
962 FTH		fth_string_copy(FTH);
963 char		fth_string_c_char_ref(FTH, ficlInteger);
964 char		fth_string_c_char_set(FTH, ficlInteger, char);
965 FTH		fth_string_delete(FTH, ficlInteger);
966 FTH		fth_string_downcase(FTH);
967 int		fth_string_equal_p(FTH, FTH);
968 int		fth_string_eval(FTH);
969 FTH		fth_string_fill(FTH, FTH);
970 FTH		fth_string_find(FTH, FTH);
971 FTH		fth_string_format(FTH, FTH);
972 int		fth_string_greater_p(FTH, FTH);
973 FTH		fth_string_index(FTH, FTH);
974 FTH		fth_string_insert(FTH, ficlInteger, FTH);
975 ficlInteger	fth_string_length(FTH);
976 int		fth_string_less_p(FTH, FTH);
977 int		fth_string_member_p(FTH, FTH);
978 int		fth_string_not_equal_p(FTH, FTH);
979 FTH		fth_string_pop(FTH);
980 FTH		fth_string_push(FTH, FTH);
981 char           *fth_string_ref(FTH);
982 FTH		fth_string_replace(FTH, FTH, FTH);
983 FTH		fth_string_reverse(FTH);
984 FTH		fth_string_scat(FTH, const char *);
985 FTH		fth_string_sformat(FTH, const char *,...);
986 FTH		fth_string_shift(FTH);
987 FTH		fth_string_sncat(FTH, const char *, ficlInteger);
988 FTH		fth_string_split(FTH, FTH);
989 FTH		fth_string_substring(FTH, ficlInteger, ficlInteger);
990 FTH		fth_string_to_array(FTH);
991 FTH		fth_string_unshift(FTH, FTH);
992 FTH		fth_string_upcase(FTH);
993 FTH		fth_string_vsformat(FTH, const char *, va_list);
994 
995 /* === symbol.c === */
996 /* symbol */
997 int		fth_string_or_symbol_p(FTH);
998 char           *fth_string_or_symbol_ref(FTH);
999 FTH		fth_symbol (const char *);
1000 int		fth_symbol_equal_p(FTH, FTH);
1001 int		fth_symbol_p(const char *);
1002 char           *fth_symbol_ref(FTH);
1003 /* keyword */
1004 FTH		fth_keyword(const char *);
1005 int		fth_keyword_equal_p(FTH, FTH);
1006 int		fth_keyword_p(const char *);
1007 char           *fth_keyword_ref(FTH);
1008 /* exception */
1009 FTH		fth_exception(const char *);
1010 int		fth_exception_equal_p(FTH, FTH);
1011 FTH		fth_exception_last_message_ref(FTH);
1012 void		fth_exception_last_message_set(FTH, FTH);
1013 FTH		fth_exception_message_ref(FTH);
1014 void		fth_exception_message_set(FTH, FTH);
1015 char           *fth_exception_ref(FTH);
1016 FTH		fth_make_exception(const char *, const char *);
1017 int		fth_symbol_or_exception_p(FTH);
1018 FTH		fth_symbol_or_exception_ref(FTH);
1019 FTH		fth_symbol_to_exception(FTH);
1020 
1021 /* === utils.c === */
1022 void           *fth_calloc(size_t, size_t);
1023 int		fth_evaluate(ficlVm *, const char *);
1024 int		fth_execute_xt(ficlVm *, ficlWord *);
1025 void		fth_free(void *);
1026 char           *fth_getenv(const char *, char *);
1027 void           *fth_malloc(size_t);
1028 void           *fth_realloc(void *, size_t);
1029 void		fth_repl(int, char **);
1030 char	       *fth_strcat(char *, size_t, const char *);
1031 char	       *fth_strcpy(char *, size_t, const char *);
1032 char           *fth_strdup(const char *);
1033 char           *fth_strerror(int);
1034 size_t		fth_strlen(const char *);
1035 char	       *fth_strncat(char *, size_t, const char *, size_t);
1036 char	       *fth_strncpy(char *, size_t, const char *, size_t);
1037 void		fth_throw (FTH, const char *,...);
1038 void		fth_throw_error(FTH, FTH);
1039 void		fth_throw_list(FTH, FTH);
1040 char	       *pop_cstring(ficlVm *);
1041 void		push_cstring(ficlVm *, char *);
1042 FTH		fth_set_argv(int, int, char **);
1043 
1044 __END_DECLS
1045 
1046 #endif				/* _FTH_H_ */
1047 
1048 /*
1049  * fth.h ends here
1050  */
1051