--- stack/stack.h 2002/03/21 03:19:32 1.19 +++ stack/stack.h 2003/08/04 14:13:16 1.24 @@ -22,10 +22,46 @@ #define HASHTBLSIZE 2048 +#define CAR(X) ((X)->content.c->car) +#define CDR(X) ((X)->content.c->cdr) + +/* printf, sscanf, fgets, fprintf, fopen, perror */ +#include +/* exit, EXIT_SUCCESS, malloc, free */ +#include +/* NULL */ +#include +/* dlopen, dlsym, dlerror */ +#include +/* strcmp, strcpy, strlen, strcat, strdup */ +#include +/* getopt, STDIN_FILENO, STDOUT_FILENO, usleep */ +#include +/* EX_NOINPUT, EX_USAGE */ +#include +/* assert */ +#include + +#ifdef __linux__ +/* mtrace, muntrace */ +#include +/* ioctl */ +#include +/* KDMKTONE */ +#include +#endif /* __linux__ */ + + + /* First, define some types. */ struct cons_struct; struct symbol_struct; +struct environment_struct; + +/* A type for pointers to external functions */ +typedef void (*funcp)(struct environment_struct*); +/* funcp is a pointer to a void function (environment *) */ /* A value of some type */ typedef struct { @@ -36,7 +72,8 @@ string, func, /* Function pointer */ symb, /* Symbol */ - tcons /* A pair of two values */ + tcons, /* A pair of two values */ + port /* An I/O port */ } type:4; /* Type of stack element */ union { @@ -51,8 +88,11 @@ void *ptr; /* Pointer to the content */ struct cons_struct *c; /* ...or a pointer to a cons cell */ struct symbol_struct *sym; /* ...or a pointer to a symbol */ + FILE *p; /* ...or an I/O stream */ int i; /* ...or an integer */ float f; /* ...or a floating point number */ + funcp func; /* ...or a function pointer */ + char *string; /* ...or a string */ } content; /* Stores a pointer or an integer */ } value; @@ -100,9 +140,6 @@ int gc_count; /* Amount currently allocated */ } environment; -/* A type for pointers to external functions */ -typedef void (*funcp)(environment*); /* funcp is a pointer to a void - function (environment *) */ void init_env(environment*); void printerr(const char*); @@ -121,14 +158,19 @@ char *mangle_str(const char*); extern void mangle(environment*); void push_sym(environment*, const char*); -extern void nl(); +extern void nl(environment*); +extern void nlport(environment*); extern void type(environment*); -void print_val(value*, int, stackitem*); +void print_val(environment *, value*, int, stackitem*, FILE*); extern void print_(environment*); extern void print(environment*); extern void princ_(environment*); extern void princ(environment*); -void print_st(value*, long); +extern void printport_(environment*); +extern void printport(environment*); +extern void princport_(environment*); +extern void princport(environment*); +void print_st(environment*, value*, long); extern void printstack(environment*); extern void swap(environment*); extern void rot(environment*); @@ -164,7 +206,11 @@ extern void foreach(environment*); extern void to(environment*); extern void readline(environment*); +extern void readlineport(environment*); +void readlinestream(environment*, FILE*); extern void sx_72656164(environment*); +extern void readport(environment*); +void readstream(environment*, FILE*); extern void beep(environment*); extern void sx_77616974(environment*); extern void copying(environment*); @@ -180,3 +226,6 @@ extern void cons(environment*); extern void assq(environment*); void assocgen(environment*, funcp); +extern void sx_646f(environment *); +extern void sx_6f70656e(environment*); +extern void sx_636c6f7365(environment*);