// cstring.h // // by John D. de Boer // The "Common" library uses null-terminated strings. // A NULL pointer is equivalent to a pointer to a null, i.e. (char)0. // The latter should never be returned by the library. // // The "string" type implies the following: // as return type: A newly-allocated block [using pointer()] is returned. // as parameter: A char pointer returned by a "string" function, or a NULL, must // be passed. The letters "old" in the function name mean that the // function will free the memory at the argument [using old()]; // otherwise, the function may reallocate the string. // as field: The struct owns the string. typedef char *string; // String copy and concatenation functions string fillstring(int LEN, char C); string copyof(const char *S); string cat(int D, char *S1, char *S2); string cat3(int D, char *S1, char *S2, char *S3); string cat4(int D, char *S1, char *S2, char *S3, char *S4); string cat5(int D, char *S1, char *S2, char *S3, char *S4, char *S5); string leftstr(const char *S, int N); string leftex(const char *S, int N); string rightstr(const char *S, int N); string rightex(const char *S, int N); string first(const char *S); string firstrem(const char *S); string last(const char *S); string lastrem(const char *S); string cstring(const uchar *PascalString); // String modification functions void nextword(char **S); void nextline(char **S); void capitalise(char *S); void makelowercase(char *S); void makeuppercase(char *S); void removechars(char *S, int REM); void repstring(string *A, const char *B, const char *C, bool Word); void replace(string *A, const char *B, const char *C); void repword(string *A, const char *B, const char *C); void repover(char *A, const char *B, const char *C); void clean(char *S); void addcr(string *S); // Decimal-string functions string intstring(long VAL, int FLD, char LR); string fig(long VAL); bool parseinteger(const char *S, long *Q); long value(const char *S); // Miscellaneous string functions char *oserrormsg(int E); string romannumeral(int VAL); // QuickDraw interface routines //void odrawold(string S); //void odrawint(long X); //void ocentreint(long X); //void odrawexponent(int EXP); // String lists typedef struct { short num; // number of strings in list string **list; // the strings } stringlist; void initstringlist(stringlist *L); bool stringisinlist(const stringlist *L, const char *S); void addstringtolist(stringlist *L, string S); void purgestringlist(stringlist *L); // Removing comments void removecomments(char *S); void cleanwhitespace(char *S); // Dividing long strings into two void dividestring(string *S1, string *S2);