amiga.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. Copyright (c) 1990-2005 Info-ZIP. All rights reserved.
  3. See the accompanying file LICENSE, version 2005-Feb-10 or later
  4. (the contents of which are also included in zip.h) for terms of use.
  5. If, for some reason, all these files are missing, the Info-ZIP license
  6. also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
  7. */
  8. /* OS specific routines for AMIGA platform.
  9. *
  10. * John Bush <John.Bush@east.sun.com> BIX: jbush
  11. * Paul Kienitz <kie@pacbell.net>
  12. *
  13. * History:
  14. *
  15. * Date DoBee Comments
  16. * ------- -------- -----------------------------------------------
  17. * 21Jan93 JBush Original coding.
  18. * Incorporated filedate.c (existing routine).
  19. *
  20. * 31Jan93 JBush Made filedate.c include unconditional.
  21. *
  22. * 18Jul93 PaulK Moved Aztec _abort() here from stat.c because we
  23. * can't share the same one between Zip and UnZip.
  24. * Added close_leftover_open_dirs() call to it.
  25. *
  26. * 17Apr95 PaulK Added Amiga internal version string so that
  27. * installer programs can compare the version being
  28. * installed to see if the copy the user already has
  29. * is older or newer. Added Prestart_Hook to support
  30. * debug tracing in deflate.a.
  31. *
  32. * 6May95 PaulK Added GetComment() for filenote support.
  33. *
  34. * 12Nov95 PaulK Added #define ZIP in front of filedate.c, for
  35. * new options in there; removed declare of set_con()
  36. * since echon() no longer expands to it (or anything).
  37. *
  38. * 12Feb96 PaulK Removed call of echon() entirely.
  39. *
  40. * 12Jul97 PaulK Made both Aztec and SAS define USE_TIME_LIB for filedate.c
  41. *
  42. * 26Aug97 PaulK Added ClearIOErr_exit()
  43. *
  44. * 2Jan98 HWalt Adapted for SAS/C using stat.c replacement functions
  45. *
  46. * 6Jun00 PaulK Removed references to time_lib, since new filedate.c
  47. * supercedes it
  48. */
  49. #include <exec/memory.h>
  50. #ifdef AZTEC_C
  51. # include <libraries/dos.h>
  52. # include <libraries/dosextens.h>
  53. # include <clib/exec_protos.h>
  54. # include <clib/dos_protos.h>
  55. # include <pragmas/exec_lib.h>
  56. # include <pragmas/dos_lib.h>
  57. #else
  58. # include <proto/exec.h>
  59. # include <proto/dos.h>
  60. #endif
  61. #include <stdlib.h>
  62. #include "ziperr.h"
  63. void ziperr(int c, const char *h);
  64. #define ZIP
  65. #if !defined(UTIL)
  66. # define NO_MKTIME
  67. #endif
  68. #ifdef AZTEC_C
  69. /* ============================================================= */
  70. /* filedate.c is an external file, since it's shared with UnZip. */
  71. /* Aztec includes it here, but SAS/C now compiles it separately. */
  72. # include "amiga/filedate.c"
  73. /* the same applies to stat.c */
  74. # include "amiga/stat.c"
  75. # define setenv BOGUS_INCOMPATIBLE_setenv
  76. # include <fcntl.h>
  77. # undef setenv
  78. # ifdef DEBUG
  79. # define PRESTART_HOOK
  80. # endif
  81. #endif
  82. extern void close_leftover_open_dirs(void);
  83. /* the following handles cleanup when a ^C interrupt happens: */
  84. void _abort(void) /* called when ^C is pressed */
  85. {
  86. close_leftover_open_dirs();
  87. ziperr(ZE_ABORT, "^C");
  88. }
  89. void ClearIOErr_exit(int e) /* EXIT is defined as this */
  90. {
  91. if (!e)
  92. ((struct Process *) FindTask(NULL))->pr_Result2 = 0;
  93. /* we clear IoErr() since we are successful, in a 1.x-compatible way */
  94. exit(e);
  95. }
  96. /* Make sure the version number here matches the number in revision.h */
  97. /* as closely as possible in strict decimal "#.#" form: */
  98. const char version_id[] = "\0$VER: Zip 2.3 ("
  99. # include "env:VersionDate"
  100. ")\r\n";
  101. /* call this with an arg of NULL to free storage: */
  102. char *GetComment(char *filename)
  103. {
  104. BPTR lk;
  105. static struct FileInfoBlock *fib = NULL;
  106. if (!filename) {
  107. if (fib) FreeMem(fib, sizeof(*fib));
  108. fib = NULL;
  109. return NULL;
  110. }
  111. if (!fib) {
  112. if (!(fib = AllocMem(sizeof(*fib), MEMF_PUBLIC)))
  113. ziperr(ZE_MEM, "was checking filenotes");
  114. }
  115. if (!(lk = Lock(filename, ACCESS_READ)))
  116. return NULL;
  117. if (!Examine(lk, fib))
  118. fib->fib_Comment[0] = '\0';
  119. UnLock(lk);
  120. return fib->fib_Comment[0] ? &fib->fib_Comment[0] : NULL;
  121. }