citadel
About:
Citadel
is an advanced messaging and collaboration system for groupware and BBS applications (preferred OS: Linux).
Fossies
Dox
:
citadel.tar.gz
("unofficial" and yet experimental doxygen-generated source code documentation)
Loading...
Searching...
No Matches
support.c
Go to the documentation of this file.
1
// Server-side utility functions
2
3
#include "
sysdep.h
"
4
#include <stdio.h>
5
#include <string.h>
6
#include <sys/stat.h>
7
#include <libcitadel.h>
8
9
#include "
citadel.h
"
10
#include "
support.h
"
11
12
// strproc() - make a string 'nice'
13
void
strproc
(
char
*
string
) {
14
int
a, b;
15
16
if
(
string
== NULL)
return
;
17
if
(IsEmptyStr(
string
))
return
;
18
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;
23
}
24
25
// a is now the length of our string.
26
// Remove leading and trailing blanks
27
while
( (
string
[a-1]<33) && (!IsEmptyStr(
string
)) )
28
string
[--a]=0;
29
b = 0;
30
while
( (
string
[b]<33) && (!IsEmptyStr(&
string
[b])) )
31
b++;
32
if
(b > 0)
33
memmove(
string
,&
string
[b], a - b + 1);
34
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]);
39
a=0;
40
}
41
}
42
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]);
51
}
52
53
}
54
55
56
// get a line of text from a file
57
// ignores lines starting with #
58
int
getstring
(FILE *fp,
char
*
string
) {
59
int
a,c;
60
do
{
61
strcpy(
string
,
""
);
62
a=0;
63
do
{
64
c=getc(fp);
65
if
(c<0) {
66
string
[a]=0;
67
return
(-1);
68
}
69
string
[a++]=c;
70
}
while
(c!=10);
71
string
[a-1]=0;
72
}
while
(
string
[0]==
'#'
);
73
return
(strlen(
string
));
74
}
citadel.h
strproc
void strproc(char *string)
Definition:
support.c:13
getstring
int getstring(FILE *fp, char *string)
Definition:
support.c:58
support.h
sysdep.h
server
support.c
Generated by
1.9.6