1 // Server-side utility functions
7 #include <libcitadel.h>
12 // strproc() - make a string 'nice'
13 void strproc(char *string) {
16 if (string == NULL) return;
17 if (IsEmptyStr(string)) return;
19 // Convert non-printable characters to blanks
20 for (a=0; !IsEmptyStr(&string[a]); ++a) {
21 if (string[a]<32) string[a]=32;
22 if (string[a]>126) string[a]=32;
25 // a is now the length of our string.
26 // Remove leading and trailing blanks
27 while( (string[a-1]<33) && (!IsEmptyStr(string)) )
30 while( (string[b]<33) && (!IsEmptyStr(&string[b])) )
33 memmove(string,&string[b], a - b + 1);
35 // Remove double blanks
36 for (a=0; !IsEmptyStr(&string[a]); ++a) {
37 if ((string[a]==32)&&(string[a+1]==32)) {
38 strcpy(&string[a],&string[a+1]);
43 // remove characters which would interfere with the network
44 for (a=0; !IsEmptyStr(&string[a]); ++a) {
45 while (string[a]=='!') strcpy(&string[a],&string[a+1]);
46 while (string[a]=='@') strcpy(&string[a],&string[a+1]);
47 while (string[a]=='_') strcpy(&string[a],&string[a+1]);
48 while (string[a]==',') strcpy(&string[a],&string[a+1]);
49 while (string[a]=='%') strcpy(&string[a],&string[a+1]);
50 while (string[a]=='|') strcpy(&string[a],&string[a+1]);
56 // get a line of text from a file
57 // ignores lines starting with #
58 int getstring(FILE *fp, char *string) {
72 } while(string[0]=='#');
73 return(strlen(string));