~ubuntu-branches/ubuntu/quantal/unzip/quantal

« back to all changes in this revision

Viewing changes to unzipstb.c

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2009-05-08 20:02:40 UTC
  • mfrom: (2.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090508200240-rk23wg0jdoyc6caj
Tags: 6.0-1
* New upstream release. Closes: #496989.
* Enabled new Unicode support. Closes: #197427. This may or may not work
  for your already created zipfiles, but it's not a bug unless they were
  created using the Unicode feature present in zip 3.0.
* Built using DATE_FORMAT=DF_YMD so that unzip -l show dates in ISO format,
  as that's the only available one which makes sense. Closes: #312886.
* Enabled new bzip2 support. Closes: #426798.
* Exit code for zipgrep should now be the right one. Closes: #441997.
* The reason why a file may not be created is now shown. Closes: #478791.
* Summary of changes in this version not being the debian/* files:
- Manpages in section 1, not 1L.
- Branding patch. UnZip by Debian. Original by Info-ZIP.
- Always #include <unistd.h>. Debian GNU/kFreeBSD needs it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
  Copyright (c) 1990-2001 Info-ZIP.  All rights reserved.
 
2
  Copyright (c) 1990-2009 Info-ZIP.  All rights reserved.
3
3
 
4
 
  See the accompanying file LICENSE, version 2000-Apr-09 or later
 
4
  See the accompanying file LICENSE, version 2009-Jan-02 or later
5
5
  (the contents of which are also included in unzip.h) for terms of use.
6
6
  If, for some reason, all these files are missing, the Info-ZIP license
7
7
  also may be found at:  ftp://ftp.info-zip.org/pub/infozip/license.html
22
22
 
23
23
#include <stdio.h>
24
24
#include "unzip.h"
 
25
#if defined(MODERN) && !defined(NO_STDDEF_H)
 
26
# include <stddef.h>
 
27
#endif
25
28
#include "unzvers.h"
26
29
 
27
30
int main(int argc, char *argv[])
28
31
{
29
 
    static UzpVer *pVersion;   /* no pervert jokes, please... */
 
32
    static ZCONST UzpVer *pVersion;     /* no pervert jokes, please... */
30
33
 
31
34
    pVersion = UzpVersion();
32
35
 
33
36
    printf("UnZip stub:  checking version numbers (DLL is dated %s)\n",
34
37
      pVersion->date);
35
 
    printf("   UnZip versions:    expecting %d.%d%d, using %d.%d%d%s\n",
 
38
    printf("   UnZip versions:    expecting %u.%u%u, using %u.%u%u%s\n",
36
39
      UZ_MAJORVER, UZ_MINORVER, UZ_PATCHLEVEL, pVersion->unzip.major,
37
40
      pVersion->unzip.minor, pVersion->unzip.patchlevel, pVersion->betalevel);
38
 
    printf("   ZipInfo versions:  expecting %d.%d%d, using %d.%d%d\n",
 
41
    printf("   ZipInfo versions:  expecting %u.%u%u, using %u.%u%u\n",
39
42
      ZI_MAJORVER, ZI_MINORVER, UZ_PATCHLEVEL, pVersion->zipinfo.major,
40
43
      pVersion->zipinfo.minor, pVersion->zipinfo.patchlevel);
41
44
 
42
45
/*
43
46
    D2_M*VER and os2dll.* are obsolete, though retained for compatibility:
44
47
 
45
 
    printf("   OS2 DLL versions:  expecting %d.%d%d, using %d.%d%d\n",
 
48
    printf("   OS2 DLL versions:  expecting %u.%u%u, using %u.%u%u\n",
46
49
      D2_MAJORVER, D2_MINORVER, D2_PATCHLEVEL, pVersion->os2dll.major,
47
50
      pVersion->os2dll.minor, pVersion->os2dll.patchlevel);
48
51
 */
49
52
 
50
53
    if (pVersion->flag & 2)
51
54
        printf("   using zlib version %s\n", pVersion->zlib_version);
 
55
 
 
56
    /* This example code only uses the dll calls UzpVersion() and
 
57
     * UzpMain().  The APIs for these two calls have maintained backward
 
58
     * compatibility since at least the UnZip release 5.3 !
 
59
     */
 
60
#   define UZDLL_MINVERS_MAJOR          5
 
61
#   define UZDLL_MINVERS_MINOR          3
 
62
#   define UZDLL_MINVERS_PATCHLEVEL     0
 
63
    /* This UnZip DLL stub requires a DLL version of at least: */
 
64
    if ( (pVersion->unzip.major < UZDLL_MINVERS_MAJOR) ||
 
65
         ((pVersion->unzip.major == UZDLL_MINVERS_MAJOR) &&
 
66
          ((pVersion->unzip.minor < UZDLL_MINVERS_MINOR) ||
 
67
           ((pVersion->unzip.minor == UZDLL_MINVERS_MINOR) &&
 
68
            (pVersion->unzip.patchlevel < UZDLL_MINVERS_PATCHLEVEL)
 
69
           )
 
70
          )
 
71
         ) )
 
72
    {
 
73
        printf("  aborting because of too old UnZip DLL version!\n");
 
74
        return -1;
 
75
    }
 
76
 
 
77
    /* In case the offsetof() macro is not supported by some C compiler
 
78
       environment, it might be replaced by something like:
 
79
         ((extent)(void *)&(((UzpVer *)0)->dllapimin))
 
80
     */
 
81
    if (pVersion->structlen >=
 
82
#if defined(MODERN) && !defined(NO_STDDEF_H)
 
83
        ( offsetof(UzpVer, dllapimin)
 
84
#else
 
85
          ((unsigned)&(((UzpVer *)0)->dllapimin))
 
86
#endif
 
87
         + sizeof(_version_type) ))
 
88
    {
 
89
#ifdef OS2DLL
 
90
#       define UZ_API_COMP_MAJOR        UZ_OS2API_COMP_MAJOR
 
91
#       define UZ_API_COMP_MINOR        UZ_OS2API_COMP_MINOR
 
92
#       define UZ_API_COMP_REVIS        UZ_OS2API_COMP_REVIS
 
93
#else /* !OS2DLL */
 
94
#ifdef WINDLL
 
95
#       define UZ_API_COMP_MAJOR        UZ_WINAPI_COMP_MAJOR
 
96
#       define UZ_API_COMP_MINOR        UZ_WINAPI_COMP_MINOR
 
97
#       define UZ_API_COMP_REVIS        UZ_WINAPI_COMP_REVIS
 
98
#else /* !WINDLL */
 
99
#       define UZ_API_COMP_MAJOR        UZ_GENAPI_COMP_MAJOR
 
100
#       define UZ_API_COMP_MINOR        UZ_GENAPI_COMP_MINOR
 
101
#       define UZ_API_COMP_REVIS        UZ_GENAPI_COMP_REVIS
 
102
#endif /* ?WINDLL */
 
103
#endif /* ?OS2DLL */
 
104
        printf(
 
105
          "   UnZip API version: can handle <= %u.%u%u, DLL supplies %u.%u%u\n",
 
106
          UZ_API_COMP_MAJOR, UZ_API_COMP_MINOR, UZ_API_COMP_REVIS,
 
107
          pVersion->dllapimin.major, pVersion->dllapimin.minor,
 
108
          pVersion->dllapimin.patchlevel);
 
109
        if ( (pVersion->dllapimin.major > UZ_API_COMP_MAJOR) ||
 
110
             ((pVersion->dllapimin.major == UZ_API_COMP_MAJOR) &&
 
111
              ((pVersion->dllapimin.minor > UZ_API_COMP_MINOR) ||
 
112
               ((pVersion->dllapimin.minor == UZ_API_COMP_MINOR) &&
 
113
                (pVersion->dllapimin.patchlevel > UZ_API_COMP_REVIS)
 
114
               )
 
115
              )
 
116
             ) )
 
117
        {
 
118
            printf("  aborting because of unsupported dll api version!\n");
 
119
            return -1;
 
120
        }
 
121
    }
52
122
    printf("\n");
53
123
 
54
124
    /* call the actual UnZip routine (string-arguments version) */