17 * strproc() - make a string 'nice'
19 void strproc(char *string)
23 if (strlen(string)==0) return;
25 /* Convert non-printable characters to blanks */
26 for (a=0; a<strlen(string); ++a) {
27 if (string[a]<32) string[a]=32;
28 if (string[a]>126) string[a]=32;
31 /* Remove leading and trailing blanks */
32 while( (string[0]<33) && (strlen(string)>0) )
33 strcpy(string,&string[1]);
34 while( (string[strlen(string)-1]<33) && (strlen(string)>0) )
35 string[strlen(string)-1]=0;
37 /* Remove double blanks */
38 for (a=0; a<strlen(string); ++a) {
39 if ((string[a]==32)&&(string[a+1]==32)) {
40 strcpy(&string[a],&string[a+1]);
45 /* remove characters which would interfere with the network */
46 for (a=0; a<strlen(string); ++a) {
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 while (string[a]=='%') strcpy(&string[a],&string[a+1]);
52 while (string[a]=='|') strcpy(&string[a],&string[a+1]);
60 * get a line of text from a file
61 * ignores lines starting with #
63 int getstring(FILE *fp, char *string)
78 } while(string[0]=='#');
79 return(strlen(string));
84 * pattern2() - searches for patn within search string, returns pos
86 int pattern2(char *search, char *patn)
89 for (a=0; a<strlen(search); ++a) {
90 if (!strncasecmp(&search[a],patn,strlen(patn))) return(a);
97 * mesg_locate() - locate a message or help file, case insensitive
99 void mesg_locate(char *targ, char *searchfor, int numdirs, char **dirs)
105 for (a=0; a<numdirs; ++a) {
106 sprintf(buf,"cd %s; exec ls",dirs[a]);
107 ls = (FILE *) popen(buf,"r");
109 while(fgets(buf,255,ls)!=NULL) {
110 while (isspace(buf[strlen(buf)-1]))
111 buf[strlen(buf)-1] = 0;
112 if (!strcasecmp(buf,searchfor)) {
114 sprintf(targ,"%s/%s",dirs[a],buf);
125 #ifndef HAVE_STRERROR
127 * replacement strerror() for systems that don't have it
129 char *strerror(int e)
133 sprintf(buf,"errno = %d",e);