mirror of
https://github.com/GnoConsortium/gno.git
synced 2024-06-08 20:29:44 +00:00
- 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
|
# 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
|
# Program name
|
||||||
|
@ -9,6 +9,18 @@ PROG = catrez
|
||||||
|
|
||||||
# Delivery directory
|
# Delivery directory
|
||||||
BINDIR = /usr/bin
|
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
|
.INCLUDE: /src/gno/prog.mk
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
catrez -- concatenate resource forks from files
|
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
|
DESCRIPTION
|
||||||
===========
|
===========
|
||||||
|
@ -16,11 +16,9 @@ See the man page for details.
|
||||||
INSTALLATION
|
INSTALLATION
|
||||||
============
|
============
|
||||||
|
|
||||||
Method 1:
|
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
|
||||||
dmake install
|
executable and manual files from this archive:
|
||||||
|
|
||||||
Method 2:
|
|
||||||
|
|
||||||
cp catrez /usr/local/bin
|
cp catrez /usr/local/bin
|
||||||
cp catrez.1 /usr/man/man1
|
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
|
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
|
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
|
minor formatting differences to the man page; and
|
||||||
addition of a describe entry.
|
addition of a describe entry.
|
||||||
(Devin Reade <gdr@eddore.myrias.com>)
|
(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.
|
v1.0.1 Resources with the "protected" attribute set were not copied correctly.
|
||||||
|
|
||||||
|
@ -70,12 +75,11 @@ the problem.
|
||||||
LEGAL
|
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
|
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
|
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
|
don't try to claim it for your own.
|
||||||
distributing the software.
|
|
||||||
|
|
||||||
For other distribution information, contact Dave Tribby <tribby@cup.hp.com>.
|
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
|
.SH NAME
|
||||||
catrez \- concatenate resource forks from files
|
catrez \- concatenate resource forks from files
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B catrez
|
.BR catrez " [" -av ]
|
||||||
[
|
.BI "-d " dest_file
|
||||||
.I -av
|
|
||||||
]
|
|
||||||
.RI "-d " dest_file
|
|
||||||
.I file1
|
.I file1
|
||||||
[
|
[
|
||||||
.IR file2 ...
|
.IR file2 ...
|
||||||
|
@ -69,3 +66,9 @@ version 1.0.2.
|
||||||
returns zero on success, non-zero otherwise.
|
returns zero on success, non-zero otherwise.
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
Dave Tribby <tribby@cup.hp.com>
|
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
|
* 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:
|
* where the options mean:
|
||||||
* -v verbose output
|
* -v verbose output
|
||||||
* -a append resources to destination rather than overwriting
|
* -a append resources to destination rather than overwriting
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
*
|
*
|
||||||
* Written by Dave Tribby (tribby@cup.hp.com) beginning 5-3-96
|
* 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,
|
dest_file_id = OpenResourceFile(noPreload+readWriteEnable,
|
||||||
NULL, (Pointer)dest_filename);
|
NULL, (Pointer)dest_filename);
|
||||||
if (error = toolerror()) {
|
if (error = toolerror()) {
|
||||||
printf(rezopenerr, error,dest_filename->text);
|
fprintf(stderr, rezopenerr, error,dest_filename->text);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ void CopyResources(char *fname)
|
||||||
|
|
||||||
/* Cannot proceed if resource fork wasn't opened */
|
/* Cannot proceed if resource fork wasn't opened */
|
||||||
if (error) {
|
if (error) {
|
||||||
printf(rezopenerr, error,fname);
|
fprintf(stderr, rezopenerr, error,fname);
|
||||||
status_return = 1;
|
status_return = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ void CopyResources(char *fname)
|
||||||
/* Load the resource */
|
/* Load the resource */
|
||||||
rez_handle = LoadResource(rez_type, rez_ID);
|
rez_handle = LoadResource(rez_type, rez_ID);
|
||||||
if (error = toolerror()) {
|
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);
|
error,rez_type,rez_ID,fname);
|
||||||
status_return = 1;
|
status_return = 1;
|
||||||
continue;
|
continue;
|
||||||
|
@ -325,7 +325,7 @@ void CopyResources(char *fname)
|
||||||
/* Add resource to destination file, ignoring "protected" attribute */
|
/* Add resource to destination file, ignoring "protected" attribute */
|
||||||
AddResource(rez_handle, rez_attr & ~resProtected, rez_type, rez_ID);
|
AddResource(rez_handle, rez_attr & ~resProtected, rez_type, rez_ID);
|
||||||
if (error = toolerror()) {
|
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);
|
error,rez_type,rez_ID);
|
||||||
status_return = 1;
|
status_return = 1;
|
||||||
}
|
}
|
||||||
|
@ -333,7 +333,7 @@ void CopyResources(char *fname)
|
||||||
/* Force it to disk */
|
/* Force it to disk */
|
||||||
WriteResource(rez_type, rez_ID);
|
WriteResource(rez_type, rez_ID);
|
||||||
if (error = toolerror()) {
|
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);
|
error,rez_type,rez_ID);
|
||||||
status_return = 1;
|
status_return = 1;
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,8 @@ void CopyResources(char *fname)
|
||||||
if (rez_attr & resProtected) {
|
if (rez_attr & resProtected) {
|
||||||
SetResourceAttr(rez_attr, rez_type, rez_ID);
|
SetResourceAttr(rez_attr, rez_type, rez_ID);
|
||||||
if (error = toolerror()) {
|
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);
|
error,rez_type,rez_ID);
|
||||||
status_return = 1;
|
status_return = 1;
|
||||||
}
|
}
|
||||||
|
@ -352,7 +353,7 @@ void CopyResources(char *fname)
|
||||||
/* Release the resource from memory */
|
/* Release the resource from memory */
|
||||||
ReleaseResource(-1, rez_type, rez_ID);
|
ReleaseResource(-1, rez_type, rez_ID);
|
||||||
if (error = toolerror()) {
|
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);
|
error,rez_type,rez_ID);
|
||||||
status_return = 1;
|
status_return = 1;
|
||||||
}
|
}
|
||||||
|
@ -377,14 +378,13 @@ static void report_stack(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
int main (int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
{
|
{
|
||||||
int p_num; /* Parameter number */
|
|
||||||
int destfileprovided = FALSE;
|
int destfileprovided = FALSE;
|
||||||
char *illegal_opt="Warning: Illegal option %s ignored\n";
|
int ch;
|
||||||
char *usage=
|
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__)
|
#if defined(__GNO__) && defined(__STACK_CHECK__)
|
||||||
_beginStackCheck();
|
_beginStackCheck();
|
||||||
|
@ -417,14 +417,11 @@ if (argc < 2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse the option parameters */
|
/* Parse the option parameters */
|
||||||
p_num = 1;
|
while ((ch = getopt(argc, argv, "avd:")) != EOF) {
|
||||||
while ((p_num < argc) && (argv[p_num][0] == '-') ) {
|
switch(ch) {
|
||||||
if (strlen(argv[p_num]) > 2)
|
|
||||||
printf(illegal_opt, argv[p_num]);
|
|
||||||
else switch ( argv[p_num][1] ) {
|
|
||||||
case 'v':
|
case 'v':
|
||||||
verboseflag = TRUE;
|
verboseflag = TRUE;
|
||||||
printf("%s: ", argv[0]);
|
printf("%s: ", *argv);
|
||||||
printf(prog_version, __DATE__);
|
printf(prog_version, __DATE__);
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
|
@ -432,31 +429,22 @@ while ((p_num < argc) && (argv[p_num][0] == '-') ) {
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
destfileprovided = TRUE;
|
destfileprovided = TRUE;
|
||||||
p_num++;
|
dest_filename = CtoGS(optarg);
|
||||||
if (p_num == argc) {
|
|
||||||
printf("Error: -d option requires a destination filename\n");
|
|
||||||
printf(usage);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
dest_filename = CtoGS(argv[p_num]);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
printf(illegal_opt, argv[p_num]);
|
|
||||||
}
|
}
|
||||||
p_num++;
|
|
||||||
}
|
}
|
||||||
|
argc -= optind;
|
||||||
|
argv = argv + optind;
|
||||||
|
|
||||||
if (!destfileprovided) {
|
if (!destfileprovided) {
|
||||||
printf("Error: No destination filename provided\n");
|
fprintf(stderr, "Error: No destination filename provided\n");
|
||||||
printf(usage);
|
fprintf(stderr, usage);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_num == argc) {
|
if (argc < 1) {
|
||||||
printf("Error: No source filenames provided\n");
|
fprintf(stderr, "Error: No source filenames provided\n");
|
||||||
printf(usage);
|
fprintf(stderr, usage);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,9 +458,8 @@ atexit(AllDone);
|
||||||
OpenDestination();
|
OpenDestination();
|
||||||
|
|
||||||
/* Open and copy each of the source files */
|
/* Open and copy each of the source files */
|
||||||
while ( (p_num < argc) && !user_break ) {
|
while ( (argc-- > 0) && !user_break ) {
|
||||||
CopyResources(argv[p_num]);
|
CopyResources(*argv++);
|
||||||
p_num++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cleanup is done in atexit() */
|
/* Cleanup is done in atexit() */
|
||||||
|
|
|
@ -2,26 +2,27 @@
|
||||||
* Resources for catrez version and comments
|
* Resources for catrez version and comments
|
||||||
* Written by Dave Tribby
|
* 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"
|
#include "Types.rez"
|
||||||
|
|
||||||
/* Version */
|
/* Version */
|
||||||
resource rVersion (1, $0000) {
|
resource rVersion (1, purgeable3) {
|
||||||
{1, 0, 2, release, 0},
|
{1, 0, 2, release, 0},
|
||||||
verUS,
|
verUS,
|
||||||
"catrez",
|
"catrez",
|
||||||
"Copyright 1996 by David M. Tribby"
|
"Concatenate resource forks. Released with GNO/ME"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Comment Templates */
|
/* Comment Templates */
|
||||||
|
|
||||||
resource rComment (1, $0000) {
|
resource rComment (1, purgeable3) {
|
||||||
"catrez v1.0.2\n"
|
"catrez v1.0.2 (September 1997)\n"
|
||||||
"Shell program to concatenate resource forks of files\n"
|
"Shell program to concatenate resource forks of files\n"
|
||||||
"by Dave Tribby\n"
|
"by Dave Tribby\n"
|
||||||
"Copyright 1996-1997\n\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
Block a user