2
#include "../fileio/machdr.h"
3
#include "../fileio/rdfile.h"
4
#include "../util/patchlevel.h"
7
extern char *realloc();
10
extern void transname();
11
extern void do_indent();
14
#define LOCALOPT "RilqVH"
18
static char options[128];
19
static char *dir_stack;
20
static int dir_ptr = -64;
32
char text[32], ftype[5], fauth[5];
33
int dir_skip = 0, write_it, query = 0, list = 0, info_only = 0;
36
(void)strcat(options, get_rdfileopt());
37
(void)strcat(options, LOCALOPT);
40
while((c = getopt(argc, argv, options)) != EOF) {
41
if(!rdfileopt((char)c)) {
60
(void)fprintf(stderr, "Binhex specific options:\n");
61
(void)fprintf(stderr, "-r:\tdo not use run length encoding\n");
63
"-i:\tgive information only, do not write\n");
64
(void)fprintf(stderr, "-l:\tgive listing\n");
66
"-q:\tquery for every file/folder before writing\n");
68
"-V:\tgive information about this version\n");
69
(void)fprintf(stderr, "-H:\tthis message\n");
70
(void)fprintf(stderr, "Default is silent writing\n");
73
(void)fprintf(stderr, "Version %s, ", VERSION);
74
(void)fprintf(stderr, "patchlevel %d", PATCHLEVEL);
75
(void)fprintf(stderr, "%s.\n", get_minb());
85
if(info_only || query) {
89
setup(argc - optind, argv + optind);
90
while((i = nextfile()) != ISATEND) {
94
} else if(i == ENDDIR) {
101
n = file_info[I_NAMEOFF] & 0x7f;
102
transname(file_info + I_NAMEOFF + 1, text, n);
104
transname(file_info + I_TYPEOFF, ftype, 4);
105
transname(file_info + I_AUTHOFF, fauth, 4);
110
(void)fprintf(stderr,
111
"name=\"%s\", type=%4.4s, author=%4.4s, data=%ld, rsrc=%ld",
112
text, ftype, fauth, (long)data_size, (long)rsrc_size);
113
} else if(i == ISDIR) {
116
if(dir_ptr == dir_max) {
118
dir_stack = malloc(64);
120
dir_stack = realloc(dir_stack, (unsigned)dir_max + 64);
123
if(dir_stack == NULL) {
124
(void)fprintf(stderr, "Insufficient memory\n");
128
for(j = 0; j <= n; j++) {
129
dir_stack[dir_ptr + j] = text[j];
131
(void)fprintf(stderr, "folder=\"%s\"", text);
136
(void)fprintf(stderr, "leaving folder \"%s\"",
137
dir_stack + dir_ptr);
145
write_it = do_query();
147
(void)fputc('\n', stderr);
149
if(!write_it && i == ISDIR) {
155
(void)fputc('\n', stderr);
171
(void)fprintf(stderr, "Usage: binhex [-%s] [files]\n", options);
172
(void)fprintf(stderr, "Use \"binhex -H\" for help.\n");