~ubuntu-branches/ubuntu/precise/boinc/precise

« back to all changes in this revision

Viewing changes to zip/zip/tailor.h

Tags: 6.12.8+dfsg-1
* New upstream release.
* Simplified debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
  Copyright (c) 1990-1999 Info-ZIP.  All rights reserved.
3
 
 
4
 
  See the accompanying file LICENSE, version 1999-Oct-05 or later
5
 
  (the contents of which are also included in zip.h) for terms of use.
6
 
  If, for some reason, both of these files are missing, the Info-ZIP license
7
 
  also may be found at:  ftp://ftp.cdrom.com/pub/infozip/license.html
8
 
*/
9
 
#ifdef AMIGA
10
 
#include "amiga/osdep.h"
11
 
#endif
12
 
 
13
 
#ifdef AOSVS
14
 
#include "aosvs/osdep.h"
15
 
#endif
16
 
 
17
 
#ifdef ATARI
18
 
#include "atari/osdep.h"
19
 
#endif
20
 
 
21
 
#ifdef __BEOS__
22
 
#include "beos/osdep.h"
23
 
#endif
24
 
 
25
 
#ifdef DOS
26
 
#include "msdos/osdep.h"
27
 
#endif
28
 
 
29
 
#ifdef __human68k__
30
 
#include "human68k/osdep.h"
31
 
#endif
32
 
 
33
 
#if ((defined(__MWERKS__) && defined(macintosh)) || defined(MACOS))
34
 
#include "macos/osdep.h"
35
 
#endif
36
 
 
37
 
#ifdef OS2
38
 
#include "os2/osdep.h"
39
 
#endif
40
 
 
41
 
#ifdef __riscos
42
 
#include "acorn/osdep.h"
43
 
#endif
44
 
 
45
 
#ifdef QDOS
46
 
#include "qdos/osdep.h"
47
 
#endif
48
 
 
49
 
#ifdef __TANDEM
50
 
#include "tandem.h"
51
 
#include "tanzip.h"
52
 
#endif
53
 
 
54
 
#ifdef UNIX
55
 
#include "unix/osdep.h"
56
 
#endif
57
 
 
58
 
#if defined(__COMPILER_KCC__) || defined(TOPS20)
59
 
#include "tops20/osdep.h"
60
 
#endif
61
 
 
62
 
#if defined(VMS) || defined(__VMS)
63
 
#include "vms/osdep.h"
64
 
#endif
65
 
 
66
 
#if defined(__VM__) || defined(VM_CMS) || defined(MVS)
67
 
#include "cmsmvs.h"
68
 
#endif
69
 
 
70
 
#ifdef WIN32
71
 
#include "win32/osdep.h"
72
 
#endif
73
 
 
74
 
#ifdef THEOS
75
 
#include "theos/osdep.h"
76
 
#endif
77
 
 
78
 
#if (defined(USE_ZLIB) && defined(ASM_CRC))
79
 
#  undef ASM_CRC
80
 
#endif
81
 
 
82
 
#if (defined(USE_ZLIB) && defined(ASMV))
83
 
#  undef ASMV
84
 
#endif
85
 
 
86
 
/* When "void" is an alias for "int", prototypes cannot be used. */
87
 
#if (defined(NO_VOID) && !defined(NO_PROTO))
88
 
#  define NO_PROTO
89
 
#endif
90
 
 
91
 
/* Used to remove arguments in function prototypes for non-ANSI C */
92
 
#ifndef NO_PROTO
93
 
#  define OF(a) a
94
 
#else /* NO_PROTO */
95
 
#  define OF(a) ()
96
 
#endif /* ?NO_PROTO */
97
 
 
98
 
/* If the compiler can't handle const define ZCONST in osdep.h */
99
 
/* Define const itself in case the system include files are bonkers */
100
 
#ifndef ZCONST
101
 
#  ifdef NO_CONST
102
 
#    define ZCONST
103
 
#    define const
104
 
#  else
105
 
#    define ZCONST const
106
 
#  endif
107
 
#endif
108
 
 
109
 
/*
110
 
 * case mapping functions. case_map is used to ignore case in comparisons,
111
 
 * to_up is used to force upper case even on Unix (for dosify option).
112
 
 */
113
 
#ifdef USE_CASE_MAP
114
 
#  define case_map(c) upper[(c) & 0xff]
115
 
#  define to_up(c)    upper[(c) & 0xff]
116
 
#else
117
 
#  define case_map(c) (c)
118
 
#  define to_up(c)    ((c) >= 'a' && (c) <= 'z' ? (c)-'a'+'A' : (c))
119
 
#endif /* USE_CASE_MAP */
120
 
 
121
 
