13 * strproc() - make a string 'nice'
15 void strproc(char *string)
19 if (strlen(string)==0) return;
21 /* Convert non-printable characters to blanks */
22 for (a=0; a<strlen(string); ++a) {
23 if (string[a]<32) string[a]=32;
24 if (string[a]>126) string[a]=32;
27 /* Remove leading and trailing blanks */
28 while( (string[0]<33) && (strlen(string)>0) )
29 strcpy(string,&string[1]);
30 while( (string[strlen(string)-1]<33) && (strlen(string)>0) )
31 string[strlen(string)-1]=0;
33 /* Remove double blanks */
34 for (a=0; a<strlen(string); ++a) {
35 if ((string[a]==32)&&(string[a+1]==32)) {
36 strcpy(&string[a],&string[a+1]);
41 /* remove characters which would interfere with the network */
42 for (a=0; a<strlen(string); ++a) {
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]);
48 while (string[a]=='|') strcpy(&string[a],&string[a+1]);
56 * num_parms() - discover number of parameters...
58 int num_parms(char *source)
63 for (a=0; a<strlen(source); ++a)
64 if (source[a]=='|') ++count;
69 * extract() - extract a parameter from a series of "|" separated...
71 void extract(char *dest, char *source, int parmnum)
77 if (strlen(source)==0) {
82 n = num_parms(source);
89 if ( (parmnum == 0) && (n == 1) ) {
91 for (n=0; n<strlen(dest); ++n)
92 if (dest[n]=='|') dest[n] = 0;
96 while (count++ < parmnum) do {
98 } while( (strlen(buf)>0) && (buf[0]!='|') );
99 if (buf[0]=='|') strcpy(buf,&buf[1]);
100 for (count = 0; count<strlen(buf); ++count)
101 if (buf[count] == '|') buf[count] = 0;
106 * extract_int() - extract an int parm w/o supplying a buffer
108 int extract_int(char *source, int parmnum)
112 extract(buf,source,parmnum);
117 * extract_long() - extract an long parm w/o supplying a buffer
119 long extract_long(char *source, long int parmnum)
123 extract(buf,source,parmnum);
130 * get a line of text from a file
131 * ignores lines starting with #
133 int getstring(FILE *fp, char *string)
148 } while(string[0]=='#');
149 return(strlen(string));
154 * pattern2() - searches for patn within search string, returns pos
156 int pattern2(char *search, char *patn)
159 for (a=0; a<strlen(search); ++a) {
160 if (!strncasecmp(&search[a],patn,strlen(patn))) return(a);
167 * mesg_locate() - locate a message or help file, case insensitive
169 void mesg_locate(char *targ, char *searchfor, int numdirs, char **dirs)
175 for (a=0; a<numdirs; ++a) {
176 sprintf(buf,"cd %s; exec ls",dirs[a]);
177 ls = (FILE *) popen(buf,"r");
179 while(fgets(buf,255,ls)!=NULL) {
180 while (isspace(buf[strlen(buf)-1]))
181 buf[strlen(buf)-1] = 0;
182 if (!strcasecmp(buf,searchfor)) {
184 sprintf(targ,"%s/%s",dirs[a],buf);
197 * replacement strerror() for systems that don't have it
203 sprintf(buf,"errno = %d",e);