mirror of https://github.com/GnoConsortium/gno.git
- use getopts to parse parameters (so that -av works like -a -v)
- print error messages on stderr instead of stdout - change man page to use bold font in a couple of places and add history - update other documentation to reflect changes in making catrez part of the standard GNO release - added test cases in "tests" directory
This commit is contained in:
parent
22929ce3a8
commit
c7a0146f19
|
@ -1,7 +1,7 @@
|
|||
#
|
||||
# This makefile is intended for use with dmake(1) on Apple IIGS
|
||||
#
|
||||
# $Id: Makefile,v 1.2 1997/09/26 06:30:33 gdr Exp $
|
||||
# $Id: Makefile,v 1.3 1997/09/30 05:14:47 gdr Exp $
|
||||
#
|
||||
|
||||
# Program name
|
||||
|
@ -9,6 +9,18 @@ PROG = catrez
|
|||
|
||||
# Delivery directory
|
||||
BINDIR = /usr/bin
|
||||
STACK = 768
|
||||
|
||||
# If optimization wasn't set on the command line use 95, since
|
||||
# catrez has been tested to work at that level.
|
||||
.IF $(OPTIMIZE) == $(NULL)
|
||||
OPTIMIZE=95
|
||||
.END
|
||||
|
||||
# If stack size wasn't set on the command line use 1024, since
|
||||
# catrez has been tested to work at that size.
|
||||
.IF $(STACK) == $(NULL)
|
||||
STACK = 1024
|
||||
.END
|
||||
|
||||
|
||||
.INCLUDE: /src/gno/prog.mk
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
catrez -- concatenate resource forks from files
|
||||
|
||||
$Id: README,v 1.2 1997/09/26 06:31:15 gdr Exp $
|
||||
$Id: README,v 1.3 1997/09/30 05:14:47 gdr Exp $
|
||||
|
||||
DESCRIPTION
|
||||
===========
|
||||
|
@ -16,11 +16,9 @@ See the man page for details.
|
|||
INSTALLATION
|
||||
============
|
||||
|
||||
Method 1:
|
||||
|
||||
dmake install
|
||||
|
||||
Method 2:
|
||||
catrez is distributed with GNO version 2.0.6, so it should already be
|
||||
included in your /usr/bin directory. If it isn't, you can copy the
|
||||
executable and manual files from this archive:
|
||||
|
||||
cp catrez /usr/local/bin
|
||||
cp catrez.1 /usr/man/man1
|
||||
|
@ -30,7 +28,11 @@ OTHER FILES
|
|||
===========
|
||||
|
||||
The ORCA/C source file for catrez is included (catrez.c), as well as the
|
||||
REZ source code (version.rez) and the "dmake" file (makefile.mk).
|
||||
REZ source code (catrez.rez), the "dmake" file (Makefile), and the
|
||||
"describe" data base entry (catrez.desc).
|
||||
|
||||
Note: Makefile invokes the standard GNO program makefile /src/gno/prog.mk
|
||||
|
||||
|
||||
CHANGES
|
||||
=======
|
||||
|
@ -43,6 +45,9 @@ v1.0.2 catrez was incorporated into the GNO base distribution. Changes
|
|||
minor formatting differences to the man page; and
|
||||
addition of a describe entry.
|
||||
(Devin Reade <gdr@eddore.myrias.com>)
|
||||
print error messages on stderr instead of stdout
|
||||
use standard parsing of command-line options
|
||||
(Dave Tribby <tribby@cup.hp.com>)
|
||||
|
||||
v1.0.1 Resources with the "protected" attribute set were not copied correctly.
|
||||
|
||||
|
@ -70,12 +75,11 @@ the problem.
|
|||
LEGAL
|
||||
=====
|
||||
|
||||
Copyright 1996 by David M. Tribby
|
||||
Copyright 1996-97 by David M. Tribby
|
||||
|
||||
This software is provided as freeware (not public domain). You may distribute
|
||||
it as long as you don't charge money for it (beyond your media costs), and you
|
||||
don't try to claim it for your own. You must also keep this archive intact when
|
||||
distributing the software.
|
||||
don't try to claim it for your own.
|
||||
|
||||
For other distribution information, contact Dave Tribby <tribby@cup.hp.com>.
|
||||
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
.\"
|
||||
.\" $Id: catrez.1,v 1.2 1997/09/26 06:29:55 gdr Exp $
|
||||
.\" $Id: catrez.1,v 1.3 1997/09/30 05:14:47 gdr Exp $
|
||||
.\"
|
||||
.TH catrez 1 "25 September 1996" GNO "Commands and Applications"
|
||||
.TH catrez 1 "September 1997" GNO "Commands and Applications"
|
||||
.SH NAME
|
||||
catrez \- concatenate resource forks from files
|
||||
.SH SYNOPSIS
|
||||
.B catrez
|
||||
[
|
||||
.I -av
|
||||
]
|
||||
.RI "-d " dest_file
|
||||
.BR catrez " [" -av ]
|
||||
.BI "-d " dest_file
|
||||
.I file1
|
||||
[
|
||||
.IR file2 ...
|
||||
|
@ -69,3 +66,9 @@ version 1.0.2.
|
|||
returns zero on success, non-zero otherwise.
|
||||
.SH AUTHOR
|
||||
Dave Tribby <tribby@cup.hp.com>
|
||||
.SH HISTORY
|
||||
Version 1.0 was released as an independent utility compatible with
|
||||
GNO in July 1996. Version 1.0.1, released in November 1996, fixed a
|
||||
problem with "protected" attributes. Version 1.0.2 was updated
|
||||
in September 1997 to use GNO 2.0.6 headers, libraries, and coding
|
||||
conventions, and released as part of GNO 2.0.6.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Concatenate resources multiple files into the resource fork of a file
|
||||
*
|
||||
* catrez [-v] [-a] -d destfile file1 [file2 ... ]
|
||||
* catrez [-va] -d destfile file1 [file2 ... ]
|
||||
* where the options mean:
|
||||
* -v verbose output
|
||||
* -a append resources to destination rather than overwriting
|
||||
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
* Written by Dave Tribby (tribby@cup.hp.com) beginning 5-3-96
|
||||
*
|
||||
* $Id: catrez.c,v 1.2 1997/09/26 06:32:43 gdr Exp $
|
||||
* $Id: catrez.c,v 1.3 1997/09/30 05:14:48 gdr Exp $
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
@ -225,7 +225,7 @@ Word OpenDestination(void)
|
|||
dest_file_id = OpenResourceFile(noPreload+readWriteEnable,
|
||||
NULL, (Pointer)dest_filename);
|
||||
if (error = toolerror()) {
|
||||
printf(rezopenerr, error,dest_filename->text);
|
||||
fprintf(stderr, rezopenerr, error,dest_filename->text);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ void CopyResources(char *fname)
|
|||
|
||||
/* Cannot proceed if resource fork wasn't opened */
|
||||
if (error) {
|
||||
printf(rezopenerr, error,fname);
|
||||
fprintf(stderr, rezopenerr, error,fname);
|
||||
status_return = 1;
|
||||
return;
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ void CopyResources(char *fname)
|
|||
/* Load the resource */
|
||||
rez_handle = LoadResource(rez_type, rez_ID);
|
||||
if (error = toolerror()) {
|
||||
printf("\nError %04X loading type %04X, ID %lX, file %s\n",
|
||||
fprintf(stderr, "\nError %04X loading type %04X, ID %lX, file %s\n",
|
||||
error,rez_type,rez_ID,fname);
|
||||
status_return = 1;
|
||||
continue;
|
||||
|
@ -325,7 +325,7 @@ void CopyResources(char *fname)
|
|||
/* Add resource to destination file, ignoring "protected" attribute */
|
||||
AddResource(rez_handle, rez_attr & ~resProtected, rez_type, rez_ID);
|
||||
if (error = toolerror()) {
|
||||
printf("\nError %04X adding type %04X, ID %lX\n",
|
||||
fprintf(stderr, "\nError %04X adding type %04X, ID %lX\n",
|
||||
error,rez_type,rez_ID);
|
||||
status_return = 1;
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ void CopyResources(char *fname)
|
|||
/* Force it to disk */
|
||||
WriteResource(rez_type, rez_ID);
|
||||
if (error = toolerror()) {
|
||||
printf("\nError %04X writing type %04X, ID %lX\n",
|
||||
fprintf(stderr, "\nError %04X writing type %04X, ID %lX\n",
|
||||
error,rez_type,rez_ID);
|
||||
status_return = 1;
|
||||
}
|
||||
|
@ -342,7 +342,8 @@ void CopyResources(char *fname)
|
|||
if (rez_attr & resProtected) {
|
||||
SetResourceAttr(rez_attr, rez_type, rez_ID);
|
||||
if (error = toolerror()) {
|
||||
printf("\nError %04X setting attributes for type %04X, ID %lX\n",
|
||||
fprintf(stderr,
|
||||
"\nError %04X setting attributes for type %04X, ID %lX\n",
|
||||
error,rez_type,rez_ID);
|
||||
status_return = 1;
|
||||
}
|
||||
|
@ -352,7 +353,7 @@ void CopyResources(char *fname)
|
|||
/* Release the resource from memory */
|
||||
ReleaseResource(-1, rez_type, rez_ID);
|
||||
if (error = toolerror()) {
|
||||
printf("\nError %04X releasing type %04X, ID %X\n",
|
||||
fprintf(stderr, "\nError %04X releasing type %04X, ID %X\n",
|
||||
error,rez_type,rez_ID);
|
||||
status_return = 1;
|
||||
}
|
||||
|
@ -377,14 +378,13 @@ static void report_stack(void)
|
|||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
int main (int argc, char **argv)
|
||||
int main(int argc, char **argv)
|
||||
/*----------------------------------------------------------------------*/
|
||||
{
|
||||
int p_num; /* Parameter number */
|
||||
int destfileprovided = FALSE;
|
||||
char *illegal_opt="Warning: Illegal option %s ignored\n";
|
||||
int ch;
|
||||
char *usage=
|
||||
"Usage:\n\tcatrez [-v] [-a] -d dest_file file1 [file2 ...]\n";
|
||||
"Usage:\n\tcatrez [-va] -d dest_file file1 [file2 ...]\n";
|
||||
|
||||
#if defined(__GNO__) && defined(__STACK_CHECK__)
|
||||
_beginStackCheck();
|
||||
|
@ -417,14 +417,11 @@ if (argc < 2) {
|
|||
}
|
||||
|
||||
/* Parse the option parameters */
|
||||
p_num = 1;
|
||||
while ((p_num < argc) && (argv[p_num][0] == '-') ) {
|
||||
if (strlen(argv[p_num]) > 2)
|
||||
printf(illegal_opt, argv[p_num]);
|
||||
else switch ( argv[p_num][1] ) {
|
||||
while ((ch = getopt(argc, argv, "avd:")) != EOF) {
|
||||
switch(ch) {
|
||||
case 'v':
|
||||
verboseflag = TRUE;
|
||||
printf("%s: ", argv[0]);
|
||||
printf("%s: ", *argv);
|
||||
printf(prog_version, __DATE__);
|
||||
break;
|
||||
case 'a':
|
||||
|
@ -432,31 +429,22 @@ while ((p_num < argc) && (argv[p_num][0] == '-') ) {
|
|||
break;
|
||||
case 'd':
|
||||
destfileprovided = TRUE;
|
||||
p_num++;
|
||||
if (p_num == argc) {
|
||||
printf("Error: -d option requires a destination filename\n");
|
||||
printf(usage);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
dest_filename = CtoGS(argv[p_num]);
|
||||
}
|
||||
dest_filename = CtoGS(optarg);
|
||||
break;
|
||||
default:
|
||||
printf(illegal_opt, argv[p_num]);
|
||||
}
|
||||
p_num++;
|
||||
}
|
||||
argc -= optind;
|
||||
argv = argv + optind;
|
||||
|
||||
if (!destfileprovided) {
|
||||
printf("Error: No destination filename provided\n");
|
||||
printf(usage);
|
||||
fprintf(stderr, "Error: No destination filename provided\n");
|
||||
fprintf(stderr, usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (p_num == argc) {
|
||||
printf("Error: No source filenames provided\n");
|
||||
printf(usage);
|
||||
if (argc < 1) {
|
||||
fprintf(stderr, "Error: No source filenames provided\n");
|
||||
fprintf(stderr, usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -470,9 +458,8 @@ atexit(AllDone);
|
|||
OpenDestination();
|
||||
|
||||
/* Open and copy each of the source files */
|
||||
while ( (p_num < argc) && !user_break ) {
|
||||
CopyResources(argv[p_num]);
|
||||
p_num++;
|
||||
while ( (argc-- > 0) && !user_break ) {
|
||||
CopyResources(*argv++);
|
||||
}
|
||||
|
||||
/* Cleanup is done in atexit() */
|
||||
|
|
|
@ -2,26 +2,27 @@
|
|||
* Resources for catrez version and comments
|
||||
* Written by Dave Tribby
|
||||
*
|
||||
* $Id: catrez.rez,v 1.1 1997/09/26 06:31:47 gdr Exp $
|
||||
* $Id: catrez.rez,v 1.2 1997/09/30 05:14:48 gdr Exp $
|
||||
*/
|
||||
|
||||
#include "Types.rez"
|
||||
|
||||
/* Version */
|
||||
resource rVersion (1, $0000) {
|
||||
resource rVersion (1, purgeable3) {
|
||||
{1, 0, 2, release, 0},
|
||||
verUS,
|
||||
"catrez",
|
||||
"Copyright 1996 by David M. Tribby"
|
||||
"Concatenate resource forks. Released with GNO/ME"
|
||||
};
|
||||
|
||||
|
||||
/* Comment Templates */
|
||||
|
||||
resource rComment (1, $0000) {
|
||||
"catrez v1.0.2\n"
|
||||
resource rComment (1, purgeable3) {
|
||||
"catrez v1.0.2 (September 1997)\n"
|
||||
"Shell program to concatenate resource forks of files\n"
|
||||
"by Dave Tribby\n"
|
||||
"Copyright 1996-1997\n\n"
|
||||
"Freeware: Distribute freely, but don't charge."
|
||||
"Freeware: Distribute freely, but don't charge.\n"
|
||||
"Distributed with GNO/ME."
|
||||
};
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* Resources for catrez version and comments
|
||||
* Written by Dave Tribby
|
||||
*/
|
||||
|
||||
#include ":H1:Orca:Libraries:Rinclude:Types.rez"
|
||||
|
||||
// Version
|
||||
resource rVersion (1, $0000) {
|
||||
{1, 0, 1, release, 0},
|
||||
verUS,
|
||||
"catrez",
|
||||
"Copyright 1996 by David M. Tribby"
|
||||
};
|
||||
|
||||
|
||||
// Comment Templates
|
||||
|
||||
resource rComment (1, $0000) {
|
||||
"catrez v1.0.1\n"
|
||||
"Shell program to concatenate resource forks of files\n"
|
||||
"by Dave Tribby\n"
|
||||
"Copyright 1996\n\n"
|
||||
"Freeware: Distribute freely, but don't charge."
|
||||
};
|
Loading…
Reference in New Issue