ZipLib.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
  3. See the accompanying file LICENSE, version 1999-Oct-05 or later
  4. (the contents of which are also included in zip.h) for terms of use.
  5. If, for some reason, both of these files are missing, the Info-ZIP license
  6. also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
  7. */
  8. /*---------------------------------------------------------------------------
  9. ZipLib.h
  10. This header-files is global to the project ZipLib.
  11. ---------------------------------------------------------------------------*/
  12. /*****************************************************************************/
  13. /* Macros, typedefs */
  14. /*****************************************************************************/
  15. #define MACOS
  16. #define MACZIP
  17. #define OLDROUTINENAMES 0 /* use new function names only */
  18. #define OLDROUTINELOCATIONS 0 /* use new headerlocations only */
  19. #define SystemSevenOrLater 1 /* Runs only on System 7.0 or later */
  20. /* These functions are defined as a macro instead of a function.
  21. so we have to undefine them for replacing (see printf.c) */
  22. #undef getc
  23. #undef getchar
  24. #undef putchar
  25. #undef putc
  26. #ifndef ZCONST
  27. # define ZCONST const
  28. #endif
  29. #define NAME_MAX 1024
  30. /*****************************************************************************/
  31. /* Includes standard headers */
  32. /*****************************************************************************/
  33. #include <ansi_prefix.mac.h>
  34. #include <stdio.h>
  35. #include <TextUtils.h>
  36. #include <Folders.h>
  37. #include <Aliases.h>
  38. #include <Resources.h>
  39. #include <Gestalt.h>
  40. #include <Traps.h>
  41. #include <Processes.h>
  42. #include <MacWindows.h>
  43. /* Many things are different for mac-users, so we need
  44. special mac functions :-) */
  45. int Zmacstat (const char *path, struct stat *buf);
  46. #define stat(path, bufPtr) Zmacstat(path, bufPtr)
  47. #define lstat(path, bufPtr) Zmacstat(path, bufPtr)
  48. int fprintf(FILE *file, const char *format, ...);
  49. int printf(const char *format, ...);
  50. void perror(const char *parm1);
  51. /*
  52. #define MAC_DEBUG 1
  53. #define DEBUG 1
  54. */
  55. #ifdef MAC_DEBUG
  56. #define LOG_DEBUG 7 /* debug-level messages */
  57. int Print2Syslog(UInt8 priority, const char *format, ...);
  58. #include <ctype.h>
  59. #define Notify(msg) \
  60. { \
  61. (void)Print2Syslog(LOG_DEBUG, "%s (file: %s line: %d)", \
  62. msg, __FILE__, __LINE__); \
  63. }
  64. #define Assert_it(cond,msg,kind) \
  65. { \
  66. if (!(cond)) \
  67. { \
  68. (void)Print2Syslog(LOG_DEBUG,"%s failed: [%s] cond: [%s] (file: %s line: %d)", \
  69. kind, msg, #cond, __FILE__, __LINE__); \
  70. } \
  71. }
  72. #define AssertBool(b,msg) Assert_it (((b) == TRUE) || ((b) == FALSE),(msg),("AssertBool "))
  73. #define AssertStr(s,msg) \
  74. { \
  75. int s_i = 0; \
  76. Assert_it ((s),(msg),("1. AssertStr ")); \
  77. while ((s)[s_i]) { \
  78. Assert_it ((!iscntrl((s)[s_i]) || ((s)[s_i] == 0x0A) || \
  79. ((s)[s_i] == 0x0D)),(s),("2. AssertStr ")); \
  80. s_i++; \
  81. } \
  82. }
  83. #define AssertTime(t,msg) Assert_it (((t).tm_sec >= 0) && ((t).tm_sec < 62) && \
  84. ((t).tm_min >= 0) && ((t).tm_min < 60) && \
  85. ((t).tm_hour >= 0) && ((t).tm_hour < 24) && \
  86. ((t).tm_mday >= 1) && ((t).tm_mday < 32) && \
  87. ((t).tm_mon >= 0) && ((t).tm_mon < 12) && \
  88. ((t).tm_wday >= 0) && ((t).tm_wday < 7) && \
  89. ((t).tm_yday >= 0) && ((t).tm_yday < 366),(msg),("AssertStr "))
  90. #define AssertIntRange(myvalue,minimum,maximum, msg) Assert_it ( \
  91. ((myvalue) >= (minimum)) && ((myvalue) <= (maximum)), msg,("AssertIntRange "))
  92. #define AssertStrNoOverlap(str1,str2,msg) \
  93. { \
  94. long s_i = 0; \
  95. AssertStr((str1),(msg)) \
  96. AssertStr((str2),(msg)) \
  97. if ((str1) < (str2)) \
  98. { \
  99. s_i = strlen((str2)); \
  100. Assert_it ( (((str1) + s_i) < (str2)),(msg),("AssertStrNoOverlap ")); \
  101. } \
  102. else \
  103. { \
  104. s_i = strlen((str1)); \
  105. Assert_it ( (((str2) + s_i) < (str1)),(msg),("AssertStrNoOverlap ")); \
  106. } \
  107. } \
  108. #else
  109. #define Assert_it(cond,msg,kind)
  110. #define AssertBool(b,msg)
  111. #define AssertStr(s,msg)
  112. #define AssertTime(t,msg)
  113. #define AssertIntRange(myvalue,minimum,maximum,msg)
  114. #define AssertStrNoOverlap(str1,str2,msg)
  115. #endif