Scheme_Object *scheme_read(Scheme_Object *port)
Reads the next S-expression from the given input port.
void scheme_write(Scheme_Object *obj, Scheme_Object *port)
writes the Scheme value obj to the given output port.
void scheme_write_w_max(Scheme_Object *obj, Scheme_Object *port, int n)
Like scheme_write, but the printing is truncated to n characters. (If printing is truncated, the last three characters are printed as ``.''.)
void scheme_display(Scheme_Object *obj, Scheme_Object *port)
displays the Scheme value obj to the given output port.
void scheme_display_w_max(Scheme_Object *obj, Scheme_Object *port, int n)
Like scheme_display, but the printing is truncated to n characters. (If printing is truncated, the last three characters are printed as ``.''.)
void scheme_write_string(char *str, long len, Scheme_Object *port)
displays the string str to the given output port.
char *scheme_write_to_string(Scheme_Object *obj, long *len)
writes the Scheme value obj to a newly allocated string. If len is not NULL, *len is set to the length of the string.
void scheme_write_to_string_w_max(Scheme_Object *obj, long *len, int n)
Like scheme_write_to_string, but the string is truncated to n characters. (If the string is truncated, the last three characters are ``.''.)
char *scheme_display_to_string(Scheme_Object *obj, long *len)
displays the Scheme value obj to a newly allocated string. If len is not NULL, *len is set to the length of the string.
void scheme_display_to_string_w_max(Scheme_Object *obj, long *len, int n)
Like scheme_display_to_string, but the string is truncated to n characters. (If the string is truncated, the last three characters are ``.''.)
void scheme_debug_print(Scheme_Object *obj)
writes the Scheme value obj to the main thread's output port.
void scheme_flush_output(Scheme_Object *port)
If port is a file port, a buffered data is written to the file. Otherwise, there is no effect. port must be an output port.
int scheme_getc(Scheme_Object *port)
Get the next character from the given input port.
long scheme_get_chars(Scheme_Object *port, long size, char *buffer)
Gets multiple characters at once. The size argument indicates the number of requested characters, to be put into the buffer array. The return value is the number of characters actually read. See also scheme_are_all_chars_ready.
int scheme_are_all_chars_ready(Scheme_Object *port)
Returns 1 if scheme_char_ready will never return 0 for port. This function is useful for ensuring that scheme_get_chars will not block for multiple-character reads.
void scheme_ungetc(int ch, Scheme_Object *port)
Puts the character ch back as the next character to be read from the given input port. The character need not have been read from port, and scheme_ungetc can be called to insert any number of characters at the start of port.
int scheme_char_ready(Scheme_Object *port)
Returns 1 if a call to scheme_getc is guranteed not to block for the given input port.
void scheme_need_wakeup(Scheme_Object *port, void *fds)
Requests that appropriate bits are set in fds to specify which file descriptors(s) the given input port reads from. (fds is sortof a pointer to an fd_set struct; see section 3.7.1.1.)
long scheme_tell(Scheme_Object *port)
Returns the current read position of the given input port.
long scheme_tell_line(Scheme_Object *port)
Returns the current read line of the given input port.
void scheme_close_input_port(Scheme_Object *port)
Closes the given input port.
void scheme_close_output_port(Scheme_Object *port)
Closes the given output port.
Scheme_Object *scheme_make_port_type(char *name)
Creates a new port subtype.
Scheme_Input_Port *scheme_make_input_port( Scheme_Object *subtype, void *data, int (*getc_fun)(Scheme_Input_Port*), int (*char_ready_fun)(Scheme_Input_Port*), void (*close_fun)(Scheme_Input_Port*), void (*need_wakeup_fun)(Scheme_Input_Port*, void *), int must_close)
Creates a new input port with arbitary control functions. The pointer data will be installed as the port's user data, which can be extracted/set with the SCHEME_INPORT_VAL macro. The C value EOF should be used by getc_fun to return an end-of-file.
The function need_wakeup_fun will be invoked when the port is blocked on a read; need_wakeup_fun should set appropriate bits in fds to specify which file decriptior(s) it is blocked on. The fds argument is conceptually an array of three fd_set structs (one for read, one for write, one for exceptions), but manipulate this array using scheme_get_fdset to get a particular element of the array, and use MZ_FD_XXX instead of FD_XXX to manipulate a single ``fd_set''.
Although the return type of scheme_make_input_port is Scheme_Input_Port *, it can be cast into a Scheme_Object *.
If must_close is non-zero, the new port will be registered with the current custodian, and close_fun is guranteed to be called before the port is garbage-collected.
Scheme_Output_Port *scheme_make_output_port( Scheme_Object *subtype, void *data, void (*write_string_fun)(char *, long, Scheme_Output_Port*), void (*close_fun)(Scheme_Output_Port*), int must_close)
Creates a new output port with arbitary control functions. The pointer data will be installed as the port's user data, which can be extracted/set with the SCHEME_OUTPORT_VAL macro. When write_string_fun is called, the second parameter is the length of the string to be written.
Although the return type of scheme_make_input_port is Scheme_Output_Port *, it can be cast into a Scheme_Object *.
If must_close is non-zero, the new port will be registered with the current custodian, and close_fun is guranteed to be called before the port is garbage-collected.
Scheme_Object *scheme_make_file_input_port(FILE *fp)
Creates a Scheme input file port from an ANSI C file pointer.
Scheme_Object *scheme_make_named_file_input_port(FILE *fp, char *filename)
Creates a Scheme input file port from an ANSI C file pointer. The filename is used for error reporting.
Scheme_Object *scheme_make_file_output_port(FILE *fp)
Creates a Scheme output file port from an ANSI C file pointer.
Scheme_Object *scheme_make_string_input_port(char *str)
Creates a Scheme input port from a string; successive read-chars on the port return successive characters in the string.
Scheme_Object *scheme_make_string_output_port()
Creates a Scheme output port; all writes to the port are kept in a string, which can be obtained with scheme_get_string_output.
char *scheme_get_string_output(Scheme_Object *port)
Returns (in a newly allocated string) all data that has been written to the given string output port so far. (The returned string is null-terminated.)
char *scheme_get_sized_string_output(Scheme_Object *port, int *len)
Returns (in a newly allocated string) all data that has been written to the given string output port so far and fills in *len with the length of the string (not including the null terminator).
void scheme_pipe(Scheme_Object **write, Scheme_Object **read)
Creates a pair of ports, setting *write and *read; data written to *write can be read back out of *read.
int scheme_file_exists(char *name)
Returns 1 if a file by the given name exists, 0 otherwise. If name specifies a directory, FALSE is returned. The name should be already expanded.
int scheme_directory_exists(char *name)
Returns 1 if a directory by the given name exists, 0 otherwise. The name should be already expanded.
char *scheme_expand_filename(char *name, int len, char *where, int *expanded)
Expands the pathname name, resolving relative paths with respect to the current directory parameter. Under Unix, this expands ``~'' into a user's home directory. On the Macintosh, aliases are resolved to real pathnames. The len argument is the length of the input string; if it is -1, the string is assumed to be null-terminated. The where argument is used if there is an error in the filename; if this is NULL, and error is not reported and NULL is returned instead. If expanded is not NULL, *expanded is set to 1 if some expansion takes place, or 0 if the input name is simply returned.
char *scheme_os_getcwd(char *buf, int buflen, int *actlen, int noexn)
Gets the current working directory according to the operating system. This is separate from MzScheme's current directory parameter.
The direcory path is written into buf, of length buflen, if it fits. Otherwise, a new (collectable) string is allocated for the directory path. If actlen is not NULL, *actlen is set to the length of the current directory path. If noexn is no 0, then an exception is raised if the operation fails.
int scheme_os_setcwd(char *buf, int noexn)
Sets the current working directory according to the operating system. This is separate from MzScheme's current directory parameter.
If noexn is not 0, then an exception is raised if the operation fails.
char *scheme_format(char *format, int flen, int argc, Scheme_Object **argv, int *rlen)
Creates a string like MzScheme's format procedure, using the format string format (of length flen) and the extra arguments specified in argc and argv. If rlen is not NULL, *rlen is filled with the length of the resulting string.
void scheme_printf(char *format, int flen, int argc, Scheme_Object **argv)
Writes to the current output port like MzScheme's printf procedure, using the format string format (of length flen) and the extra arguments specified in argc and argv.