From a116529db138f1cc60a5f176e7a486a1946911d3 Mon Sep 17 00:00:00 2001 From: Jeff Teunissen Date: Sat, 25 May 2002 02:47:53 +0000 Subject: [PATCH] pak tool: Re-add the -f option and clean up the man page. --- tools/pak/pak.1 | 35 +++++++++++++++++++++++++++-------- tools/pak/pak.c | 26 +++++++++++++++++++------- 2 files changed, 46 insertions(+), 15 deletions(-) diff --git a/tools/pak/pak.1 b/tools/pak/pak.1 index e4c7558ce..2dc4ce8ba 100644 --- a/tools/pak/pak.1 +++ b/tools/pak/pak.1 @@ -34,7 +34,7 @@ pak \- The QuakeForge Packfile Tool .SH SYNOPSIS .B pak -<\fIcommand\fP> [\fIoption\fP]... \fIARCHIVE\fP \fIFILE\fP... +<\fBcommand\fP> [\fBoptions\fP] \fIARCHIVE\fP \fIFILE\fP... .SH DESCRIPTION \fBpak\fP is a utility for managing pack (*.pak) archives. The format used is compatible with Quake and Quake II. Pak archives are a convenient way to store @@ -45,7 +45,7 @@ internally. used at a time. .TP .B \-c, \-\-create -Create an archive. Overwrites any contents. +Create an archive. Overwrites any contents the archive may have had. .TP .B \-t, \-\-test Test an archive for valid formatting. @@ -62,18 +62,37 @@ Show the version of pak. .SH OPTIONS \fBpak\fP takes the following arguments as options. .TP +.B \-f, \-\-file ARCHIVE +Use ARCHIVE as the archive filename, instead of the first non-option argument. +This option is provided for compatibility with older versions of \fBpak\fP. +.TP .B \-p, \-\-pad Can be useful when creating an archive. File space is padded to a 4\-byte -boundary, assisting in the speed of loading files from the archive. +boundary, assisting in the speed of loading files from the archive. The file +data itself is not changed. .TP .B \-q, \-\-quiet Inhibit some of pak's normal output. .TP .B \-v, \-\-verbose Display more output than usual. -.SH "SEE ALSO" -.BR quakeforge (1) +.SH "EXIT STATUS" +\fBpak\fP returns a zero exit status when it has completed a command +successfully (without error). Otherwise, it returns a non-zero exit status. +.SH BUGS +.PP +The program does not currently handle compression or decompression. This +is planned for a future version. +.PP +The program does not currently handle extraction of individual files inside an +archive. This is planned for a future version. +.PP +The program cannot modify an archive once it has been created. .SH AUTHORS -\fBpak\fP was written by Bill Currie for QuakeForge. -Jeff Teunissen has also work on it, mostly in the -interface. +Bill Currie (taniwha@quakeforge.net) wrote most of the program. +.PP +Jeff Teunissen (deek@quakeforge.net) wrote the command-line interface and the +documentation. +.SH "SEE ALSO" +.BR quakeforge (1), +.BR qfcc (1) diff --git a/tools/pak/pak.c b/tools/pak/pak.c index c066e6119..f690be163 100644 --- a/tools/pak/pak.c +++ b/tools/pak/pak.c @@ -32,6 +32,14 @@ static const char rcsid[] = # include "config.h" #endif +#ifdef HAVE_STRING_H +# include +#endif + +#ifdef HAVE_STRINGS_H +# include +#endif + #include #include #include @@ -61,7 +69,7 @@ static void usage (int status) { printf ("%s - QuakeForge Packfile tool\n", this_program); - printf ("Usage: %s [options] ARCHIVE FILE [FILE ...]\n", + printf ("Usage: %s [options] ARCHIVE [FILE...]\n", this_program); printf ("Commands:\n" @@ -72,6 +80,7 @@ usage (int status) " -V, --version Output version information and exit\n\n"); printf ("Options:\n" + " -f, --file ARCHIVE Use ARCHIVE for archive filename\n" " -p, --pad Pad file space to a 32-bit boundary\n" " -q, --quiet Inhibit usual output\n" " -v, --verbose Display more output than usual\n"); @@ -93,7 +102,7 @@ decode_args (int argc, char **argv) "x" // extract archive contents "h" // show help "V" // show version -// "f:" // filename + "f:" // filename "p" // pad "q" // quiet "v" // verbose @@ -115,6 +124,9 @@ decode_args (int argc, char **argv) case 'x': // extract options.mode = mo_extract; break; + case 'f': // set filename + options.packfile = strdup (optarg); + break; case 'q': // lower verbosity options.verbosity--; break; @@ -129,7 +141,7 @@ decode_args (int argc, char **argv) } } - if (argv[optind] && *(argv[optind])) + if ((!options.packfile) && argv[optind] && *(argv[optind])) options.packfile = strdup (argv[optind++]); return optind; @@ -146,9 +158,9 @@ main (int argc, char **argv) decode_args (argc, argv); if (!options.packfile) { - fprintf (stderr, "%s: no archive file specified, giving up.\n", + fprintf (stderr, "%s: no archive file specified.\n", this_program); - return 1; + usage (1); } switch (options.mode) { @@ -198,9 +210,9 @@ main (int argc, char **argv) pack_close (pack); break; default: - fprintf (stderr, "%s: No command given, bailing out.\n", + fprintf (stderr, "%s: No command given.\n", this_program); - return 1; + usage (1); } return 0; }