Back to index

citadel  8.12
Functions
support.h File Reference

Go to the source code of this file.

Functions

void strproc (char *string)
int getstring (FILE *fp, char *string)
void mesg_locate (char *targ, size_t n, const char *searchfor, int numdirs, const char *const *dirs)

Function Documentation

int getstring ( FILE *  fp,
char *  string 
)

Definition at line 70 of file support.c.

{
       int a,c;
       do {
              strcpy(string,"");
              a=0;
              do {
                     c=getc(fp);
                     if (c<0) {
                            string[a]=0;
                            return(-1);
                            }
                     string[a++]=c;
                     } while(c!=10);
                     string[a-1]=0;
              } while(string[0]=='#');
       return(strlen(string));
}
void mesg_locate ( char *  targ,
size_t  n,
const char *  searchfor,
int  numdirs,
const char *const *  dirs 
)

Definition at line 95 of file support.c.

{
       int a;
       char buf[SIZ];
       struct stat test;

       for (a=0; a<numdirs; ++a) {
              snprintf(buf, sizeof buf, "%s/%s", dirs[a], searchfor);
              if (!stat(buf, &test)) {
                     snprintf(targ, n, "%s/%s", dirs[a], searchfor);
                     return;
              }
       }
       strcpy(targ,"");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void strproc ( char *  string)

Definition at line 21 of file support.c.

{
       int a, b;

       if (string == NULL) return;
       if (IsEmptyStr(string)) return;

       /* Convert non-printable characters to blanks */
       for (a=0; !IsEmptyStr(&string[a]); ++a) {
              if (string[a]<32) string[a]=32;
              if (string[a]>126) string[a]=32;
       }

       /* a is now the length of our string. */
       /* Remove leading and trailing blanks */
       while( (string[a-1]<33) && (!IsEmptyStr(string)) )
              string[--a]=0;
       b = 0;
       while( (string[b]<33) && (!IsEmptyStr(&string[b])) )
              b++;
       if (b > 0)
              memmove(string,&string[b], a - b + 1);

       /* Remove double blanks */
       for (a=0; !IsEmptyStr(&string[a]); ++a) {
              if ((string[a]==32)&&(string[a+1]==32)) {
                     strcpy(&string[a],&string[a+1]);
                     a=0;
              }
       }

       /* remove characters which would interfere with the network */
       for (a=0; !IsEmptyStr(&string[a]); ++a) {
              while (string[a]=='!') strcpy(&string[a],&string[a+1]);
              while (string[a]=='@') strcpy(&string[a],&string[a+1]);
              while (string[a]=='_') strcpy(&string[a],&string[a+1]);
              while (string[a]==',') strcpy(&string[a],&string[a+1]);
              while (string[a]=='%') strcpy(&string[a],&string[a+1]);
              while (string[a]=='|') strcpy(&string[a],&string[a+1]);
       }

}