home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / zip21.zip / amiga / amiga.c next >
C/C++ Source or Header  |  1996-04-05  |  3KB  |  104 lines

  1. /*
  2.  
  3.  Copyright (C) 1990-1996 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    <JBush@landfill.east.sun.com>  BIX: jbush
  15.  * Paul Kienitz <Paul.Kienitz@f28.n125.z1.fidonet.org>
  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.  
  45. #include "ziperr.h"
  46. void ziperr(int c, char *h);
  47.  
  48. /* ============================================================ */
  49. /* filedate.c is an external file, since it's shared with UnZip */
  50.  
  51. #define ZIP
  52. #include "amiga/filedate.c"
  53.  
  54. #ifdef AZTEC_C
  55. #  include <fcntl.h>
  56. #  ifdef DEBUG
  57. #    define PRESTART_HOOK
  58. #  endif
  59.  
  60. /* ============================================================ */
  61. /* the same applies to stat.c, but only for Aztec               */
  62.  
  63. #  include "amiga/stat.c"
  64.  
  65. /* the following handles cleanup when a ^C interrupt happens: */
  66.  
  67. void _abort(void)               /* called when ^C is pressed */
  68. {
  69.     close_leftover_open_dirs();
  70.     ziperr(ZE_ABORT, "^C");
  71. }
  72.  
  73. #endif /* AZTEC_C */
  74.  
  75. /* Make sure the version number here matches the mumber in revision.h */
  76. /* as closely as possible in strict decimal "#.#" form:               */
  77. static char version_id[] = "\0$VER: Zip 2.1 ("
  78. #  include "env:VersionDate"
  79. ")\r\n";
  80.  
  81. /* call this with an arg of NULL to free storage: */
  82.  
  83. char *GetComment(char *filename)
  84. {
  85.     BPTR lk;
  86.     static struct FileInfoBlock *fib = NULL;
  87.  
  88.     if (!filename) {
  89.         if (fib) FreeMem(fib, sizeof(*fib));
  90.         fib = NULL;
  91.         return NULL;
  92.     }
  93.     if (!fib) {
  94.         if (!(fib = AllocMem(sizeof(*fib), MEMF_PUBLIC)))
  95.             ziperr(ZE_MEM, "was checking filenotes");
  96.     }
  97.     if (!(lk = Lock(filename, ACCESS_READ)))
  98.         return NULL;
  99.     if (!Examine(lk, fib))
  100.         fib->fib_Comment[0] = '\0';
  101.     UnLock(lk);
  102.     return fib->fib_Comment[0] ? &fib->fib_Comment[0] : NULL;
  103. }
  104.