home *** CD-ROM | disk | FTP | other *** search
- #define PROGNAME "Filecheck" /***/
-
- #include "aedoor.h"
- #include"bbs:bgcheck/bgcheck.h"
- #include "env:timedate.h"
-
-
- static const char VersionTag[] = "\0$VER: "PROGNAME" "REVISION" "REVDATE" "REVTIME;
-
- void Start(int node);
- void main(int argc, char *argv[])
- {
- int Node=0;
-
- if (argc<2) {printf("Sorry, %s must be called from S!X or /X\n",argv[0]);exit(0);}
- Node=atoi(argv[1]);
- Register(Node);
- XIM_Msg->Command=140;
- CheckMessage();
- SetTaskPri(FindTask(0),atol(XIM_Msg->String));
- Start(Node);
- ShutDown();
- }
- void Start(Node)
- {
-
- char buffer[255]="",
- file[255]="",
- filepath[255]="",
- **main_config=NULL,
- *p=NULL;
- BPTR readfh=NULL;
- ULONG len=0,
- pos=0;
- struct Filedata *filedata=NULL;
- BOOL msgbase=FALSE;
-
- SendStrDataCmd(BB_MAINLINE,"",1);
- strcpy(buffer,XIM_Msg->String);
-
- p=strchr(buffer,' ');
- strcpy(file,p+1);
- upperstring(file);
-
- sprintf(buffer,"FC: %s",file);
- SendStrDataCmd(177,buffer,0);
-
- Forbid();
- filedata=(struct Filedata *)FindSemaphore(file);
- Permit();
-
- if (filedata)
- {
- ObtainSemaphore((struct SignalSemaphore *)filedata);
- if (filedata->MsgBase) msgbase=TRUE;
- strcpy(filepath,filedata->filepath);
- ReleaseSemaphore((struct SignalSemaphore *)filedata);
-
- main_config=(char **)realloc(main_config,sizeof(char *));
- main_config[0]=NULL;
-
- strcpy(buffer,"bbs:bgcheck/bgfilehandler.config");
- readfh=Open(buffer,MODE_OLDFILE);
- pos=0;
- if (!readfh && pos!=60)
- {
- pos++;
- readfh=Open(buffer,MODE_OLDFILE);
- if (!readfh) Delay(TICKS_PER_SECOND);
- }
- if (readfh)
- {
- for (pos=0;FGets(readfh,buffer,254);pos++)
- {
- main_config=(char **) realloc(main_config,(pos+1)*sizeof(char *));
- main_config[pos]=NULL;
- len=strlen(buffer);
- if (buffer[len-1]=='\n') buffer[--len]='\0';
- upperstring(buffer);
- main_config[pos]=(char *) malloc (len+1);
- if (main_config[pos]) strcpy(main_config[pos],buffer);
- }
- }
- if (readfh) Close(readfh);
- main_config=(char **) realloc(main_config,(pos+1)*sizeof(char *));
- main_config[pos]=NULL;
-
- pos=0;
- sprintf(buffer,"FILECHECK.%d",pos);
- while (p=getconfig(main_config,buffer))
- {
- if (p[0]!=0)
- {
- sprintf(buffer,"%s %d",p,Node);
- System(buffer,NULL);
- }
- pos++;
- sprintf(buffer,"FILECHECK.%d",pos);
- }
-
-
- for (pos=0;main_config[pos]!=NULL;pos++)
- free(main_config[pos]);
- if (main_config) free (main_config);
-
- RemSemaphore((struct SignalSemaphore *)filedata);
- ObtainSemaphore((struct SignalSemaphore *)filedata);
- ReleaseSemaphore((struct SignalSemaphore *)filedata);
- FreeMem(filedata,sizeof(struct Filedata));
- }
-
- if (!msgbase)
- {
- sprintf(buffer,"%s%s",filepath,file);
- DeleteFile(buffer);
- SendDataCmd(DT_GOODFILE,3);
- }
- }
-