|
|
To use a string structure, the caller needs to know a string driver
and needs to know the driver-dependent data used by that string
structure. A simple string driver is mail_string
, a string
driver that takes an in-memory char*
string as the
driver-dependent data. The DOS port uses string drivers
that take a struct holding a file descriptor and a file offset. Often,
the user of a string driver is the same module that defined it, so
usually the programmer knows about its conventions. The following
calls are used to access a string structure:
void INIT(STRING *s, STRINGDRIVER *d, void *data, unsigned long size);
This call initializes the string structure.
unsigned long SIZE(STRING *s);
This call returns the number of characters remaining in the string after the current string character pointer.
char CHR(STRING *s);
This call returns the character at the current string character pointer.
char SNX(STRING *s);
This call returns the character at the current string character pointer, and increments the string character pointer.
unsigned long GETPOS(STRING *s, unsigned long i);
This function returns the value of the current string character pointer.
void SETPOS(STRING *s, unsigned long i);
This function sets the string character pointer to the given value.