/* Define void, zvoid, and extent (size_t) */
122
 
#include <stdio.h>
123
 
 
124
 
#ifndef NO_STDDEF_H
125
 
#  include <stddef.h>
126
 
#endif /* !NO_STDDEF_H */
127
 
 
128
 
#ifndef NO_STDLIB_H
129
 
#  include <stdlib.h>
130
 
#endif /* !NO_STDLIB_H */
131
 
 
132
 
#ifndef NO_UNISTD_H
133
 
#  include <unistd.h> /* usually defines _POSIX_VERSION */
134
 
#endif /* !NO_UNISTD_H */
135
 
 
136
 
#ifndef NO_FCNTL_H
137
 
#  include <fcntl.h>
138
 
#endif /* !NO_FNCTL_H */
139
 
 
140
 
#ifndef NO_STRING_H
141
 
#  include <string.h>
142
 
#else
143
 
#  include <strings.h>
144
 
#endif /* NO_STRING_H */
145
 
 
146
 
#ifdef NO_VOID
147
 
#  define void int
148
 
   typedef char zvoid;
149
 
#else /* !NO_VOID */
150
 
# ifdef NO_TYPEDEF_VOID
151
 
#  define zvoid void
152
 
# endif
153
 
#endif /* ?NO_VOID */
154
 
 
155
 
#ifdef NO_STRRCHR
156
 
#  define strrchr rindex
157
 
#endif
158
 
 
159
 
#ifdef NO_STRCHR
160
 
#  define strchr index
161
 
#endif
162
 
 
163
 
/*
164
 
 * A couple of forward declarations that are needed on systems that do
165
 
 * not supply C runtime library prototypes.
166
 
 */
167
 
#ifdef NO_PROTO
168
 
char *strcpy();
169
 
char *strcat();
170
 
char *strrchr();
171
 
/* XXX use !defined(ZMEM) && !defined(__hpux__) ? */
172
 
#if !defined(ZMEM) && defined(NO_STRING_H)
173
 
char *memset();
174
 
char *memcpy();
175
 
#endif /* !ZMEM && NO_STRING_H */
176
 
 
177
 
/* XXX use !defined(__hpux__) ? */
178
 
#ifdef NO_STDLIB_H
179
 
char *calloc();
180
 
char *malloc();
181
 
char *getenv();
182
 
long atol();
183
 
#endif /* NO_STDLIB_H */
184
 
 
185
 
#endif /* NO_PROTO */
186
 
 
187
 
#ifndef NO_MKTEMP
188
 
char *mktemp();
189
 
#endif /* !NO_MKTEMP */
190
 
 
191
 
/*
192
 
 * SEEK_* macros, should be defined in stdio.h
193
 
 */
194
 
/* Define fseek() commands */
195
 
#ifndef SEEK_SET
196
 
#  define SEEK_SET 0
197
 
#endif /* !SEEK_SET */
198
 
 
199
 
#ifndef SEEK_CUR
200
 
#  define SEEK_CUR 1
201
 
#endif /* !SEEK_CUR */
202
 
 
203
 
#ifndef FALSE
204
 
#  define FALSE 0
205
 
#endif
206
 
 
207
 
#ifndef TRUE
208
 
#  define TRUE 1
209
 
#endif
210
 
 
211
 
#ifdef NO_SIZE_T
212
 
   typedef unsigned int extent;
213
 
#else
214
 
   typedef size_t extent;
215
 
#endif
216
 
 
217
 
#ifdef NO_TIME_T
218
 
   typedef long time_t;
219
 
#endif
220
 
 
221
 
/* DBCS support for Info-ZIP's zip  (mainly for japanese (-: )
222
 
 * by Yoshioka Tsuneo (QWF00133@nifty.ne.jp,tsuneo-y@is.aist-nara.ac.jp)
223
 
 * This code is public domain!   Date: 1998/12/20
224
 
 */
225
 
#ifdef _MBCS
226
 
#   include <locale.h>
227
 
 
228
 
    /* Multi Byte Character Set */
229
 
    extern char *___tmp_ptr;
230
 
    unsigned char *zmbschr OF((ZCONST unsigned char *, unsigned int));
231
 
    unsigned char *zmbsrchr OF((ZCONST unsigned char *, unsigned int));
232
 
#   define CLEN(ptr) mblen(ptr, MB_CUR_MAX)
233
 
#   define PREINCSTR(ptr) (ptr += CLEN(ptr))
234
 
#   define POSTINCSTR(ptr) (___tmp_ptr=(char *)ptr,ptr += CLEN(ptr),___tmp_ptr)
235
 
    int lastchar OF((ZCONST char *ptr));
236
 
