2 Copyright (C) 1998 BJ Eirich (aka vecna)
\r
3 This program is free software; you can redistribute it and/or
\r
4 modify it under the terms of the GNU General Public License
\r
5 as published by the Free Software Foundation; either version 2
\r
6 of the License, or (at your option) any later version.
\r
7 This program is distributed in the hope that it will be useful,
\r
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
\r
10 See the GNU General Public Lic
\r
11 See the GNU General Public License for more details.
\r
12 You should have received a copy of the GNU General Public License
\r
13 along with this program; if not, write to the Free Software
\r
14 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
\r
20 #define byte unsigned char
\r
21 // ================================= Data ====================================
\r
25 char strbuf[2048],*filebuf;
\r
27 char headertag[]={ 'V','R','G','P','A','C','K',0 };
\r
31 unsigned char fname[84]; // pathname thingo
\r
32 int size; // size of the file
\r
33 int packofs; // where the file can be found in PACK
\r
34 int count; // internal (engine-runtime) use
\r
35 char extractable; // can UNPACK .. unpack it?
\r
36 char override; // should the engine override it w/
\r
40 struct filestruct filetbl[512];
\r
42 // ================================= Code ====================================
\r
44 void DecryptHeader()
\r
45 { byte lastvalue, precodebyte, *ptr;
\r
47 ptr=(byte *) filetbl;
\r
51 while (ptr < (byte *) (int) filetbl + (int) 5120)
\r
55 lastvalue=precodebyte;
\r
60 void CheckPackHeader()
\r
63 fread(strbuf, 1, 7, pack);
\r
65 if (strcmp(strbuf,headertag))
\r
67 printf("*error* Not a valid VRG packfile. \n");
\r
70 fread(&a, 1, 1, pack);
\r
73 printf("*error* Incorrect VRG packfile version. \n");
\r
76 fread(&numfiles, 1, 4, pack);
\r
77 fread(&filetbl, 100, numfiles, pack);
\r
84 printf("UNPACK v.0.1 Copyright (C)1997 BJ Eirich\n");
\r
85 for (i=0; i<numfiles; i++)
\r
87 filebuf=(char *) malloc(filetbl[i].size);
\r
88 fread(filebuf, 1, filetbl[i].size, pack);
\r
89 if (filetbl[i].extractable)
\r
91 src=fopen(filetbl[i].fname, "wb");
\r
92 printf("File: %s \n",filetbl[i].fname);
\r
93 fwrite(filebuf, 1, filetbl[i].size, src);
\r
96 else printf("File: %s unexctractable.\n",filetbl[i].fname);
\r
101 int main(int argc, char *argv[])
\r
105 printf("UNPACK v.0.1 Copyright (C)1997 BJ Eirich \n");
\r
106 printf("USAGE: UNPACK <VRG packfile> \n");
\r
110 if (!(pack=fopen(argv[1],"rb")))
\r
112 printf("Unable to open file %s. \n",argv[1]);
\r