mirror of
https://github.com/GnoConsortium/gno.git
synced 2025-02-24 07:28:58 +00:00
initial checkin as provided by Evan Day, except for:
- fixed up some rcs identifiers - fixed up some formatting in the man page
This commit is contained in:
parent
8056066083
commit
e713312837
32
bin/chtyp/Makefile
Normal file
32
bin/chtyp/Makefile
Normal file
@ -0,0 +1,32 @@
|
||||
#
|
||||
# This makefile is intended for use with dmake(1) on Apple IIGS
|
||||
#
|
||||
# Created by Dave Tribby, August 1997
|
||||
# Modified by Evan Day, September 1997
|
||||
#
|
||||
# $Id: Makefile,v 1.1 1997/10/03 05:06:50 gdr Exp $
|
||||
|
||||
# Program name
|
||||
PROG= chtyp
|
||||
# Source files
|
||||
SRCS= chtyp.c ftypes.c
|
||||
|
||||
# If optimization wasn't set on the command line use 79, since
|
||||
# chtyp has been tested to work at that level.
|
||||
.IF $(OPTIMIZE) == $(NULL)
|
||||
OPTIMIZE=79
|
||||
.END
|
||||
|
||||
# Current implementation is using 960 bytes give or take
|
||||
STACK = 1024
|
||||
|
||||
# Installation point
|
||||
BINDIR = /bin
|
||||
|
||||
.INCLUDE : /src/gno/prog.mk
|
||||
|
||||
#
|
||||
# Additional dependancies
|
||||
#
|
||||
chtyp.o:: ftypes.h
|
||||
ftypes.o:: ftypes.h
|
72
bin/chtyp/chtyp.1
Normal file
72
bin/chtyp/chtyp.1
Normal file
@ -0,0 +1,72 @@
|
||||
.\"
|
||||
.\" $Id: chtyp.1,v 1.1 1997/10/03 05:06:50 gdr Exp $
|
||||
.\"
|
||||
.TH CHTYP 1 "28 September 1997" GNO "Commands and Applications"
|
||||
.SH NAME
|
||||
.BR chtyp
|
||||
\- change GS/OS file type information
|
||||
.SH SYNOPSIS
|
||||
.BR chtyp
|
||||
[ [
|
||||
.IR -t " " ftype
|
||||
] [
|
||||
.IR -a " " atype
|
||||
] ] | [
|
||||
.IR -l " " lang
|
||||
]
|
||||
.IR file ...
|
||||
.SH DESCRIPTION
|
||||
Set GS/OS file type information for the specified
|
||||
.IR files
|
||||
.LP
|
||||
File types may be specified either as a number (decimal,
|
||||
hexadecimal with a leading 0x, or octal with a leading 0)
|
||||
or by a three letter abbreviation. Abbreviations are from
|
||||
the official File Type Notes Index.
|
||||
.LP
|
||||
Auxilary types may only be specified as a number (decimal,
|
||||
hexadecimal, or octal).
|
||||
.LP
|
||||
If a file type is specified with no aux type, or vice versa,
|
||||
only the specified parameter is changed - the other is left
|
||||
as is.
|
||||
.LP
|
||||
The language option sets the file type and aux type appropriate
|
||||
for a source file of the specified language. See below for a
|
||||
list of valid languages.
|
||||
.SH OPTIONS
|
||||
The following options are available:
|
||||
.IP "\fB-t\fR \fIftype\fR"
|
||||
Set the file type of the indicated files to the specified
|
||||
.IR ftype "."
|
||||
The file type may be specified as a number (in decimal, as a
|
||||
hexadecimal number with a leading 0x, or as an octal number
|
||||
with a leading 0) or by one of the official three letter
|
||||
abbreviations listed in the File Type Notes Index. Types set
|
||||
by abbreviation may not have their auxilary file types set
|
||||
due to the large variety of assigned auxilary types for each
|
||||
file type.
|
||||
.IP "\fB-a\fR \fIatype\fR"
|
||||
Set the auxilary file type of the indicated files to the
|
||||
.IR atype
|
||||
specified. The auxilary type may only be specified as a
|
||||
number.
|
||||
.IP "\fB-l\fR \fIlang\fR"
|
||||
Set the file type and auxilary file type to that of a source
|
||||
file of the selected
|
||||
.IR lang "."
|
||||
The
|
||||
.IR -l
|
||||
flag may not be used with the
|
||||
.IR -t
|
||||
or
|
||||
.IR -a
|
||||
flags.
|
||||
.IP
|
||||
Valid language types are: APWTXT, ASM, PASCAL, EXEC, CC, LINKER,
|
||||
DESKTOP, REZ, TMLPASCAL, DISASM, SDEASM, SDECMD, PS.
|
||||
.SH HISTORY
|
||||
.BR chtyp
|
||||
was originally written by Greg Thompson. Jawaid Bazyar rewrote it
|
||||
later for GNO/ME, and it has since been rewritten from scratch for
|
||||
GNO/ME v2.0.6 by Evan Day <day@engr.orst.edu>.
|
145
bin/chtyp/chtyp.c
Normal file
145
bin/chtyp/chtyp.c
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* chtyp
|
||||
*
|
||||
* Sets the file/aux type for GS/OS files.
|
||||
*
|
||||
* $Id: chtyp.c,v 1.1 1997/10/03 05:06:50 gdr Exp $
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gsos.h>
|
||||
|
||||
#include "ftypes.h"
|
||||
|
||||
void usage(void);
|
||||
void version(void);
|
||||
|
||||
#ifdef __STACK_CHECK__
|
||||
#include <gno/gno.h>
|
||||
|
||||
static void cleanup(void)
|
||||
{
|
||||
(void) fprintf(stderr, "Stack Usage: %d.\n", _endStackCheck());
|
||||
}
|
||||
#endif
|
||||
|
||||
static GSString255 path;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *ftype = NULL;
|
||||
char *atype = NULL;
|
||||
char *lang = NULL;
|
||||
char *left = NULL;
|
||||
int filet = -1;
|
||||
long auxt = -1;
|
||||
int ch;
|
||||
FileInfoRecGS finfo = {4, &path};
|
||||
|
||||
#ifdef __STACK_CHECK__
|
||||
atexit(cleanup);
|
||||
_beginStackCheck();
|
||||
#endif
|
||||
|
||||
while((ch = getopt(argc, argv, "t:a:l:vV")) != -1)
|
||||
switch(ch) {
|
||||
case 't':
|
||||
if(lang) {
|
||||
(void) fprintf(stderr,
|
||||
"chtyp: -t cannot be used with -l\n");
|
||||
usage();
|
||||
}
|
||||
ftype = optarg;
|
||||
break;
|
||||
case 'a':
|
||||
if(lang) {
|
||||
(void) fprintf(stderr,
|
||||
"chtyp: -a cannot be used with -l\n");
|
||||
usage();
|
||||
}
|
||||
atype = optarg;
|
||||
break;
|
||||
case 'l':
|
||||
if(ftype || atype) {
|
||||
(void) fprintf(stderr,
|
||||
"chtyp: -l cannot be used with %s%s\n",
|
||||
ftype ? "-t" : "-a",
|
||||
ftype && atype ? " or -a." : ".");
|
||||
usage();
|
||||
}
|
||||
lang = optarg;
|
||||
break;
|
||||
case 'v':
|
||||
case 'V':
|
||||
version();
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv = argv + optind;
|
||||
|
||||
if(argc == 0) {
|
||||
(void) fprintf(stderr, "chtyp: no files specified\n");
|
||||
usage();
|
||||
}
|
||||
|
||||
if(lang) {
|
||||
if(find_lang(lang, &filet, &auxt) == -1) {
|
||||
(void) fprintf(stderr, "chtyp: unknown language argument \"%s\".\n",
|
||||
lang);
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
if(ftype) {
|
||||
filet = (int) strtol(ftype, &left, 0);
|
||||
if(errno == ERANGE || *left)
|
||||
if(find_type(ftype, &filet, &auxt) == -1) {
|
||||
(void) fprintf(stderr,
|
||||
"chtyp: invalid argument to -t option.\n");
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
if(atype) {
|
||||
errno = 0; /* be sure to reset errno! */
|
||||
auxt = strtol(atype, (char **) NULL, 0);
|
||||
if(errno == ERANGE) {
|
||||
(void) fprintf(stderr, "chtyp: invalid argument to -a option.\n");
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
ch = 0;
|
||||
while(argc) {
|
||||
strcpy(path.text, argv[ch]);
|
||||
path.length = strlen(argv[ch++]);
|
||||
GetFileInfoGS(&finfo);
|
||||
if(filet != -1)
|
||||
finfo.fileType = filet;
|
||||
if(auxt != -1)
|
||||
finfo.auxType = auxt;
|
||||
SetFileInfoGS(&finfo);
|
||||
argc--;
|
||||
}
|
||||
}
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
(void) fprintf(stderr,
|
||||
"Usage: chtyp { [-t type] [-a auxtype] } | { [-l lang] } file ...\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
static void version(void)
|
||||
{
|
||||
(void) fprintf(stderr,
|
||||
"V 2.0.0 Copyright 1997 by Evan Day, day@engr.orst.edu\n");
|
||||
usage();
|
||||
}
|
9
bin/chtyp/chtyp.desc
Normal file
9
bin/chtyp/chtyp.desc
Normal file
@ -0,0 +1,9 @@
|
||||
Name: df
|
||||
Version: 2.0.0 (28 Sep 97)
|
||||
Shell: GNO/ME
|
||||
Author: Evan Day
|
||||
Contact: day@engr.orst.edu
|
||||
Where: /usr/bin
|
||||
FTP:
|
||||
|
||||
Set GS/OS file types.
|
34
bin/chtyp/chtyp.rez
Normal file
34
bin/chtyp/chtyp.rez
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* $Id: chtyp.rez,v 1.1 1997/10/03 05:06:50 gdr Exp $
|
||||
*/
|
||||
|
||||
#include "Types.Rez"
|
||||
#include "proginfo.rez"
|
||||
|
||||
resource rVersion (0x1, purgeable3, nocrossbank) {
|
||||
|
||||
{ 2, 0, 0, /* version 2.0.0 */
|
||||
release, /* development|alpha|beta|final|release */
|
||||
0 /* non-final release number */
|
||||
},
|
||||
verUS, /* country code -- only some are avail */
|
||||
"chtyp", /* name */
|
||||
/* _Very_ brief descrition. Check "file info" */
|
||||
/* shown in the Finder to see if it's too long */
|
||||
/* Note that \n is used to separate lines here. */
|
||||
"Change GS/OS file type information.\n"
|
||||
"Requires GNO/ME Shell.\n"
|
||||
"Evan Day <day@engr.orst.edu>"
|
||||
};
|
||||
|
||||
resource rProgramInfo (0x1, purgeable3, nocrossbank) {
|
||||
{ 6, 0, 1,
|
||||
release,
|
||||
0
|
||||
},
|
||||
16384,
|
||||
16384,
|
||||
768,
|
||||
progRequiresGNO+progAppleTalkOK+progAllowsCDAs,
|
||||
piCompatible*ProgShellGSH+piSpecialFeatures*ProgShellGSH
|
||||
};
|
171
bin/chtyp/ftypes.c
Normal file
171
bin/chtyp/ftypes.c
Normal file
@ -0,0 +1,171 @@
|
||||
/*
|
||||
* ftypes.c
|
||||
*
|
||||
* data/routines to change an official Apple 3-letter filetype abbrevation
|
||||
* into a full filetype/auxtype pair (or back, I suppose)
|
||||
*
|
||||
* also data/routines to change a language type (as specified in chtyp.1)
|
||||
* into a filetype/auxtype pair.
|
||||
*
|
||||
* $Id: ftypes.c,v 1.1 1997/10/03 05:06:50 gdr Exp $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static struct type_list {
|
||||
char *name;
|
||||
int file_type;
|
||||
long aux_type;
|
||||
} types[] = {
|
||||
{ "non", 0x00, 0x0000 }, /* common abbrev for $00 */
|
||||
{ "unk", 0x00, 0x0000 }, /* official abbrev for $00 */
|
||||
{ "bad", 0x01, 0x0000 },
|
||||
{ "pcd", 0x02, 0x0000 },
|
||||
{ "ptx", 0x03, 0x0000 },
|
||||
{ "txt", 0x04, 0x0000 },
|
||||
{ "pda", 0x05, 0x0000 },
|
||||
{ "bin", 0x06, 0x0000 },
|
||||
{ "fnt", 0x07, 0x0000 },
|
||||
{ "fot", 0x08, 0x0000 },
|
||||
{ "ba3", 0x09, 0x0000 },
|
||||
{ "da3", 0x0a, 0x0000 },
|
||||
{ "wpf", 0x0b, 0x0000 },
|
||||
{ "sos", 0x0c, 0x0000 },
|
||||
{ "dir", 0x0f, 0x0000 },
|
||||
{ "rpd", 0x10, 0x0000 },
|
||||
{ "rpi", 0x11, 0x0000 },
|
||||
{ "afd", 0x12, 0x0000 },
|
||||
{ "afm", 0x13, 0x0000 },
|
||||
{ "afr", 0x14, 0x0000 },
|
||||
{ "scl", 0x15, 0x0000 },
|
||||
{ "pfs", 0x16, 0x0000 },
|
||||
{ "adb", 0x19, 0x0000 },
|
||||
{ "awp", 0x1a, 0x0000 },
|
||||
{ "asp", 0x1b, 0x0000 },
|
||||
{ "tdm", 0x20, 0x0000 },
|
||||
{ "8sc", 0x2a, 0x0000 },
|
||||
{ "8ob", 0x2b, 0x0000 },
|
||||
{ "8ic", 0x2c, 0x0000 },
|
||||
{ "8ld", 0x2d, 0x0000 },
|
||||
{ "p8c", 0x2e, 0x0000 },
|
||||
{ "ptp", 0x2e, 0x8001 }, /* Point-to-point drivers */
|
||||
{ "ftd", 0x42, 0x0000 },
|
||||
{ "gwp", 0x50, 0x0000 },
|
||||
{ "gss", 0x51, 0x0000 },
|
||||
{ "gdb", 0x52, 0x0000 },
|
||||
{ "drw", 0x53, 0x0000 },
|
||||
{ "gdp", 0x54, 0x0000 },
|
||||
{ "hmd", 0x55, 0x0000 },
|
||||
{ "edu", 0x56, 0x0000 },
|
||||
{ "stn", 0x57, 0x0000 },
|
||||
{ "hlp", 0x58, 0x0000 },
|
||||
{ "com", 0x59, 0x0000 },
|
||||
{ "cfg", 0x5a, 0x0000 },
|
||||
{ "anm", 0x5b, 0x0000 },
|
||||
{ "mum", 0x5c, 0x0000 },
|
||||
{ "ent", 0x5d, 0x0000 },
|
||||
{ "dvu", 0x5e, 0x0000 },
|
||||
{ "bio", 0x6b, 0x0000 },
|
||||
{ "tdr", 0x6d, 0x0000 },
|
||||
{ "pre", 0x6e, 0x0000 },
|
||||
{ "hdv", 0x6f, 0x0000 },
|
||||
{ "wp", 0xa0, 0x0000 },
|
||||
{ "gsb", 0xab, 0x0000 },
|
||||
{ "tdf", 0xac, 0x0000 },
|
||||
{ "bdf", 0xad, 0x0000 },
|
||||
{ "src", 0xb0, 0x0000 },
|
||||
{ "obj", 0xb1, 0x0000 },
|
||||
{ "lib", 0xb2, 0x0000 },
|
||||
{ "s16", 0xb3, 0x0000 },
|
||||
{ "rtl", 0xb4, 0x0000 },
|
||||
{ "exe", 0xb5, 0x0000 },
|
||||
{ "pif", 0xb6, 0x0000 },
|
||||
{ "tif", 0xb7, 0x0000 },
|
||||
{ "nda", 0xb8, 0x0000 },
|
||||
{ "cda", 0xb9, 0x0000 },
|
||||
{ "tol", 0xba, 0x0000 },
|
||||
{ "dvr", 0xbb, 0x0000 },
|
||||
{ "ldf", 0xbc, 0x0000 },
|
||||
{ "fst", 0xbd, 0x0000 },
|
||||
{ "doc", 0xbf, 0x0000 },
|
||||
{ "pnt", 0xc0, 0x0000 },
|
||||
{ "pic", 0xc1, 0x0000 },
|
||||
{ "ani", 0xc2, 0x0000 },
|
||||
{ "pal", 0xc3, 0x0000 },
|
||||
{ "oog", 0xc5, 0x0000 },
|
||||
{ "scr", 0xc6, 0x0000 },
|
||||
{ "cdv", 0xc7, 0x0000 },
|
||||
{ "fon", 0xc8, 0x0000 },
|
||||
{ "fnd", 0xc9, 0x0000 },
|
||||
{ "icn", 0xca, 0x0000 },
|
||||
{ "mus", 0xd5, 0x0000 },
|
||||
{ "ins", 0xd6, 0x0000 },
|
||||
{ "mdi", 0xd7, 0x0000 },
|
||||
{ "snd", 0xd8, 0x0000 },
|
||||
{ "dbm", 0xdb, 0x0000 },
|
||||
{ "lbr", 0xe0, 0x0000 },
|
||||
{ "atk", 0xe2, 0x0000 },
|
||||
{ "r16", 0xee, 0x0000 },
|
||||
{ "pas", 0xef, 0x0000 },
|
||||
{ "cmd", 0xf0, 0x0000 },
|
||||
{ "os" , 0xf9, 0x0000 },
|
||||
{ "int", 0xfa, 0x0000 },
|
||||
{ "ivr", 0xfb, 0x0000 },
|
||||
{ "bas", 0xfc, 0x0000 },
|
||||
{ "var", 0xfd, 0x0000 },
|
||||
{ "rel", 0xfe, 0x0000 },
|
||||
{ "sys", 0xff, 0x0000 }
|
||||
};
|
||||
|
||||
#define NUM_TYPES 98
|
||||
|
||||
static struct lang_list {
|
||||
char *name;
|
||||
int file_type;
|
||||
long aux_type;
|
||||
} langs[] = {
|
||||
{ "apwtxt", 0xb0, 0x0001},
|
||||
{ "asm", 0xb0, 0x0003},
|
||||
{ "pascal", 0xb0, 0x0005},
|
||||
{ "exec", 0xb0, 0x0006},
|
||||
{ "cc", 0xb0, 0x0008},
|
||||
{ "linker", 0xb0, 0x0009},
|
||||
{ "apwc", 0xb0, 0x000a},
|
||||
{ "desktop", 0xb0, 0x000c},
|
||||
{ "rez", 0xb0, 0x0015},
|
||||
{ "tmlpascal", 0xb0, 0x001e},
|
||||
{ "disasm", 0xb0, 0x0115},
|
||||
{ "sdeasm", 0xb0, 0x0503},
|
||||
{ "sdecmd", 0xb0, 0x0506},
|
||||
{ "ps", 0xb0, 0x0719},
|
||||
};
|
||||
|
||||
#define NUM_LANGS 14
|
||||
|
||||
int find_type(char *type_str, int *f, long *a)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < NUM_TYPES; i++)
|
||||
if(!stricmp(type_str, types[i].name)) {
|
||||
*f = types[i].file_type;
|
||||
*a = types[i].aux_type;
|
||||
return(0);
|
||||
}
|
||||
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int find_lang(char *lang_str, int *f, long *a)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < NUM_LANGS; i++)
|
||||
if(!stricmp(lang_str, langs[i].name)) {
|
||||
*f = langs[i].file_type;
|
||||
*a = langs[i].aux_type;
|
||||
return(0);
|
||||
}
|
||||
|
||||
return(-1);
|
||||
}
|
6
bin/chtyp/ftypes.h
Normal file
6
bin/chtyp/ftypes.h
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* $Id: ftypes.h,v 1.1 1997/10/03 05:06:50 gdr Exp $
|
||||
*/
|
||||
|
||||
extern int find_type(char *, int *, long *);
|
||||
extern int find_lang(char *, int *, long *);
|
Loading…
x
Reference in New Issue
Block a user