1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
/*
Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
See the accompanying file LICENSE, version 2004-May-22 or later
(the contents of which are also included in zip.h) for terms of use.
If, for some reason, both of these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
*/
/* OS specific routines for AMIGA platform.
*
* John Bush <John.Bush@east.sun.com> BIX: jbush
* Paul Kienitz <kie@pacbell.net>
*
* History:
*
* Date DoBee Comments
* ------- -------- -----------------------------------------------
* 21Jan93 JBush Original coding.
* Incorporated filedate.c (existing routine).
*
* 31Jan93 JBush Made filedate.c include unconditional.
*
* 18Jul93 PaulK Moved Aztec _abort() here from stat.c because we
* can't share the same one between Zip and UnZip.
* Added close_leftover_open_dirs() call to it.
*
* 17Apr95 PaulK Added Amiga internal version string so that
* installer programs can compare the version being
* installed to see if the copy the user already has
* is older or newer. Added Prestart_Hook to support
* debug tracing in deflate.a.
*
* 6May95 PaulK Added GetComment() for filenote support.
*
* 12Nov95 PaulK Added #define ZIP in front of filedate.c, for
* new options in there; removed declare of set_con()
* since echon() no longer expands to it (or anything).
*
* 12Feb96 PaulK Removed call of echon() entirely.
*
* 12Jul97 PaulK Made both Aztec and SAS define USE_TIME_LIB for filedate.c
*
* 26Aug97 PaulK Added ClearIOErr_exit()
*
* 2Jan98 HWalt Adapted for SAS/C using stat.c replacement functions
*/
#include <exec/memory.h>
#ifdef AZTEC_C
# include <libraries/dos.h>
# include <libraries/dosextens.h>
# include <clib/exec_protos.h>
# include <clib/dos_protos.h>
# include <pragmas/exec_lib.h>
# include <pragmas/dos_lib.h>
#else
# include <proto/exec.h>
# include <proto/dos.h>
#endif
#include <stdlib.h>
#ifndef ZCONST
# define ZCONST const
#endif
#include "ziperr.h"
void ziperr(int c, ZCONST char *h);
#if defined(AZTEC_C) || defined(__SASC)
# define USE_TIME_LIB
#endif
#define ZIP
#if !defined(UTIL) && !defined(USE_TIME_LIB)
# define NO_MKTIME
#endif
#ifdef AZTEC_C
/* ============================================================= */
/* filedate.c is an external file, since it's shared with UnZip. */
/* Aztec includes it here, but SAS/C now compiles it separately. */
# include "amiga/filedate.c"
/* the same applies to stat.c */
# include "amiga/stat.c"
# define setenv BOGUS_INCOMPATIBLE_setenv
# include <fcntl.h>
# undef setenv
# ifdef DEBUG
# define PRESTART_HOOK
# endif
#endif
extern void close_leftover_open_dirs(void);
/* the following handles cleanup when a ^C interrupt happens: */
void _abort(void) /* called when ^C is pressed */
{
close_leftover_open_dirs();
ziperr(ZE_ABORT, "^C");
}
void ClearIOErr_exit(int e) /* EXIT is defined as this */
{
if (!e)
((struct Process *) FindTask(NULL))->pr_Result2 = 0;
/* we clear IoErr() since we are successful, in a 1.x-compatible way */
exit(e);
}
/* Make sure the version number here matches the number in revision.h */
/* as closely as possible in strict decimal "#.#" form: */
const char version_id[] = "\0$VER: Zip 2.3 ("
# include "env:VersionDate"
")\r\n";
/* call this with an arg of NULL to free storage: */
char *GetComment(char *filename)
{
BPTR lk;
static struct FileInfoBlock *fib = NULL;
if (!filename) {
if (fib) FreeMem(fib, sizeof(*fib));
fib = NULL;
return NULL;
}
if (!fib) {
if (!(fib = AllocMem(sizeof(*fib), MEMF_PUBLIC)))
ziperr(ZE_MEM, "was checking filenotes");
}
if (!(lk = Lock(filename, ACCESS_READ)))
return NULL;
if (!Examine(lk, fib))
fib->fib_Comment[0] = '\0';
UnLock(lk);
return fib->fib_Comment[0] ? &fib->fib_Comment[0] : NULL;
}
|