Library Reference
This module provides both temporary and persistent storage for
arbitrary-length character strings.
Strings stored by the module can be identified by either a pointer or an
integer.
The set of persistent strings can be written at any time to a text file
as either a sequence of lines, one string per line in the form of a C
string denotation, or as the C definition of an initialized data structure.
#include "csm.h"
int stostr(char *c, int l)
char *StringTable(int i);
char *NoStr
int NoStrIndex;
int numstr;
ObstackP Csm_obstk;
char *CsmStrPtr;
char *prtstcon(FILE *d, char *p)
savestr(FILE *d)
dmpstr(FILE *d)
Stostr stores a character string c of length l in the
memory, returning the index of the string.
StringTable is a macro that delivers a pointer to a null-terminated
string, given the index of that string established by stostr .
The number of strings currently stored is
given by numstr (initially 0); thus numstr-1 is
the largest index that can be used as an argument to StringTable .
`csm.h' defines the constant NoStr
to be a unique character pointer that represents no string. It also
defines NoStrIndex
to be a unique string index that will never be used to represent a
string. The string indexed by NoStrIndex contains no
characters.
Csm_obstk is a region that can hold sets of strings.
It can be managed by the operations of the memory object allocator
(see Memory Object Management).
The actual characters of the strings stored by stostr are stored
in Csm_obstk .
CsmStrPtr is a pointer that can be set by a client of the character
storage module to point to a string in Csm_obstk .
When this pointer is passed to stostr , stostr assumes that
another copy of the string need not be stored.
Prtstcon prints the string pointed to by p on the current
line of file d . The string is printed as a C string constant with
the quotes omitted. This function can be omitted from the module by
compiling with the C flag -DNOPRINT .
Dmpstr prints the set of strings StringTable(0) through
StringTable(numstr-1) on file d as a sequence of lines.
This function can also be omitted from the module by compiling with the
C flag -DNOPRINT .
Savestr writes the current state of the module on file d ,
in the form of C initialized variables.
Only the strings stored by stostr will be written to d .
This file can be used to create a copy of the module
initialized to the current state by naming it `csmtbl.h'
and recompiling the module.
The save
function is available only if the module was compiled with the C flag
-DSAVE , and if the printing routines were not omitted.
|