1/*
2  Copyright (c) 1990-2007 Info-ZIP.  All rights reserved.
3
4  See the accompanying file LICENSE, version 2007-Mar-4 or later
5  (the contents of which are also included in zip.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
8*/
9#ifndef VMS
10#  define VMS 1
11#endif
12
13#if (defined(__VMS_VER) && !defined(__CRTL_VER))
14#  define __CRTL_VER __VMS_VER
15#endif
16
17#if (defined(__VMS_VERSION) && !defined(VMS_VERSION))
18#  define VMS_VERSION __VMS_VERSION
19#endif
20
21#if !(defined(__DECC) || defined(__DECCXX) || defined(__GNUC__))
22     /* VAX C does not properly support the void keyword. (Only functions
23        are allowed to have the type "void".)  */
24#  ifndef NO_TYPEDEF_VOID
25#    define NO_TYPEDEF_VOID
26#  endif
27#  define NO_FCNTL_H        /* VAXC does not supply fcntl.h. */
28#endif /* VAX C */
29
30#define USE_CASE_MAP
31#define PROCNAME(n) \
32 (((action == ADD) || (action == UPDATE) || (action == FRESHEN)) ? \
33 wild(n) : procname(n, filter_match_case))
34
35/* 2004-11-09 SMS.
36   Large file support.
37*/
38#ifdef LARGE_FILE_SUPPORT
39
40#  define _LARGEFILE                   /* Define the pertinent macro. */
41
42/* LARGE_FILE_SUPPORT implies ZIP64_SUPPORT,
43   unless explicitly disabled by NO_ZIP64_SUPPORT.
44*/
45#  ifdef NO_ZIP64_SUPPORT
46#    ifdef ZIP64_SUPPORT
47#      undef ZIP64_SUPPORT
48#    endif /* def ZIP64_SUPPORT */
49#  else /* def NO_ZIP64_SUPPORT */
50#    ifndef ZIP64_SUPPORT
51#      define ZIP64_SUPPORT
52#    endif /* ndef ZIP64_SUPPORT */
53#  endif /* def NO_ZIP64_SUPPORT */
54
55#  define ZOFF_T_FORMAT_SIZE_PREFIX "ll"
56
57#else /* def LARGE_FILE_SUPPORT */
58
59#  define ZOFF_T_FORMAT_SIZE_PREFIX "l"
60
61#endif /* def LARGE_FILE_SUPPORT */
62
63/* Need _LARGEFILE for types.h. */
64
65#include <types.h>
66
67#ifdef __GNUC__
68#include <sys/types.h>
69#endif /* def __GNUC__ */
70
71/* Need types.h for off_t. */
72
73#ifdef LARGE_FILE_SUPPORT
74   typedef off_t zoff_t;
75   typedef unsigned long long uzoff_t;
76#else /* def LARGE_FILE_SUPPORT */
77   typedef long zoff_t;
78   typedef unsigned long uzoff_t;
79#endif /* def LARGE_FILE_SUPPORT */
80
81#include <stat.h>
82
83typedef struct stat z_stat;
84
85#include <unixio.h>
86
87#if defined(__GNUC__) && !defined(ZCRYPT_INTERNAL)
88#  include <unixlib.h>          /* ctermid() declaration needed in ttyio.c */
89#endif
90#ifdef ZCRYPT_INTERNAL
91#  include <unixlib.h>          /* getpid() declaration for srand seed */
92#endif
93
94#if defined(_MBCS)
95#  undef _MBCS                 /* Zip on VMS does not support MBCS */
96#endif
97
98/* VMS is run on little-endian processors with 4-byte ints:
99 * enable the optimized CRC-32 code */
100#ifdef IZ_CRC_BE_OPTIMIZ
101#  undef IZ_CRC_BE_OPTIMIZ
102#endif
103#if !defined(IZ_CRC_LE_OPTIMIZ) && !defined(NO_CRC_OPTIMIZ)
104#  define IZ_CRC_LE_OPTIMIZ
105#endif
106#if !defined(IZ_CRCOPTIM_UNFOLDTBL) && !defined(NO_CRC_OPTIMIZ)
107#  define IZ_CRCOPTIM_UNFOLDTBL
108#endif
109
110#if !defined(NO_EF_UT_TIME) && !defined(USE_EF_UT_TIME)
111#  if (defined(__CRTL_VER) && (__CRTL_VER >= 70000000))
112#    define USE_EF_UT_TIME
113#  endif
114#endif
115
116#if defined(VMS_PK_EXTRA) && defined(VMS_IM_EXTRA)
117#  undef VMS_IM_EXTRA                 /* PK style takes precedence */
118#endif
119#if !defined(VMS_PK_EXTRA) && !defined(VMS_IM_EXTRA)
120#  define VMS_PK_EXTRA 1              /* PK style VMS support is default */
121#endif
122
123/* 2007-02-22 SMS.
124 * <unistd.h> is needed for symbolic link functions, so use it when the
125 * symbolic link criteria are met.
126 */
127#if defined(__VAX) || __CRTL_VER < 70301000
128#  define NO_UNISTD_H
129#  define NO_SYMLINKS
130#endif /* defined(__VAX) || __CRTL_VER < 70301000 */
131
132/* 2007-02-22 SMS.  Use delete() when unlink() is not available. */
133#if defined(NO_UNISTD_H) || (__CRTL_VER < 70000000)
134#  define unlink delete
135#endif /* defined(NO_UNISTD_H) || __CRTL_VER < 70000000) */
136
137#define SSTAT vms_stat
138#define EXIT(exit_code) vms_exit(exit_code)
139#define RETURN(exit_code) return (vms_exit(exit_code), 1)
140
141
142#ifdef __DECC
143
144/* File open callback ID values. */
145
146#  define FOPM_ID 1
147#  define FOPR_ID 2
148#  define FOPW_ID 3
149
150/* File open callback ID storage. */
151
152extern int fopm_id;
153extern int fopr_id;
154extern int fopw_id;
155
156/* File open callback ID function. */
157
158extern int acc_cb();
159
160/* Option macros for zfopen().
161 * General: Stream access
162 * Output: fixed-length, 512-byte records.
163 *
164 * Callback function (DEC C only) sets deq, mbc, mbf, rah, wbh, ...
165 */
166
167#  define FOPM "r+b", "ctx=stm", "rfm=fix", "mrs=512", "acc", acc_cb, &fopm_id
168#  define FOPR "rb",  "ctx=stm", "acc", acc_cb, &fopr_id
169#  define FOPW "wb",  "ctx=stm", "rfm=fix", "mrs=512", "acc", acc_cb, &fopw_id
170
171#else /* def __DECC */ /* (So, GNU C, VAX C, ...)*/
172
173#  define FOPM "r+b", "ctx=stm", "rfm=fix", "mrs=512"
174#  define FOPR "rb",  "ctx=stm"
175#  define FOPW "wb",  "ctx=stm", "rfm=fix", "mrs=512"
176
177#endif /* def __DECC */
178
179