#   define MBSCHR(str,c) (char *)zmbschr((ZCONST unsigned char *)(str), c)
237
 
#   define MBSRCHR(str,c) (char *)zmbsrchr((ZCONST unsigned char *)(str), (c))
238
 
#   define SETLOCALE(category, locale) setlocale(category, locale)
239
 
#else /* !_MBCS */
240
 
#   define CLEN(ptr) 1
241
 
#   define PREINCSTR(ptr) (++(ptr))
242
 
#   define POSTINCSTR(ptr) ((ptr)++)
243
 
#   define lastchar(ptr) ((*(ptr)=='\0') ? '\0' : ptr[strlen(ptr)-1])
244
 
#   define MBSCHR(str, c) strchr(str, c)
245
 
#   define MBSRCHR(str, c) strrchr(str, c)
246
 
#   define SETLOCALE(category, locale)
247
 
#endif /* ?_MBCS */
248
 
#define INCSTR(ptr) PREINCSTR(ptr)
249
 
 
250
 
 
251
 
/* System independent replacement for "struct utimbuf", which is missing
252
 
 * in many older OS environments.
253
 
 */
254
 
typedef struct ztimbuf {
255
 
    time_t actime;              /* new access time */
256
 
    time_t modtime;             /* new modification time */
257
 
} ztimbuf;
258
 
 
259
 
/* This macro round a time_t value to the OS specific resolution */
260
 
#ifndef ROUNDED_TIME
261
 
#  define ROUNDED_TIME(time)   (time)
262
 
#endif
263
 
 
264
 
/* Some systems define S_IFLNK but do not support symbolic links */
265
 
#if defined (S_IFLNK) && defined(NO_SYMLINK)
266
 
#  undef S_IFLNK
267
 
#endif
268
 
 
269
 
#ifndef FOPR    /* fallback default definitions for FOPR, FOPM, FOPW: */
270
 
#  define FOPR "r"
271
 
#  define FOPM "r+"
272
 
#  define FOPW "w"
273
 
#endif /* fallback definition */
274
 
 
275
 
#ifndef FOPW_TMP    /* fallback default for opening writable temp files */
276
 
#  define FOPW_TMP FOPW
277
 
#endif
278
 
 
279
 
/* Open the old zip file in exclusive mode if possible (to avoid adding
280
 
 * zip file to itself).
281
 
 */
282
 
#ifdef OS2
283
 
#  define FOPR_EX FOPM
284
 
#else
285
 
#  define FOPR_EX FOPR
286
 
#endif
287
 
 
288
 
 
289
 
/* MSDOS file or directory attributes */
290
 
#define MSDOS_HIDDEN_ATTR 0x02
291
 
#define MSDOS_DIR_ATTR 0x10
292
 
 
293
 
 
294
 
/* Define this symbol if your target allows access to unaligned data.
295
 
 * This is not mandatory, just a speed optimization. The compressed
296
 
 * output is strictly identical.
297
 
 */
298
 
#if (defined(MSDOS) && !defined(WIN32)) || defined(i386)
299
 
#    define UNALIGNED_OK
300
 
#endif
301
 
#if defined(mc68020) || defined(vax)
302
 
#    define UNALIGNED_OK
303
 
#endif
304
 
 
305
 
#if (defined(SMALL_MEM) && !defined(CBSZ))
306
 
#   define CBSZ 2048 /* buffer size for copying files */
307
 
#   define ZBSZ 2048 /* buffer size for temporary zip file */
308
 
#endif
309
 
 
310
 
#if (defined(MEDIUM_MEM) && !defined(CBSZ))
311
 
#  define CBSZ 8192
312
 
#  define ZBSZ 8192
313
 
#endif
314
 
 
315
 
#ifndef CBSZ
316
 
#  define CBSZ 16384
317
 
#  define ZBSZ 16384
318
 
#endif
319
 
 
320
 
#ifndef SBSZ
321
 
#  define SBSZ CBSZ     /* copy buf size for STORED entries, see zipup() */
322
 
#endif
323
 
 
324
 
#ifndef MEMORY16
325
 
#  ifdef __WATCOMC__
326
 
#    undef huge
327
 
#    undef far
328
 
#    undef near
329
 
#  endif
330
 
#  ifdef THEOS
331
 
#    undef far
332
 
#    undef near
333
 
#  endif
334
 
#  if (!defined(__IBMC__) || !defined(OS2))
335
 
#    ifndef huge
336
 
#      define huge
337
 
#    endif
338
 
#    ifndef far
339
 
#      define far
340
 
#    endif
341
 
#    ifndef near
342
 
#      define near
343
 
#    endif
344
 
#  endif
345
 
#  define nearmalloc malloc
346
 
