1 // Server-side utility functions
2 // Copyright (c) 1987-2022 by the citadel.org team
3 // This program is open source software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License, version 3.
10 #include <libcitadel.h>
15 // strproc() - make a string 'nice'
16 void strproc(char *string) {
19 if (string == NULL) return;
20 if (IsEmptyStr(string)) return;
22 // Convert non-printable characters to blanks
23 for (a=0; !IsEmptyStr(&string[a]); ++a) {
24 if (string[a]<32) string[a]=32;
25 if (string[a]>126) string[a]=32;
28 // a is now the length of our string.
29 // Remove leading and trailing blanks
30 while( (string[a-1]<33) && (!IsEmptyStr(string)) )
33 while( (string[b]<33) && (!IsEmptyStr(&string[b])) )
36 memmove(string,&string[b], a - b + 1);
38 // Remove double blanks
39 for (a=0; !IsEmptyStr(&string[a]); ++a) {
40 if ((string[a]==32)&&(string[a+1]==32)) {
41 strcpy(&string[a],&string[a+1]);
46 // remove characters which would interfere with the network
47 for (a=0; !IsEmptyStr(&string[a]); ++a) {
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]);
51 while (string[a]==',') strcpy(&string[a],&string[a+1]);
52 while (string[a]=='%') strcpy(&string[a],&string[a+1]);
53 while (string[a]=='|') strcpy(&string[a],&string[a+1]);
59 // get a line of text from a file
60 // ignores lines starting with #
61 int getstring(FILE *fp, char *string) {
75 } while(string[0]=='#');
76 return(strlen(string));