14 * strproc() - make a string 'nice'
16 void strproc(char *string)
20 if (strlen(string)==0) return;
22 /* Convert non-printable characters to blanks */
23 for (a=0; a<strlen(string); ++a) {
24 if (string[a]<32) string[a]=32;
25 if (string[a]>126) string[a]=32;
28 /* Remove leading and trailing blanks */
29 while( (string[0]<33) && (strlen(string)>0) )
30 strcpy(string,&string[1]);
31 while( (string[strlen(string)-1]<33) && (strlen(string)>0) )
32 string[strlen(string)-1]=0;
34 /* Remove double blanks */
35 for (a=0; a<strlen(string); ++a) {
36 if ((string[a]==32)&&(string[a+1]==32)) {
37 strcpy(&string[a],&string[a+1]);
42 /* remove characters which would interfere with the network */
43 for (a=0; a<strlen(string); ++a) {
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]);
48 while (string[a]=='%') strcpy(&string[a],&string[a+1]);
49 while (string[a]=='|') strcpy(&string[a],&string[a+1]);
57 * num_parms() - discover number of parameters...
59 int num_parms(char *source)
64 for (a=0; a<strlen(source); ++a)
65 if (source[a]=='|') ++count;
70 * extract() - extract a parameter from a series of "|" separated...
72 void extract(char *dest, char *source, int parmnum)
78 if (strlen(source)==0) {
83 n = num_parms(source);
90 if ( (parmnum == 0) && (n == 1) ) {
92 for (n=0; n<strlen(dest); ++n)
93 if (dest[n]=='|') dest[n] = 0;
97 while (count++ < parmnum) do {
99 } while( (strlen(buf)>0) && (buf[0]!='|') );
100 if (buf[0]=='|') strcpy(buf,&buf[1]);
101 for (count = 0; count<strlen(buf); ++count)
102 if (buf[count] == '|') buf[count] = 0;
107 * extract_int() - extract an int parm w/o supplying a buffer
109 int extract_int(char *source, int parmnum)
113 extract(buf,source,parmnum);
118 * extract_long() - extract an long parm w/o supplying a buffer
120 long extract_long(char *source, long int parmnum)
124 extract(buf,source,parmnum);
131 * get a line of text from a file
132 * ignores lines starting with #
134 int getstring(FILE *fp, char *string)
149 } while(string[0]=='#');
150 return(strlen(string));
155 * pattern2() - searches for patn within search string, returns pos
157 int pattern2(char *search, char *patn)
160 for (a=0; a<strlen(search); ++a) {
161 if (!strncasecmp(&search[a],patn,strlen(patn))) return(a);
168 * mesg_locate() - locate a message or help file, case insensitive
170 void mesg_locate(char *targ, char *searchfor, int numdirs, char **dirs)
176 for (a=0; a<numdirs; ++a) {
177 sprintf(buf,"cd %s; exec ls",dirs[a]);
178 ls = (FILE *) popen(buf,"r");
180 while(fgets(buf,255,ls)!=NULL) {
181 while (isspace(buf[strlen(buf)-1]))
182 buf[strlen(buf)-1] = 0;
183 if (!strcasecmp(buf,searchfor)) {
185 sprintf(targ,"%s/%s",dirs[a],buf);
196 #ifndef HAVE_STRERROR
198 * replacement strerror() for systems that don't have it
200 char *strerror(int e)
204 sprintf(buf,"errno = %d",e);