1/*
2  Copyright (c) 1990-2000 Info-ZIP.  All rights reserved.
3
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
8*/
9/*---------------------------------------------------------------------------
10
11  UnZpLib.h
12
13  This header-files is global to the project UnZpLib.
14
15  ---------------------------------------------------------------------------*/
16
17/*****************************************************************************/
18/*  Macros, typedefs                                                         */
19/*****************************************************************************/
20
21#define MacStaticLib
22#define MACUNZIP
23
24/* These functions are defined as a macro instead of a function.
25so we have to undefine them for replacing (see printf.c)  */
26#undef getc
27#undef getchar
28#undef putchar
29#undef putc
30
31#ifndef    TRUE
32#define    TRUE 1
33#endif  /* TRUE */
34#ifndef    FALSE
35#define    FALSE 0
36#endif  /* FALSE */
37
38/*
39#define DEBUG_TIME
40 */
41
42
43#define USE_EF_UT_TIME
44
45/* since we have no TZ environment variable on Macs
46   this option must be disabled */
47#undef IZ_CHECK_TZ
48
49
50/*****************************************************************************/
51/*  Includes standard headers                                                */
52/*****************************************************************************/
53#include <ansi_prefix.mac.h>
54#include <TextUtils.h>
55#include <Folders.h>
56#include <Aliases.h>
57#include <Resources.h>
58#include <Gestalt.h>
59#include <Traps.h>
60#include <Processes.h>
61#include <MacWindows.h>
62#include <Fonts.h>
63#include <ToolUtils.h>
64#include <Dialogs.h>
65#include <Devices.h>
66#include <StandardFile.h>
67
68
69/*
70#define MAC_DEBUG  1
71 */
72
73
74#ifdef MAC_DEBUG
75#define LOG_DEBUG   7   /* debug-level messages */
76int Print2Syslog(UInt8 priority, const char *format, ...);
77#include <ctype.h>
78
79
80#define Notify(msg)                                             \
81    {                                                           \
82    (void)Print2Syslog(LOG_DEBUG, "%s (file: %s line: %d)",     \
83                       msg, __FILE__, __LINE__);                \
84    }
85
86
87
88#define Assert_it(cond,msg,kind)                                    \
89    {                                                               \
90    if (!(cond))                                                    \
91        {                                                           \
92        (void)Print2Syslog(LOG_DEBUG, "%s failed: [%s] cond: [%s] (file: %s line: %d)", \
93                           kind, msg, #cond, __FILE__, __LINE__);   \
94        }                                                           \
95    }
96
97
98
99#define AssertBool(b,msg) \
100    Assert_it (((b) == TRUE) || ((b) == FALSE),(msg),("AssertBool "))
101
102
103
104#define AssertStr(s,msg)                                            \
105    {                                                               \
106        int s_i = 0;                                                \
107        Assert_it ((s),(msg),("1. AssertStr "));                    \
108        while ((s)[s_i]) {                                          \
109            Assert_it ((!iscntrl((s)[s_i]) || ((s)[s_i] == 0x0A) || \
110                       ((s)[s_i] == 0x0D)),(s),("2. AssertStr "));  \
111            s_i++;                                                  \
112        }                                                           \
113    }
114
115
116
117#define AssertTime(t,msg) \
118    Assert_it (((t).tm_sec  >=  0) && ((t).tm_sec  < 62) &&   \
119               ((t).tm_min  >=  0) && ((t).tm_min  < 60) &&   \
120               ((t).tm_hour >=  0) && ((t).tm_hour < 24) &&   \
121               ((t).tm_mday >=  1) && ((t).tm_mday < 32) &&   \
122               ((t).tm_mon  >=  0) && ((t).tm_mon  < 12) &&   \
123               ((t).tm_wday >=  0) && ((t).tm_wday < 7)  &&   \
124               ((t).tm_yday >=  0) && ((t).tm_yday < 366),(msg),("AssertStr "))
125
126
127
128#define AssertIntRange(myvalue,minimum,maximum, msg) \
129    Assert_it (((myvalue) >= (minimum)) && ((myvalue) <= (maximum)), \
130               msg,("AssertIntRange "))
131
132
133
134#define AssertStrNoOverlap(str1,str2,msg)                           \
135    {                                                               \
136        long s_i = 0;                                               \
137        AssertStr((str1),(msg))                                     \
138        AssertStr((str2),(msg))                                     \
139        if ((str1) < (str2))                                        \
140            {                                                       \
141            s_i = strlen((str2));                                   \
142            Assert_it ( (((str1) + s_i) < (str2)),(msg),("AssertStrNoOverlap "));   \
143            }                                                       \
144        else                                                        \
145            {                                                       \
146            s_i = strlen((str1));                                   \
147            Assert_it ( (((str2) + s_i) < (str1)),(msg),("AssertStrNoOverlap "));   \
148            }                                                       \
149    }                                                               \
150
151
152
153
154#else /* !MAC_DEBUG */
155#define Assert_it(cond,msg,kind)
156#define AssertBool(b,msg)
157#define AssertStr(s,msg)
158#define AssertTime(t,msg)
159#define AssertIntRange(myvalue,minimum,maximum,msg)
160#define AssertStrNoOverlap(str1,str2,msg)
161#endif /* ?MAC_DEBUG */
162