home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / plug-ins / script-fu / siod.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-09-25  |  10.9 KB  |  425 lines

  1.  
  2. /* Scheme In One Defun, but in C this time.
  3.  
  4.  *                   COPYRIGHT (c) 1988-1994 BY                             *
  5.  *        PARADIGM ASSOCIATES INCORPORATED, CAMBRIDGE, MASSACHUSETTS.       *
  6.  *        See the source file SLIB.C for more information.                  *
  7.  
  8.  $Id: siod.h,v 1.3 1999/09/23 23:42:37 yosh Exp $
  9.  
  10.  */
  11. #ifndef __SIOD_H__
  12. #define __SIOD_H__
  13.  
  14. #include <stdio.h>
  15.  
  16. struct obj
  17.   {
  18.     short gc_mark;
  19.     short type;
  20.     union
  21.       {
  22.     struct
  23.       {
  24.         struct obj *car;
  25.         struct obj *cdr;
  26.       }
  27.     cons;
  28.     struct
  29.       {
  30.         double data;
  31.       }
  32.     flonum;
  33.     struct
  34.       {
  35.         char *pname;
  36.         struct obj *vcell;
  37.       }
  38.     symbol;
  39.     struct
  40.       {
  41.         char *name;
  42.         struct obj *(*f) (void);
  43.       }
  44.     subr0;
  45.     struct
  46.       {
  47.         char *name;
  48.         struct obj *(*f) (struct obj *);
  49.       }
  50.     subr1;
  51.     struct
  52.       {
  53.         char *name;
  54.         struct obj *(*f) (struct obj *, struct obj *);
  55.       }
  56.     subr2;
  57.     struct
  58.       {
  59.         char *name;
  60.         struct obj *(*f) (struct obj *, struct obj *, struct obj *);
  61.       }
  62.     subr3;
  63.     struct
  64.       {
  65.         char *name;
  66.         struct obj *(*f) (struct obj *, struct obj *, struct obj *,
  67.                   struct obj *);
  68.       }
  69.     subr4;
  70.     struct
  71.       {
  72.         char *name;
  73.         struct obj *(*f) (struct obj *, struct obj *, struct obj *,
  74.                   struct obj *, struct obj *);
  75.       }
  76.     subr5;
  77.     struct
  78.       {
  79.         char *name;
  80.         struct obj *(*f) (struct obj **, struct obj **);
  81.       }
  82.     subrm;
  83.     struct
  84.       {
  85.         char *name;
  86.         struct obj *(*f) (void *,...);
  87.       }
  88.     subr;
  89.     struct
  90.       {
  91.         struct obj *env;
  92.         struct obj *code;
  93.       }
  94.     closure;
  95.     struct
  96.       {
  97.         long dim;
  98.         long *data;
  99.       }
  100.     long_array;
  101.     struct
  102.       {
  103.         long dim;
  104.         double *data;
  105.       }
  106.     double_array;
  107.     struct
  108.       {
  109.         long dim;
  110.         char *data;
  111.       }
  112.     string;
  113.     struct
  114.       {
  115.         long dim;
  116.         struct obj **data;
  117.       }
  118.     lisp_array;
  119.     struct
  120.       {
  121.         FILE *f;
  122.         char *name;
  123.       }
  124.     c_file;
  125.       }
  126.     storage_as;
  127.   };
  128.  
  129. #define CAR(x) ((*x).storage_as.cons.car)
  130. #define CDR(x) ((*x).storage_as.cons.cdr)
  131. #define PNAME(x) ((*x).storage_as.symbol.pname)
  132. #define VCELL(x) ((*x).storage_as.symbol.vcell)
  133. #define SUBR0(x) (*((*x).storage_as.subr0.f))
  134. #define SUBR1(x) (*((*x).storage_as.subr1.f))
  135. #define SUBR2(x) (*((*x).storage_as.subr2.f))
  136. #define SUBR3(x) (*((*x).storage_as.subr3.f))
  137. #define SUBR4(x) (*((*x).storage_as.subr4.f))
  138. #define SUBR5(x) (*((*x).storage_as.subr5.f))
  139. #define SUBRM(x) (*((*x).storage_as.subrm.f))
  140. #define SUBRF(x) (*((*x).storage_as.subr.f))
  141. #define FLONM(x) ((*x).storage_as.flonum.data)
  142.  
  143. #define NIL ((struct obj *) 0)
  144. #define EQ(x,y) ((x) == (y))
  145. #define NEQ(x,y) ((x) != (y))
  146. #define NULLP(x) EQ(x,NIL)
  147. #define NNULLP(x) NEQ(x,NIL)
  148.  
  149. #define TYPE(x) (((x) == NIL) ? 0 : ((*(x)).type))
  150.  
  151. #define TYPEP(x,y) (TYPE(x) == (y))
  152. #define NTYPEP(x,y) (TYPE(x) != (y))
  153.  
  154. #define tc_nil    0
  155. #define tc_cons   1
  156. #define tc_flonum 2
  157. #define tc_symbol 3
  158. #define tc_subr_0 4
  159. #define tc_subr_1 5
  160. #define tc_subr_2 6
  161. #define tc_subr_3 7
  162. #define tc_lsubr  8
  163. #define tc_fsubr  9
  164. #define tc_msubr  10
  165. #define tc_closure 11
  166. #define tc_free_cell 12
  167. #define tc_string       13
  168. #define tc_double_array 14
  169. #define tc_long_array   15
  170. #define tc_lisp_array   16
  171. #define tc_c_file       17
  172. #define tc_byte_array   18
  173. #define tc_subr_4 19
  174. #define tc_subr_5 20
  175. #define tc_subr_2n 21
  176. #define FO_comment 35
  177. #define tc_user_min 50
  178. #define tc_user_max 100
  179.  
  180. #define FO_fetch 127
  181. #define FO_store 126
  182. #define FO_list  125
  183. #define FO_listd 124
  184.  
  185. #define tc_table_dim 100
  186.  
  187. typedef struct obj *LISP;
  188. typedef LISP (*SUBR_FUNC) (void);
  189.  
  190. #define CONSP(x)   TYPEP(x,tc_cons)
  191. #define FLONUMP(x) TYPEP(x,tc_flonum)
  192. #define SYMBOLP(x) TYPEP(x,tc_symbol)
  193.  
  194. #define NCONSP(x)   NTYPEP(x,tc_cons)
  195. #define NFLONUMP(x) NTYPEP(x,tc_flonum)
  196. #define NSYMBOLP(x) NTYPEP(x,tc_symbol)
  197.  
  198. #define TKBUFFERN 5120
  199.  
  200. struct gen_readio
  201.   {
  202.     int (*getc_fcn) (void *);
  203.     void (*ungetc_fcn) (int, void *);
  204.     void *cb_argument;
  205.   };
  206.  
  207. struct gen_printio
  208.   {
  209.     int (*putc_fcn) (int, void *);
  210.     int (*puts_fcn) (char *, void *);
  211.     void *cb_argument;
  212.   };
  213.  
  214. #define GETC_FCN(x) (*((*x).getc_fcn))((*x).cb_argument)
  215. #define UNGETC_FCN(c,x) (*((*x).ungetc_fcn))(c,(*x).cb_argument)
  216. #define PUTC_FCN(c,x) (*((*x).putc_fcn))(c,(*x).cb_argument)
  217. #define PUTS_FCN(c,x) (*((*x).puts_fcn))(c,(*x).cb_argument)
  218.  
  219. struct repl_hooks
  220.   {
  221.     void (*repl_puts) (char *);
  222.       LISP (*repl_read) (void);
  223.       LISP (*repl_eval) (LISP);
  224.     void (*repl_print) (LISP);
  225.   };
  226.  
  227. void process_cla (int argc, char **argv, int warnflag);
  228. void print_welcome (void);
  229. void print_hs_1 (void);
  230. void print_hs_2 (void);
  231. long no_interrupt (long n);
  232. LISP get_eof_val (void);
  233. long repl_driver (long want_sigint, long want_init, struct repl_hooks *);
  234. void set_repl_hooks (void (*puts_f) (char *),
  235.              LISP (*read_f) (void),
  236.              LISP (*eval_f) (LISP),
  237.              void (*print_f) (LISP));
  238. long repl (struct repl_hooks *);
  239. LISP my_err (char *message, LISP x);
  240. LISP errswitch (void);
  241. char *get_c_string (LISP x);
  242. char *get_c_string_dim (LISP x, long *);
  243. char *try_get_c_string (LISP x);
  244. long get_c_long (LISP x);
  245. double get_c_double (LISP x);
  246. LISP lerr (LISP message, LISP x);
  247.  
  248. LISP newcell (long type);
  249. LISP cons (LISP x, LISP y);
  250. LISP consp (LISP x);
  251. LISP car (LISP x);
  252. LISP cdr (LISP x);
  253. LISP setcar (LISP cell, LISP value);
  254. LISP setcdr (LISP cell, LISP value);
  255. LISP flocons (double x);
  256. LISP numberp (LISP x);
  257. LISP plus (LISP x, LISP y);
  258. LISP ltimes (LISP x, LISP y);
  259. LISP difference (LISP x, LISP y);
  260. LISP Quotient (LISP x, LISP y);
  261. LISP greaterp (LISP x, LISP y);
  262. LISP lessp (LISP x, LISP y);
  263. LISP eq (LISP x, LISP y);
  264. LISP eql (LISP x, LISP y);
  265. LISP symcons (char *pname, LISP vcell);
  266. LISP symbolp (LISP x);
  267. LISP symbol_boundp (LISP x, LISP env);
  268. LISP symbol_value (LISP x, LISP env);
  269. LISP cintern (char *name);
  270. LISP rintern (char *name);
  271. LISP subrcons (long type, char *name, SUBR_FUNC f);
  272. LISP closure (LISP env, LISP code);
  273. void gc_protect (LISP * location);
  274. void gc_protect_n (LISP * location, long n);
  275. void gc_protect_sym (LISP * location, char *st);
  276. void gc_unprotect (LISP * location);
  277.  
  278. void init_storage (void);
  279. void init_slibu (void);
  280.  
  281. void init_subr (char *name, long type, SUBR_FUNC fcn);
  282. void init_subr_0 (char *name, LISP (*fcn) (void));
  283. void init_subr_1 (char *name, LISP (*fcn) (LISP));
  284. void init_subr_2 (char *name, LISP (*fcn) (LISP, LISP));
  285. void init_subr_2n (char *name, LISP (*fcn) (LISP, LISP));
  286. void init_subr_3 (char *name, LISP (*fcn) (LISP, LISP, LISP));
  287. void init_subr_4 (char *name, LISP (*fcn) (LISP, LISP, LISP, LISP));
  288. void init_subr_5 (char *name, LISP (*fcn) (LISP, LISP, LISP, LISP, LISP));
  289. void init_lsubr (char *name, LISP (*fcn) (LISP));
  290. void init_fsubr (char *name, LISP (*fcn) (LISP, LISP));
  291. void init_msubr (char *name, LISP (*fcn) (LISP *, LISP *));
  292.  
  293. LISP assq (LISP x, LISP alist);
  294. LISP delq (LISP elem, LISP l);
  295. void set_gc_hooks (long type,
  296.            LISP (*rel) (LISP),
  297.            LISP (*mark) (LISP),
  298.            void (*scan) (LISP),
  299.            void (*free) (LISP),
  300.            long *kind);
  301. LISP gc_relocate (LISP x);
  302. LISP user_gc (LISP args);
  303. LISP gc_status (LISP args);
  304. void set_eval_hooks (long type, LISP (*fcn) (LISP, LISP *, LISP *));
  305. LISP leval (LISP x, LISP env);
  306. LISP symbolconc (LISP args);
  307. void set_print_hooks (long type, void (*fcn) (LISP, struct gen_printio *));
  308. LISP lprin1g (LISP exp, struct gen_printio *f);
  309. LISP lprin1f (LISP exp, FILE * f);
  310. LISP lprint (LISP exp, LISP);
  311. LISP lread (LISP);
  312. LISP lreadtk (char *, long j);
  313. LISP lreadf (FILE * f);
  314. void set_read_hooks (char *all_set, char *end_set,
  315.              LISP (*fcn1) (int, struct gen_readio *),
  316.              LISP (*fcn2) (char *, long, int *));
  317. LISP apropos (LISP);
  318. LISP vload (char *fname, long cflag, long rflag);
  319. LISP load (LISP fname, LISP cflag, LISP rflag);
  320. LISP require (LISP fname);
  321. LISP save_forms (LISP fname, LISP forms, LISP how);
  322. LISP quit (void);
  323. LISP nullp (LISP x);
  324. LISP strcons (long length, char *data);
  325. LISP read_from_string (LISP x);
  326. LISP aref1 (LISP a, LISP i);
  327. LISP aset1 (LISP a, LISP i, LISP v);
  328. LISP cons_array (LISP dim, LISP kind);
  329. LISP arcons (long typecode, long n, long initp);
  330. LISP string_append (LISP args);
  331. LISP string_length (LISP string);
  332. LISP string_search (LISP, LISP);
  333. LISP substring (LISP, LISP, LISP);
  334. LISP string_trim (LISP);
  335. LISP string_trim_left (LISP);
  336. LISP string_trim_right (LISP);
  337. LISP string_upcase (LISP);
  338. LISP string_downcase (LISP);
  339. void init_subrs (void);
  340. LISP copy_list (LISP);
  341. long c_sxhash (LISP, long);
  342. LISP sxhash (LISP, LISP);
  343. LISP href (LISP, LISP);
  344. LISP hset (LISP, LISP, LISP);
  345. LISP fast_print (LISP, LISP);
  346. LISP fast_read (LISP);
  347. LISP equal (LISP, LISP);
  348. LISP assoc (LISP x, LISP alist);
  349. LISP make_list (LISP x, LISP v);
  350. void set_fatal_exit_hook (void (*fcn) (void));
  351. LISP parse_number (LISP x);
  352. LISP intern (LISP x);
  353. void init_trace (void);
  354. long repl_c_string (char *, long want_sigint, long want_init, long want_print);
  355. char *siod_version (void);
  356. LISP nreverse (LISP);
  357. LISP number2string (LISP, LISP, LISP, LISP);
  358. LISP string2number (LISP, LISP);
  359. LISP siod_verbose (LISP);
  360. int siod_verbose_check (int);
  361. LISP setvar (LISP, LISP, LISP);
  362. long allocate_user_tc (void);
  363. LISP cadr (LISP);
  364. LISP caar (LISP);
  365. LISP cddr (LISP);
  366. LISP caaar (LISP);
  367. LISP caadr (LISP);
  368. LISP cadar (LISP);
  369. LISP caddr (LISP);
  370. LISP cdaar (LISP);
  371. LISP cdadr (LISP);
  372. LISP cddar (LISP);
  373. LISP cdddr (LISP);
  374. void chk_string (LISP, char **, long *);
  375. LISP a_true_value (void);
  376. LISP lapply (LISP fcn, LISP args);
  377. LISP mallocl (void *lplace, long size);
  378. void gput_st (struct gen_printio *, char *);
  379. void put_st (char *st);
  380. LISP listn (long n,...);
  381. char *must_malloc (unsigned long size);
  382. LISP lstrbreakup (LISP str, LISP lmarker);
  383. LISP lstrunbreakup (LISP elems, LISP lmarker);
  384. LISP nconc (LISP, LISP);
  385. LISP poparg (LISP *, LISP);
  386. FILE *get_c_file (LISP p, FILE * deflt);
  387. char *last_c_errmsg (int);
  388. LISP llast_c_errmsg (int);
  389.  
  390. #define SAFE_STRCPY(_to,_from) safe_strcpy((_to),sizeof(_to),(_from))
  391. #define SAFE_STRCAT(_to,_from) safe_strcat((_to),sizeof(_to),(_from))
  392. #define SAFE_STRLEN(_buff) safe_strlen((_buff),sizeof(_buff))
  393.  
  394. char *safe_strcpy (char *s1, size_t size1, const char *s2);
  395. char *safe_strcat (char *s1, size_t size1, const char *s2);
  396.  
  397. size_t safe_strlen (const char *s, size_t size);
  398. LISP memq (LISP x, LISP il);
  399. LISP lstrbreakup (LISP, LISP);
  400. LISP lstrbreakup (LISP, LISP);
  401. LISP nth (LISP, LISP);
  402. LISP butlast (LISP);
  403. LISP last (LISP);
  404. LISP readtl (struct gen_readio *f);
  405. LISP funcall1 (LISP, LISP);
  406. LISP funcall2 (LISP, LISP, LISP);
  407. LISP apply1 (LISP, LISP, LISP);
  408. LISP lgetc (LISP p);
  409. LISP lungetc (LISP i, LISP p);
  410. LISP lputc (LISP c, LISP p);
  411. LISP lputs (LISP str, LISP p);
  412.  
  413. int assemble_options (LISP,...);
  414. LISP ccall_catch (LISP tag, LISP (*fcn) (void *), void *);
  415. LISP lref_default (LISP li, LISP x, LISP fcn);
  416.  
  417.  
  418. LISP symalist (char *item,...);
  419.  
  420. LISP encode_st_mode (LISP l);
  421. LISP encode_open_flags (LISP l);
  422.  
  423.  
  424. #endif /* __SIOD_H__ */
  425.