home *** CD-ROM | disk | FTP | other *** search
- #include<stdio.h>
- #include<stdlib.h>
- #include<ctype.h>
- #include<string.h>
- #include <proto/FileID.h>
- #include <proto/dos.h>
- #include <proto/exec.h>
-
-
-
- main(int argc, char **argv)
- {
- char version[]="$VER: LZXCHECK/STRIP V1.0 ©1996 Joe Cool Date: 18.01.1996\n";
- struct FI_FileInfo *MyFileInfo=NULL;
- struct FileIDBase *FileIDBase=NULL;
- char buffer[200],
- *filename=NULL;
- BOOL file_ok=FALSE;
- BPTR readfh=NULL;
-
- printf ("\nLZXCHECK/STRIP V1.0 ©1996 Joe Cool\n");
-
-
- if(!(FileIDBase = (struct FileIDBase *)OpenLibrary("FileID.library",6L)))
- {
- printf ("Couldn`t open FileID.library\n");
- exit (RETURN_FAIL);
- }
- if(!(MyFileInfo = (struct FI_FileInfo *)FIAllocFileInfo()))
- {
- printf ("Can't allocate FI_FileInfo!\n");
- exit (RETURN_FAIL);
- }
- if (argc==1)
- {
- printf("Usage: LZXStrip <LZX-Archive>\n\n");
- exit (RETURN_FAIL);
- }
-
- if(FIIdentifyFromName((struct FI_FileInfo *)MyFileInfo,argv[1]))
- {
- printf("\"%s\" is does not exist!\n\n",argv[1]);
- exit (RETURN_FAIL);
- }
-
- if (MyFileInfo->FI_ID!=543)
- {
- printf("Not a LZX-Archive!\n\n");
- exit (RETURN_FAIL);
- }
- filename=strrchr(argv[1],'/');
- if (filename)
- {
- filename++;
- printf ("Processing file: %s\n",filename);
- }
- else printf ("Processing file: %s\n",argv[1]);
-
- printf("Testing....");
-
- readfh=Open("t:lzx.temp",MODE_NEWFILE);
- sprintf (buffer,"lzx t -mfl \"%s\"",argv[1]);
- Execute (buffer,NULL,readfh);
- Close (readfh);
- readfh=Open("t:lzx.temp",MODE_OLDFILE);
-
- while (FGets(readfh, buffer, 200) && (!file_ok))
- {
- if (strstr(buffer,"Operation successful")) file_ok=TRUE;
- }
- Close (readfh);
- DeleteFile("t:lzx.temp");
-
- if (!file_ok)
- {
- printf("corrupt!\n");
- }
- else
- {
- printf("ok!\n");
- printf("Stripping..not implemented yet\n");
-
- readfh=Open("t:lzx.temp",MODE_NEWFILE);
- sprintf (buffer,"lzx l -mfl \"%s\"",argv[1]);
- Execute (buffer,NULL,readfh);
- Close (readfh);
-
- Execute ("type t:lzx.temp",NULL,NULL);
-
-
-
-
-
- }
-
-
-
- if (file_ok) printf("\nFile is OK!\n");
- else
- {
- printf("\nFile is corrupt!\n");
- exit (RETURN_FAIL);
- }
-
- if(MyFileInfo) FIFreeFileInfo((struct FI_FileInfo *)MyFileInfo);
- if(FileIDBase) CloseLibrary((struct Library *)FileIDBase);
-
-
-
- }
-