previous up next     contents index
Next: Library Functions Up: MzScheme Architecture Previous: Library Functions

Ports

  Ports are represented as Scheme values with the types  scheme_input_port_type and  scheme_output_port_type. The function  scheme_read takes an input port value and returns the next S-expression from the port. The function  scheme_write takes an output port and a value and writes the value to the port. Other standard low-level port functions are also provided, such as  scheme_getc.

    File ports can be created with  scheme_make_file_input_port and  scheme_make_file_output_port; these functions take a FILE * file pointer and return a Scheme port. Strings can be read or written with  scheme_make_string_input_port, which takes a NULL-terminated string, and  scheme_make_string_output_port, which takes no arguments. The contents of a string output port can be obtained with  scheme_get_string_output.

  Custom ports, with arbitrary read/write handlers, can be created with  scheme_make_input_port and  scheme_make_output_port.





PLT