]> git.saurik.com Git - wxWidgets.git/blame_incremental - utils/Install/sfxzip/globals.c
added default style wxFRAME_TOOL_WINDOW to creation
[wxWidgets.git] / utils / Install / sfxzip / globals.c
... / ...
CommitLineData
1/*---------------------------------------------------------------------------
2
3 globals.c
4
5 Routines to allocate and initialize globals, with or without threads.
6
7 Contents: registerGlobalPointer()
8 deregisterGlobalPointer()
9 getGlobalPointer()
10 globalsCtor()
11
12 ---------------------------------------------------------------------------*/
13
14
15#define UNZIP_INTERNAL
16#include "unzip.h"
17
18#ifndef FUNZIP
19/* initialization of sigs is completed at runtime so unzip(sfx) executable
20 * won't look like a zipfile
21 */
22char central_hdr_sig[4] = {0, 0, 0x01, 0x02};
23char local_hdr_sig[4] = {0, 0, 0x03, 0x04};
24char end_central_sig[4] = {0, 0, 0x05, 0x06};
25/* extern char extd_local_sig[4] = {0, 0, 0x07, 0x08}; NOT USED YET */
26
27ZCONST char *fnames[2] = {"*", NULL}; /* default filenames vector */
28#endif
29
30
31#ifndef REENTRANT
32 Uz_Globs G;
33#else /* REENTRANT */
34
35# ifndef USETHREADID
36 Uz_Globs *GG;
37# else /* USETHREADID */
38# define THREADID_ENTRIES 0x40
39
40 int lastScan;
41 Uz_Globs *threadPtrTable[THREADID_ENTRIES];
42 ulg threadIdTable [THREADID_ENTRIES] = {
43 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
44 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* Make sure there are */
45 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, /* THREADID_ENTRIES 0s */
46 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0
47 };
48
49 static ZCONST char Far TooManyThreads[] =
50 "error: more than %d simultaneous threads.\n\
51 Some threads are probably not calling DESTROYTHREAD()\n";
52 static ZCONST char Far EntryNotFound[] =
53 "error: couldn't find global pointer in table.\n\
54 Maybe somebody accidentally called DESTROYTHREAD() twice.\n";
55 static ZCONST char Far GlobalPointerMismatch[] =
56 "error: global pointer in table does not match pointer passed as\
57 parameter\n";
58
59static void registerGlobalPointer OF((__GPRO));
60
61
62
63static void registerGlobalPointer(__G)
64 __GDEF
65{
66 int scan=0;
67 ulg tid = GetThreadId();
68
69 while (threadIdTable[scan] && scan < THREADID_ENTRIES)
70 scan++;
71
72 if (scan == THREADID_ENTRIES) {
73 ZCONST char *tooMany = LoadFarString(TooManyThreads);
74 Info(slide, 0x421, ((char *)slide, tooMany, THREADID_ENTRIES));
75 free(pG);
76 EXIT(PK_MEM); /* essentially memory error before we've started */
77 }
78
79 threadIdTable [scan] = tid;
80 threadPtrTable[scan] = pG;
81 lastScan = scan;
82}
83
84
85
86void deregisterGlobalPointer(__G)
87 __GDEF
88{
89 int scan=0;
90 ulg tid = GetThreadId();
91
92
93 while (threadIdTable[scan] != tid && scan < THREADID_ENTRIES)
94 scan++;
95
96/*---------------------------------------------------------------------------
97 There are two things we can do if we can't find the entry: ignore it or
98 scream. The most likely reason for it not to be here is the user calling
99 this routine twice. Since this could cause BIG problems if any globals
100 are accessed after the first call, we'd better scream.
101 ---------------------------------------------------------------------------*/
102
103 if (scan == THREADID_ENTRIES || threadPtrTable[scan] != pG) {
104 ZCONST char *noEntry;
105 if (scan == THREADID_ENTRIES)
106 noEntry = LoadFarString(EntryNotFound);
107 else
108 noEntry = LoadFarString(GlobalPointerMismatch);
109 Info(slide, 0x421, ((char *)slide, noEntry));
110 EXIT(PK_WARN); /* programming error, but after we're all done */
111 }
112
113 threadIdTable [scan] = 0;
114 lastScan = scan;
115 free(threadPtrTable[scan]);
116}
117
118
119
120Uz_Globs *getGlobalPointer()
121{
122 int scan=0;
123 ulg tid = GetThreadId();
124
125 while (threadIdTable[scan] != tid && scan < THREADID_ENTRIES)
126 scan++;
127
128/*---------------------------------------------------------------------------
129 There are two things we can do if we can't find the entry: ignore it or
130 scream. The most likely reason for it not to be here is the user calling
131 this routine twice. Since this could cause BIG problems if any globals
132 are accessed after the first call, we'd better scream.
133 ---------------------------------------------------------------------------*/
134
135 if (scan == THREADID_ENTRIES) {
136 ZCONST char *noEntry = LoadFarString(EntryNotFound);
137 fprintf(stderr, noEntry); /* can't use Info w/o a global pointer */
138 EXIT(PK_ERR); /* programming error while still working */
139 }
140
141 return threadPtrTable[scan];
142}
143
144# endif /* ?USETHREADID */
145#endif /* ?REENTRANT */
146
147
148
149Uz_Globs *globalsCtor()
150{
151#ifdef REENTRANT
152 Uz_Globs *pG = (Uz_Globs *)malloc(sizeof(Uz_Globs));
153
154 if (!pG)
155 return (Uz_Globs *)NULL;
156#endif /* REENTRANT */
157
158 /* for REENTRANT version, G is defined as (*pG) */
159
160 memzero(&G, sizeof(Uz_Globs));
161
162#ifndef FUNZIP
163#ifdef CMS_MVS
164 uO.aflag=1;
165 uO.C_flag=1;
166#endif
167
168 uO.lflag=(-1);
169 G.wildzipfn = "";
170 G.pfnames = (char **)fnames;
171 G.pxnames = (char **)&fnames[1];
172 G.pInfo = G.info;
173 G.sol = TRUE; /* at start of line */
174
175 G.message = UzpMessagePrnt;
176 G.input = UzpInput; /* not used by anyone at the moment... */
177#if defined(WINDLL) || defined(MACOS)
178 G.mpause = NULL; /* has scrollbars: no need for pausing */
179#else
180 G.mpause = UzpMorePause;
181#endif
182 G.decr_passwd = UzpPassword;
183#endif /* !FUNZIP */
184
185#if (!defined(DOS_FLX_H68_OS2_W32) && !defined(AMIGA) && !defined(RISCOS))
186#if (!defined(MACOS) && !defined(ATARI) && !defined(VMS))
187 G.echofd = -1;
188#endif /* !(MACOS || ATARI || VMS) */
189#endif /* !(DOS_FLX_H68_OS2_W32 || AMIGA || RISCOS) */
190
191#ifdef SYSTEM_SPECIFIC_CTOR
192 SYSTEM_SPECIFIC_CTOR(__G);
193#endif
194
195#ifdef REENTRANT
196#ifdef USETHREADID
197 registerGlobalPointer(__G);
198#else
199 GG = &G;
200#endif /* ?USETHREADID */
201#endif /* REENTRANT */
202
203 return &G;
204}