Closing Streams

Closing Streams — Closing streams and retrieving their character counts

Functions

void glk_stream_close ()

Types and Values

Includes

#include <libchimara/glk.h>

Description

When you close a Glk stream, you have the opportunity to examine the character counts — the number of characters written to or read from the stream.

Functions

glk_stream_close ()

void
glk_stream_close (strid_t str,
                  stream_result_t *result);

Closes the stream str . The result argument points to a structure which is filled in with the final character counts of the stream. If you do not care about these, you may pass NULL as the result argument.

If str is the current output stream, the current output stream is set to NULL.

You cannot close window streams; use glk_window_close() instead. See Window Opening, Closing, and Constraints.

Parameters

str

Stream to close.

 

result

Pointer to a stream_result_t, or NULL.

 

Types and Values

stream_result_t

typedef struct {
    glui32 readcount;
    glui32 writecount;
} stream_result_t;

If you are interested in the character counts of a stream (see Streams), then you can pass a pointer to stream_result_t as an argument of glk_stream_close() or glk_window_close(). The structure will be filled with the stream's final character counts.

Members

glui32 readcount;

Number of characters read from the stream.

 

glui32 writecount;

Number of characters printed to the stream, including ones that were thrown away.