home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / zip22.zip / amiga / amiga.c next >
C/C++ Source or Header  |  1997-10-06  |  4KB  |  126 lines

  1. /*
  2.  
  3.  Copyright (C) 1990-1997 Mark Adler, Richard B. Wales, Jean-loup Gailly,
  4.  Kai Uwe Rommel, Onno van der Linden, Igor Mandrichenko, Paul Kienitz and
  5.  John Bush.
  6.  Permission is granted to any individual or institution to use, copy, or
  7.  redistribute this software so long as all of the original files are included,
  8.  that it is not sold for profit, and that this copyright notice is retained.
  9.  
  10. */
  11.  
  12. /* OS specific routines for AMIGA platform.
  13.  *
  14.  * John Bush    <John.Bush@east.sun.com>  BIX: jbush
  15.  * Paul Kienitz <kie@pacbell.net>
  16.  *
  17.  * History:
  18.  *
  19.  * Date     DoBee    Comments
  20.  * -------  -------- -----------------------------------------------
  21.  * 21Jan93  JBush    Original coding.
  22.  *                   Incorporated filedate.c (existing routine).
  23.  *
  24.  * 31Jan93  JBush    Made filedate.c include unconditional.
  25.  *
  26.  * 18Jul93  PaulK    Moved Aztec _abort() here from stat.c because we
  27.  *                   can't share the same one between Zip and UnZip.
  28.  *                   Added close_leftover_open_dirs() call to it.
  29.  *
  30.  * 17Apr95  PaulK    Added Amiga internal version string so that
  31.  *                   installer programs can compare the version being
  32.  *                   installed to see if the copy the user already has
  33.  *                   is older or newer.  Added Prestart_Hook to support
  34.  *                   debug tracing in deflate.a.
  35.  *
  36.  *  6May95  PaulK    Added GetComment() for filenote support.
  37.  *
  38.  * 12Nov95  PaulK    Added #define ZIP in front of filedate.c, for
  39.  *                   new options in there; removed declare of set_con()
  40.  *                   since echon() no longer expands to it (or anything).
  41.  *
  42.  * 12Feb96  PaulK    Removed call of echon() entirely.
  43.  *
  44.  * 12Jul97  PaulK    Made both Aztec and SAS define USE_TIME_LIB for filedate.c
  45.  *
  46.  * 26Aug97  PaulK    Added ClearIOErr_exit()
  47.  */
  48.  
  49. #include <stdlib.h>
  50. #include "ziperr.h"
  51. void ziperr(int c, char *h);
  52.  
  53. /* ============================================================ */
  54. /* filedate.c is an external file, since it's shared with UnZip */
  55.  
  56. #if defined(AZTEC_C) || defined(__SASC)
  57. #  define USE_TIME_LIB
  58. #endif
  59.  
  60. #define ZIP
  61. #if !defined(UTIL) && !defined(USE_TIME_LIB)
  62. #  define NO_MKTIME
  63. #endif
  64. #include "amiga/filedate.c"
  65.  
  66. #ifdef AZTEC_C
  67. #  define setenv BOGUS_INCOMPATIBLE_setenv
  68. #  include <fcntl.h>
  69. #  undef setenv
  70. #  ifdef DEBUG
  71. #    define PRESTART_HOOK
  72. #  endif
  73. #endif
  74.  
  75. /* ============================================================ */
  76. /* the same applies to stat.c                                   */
  77.  
  78. #include "amiga/stat.c"
  79.  
  80. /* the following handles cleanup when a ^C interrupt happens: */
  81.  
  82. void _abort(void)               /* called when ^C is pressed */
  83. {
  84.     close_leftover_open_dirs();
  85.     ziperr(ZE_ABORT, "^C");
  86. }
  87.  
  88. void ClearIOErr_exit(int e)     /* EXIT is defined as this */
  89. {
  90.     if (!e)
  91.         ((struct Process *) FindTask(NULL))->pr_Result2 = 0;
  92.     /* we clear IoErr() since we are successful, in a 1.x-compatible way */
  93.     exit(e);
  94. }
  95.  
  96.  
  97. /* Make sure the version number here matches the number in revision.h */
  98. /* as closely as possible in strict decimal "#.#" form:               */
  99. const char version_id[] = "\0$VER: Zip 2.2 ("
  100. #  include "env:VersionDate"
  101. ")\r\n";
  102.  
  103. /* call this with an arg of NULL to free storage: */
  104.  
  105. char *GetComment(char *filename)
  106. {
  107.     BPTR lk;
  108.     static struct FileInfoBlock *fib = NULL;
  109.  
  110.     if (!filename) {
  111.         if (fib) FreeMem(fib, sizeof(*fib));
  112.         fib = NULL;
  113.         return NULL;
  114.     }
  115.     if (!fib) {
  116.         if (!(fib = AllocMem(sizeof(*fib), MEMF_PUBLIC)))
  117.             ziperr(ZE_MEM, "was checking filenotes");
  118.     }
  119.     if (!(lk = Lock(filename, ACCESS_READ)))
  120.         return NULL;
  121.     if (!Examine(lk, fib))
  122.         fib->fib_Comment[0] = '\0';
  123.     UnLock(lk);
  124.     return fib->fib_Comment[0] ? &fib->fib_Comment[0] : NULL;
  125. }
  126.