11 * struncmp() - case-insensitive version of strncmp()
12 * citadel.h will #define a strucmp() based on this
14 int struncmp(char *lstr, char *rstr, int len)
19 lc=tolower(lstr[pos]);
20 rc=tolower(rstr[pos]);
21 if ((lc==0)&&(rc==0)) return(0);
22 if (lc<rc) return(-1);
31 * strproc() - make a string 'nice'
33 void strproc(char *string)
37 if (strlen(string)==0) return;
39 /* Convert non-printable characters to blanks */
40 for (a=0; a<strlen(string); ++a) {
41 if (string[a]<32) string[a]=32;
42 if (string[a]>126) string[a]=32;
45 /* Remove leading and trailing blanks */
46 while( (string[0]<33) && (strlen(string)>0) )
47 strcpy(string,&string[1]);
48 while( (string[strlen(string)-1]<33) && (strlen(string)>0) )
49 string[strlen(string)-1]=0;
51 /* Remove double blanks */
52 for (a=0; a<strlen(string); ++a) {
53 if ((string[a]==32)&&(string[a+1]==32)) {
54 strcpy(&string[a],&string[a+1]);
59 /* remove characters which would interfere with the network */
60 for (a=0; a<strlen(string); ++a) {
61 while (string[a]=='!') strcpy(&string[a],&string[a+1]);
62 while (string[a]=='@') strcpy(&string[a],&string[a+1]);
63 while (string[a]=='_') strcpy(&string[a],&string[a+1]);
64 while (string[a]==',') strcpy(&string[a],&string[a+1]);
65 while (string[a]=='%') strcpy(&string[a],&string[a+1]);
66 while (string[a]=='|') strcpy(&string[a],&string[a+1]);
74 * num_parms() - discover number of parameters...
76 int num_parms(char *source)
81 for (a=0; a<strlen(source); ++a)
82 if (source[a]=='|') ++count;
87 * extract() - extract a parameter from a series of "|" separated...
89 void extract(char *dest, char *source, int parmnum)
95 if (strlen(source)==0) {
100 n = num_parms(source);
107 if ( (parmnum == 0) && (n == 1) ) {
109 for (n=0; n<strlen(dest); ++n)
110 if (dest[n]=='|') dest[n] = 0;
114 while (count++ < parmnum) do {
116 } while( (strlen(buf)>0) && (buf[0]!='|') );
117 if (buf[0]=='|') strcpy(buf,&buf[1]);
118 for (count = 0; count<strlen(buf); ++count)
119 if (buf[count] == '|') buf[count] = 0;
124 * extract_int() - extract an int parm w/o supplying a buffer
126 int extract_int(char *source, int parmnum)
130 extract(buf,source,parmnum);
135 * extract_long() - extract an long parm w/o supplying a buffer
137 long extract_long(char *source, long int parmnum)
141 extract(buf,source,parmnum);
148 * get a line of text from a file
149 * ignores lines starting with #
151 int getstring(FILE *fp, char *string)
166 } while(string[0]=='#');
167 return(strlen(string));
172 * sort message pointers
174 void sort_fullroom(struct fullroom *frptr)
178 for (a=MSGSPERRM-2; a>=0; --a) {
179 for (b=0; b<=a; ++b) {
180 if ((frptr->FRnum[b]) > (frptr->FRnum[b+1])) {
181 hold = frptr->FRnum[b];
182 frptr->FRnum[b] = frptr->FRnum[b+1];
183 frptr->FRnum[b+1] = hold;
190 * pattern2() - searches for patn within search string, returns pos
192 int pattern2(char *search, char *patn)
195 for (a=0; a<strlen(search); ++a) {
196 if (!struncmp(&search[a],patn,strlen(patn))) return(a);
203 * mesg_locate() - locate a message or help file, case insensitive
205 void mesg_locate(char *targ, char *searchfor, int numdirs, char **dirs)
211 for (a=0; a<numdirs; ++a) {
212 sprintf(buf,"cd %s; exec ls",dirs[a]);
213 ls = (FILE *) popen(buf,"r");
215 while(fgets(buf,255,ls)!=NULL) {
216 while (isspace(buf[strlen(buf)-1]))
217 buf[strlen(buf)-1] = 0;
218 if (!strucmp(buf,searchfor)) {
220 sprintf(targ,"%s/%s",dirs[a],buf);
233 * replacement strerror() for systems that don't have it
239 sprintf(buf,"errno = %d",e);