From 2004e086752a4baad39beb22c9721e79bf59d32b Mon Sep 17 00:00:00 2001 From: Florian Schulze Date: Sun, 17 Feb 2002 13:35:01 +0000 Subject: [PATCH] Added pack and unpack projects. --- VisualC6/jumpnbump.dsp | 19 +++- VisualC6/jumpnbump.dsw | 27 ++++++ VisualC6/pack/pack.dsp | 100 ++++++++++++++++++++ VisualC6/unpack/unpack.dsp | 100 ++++++++++++++++++++ modify/pack.c | 182 +++++++++++++++++++++---------------- modify/unpack.c | 7 +- 6 files changed, 354 insertions(+), 81 deletions(-) create mode 100644 VisualC6/pack/pack.dsp create mode 100644 VisualC6/unpack/unpack.dsp diff --git a/VisualC6/jumpnbump.dsp b/VisualC6/jumpnbump.dsp index 2298353..fa2974f 100644 --- a/VisualC6/jumpnbump.dsp +++ b/VisualC6/jumpnbump.dsp @@ -44,7 +44,6 @@ RSC=rc.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /GX /O2 /I "../" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "USE_SDL" /YX /FD /c -# SUBTRACT CPP /Z # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x407 /d "NDEBUG" @@ -56,6 +55,15 @@ LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDLmain.lib SDL.lib SDL_mixer.lib /nologo /subsystem:windows /machine:I386 # SUBTRACT LINK32 /debug +# Begin Custom Build +ProjDir=. +InputPath=.\Release\jumpnbump.exe +SOURCE="$(InputPath)" + +"$(ProjDir)\..\data\jumpbump.dat" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + call "$(ProjDir)\..\data\pack.bat" "$(ProjDir)\..\data" "..\VisualC6\pack\Release\pack.exe" + +# End Custom Build !ELSEIF "$(CFG)" == "jumpnbump - Win32 Debug" @@ -82,6 +90,15 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDLmain.lib SDL.lib SDL_mixer.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# Begin Custom Build +ProjDir=. +InputPath=.\Debug\jumpnbump.exe +SOURCE="$(InputPath)" + +"$(ProjDir)\..\data\jumpbump.dat" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + call "$(ProjDir)\..\data\pack.bat" "$(ProjDir)\..\data" "..\VisualC6\pack\Debug\pack.exe" + +# End Custom Build !ENDIF diff --git a/VisualC6/jumpnbump.dsw b/VisualC6/jumpnbump.dsw index 97b55b4..146faf8 100644 --- a/VisualC6/jumpnbump.dsw +++ b/VisualC6/jumpnbump.dsw @@ -9,6 +9,33 @@ Package=<5> {{{ }}} +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name pack + End Project Dependency +}}} + +############################################################################### + +Project: "pack"=.\pack\pack.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "unpack"=.\unpack\unpack.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + Package=<4> {{{ }}} diff --git a/VisualC6/pack/pack.dsp b/VisualC6/pack/pack.dsp new file mode 100644 index 0000000..b6a24c9 --- /dev/null +++ b/VisualC6/pack/pack.dsp @@ -0,0 +1,100 @@ +# Microsoft Developer Studio Project File - Name="pack" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=pack - Win32 Debug +!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "pack.mak". +!MESSAGE +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "pack.mak" CFG="pack - Win32 Debug" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "pack - Win32 Release" (basierend auf "Win32 (x86) Console Application") +!MESSAGE "pack - Win32 Debug" (basierend auf "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pack - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "pack - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "pack - Win32 Release" +# Name "pack - Win32 Debug" +# Begin Group "Quellcodedateien" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\..\modify\pack.c +# End Source File +# End Group +# Begin Group "Header-Dateien" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Ressourcendateien" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/VisualC6/unpack/unpack.dsp b/VisualC6/unpack/unpack.dsp new file mode 100644 index 0000000..1490f54 --- /dev/null +++ b/VisualC6/unpack/unpack.dsp @@ -0,0 +1,100 @@ +# Microsoft Developer Studio Project File - Name="unpack" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=unpack - Win32 Debug +!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "unpack.mak". +!MESSAGE +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "unpack.mak" CFG="unpack - Win32 Debug" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "unpack - Win32 Release" (basierend auf "Win32 (x86) Console Application") +!MESSAGE "unpack - Win32 Debug" (basierend auf "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "unpack - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "unpack - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "unpack - Win32 Release" +# Name "unpack - Win32 Debug" +# Begin Group "Quellcodedateien" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\..\modify\unpack.c +# End Source File +# End Group +# Begin Group "Header-Dateien" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Ressourcendateien" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/modify/pack.c b/modify/pack.c index 4f3d087..2f91bc1 100644 --- a/modify/pack.c +++ b/modify/pack.c @@ -4,106 +4,130 @@ #include #include #include +#ifndef _MSC_VER #include #include +#else +#include +typedef unsigned int u_int32_t; +#endif typedef struct { - char filename[12]; - u_int32_t offset; - u_int32_t size; + char filename[12]; + u_int32_t offset; + u_int32_t size; } DirEntry; int main(int argc, char **argv) { - int fd; - DirEntry *datafile; - int num_entries, i; - int c; - char *outfile = NULL; - int offset = 0; + int fd; + DirEntry *datafile; + int num_entries, i; + int c; + char *outfile = NULL; + int offset = 0; - while ((c = getopt(argc, argv, "o:")) != EOF) { - switch (c) { - case 'o': - if (optarg) { - outfile = strdup(optarg); +#ifndef _MSC_VER + while ((c = getopt(argc, argv, "o:")) != EOF) { + switch (c) { + case 'o': + if (optarg) { + outfile = strdup(optarg); + } + break; } - break; } - } - argc -= optind; - argv += optind; + argc -= optind; + argv += optind; +#else + c = 1; + while (c 12) { - fprintf(stderr, "filename %s is longer than 12 chars\n", argv[i]); - exit(1); + for (i = 0; i < num_entries; i++) { + struct stat dummy; + if (stat(argv[i], &dummy)) { + fprintf(stderr, "%s is not accessible: ", argv[i]); + perror(""); + exit(1); + } + if (strlen(argv[i]) > 12) { + fprintf(stderr, "filename %s is longer than 12 chars\n", argv[i]); + exit(1); + } + strncpy(datafile[i].filename, argv[i], 12); + datafile[i].size = dummy.st_size; + /* num_entries * (12 + 8) */ + datafile[i].offset = offset; + offset += datafile[i].size; } - strncpy(datafile[i].filename, argv[i], 12); - datafile[i].size = dummy.st_size; - /* num_entries * (12 + 8) */ - datafile[i].offset = offset; - offset += datafile[i].size; - } - /* here, we checked that all files are ok, and ready to roll the packfile */ - fd = open(outfile, O_RDWR | O_CREAT, 0644); - if (fd == -1) { - perror("opening packfile"); - exit(1); - } - printf("Opened %s\n", outfile); + /* here, we checked that all files are ok, and ready to roll the packfile */ + fd = open(outfile, O_RDWR | O_CREAT, 0644); + if (fd == -1) { + perror("opening packfile"); + exit(1); + } + printf("Opened %s\n", outfile); - /* write number of entries in this data file */ - write(fd, &num_entries, 4); + /* write number of entries in this data file */ + write(fd, &num_entries, 4); - /* write the directory structure */ - for (i = 0; i < num_entries; i++) { - write(fd, &datafile[i], 20); - } + /* write the directory structure */ + for (i = 0; i < num_entries; i++) { + write(fd, &datafile[i], 20); + } - /* write in the actual files */ - for (i = 0; i < num_entries; i++) { - int infd; - char *buf; + /* write in the actual files */ + for (i = 0; i < num_entries; i++) { + int infd; + char *buf; - printf("adding %s ", argv[i]); + printf("adding %s ", argv[i]); - infd = open(argv[i], O_RDONLY); - if (infd == -1) { - perror("opening file"); - exit(1); + infd = open(argv[i], O_RDONLY); + if (infd == -1) { + perror("opening file"); + exit(1); + } + buf = malloc(datafile[i].size + 16); + read(infd, buf, datafile[i].size); + close(infd); + write(fd, buf, datafile[i].size); + free(buf); + printf(" OK\n"); } - buf = malloc(datafile[i].size + 16); - read(infd, buf, datafile[i].size); - close(infd); - write(fd, buf, datafile[i].size); - free(buf); - printf(" OK\n"); - } - close(fd); - return 0; + close(fd); + return 0; } diff --git a/modify/unpack.c b/modify/unpack.c index 44a778d..76b7ed9 100644 --- a/modify/unpack.c +++ b/modify/unpack.c @@ -1,9 +1,14 @@ #include #include #include -#include #include #include +#ifndef _MSC_VER +#include +#else +#include +typedef unsigned int u_int32_t; +#endif typedef struct { char filename[12]; -- 2.39.2