2 Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
4 See the accompanying file LICENSE, version 2000-Apr-09 or later
5 (the contents of which are also included in unzip.h) for terms of use.
6 If, for some reason, all these files are missing, the Info-ZIP license
7 also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
9 /*---------------------------------------------------------------------------
12 *** This is only needed to build funzip correctly and is a direct copy
13 of globals.c. Don't forget to update here if you update globals.c!! ***
15 ---------------------------------------------------------------------------*/
19 #define UNZIP_INTERNAL
23 /* initialization of sigs is completed at runtime so unzip(sfx) executable
24 * won't look like a zipfile
26 char central_hdr_sig
[4] = {0, 0, 0x01, 0x02};
27 char local_hdr_sig
[4] = {0, 0, 0x03, 0x04};
28 char end_central_sig
[4] = {0, 0, 0x05, 0x06};
29 /* extern char extd_local_sig[4] = {0, 0, 0x07, 0x08}; NOT USED YET */
31 ZCONST
char *fnames
[2] = {"*", NULL
}; /* default filenames vector */
41 # else /* USETHREADID */
42 # define THREADID_ENTRIES 0x40
45 Uz_Globs
*threadPtrTable
[THREADID_ENTRIES
];
46 ulg threadIdTable
[THREADID_ENTRIES
] = {
47 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
48 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* Make sure there are */
49 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* THREADID_ENTRIES 0s */
50 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0
53 static ZCONST
char Far TooManyThreads
[] =
54 "error: more than %d simultaneous threads.\n\
55 Some threads are probably not calling DESTROYTHREAD()\n";
56 static ZCONST
char Far EntryNotFound
[] =
57 "error: couldn't find global pointer in table.\n\
58 Maybe somebody accidentally called DESTROYTHREAD() twice.\n";
59 static ZCONST
char Far GlobalPointerMismatch
[] =
60 "error: global pointer in table does not match pointer passed as\
63 static void registerGlobalPointer
OF((__GPRO
));
67 static void registerGlobalPointer(__G
)
71 ulg tid
= GetThreadId();
73 while (threadIdTable
[scan
] && scan
< THREADID_ENTRIES
)
76 if (scan
== THREADID_ENTRIES
) {
77 ZCONST
char *tooMany
= LoadFarString(TooManyThreads
);
78 Info(slide
, 0x421, ((char *)slide
, tooMany
, THREADID_ENTRIES
));
80 EXIT(PK_MEM
); /* essentially memory error before we've started */
83 threadIdTable
[scan
] = tid
;
84 threadPtrTable
[scan
] = pG
;
90 void deregisterGlobalPointer(__G
)
94 ulg tid
= GetThreadId();
97 while (threadIdTable
[scan
] != tid
&& scan
< THREADID_ENTRIES
)
100 /*---------------------------------------------------------------------------
101 There are two things we can do if we can't find the entry: ignore it or
102 scream. The most likely reason for it not to be here is the user calling
103 this routine twice. Since this could cause BIG problems if any globals
104 are accessed after the first call, we'd better scream.
105 ---------------------------------------------------------------------------*/
107 if (scan
== THREADID_ENTRIES
|| threadPtrTable
[scan
] != pG
) {
108 ZCONST
char *noEntry
;
109 if (scan
== THREADID_ENTRIES
)
110 noEntry
= LoadFarString(EntryNotFound
);
112 noEntry
= LoadFarString(GlobalPointerMismatch
);
113 Info(slide
, 0x421, ((char *)slide
, noEntry
));
114 EXIT(PK_WARN
); /* programming error, but after we're all done */
117 threadIdTable
[scan
] = 0;
119 free(threadPtrTable
[scan
]);
124 Uz_Globs
*getGlobalPointer()
127 ulg tid
= GetThreadId();
129 while (threadIdTable
[scan
] != tid
&& scan
< THREADID_ENTRIES
)
132 /*---------------------------------------------------------------------------
133 There are two things we can do if we can't find the entry: ignore it or
134 scream. The most likely reason for it not to be here is the user calling
135 this routine twice. Since this could cause BIG problems if any globals
136 are accessed after the first call, we'd better scream.
137 ---------------------------------------------------------------------------*/
139 if (scan
== THREADID_ENTRIES
) {
140 ZCONST
char *noEntry
= LoadFarString(EntryNotFound
);
141 fprintf(stderr
, noEntry
); /* can't use Info w/o a global pointer */
142 EXIT(PK_ERR
); /* programming error while still working */
145 return threadPtrTable
[scan
];
148 # endif /* ?USETHREADID */
149 #endif /* ?REENTRANT */
153 Uz_Globs
*globalsCtor()
156 Uz_Globs
*pG
= (Uz_Globs
*)malloc(sizeof(Uz_Globs
));
159 return (Uz_Globs
*)NULL
;
160 #endif /* REENTRANT */
162 /* for REENTRANT version, G is defined as (*pG) */
164 memzero(&G
, sizeof(Uz_Globs
));
172 uO
.aflag
=1; /* default to '-a' auto create Text Files as type 101 */
177 G
.pfnames
= (char **)fnames
;
178 G
.pxnames
= (char **)&fnames
[1];
180 G
.sol
= TRUE
; /* at start of line */
182 G
.message
= UzpMessagePrnt
;
183 G
.input
= UzpInput
; /* not used by anyone at the moment... */
184 #if defined(WINDLL) || defined(MACOS)
185 G
.mpause
= NULL
; /* has scrollbars: no need for pausing */
187 G
.mpause
= UzpMorePause
;
189 G
.decr_passwd
= UzpPassword
;
192 #if (!defined(DOS_FLX_H68_NLM_OS2_W32) && !defined(AMIGA) && !defined(RISCOS))
193 #if (!defined(MACOS) && !defined(ATARI) && !defined(VMS))
195 #endif /* !(MACOS || ATARI || VMS) */
196 #endif /* !(DOS_FLX_H68_NLM_OS2_W32 || AMIGA || RISCOS) */
198 #ifdef SYSTEM_SPECIFIC_CTOR
199 SYSTEM_SPECIFIC_CTOR(__G
);
204 registerGlobalPointer(__G
);
207 #endif /* ?USETHREADID */
208 #endif /* REENTRANT */