#include "bbs.h"
extern struct myst my_struct;

/* Check_Our_List.c */

/* our list of files that are not allowed to be sent up     */
/* also have to add this to the function that uploads files */
/* without entering the file name */

/* str = ptr to filename of file to upload */

static int Check_Our_List(char *fname, char *str)
{
 FILE *fp;
 char buff[255];
 char dest[255];
 register char *s, *p, *tmpstr;

 
 if(!(fp = fopen(fname,"r")))     /* can't find our file */
     return(SUCCESS);
 
 while(fgets(&buff[0],250,fp)!=0) {
     buff[strlen(buff)-1] = '\0'; 
     if(ParsePatternNoCase(buff,dest,200)!=-1L)
     {
       if(MatchPatternNoCase(dest,str))
       {
         fclose(fp); return(FAILURE);
       }
     }
  }
  fclose(fp);
  return(SUCCESS);
}
extern BOOL LcFileXfr;
extern char  Conference_Location[100];
//extern char *NotAllowedFiles;

int Check_For_File(char *Fn)
{
 char path[255],final[255];
 FILE *ft;
 int x;

 if(strstr(Fn,"%") || strstr(Fn,"#") || strstr(Fn,"?") || strstr(Fn," ") ||
    strstr(Fn,"/") || strstr(Fn,"(") || strstr(Fn,")"))
     return(FAILURE);
 
 /* here we can add our own file list of files to check */
 if(Sopt->FilesNot[0]!=NULL) {
     x = Check_Our_List(Sopt->FilesNot,Fn);   /* a list of files not to allow up */
     if(x == FAILURE)
          return(FAILURE);

 }
 if(!LcFileXfr)
 {
 strcpy(path,Conference_Location);
 strcat(path,"LcFiles/");
 sprintf(final,"%s%s",path,Fn);
 if(ft=fopen(final,"r"))
 {
   fclose(ft); return(FAILURE);
 }
 }
//---------------- lcfiles checking finished
      x=1;
      sprintf(path,"DLPATH.%d",x++);  
	 while(GetFromConf(CN-1,path,path)) {
		    	strcpy(final,path);
			    strcat(final,Fn);
 			ft = fopen(final,"r");
	    		if(ft!=NULL) {  /* Found the file so return fail */
	    			if(ft) fclose(ft);
		    		return(FAILURE);
				}
            sprintf(path,"DLPATH.%d",x++);
		} 
 /*=== 11w add */
      x=1;
      sprintf(path,"ULPATH.%d",x++);
      while(GetFromConf(CN-1,path,path))
      {
			    strcpy(final,path);
			    strcat(final,Fn);
			    ft = fopen(final,"r");
			    if(ft!=NULL) {
				    if(ft) fclose(ft);
				    return(FAILURE);
			    }
sprintf(path,"ULPATH.%d",x++);
		    }
           
/*-- 11w end addition */
 return(SUCCESS);
}