#  define nearfree free
347
 
#  define farmalloc malloc
348
 
#  define farfree free
349
 
#endif /* !MEMORY16 */
350
 
 
351
 
#ifndef Far
352
 
#  define Far far
353
 
#endif
354
 
 
355
 
#if (defined(BIG_MEM) || defined(MMAP)) && !defined(DYN_ALLOC)
356
 
#   define DYN_ALLOC
357
 
#endif
358
 
 
359
 
#ifndef SSTAT
360
 
#  define SSTAT      stat
361
 
#endif
362
 
#ifdef S_IFLNK
363
 
#  define LSTAT      lstat
364
 
#  define LSSTAT(n, s)  (linkput ? lstat((n), (s)) : SSTAT((n), (s)))
365
 
#else
366
 
#  define LSTAT      SSTAT
367
 
#  define LSSTAT     SSTAT
368
 
#endif
369
 
 
370
 
/* The following default definition of the second input for the crypthead()
371
 
 * random seed computation can be used on most systems (all those that
372
 
 * supply a UNIX compatible getpid() function).
373
 
 */
374
 
#ifdef ZCRYPT_INTERNAL
375
 
#  ifndef ZCR_SEED2
376
 
#    define ZCR_SEED2     (unsigned) getpid()   /* use PID as seed pattern */
377
 
#  endif
378
 
#endif /* ZCRYPT_INTERNAL */
379
 
 
380
 
/* The following OS codes are defined in pkzip appnote.txt */
381
 
#ifdef AMIGA
382
 
#  define OS_CODE  0x100
383
 
#endif
384
 
#ifdef VMS
385
 
#  define OS_CODE  0x200
386
 
#endif
387
 
/* unix    3 */
388
 
#ifdef VM_CMS
389
 
#  define OS_CODE  0x400
390
 
#endif
391
 
#ifdef ATARI
392
 
#  define OS_CODE  0x500
393
 
#endif
394
 
#ifdef OS2
395
 
#  define OS_CODE  0x600
396
 
#endif
397
 
#ifdef MACOS
398
 
#  define OS_CODE  0x700
399
 
#endif
400
 
/* z system 8 */
401
 
/* cp/m     9 */
402
 
#ifdef TOPS20
403
 
#  define OS_CODE  0xa00
404
 
#endif
405
 
#ifdef WIN32
406
 
#  define OS_CODE  0xb00
407
 
#endif
408
 
#ifdef QDOS
409
 
#  define OS_CODE  0xc00
410
 
#endif
411
 
#ifdef RISCOS
412
 
#  define OS_CODE  0xd00
413
 
#endif
414
 
#ifdef VFAT
415
 
#  define OS_CODE  0xe00
416
 
#endif
417
 
#ifdef MVS
418
 
#  define OS_CODE  0xf00
419
 
#endif
420
 
#ifdef __BEOS__
421
 
#  define OS_CODE  0x1000
422
 
#endif
423
 
#ifdef TANDEM
424
 
#  define OS_CODE  0x1100
425
 
#endif
426
 
#ifdef THEOS
427
 
#  define OS_CODE  0x1200
428
 
#endif
429
 
 
430
 
#define NUM_HOSTS 19
431
 
/* Number of operating systems. Should be updated when new ports are made */
432
 
 
433
 
#if defined(DOS) && !defined(OS_CODE)
434
 
#  define OS_CODE  0x000
435
 
#endif
436
 
 
437
 
#ifndef OS_CODE
438
 
#  define OS_CODE  0x300  /* assume Unix */
439
 
#endif
440
 
 
441
 
/* can't use "return 0" from main() on VMS */
442
 
#ifndef EXIT
443
 
//#  define EXIT  exit
444
 
#  define EXIT  ziperr
445
 
#endif
446
 
#ifndef RETURN
447
 
#  define RETURN return
448
 
#endif
449
 
 
450
 
#ifndef ZIPERR
451
 
#  define ZIPERR ziperr
452
 
#endif
453
 
 
454
 
#if (defined(USE_ZLIB) && defined(MY_ZCALLOC))
455
 
   /* special zcalloc function is not needed when linked against zlib */
456
 
#  undef MY_ZCALLOC
457
 
#endif
458
 
 
459
 
#if (!defined(USE_ZLIB) && !defined(MY_ZCALLOC))
460
 
   /* Any system without a special calloc function */
461
 
#  define zcalloc(items,size) \
462
 
          (zvoid far *)calloc((unsigned)(items), (unsigned)(size))
463
 
#  define zcfree    free
464
 
#endif /* !USE_ZLIB && !MY_ZCALLOC */
465
 
 
466
 
/* end of tailor.h */