12 * strproc() - make a string 'nice'
14 void strproc(char *string)
18 if (strlen(string)==0) return;
20 /* Convert non-printable characters to blanks */
21 for (a=0; a<strlen(string); ++a) {
22 if (string[a]<32) string[a]=32;
23 if (string[a]>126) string[a]=32;
26 /* Remove leading and trailing blanks */
27 while( (string[0]<33) && (strlen(string)>0) )
28 strcpy(string,&string[1]);
29 while( (string[strlen(string)-1]<33) && (strlen(string)>0) )
30 string[strlen(string)-1]=0;
32 /* Remove double blanks */
33 for (a=0; a<strlen(string); ++a) {
34 if ((string[a]==32)&&(string[a+1]==32)) {
35 strcpy(&string[a],&string[a+1]);
40 /* remove characters which would interfere with the network */
41 for (a=0; a<strlen(string); ++a) {
42 while (string[a]=='!') strcpy(&string[a],&string[a+1]);
43 while (string[a]=='@') strcpy(&string[a],&string[a+1]);
44 while (string[a]=='_') strcpy(&string[a],&string[a+1]);
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]);
55 * num_parms() - discover number of parameters...
57 int num_parms(char *source)
62 for (a=0; a<strlen(source); ++a)
63 if (source[a]=='|') ++count;
68 * extract() - extract a parameter from a series of "|" separated...
70 void extract(char *dest, char *source, int parmnum)
76 if (strlen(source)==0) {
81 n = num_parms(source);
88 if ( (parmnum == 0) && (n == 1) ) {
90 for (n=0; n<strlen(dest); ++n)
91 if (dest[n]=='|') dest[n] = 0;
95 while (count++ < parmnum) do {
97 } while( (strlen(buf)>0) && (buf[0]!='|') );
98 if (buf[0]=='|') strcpy(buf,&buf[1]);
99 for (count = 0; count<strlen(buf); ++count)
100 if (buf[count] == '|') buf[count] = 0;
105 * extract_int() - extract an int parm w/o supplying a buffer
107 int extract_int(char *source, int parmnum)
111 extract(buf,source,parmnum);
116 * extract_long() - extract an long parm w/o supplying a buffer
118 long extract_long(char *source, long int parmnum)
122 extract(buf,source,parmnum);
129 * get a line of text from a file
130 * ignores lines starting with #
132 int getstring(FILE *fp, char *string)
147 } while(string[0]=='#');
148 return(strlen(string));
153 * pattern2() - searches for patn within search string, returns pos
155 int pattern2(char *search, char *patn)
158 for (a=0; a<strlen(search); ++a) {
159 if (!strncasecmp(&search[a],patn,strlen(patn))) return(a);
166 * mesg_locate() - locate a message or help file, case insensitive
168 void mesg_locate(char *targ, char *searchfor, int numdirs, char **dirs)
174 for (a=0; a<numdirs; ++a) {
175 sprintf(buf,"cd %s; exec ls",dirs[a]);
176 ls = (FILE *) popen(buf,"r");
178 while(fgets(buf,255,ls)!=NULL) {
179 while (isspace(buf[strlen(buf)-1]))
180 buf[strlen(buf)-1] = 0;
181 if (!strcasecmp(buf,searchfor)) {
183 sprintf(targ,"%s/%s",dirs[a],buf);
196 * replacement strerror() for systems that don't have it
202 sprintf(buf,"errno = %d",e);