home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2003 April / VPR0304.ISO / OLS / ZIPS3001 / zips3001.lzh / SFX32GUI.DIF < prev    next >
Text File  |  1998-10-11  |  59KB  |  1,668 lines

  1. diff -urP origsrc/crypt.c src/crypt.c
  2. --- origsrc/crypt.c    Mon Oct  6 04:05:30 1997
  3. +++ src/crypt.c    Mon Mar 31 05:59:58 1997
  4. @@ -1,12 +1,560 @@
  5.  /*
  6. -   crypt.c (dummy version) by Info-ZIP.      Last revised:  5 Oct 97
  7. +   crypt.c (full version) by Info-ZIP.      Last revised:  [see crypt.h]
  8.  
  9. -   This is a non-functional version of Info-ZIP's crypt.c encryption/
  10. -   decryption code for Zip, ZipCloak, UnZip and fUnZip.  This file is
  11. -   not copyrighted and may be distributed freely. :-)  See the "WHERE"
  12. -   file for sites from which to obtain the full encryption/decryption
  13. -   sources (zcrypt27.zip or later).
  14. +   This code is not copyrighted and is put in the public domain.  The
  15. +   encryption/decryption parts (as opposed to the non-echoing password
  16. +   parts) were originally written in Europe; the whole file can there-
  17. +   fore be freely distributed from any country except the USA.  If this
  18. +   code is imported into the USA, it cannot be re-exported from from
  19. +   there to another country.  (This restriction might seem curious, but
  20. +   this is what US law requires.)
  21.   */
  22.  
  23. -/* something "externally visible" to shut up compiler/linker warnings */
  24. -int zcr_dummy;
  25. +/* This encryption code is a direct transcription of the algorithm from
  26. +   Roger Schlafly, described by Phil Katz in the file appnote.txt.  This
  27. +   file (appnote.txt) is distributed with the PKZIP program (even in the
  28. +   version without encryption capabilities).
  29. + */
  30. +
  31. +#define ZCRYPT_INTERNAL
  32. +#include "zip.h"
  33. +#include "crypt.h"
  34. +#include "ttyio.h"
  35. +
  36. +#ifndef FALSE
  37. +#  define FALSE 0
  38. +#endif
  39. +
  40. +#ifdef ZIP
  41. +   /* For the encoding task used in Zip (and ZipCloak), we want to initialize
  42. +      the crypt algorithm with some reasonably unpredictable bytes, see
  43. +      the crypthead() function. The standard rand() library function is
  44. +      used to supply these `random' bytes, which in turn is initialized by
  45. +      a srand() call. The srand() function takes an "unsigned" (at least 16bit)
  46. +      seed value as argument to determine the starting point of the rand()
  47. +      pseudo-random number generator.
  48. +      This seed number is constructed as "Seed = Seed1 .XOR. Seed2" with
  49. +      Seed1 supplied by the current time (= "(unsigned)time()") and Seed2
  50. +      as some (hopefully) nondeterministic bitmask. On many (most) systems,
  51. +      we use some "process specific" number, as the PID or something similar,
  52. +      but when nothing unpredictable is available, a fixed number may be
  53. +      sufficient.
  54. +      NOTE:
  55. +      1.) This implementation requires the availability of the following
  56. +          standard UNIX C runtime library functions: time(), rand(), srand().
  57. +          On systems where some of them are missing, the environment that
  58. +          incorporates the crypt routines must supply suitable replacement
  59. +          functions.
  60. +      2.) It is a very bad idea to use a second call to time() to set the
  61. +          "Seed2" number! In this case, both "Seed1" and "Seed2" would be
  62. +          (almost) identical, resulting in a (mostly) "zero" constant seed
  63. +          number passed to srand().
  64. +
  65. +      The implementation environment defined in the "zip.h" header should
  66. +      supply a reasonable definition for ZCR_SEED2 (an unsigned number; for
  67. +      most implementations of rand() and srand(), only the lower 16 bits are
  68. +      significant!). An example that works on many systems would be
  69. +           "#define ZCR_SEED2  (unsigned)getpid()".
  70. +      The default definition for ZCR_SEED2 supplied below should be regarded
  71. +      as a fallback to allow successful compilation in "beta state"
  72. +      environments.
  73. +    */
  74. +#  include <time.h>     /* time() function supplies first part of crypt seed */
  75. +   /* "last resort" source for second part of crypt seed pattern */
  76. +#  ifndef ZCR_SEED2
  77. +#    define ZCR_SEED2 (unsigned)3141592654L     /* use PI as default pattern */
  78. +#  endif
  79. +#  ifdef GLOBAL         /* used in Amiga system headers, maybe others too */
  80. +#    undef GLOBAL
  81. +#  endif
  82. +#  define GLOBAL(g) g
  83. +#else /* !ZIP */
  84. +#  define GLOBAL(g) G.g
  85. +#endif /* ?ZIP */
  86. +
  87. +
  88. +#ifdef UNZIP
  89. +   /* char *key = (char *)NULL; moved to globals.h */
  90. +#  ifndef FUNZIP
  91. +     local int testp OF((__GPRO__ uch *h));
  92. +     local int testkey OF((__GPRO__ uch *h, char *key));
  93. +#  endif
  94. +#endif /* UNZIP */
  95. +
  96. +#ifndef UNZIP             /* moved to globals.h for UnZip */
  97. +   local ulg keys[3];     /* keys defining the pseudo-random sequence */
  98. +#endif /* !UNZIP */
  99. +
  100. +#ifndef Trace
  101. +#  ifdef CRYPT_DEBUG
  102. +#    define Trace(x) fprintf x
  103. +#  else
  104. +#    define Trace(x)
  105. +#  endif
  106. +#endif
  107. +
  108. +#ifndef CRC_32_TAB
  109. +#  define CRC_32_TAB     crc_32_tab
  110. +#endif
  111. +
  112. +#define CRC32(c, b) (CRC_32_TAB[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8))
  113. +
  114. +/***********************************************************************
  115. + * Return the next byte in the pseudo-random sequence
  116. + */
  117. +int decrypt_byte(__G)
  118. +    __GDEF
  119. +{
  120. +    unsigned temp;  /* POTENTIAL BUG:  temp*(temp^1) may overflow in an
  121. +                     * unpredictable manner on 16-bit systems; not a problem
  122. +                     * with any known compiler so far, though */
  123. +
  124. +    temp = ((unsigned)GLOBAL(keys[2]) & 0xffff) | 2;
  125. +    return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
  126. +}
  127. +
  128. +/***********************************************************************
  129. + * Update the encryption keys with the next byte of plain text
  130. + */
  131. +int update_keys(__G__ c)
  132. +    __GDEF
  133. +    int c;                  /* byte of plain text */
  134. +{
  135. +    GLOBAL(keys[0]) = CRC32(GLOBAL(keys[0]), c);
  136. +    GLOBAL(keys[1]) += GLOBAL(keys[0]) & 0xff;
  137. +    GLOBAL(keys[1]) = GLOBAL(keys[1]) * 134775813L + 1;
  138. +    {
  139. +      register int keyshift = (int)(GLOBAL(keys[1]) >> 24);
  140. +      GLOBAL(keys[2]) = CRC32(GLOBAL(keys[2]), keyshift);
  141. +    }
  142. +    return c;
  143. +}
  144. +
  145. +
  146. +/***********************************************************************
  147. + * Initialize the encryption keys and the random header according to
  148. + * the given password.
  149. + */
  150. +void init_keys(__G__ passwd)
  151. +    __GDEF
  152. +    char *passwd;             /* password string with which to modify keys */
  153. +{
  154. +    GLOBAL(keys[0]) = 305419896L;
  155. +    GLOBAL(keys[1]) = 591751049L;
  156. +    GLOBAL(keys[2]) = 878082192L;
  157. +    while (*passwd != '\0') {
  158. +        update_keys(__G__ (int)*passwd);
  159. +        passwd++;
  160. +    }
  161. +}
  162. +
  163. +
  164. +#ifdef ZIP
  165. +
  166. +/***********************************************************************
  167. + * Write encryption header to file zfile using the password passwd
  168. + * and the cyclic redundancy check crc.
  169. + */
  170. +void crypthead(passwd, crc, zfile)
  171. +    char *passwd;                /* password string */
  172. +    ulg crc;                     /* crc of file being encrypted */
  173. +    FILE *zfile;                 /* where to write header */
  174. +{
  175. +    int n;                       /* index in random header */
  176. +    int t;                       /* temporary */
  177. +    int c;                       /* random byte */
  178. +    int ztemp;                   /* temporary for zencoded value */
  179. +    uch header[RAND_HEAD_LEN-2]; /* random header */
  180. +    static unsigned calls = 0;   /* ensure different random header each time */
  181. +
  182. +    /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
  183. +     * output of rand() to get less predictability, since rand() is
  184. +     * often poorly implemented.
  185. +     */
  186. +    if (++calls == 1) {
  187. +        srand((unsigned)time(NULL) ^ ZCR_SEED2);
  188. +    }
  189. +    init_keys(passwd);
  190. +    for (n = 0; n < RAND_HEAD_LEN-2; n++) {
  191. +        c = (rand() >> 7) & 0xff;
  192. +        header[n] = (uch)zencode(c, t);
  193. +    }
  194. +    /* Encrypt random header (last two bytes is high word of crc) */
  195. +    init_keys(passwd);
  196. +    for (n = 0; n < RAND_HEAD_LEN-2; n++) {
  197. +        ztemp = zencode(header[n], t);
  198. +        putc(ztemp, zfile);
  199. +    }
  200. +    ztemp = zencode((int)(crc >> 16) & 0xff, t);
  201. +    putc(ztemp, zfile);
  202. +    ztemp = zencode((int)(crc >> 24) & 0xff, t);
  203. +    putc(ztemp, zfile);
  204. +}
  205. +
  206. +
  207. +#ifdef UTIL
  208. +
  209. +/***********************************************************************
  210. + * Encrypt the zip entry described by z from file source to file dest
  211. + * using the password passwd.  Return an error code in the ZE_ class.
  212. + */
  213. +int zipcloak(z, source, dest, passwd)
  214. +    struct zlist far *z;    /* zip entry to encrypt */
  215. +    FILE *source, *dest;    /* source and destination files */
  216. +    char *passwd;           /* password string */
  217. +{
  218. +    int c;                  /* input byte */
  219. +    int res;                /* result code */
  220. +    ulg n;                  /* holds offset and counts size */
  221. +    ush flag;               /* previous flags */
  222. +    int t;                  /* temporary */
  223. +    int ztemp;              /* temporary storage for zencode value */
  224. +
  225. +    /* Set encrypted bit, clear extended local header bit and write local
  226. +       header to output file */
  227. +    if ((n = ftell(dest)) == -1L) return ZE_TEMP;
  228. +    z->off = n;
  229. +    flag = z->flg;
  230. +    z->flg |= 1,  z->flg &= ~8;
  231. +    z->lflg |= 1, z->lflg &= ~8;
  232. +    z->siz += RAND_HEAD_LEN;
  233. +    if ((res = putlocal(z, dest)) != ZE_OK) return res;
  234. +
  235. +    /* Initialize keys with password and write random header */
  236. +    crypthead(passwd, z->crc, dest);
  237. +
  238. +    /* Skip local header in input file */
  239. +    if (fseek(source, (long)(4 + LOCHEAD + (ulg)z->nam + (ulg)z->ext),
  240. +              SEEK_CUR)) {
  241. +        return ferror(source) ? ZE_READ : ZE_EOF;
  242. +    }
  243. +
  244. +    /* Encrypt data */
  245. +    for (n = z->siz - RAND_HEAD_LEN; n; n--) {
  246. +        if ((c = getc(source)) == EOF) {
  247. +            return ferror(source) ? ZE_READ : ZE_EOF;
  248. +        }
  249. +        ztemp = zencode(c, t);
  250. +        putc(ztemp, dest);
  251. +    }
  252. +    /* Skip extended local header in input file if there is one */
  253. +    if ((flag & 8) != 0 && fseek(source, 16L, SEEK_CUR)) {
  254. +        return ferror(source) ? ZE_READ : ZE_EOF;
  255. +    }
  256. +    if (fflush(dest) == EOF) return ZE_TEMP;
  257. +    return ZE_OK;
  258. +}
  259. +
  260. +/***********************************************************************
  261. + * Decrypt the zip entry described by z from file source to file dest
  262. + * using the password passwd.  Return an error code in the ZE_ class.
  263. + */
  264. +int zipbare(__G__ z, source, dest, passwd)
  265. +    __GDEF
  266. +    struct zlist far *z;  /* zip entry to encrypt */
  267. +    FILE *source, *dest;  /* source and destination files */
  268. +    char *passwd;         /* password string */
  269. +{
  270. +    int c0, c1;           /* last two input bytes */
  271. +    ulg offset;           /* used for file offsets */
  272. +    ulg size;             /* size of input data */
  273. +    int r;                /* size of encryption header */
  274. +    int res;              /* return code */
  275. +    ush flag;             /* previous flags */
  276. +
  277. +    /* Save position and skip local header in input file */
  278. +    if ((offset = ftell(source)) == -1L ||
  279. +        fseek(source, (long)(4 + LOCHEAD + (ulg)z->nam + (ulg)z->ext),
  280. +              SEEK_CUR)) {
  281. +        return ferror(source) ? ZE_READ : ZE_EOF;
  282. +    }
  283. +    /* Initialize keys with password */
  284. +    init_keys(passwd);
  285. +
  286. +    /* Decrypt encryption header, save last two bytes */
  287. +    c1 = 0;
  288. +    for (r = RAND_HEAD_LEN; r; r--) {
  289. +        c0 = c1;
  290. +        if ((c1 = getc(source)) == EOF) {
  291. +            return ferror(source) ? ZE_READ : ZE_EOF;
  292. +        }
  293. +        Trace((stdout, " (%02x)", c1));
  294. +        zdecode(c1);
  295. +        Trace((stdout, " %02x", c1));
  296. +    }
  297. +    Trace((stdout, "\n"));
  298. +
  299. +    /* If last two bytes of header don't match crc (or file time in the
  300. +     * case of an extended local header), back up and just copy. For
  301. +     * pkzip 2.0, the check has been reduced to one byte only.
  302. +     */
  303. +#ifdef ZIP10
  304. +    if ((ush)(c0 | (c1<<8)) !=
  305. +        (z->flg & 8 ? (ush) z->tim & 0xffff : (ush)(z->crc >> 16))) {
  306. +#else
  307. +    c0++; /* avoid warning on unused variable */
  308. +    if ((ush)c1 != (z->flg & 8 ? (ush) z->tim >> 8 : (ush)(z->crc >> 24))) {
  309. +#endif
  310. +        if (fseek(source, offset, SEEK_SET)) {
  311. +            return ferror(source) ? ZE_READ : ZE_EOF;
  312. +        }
  313. +        if ((res = zipcopy(z, source, dest)) != ZE_OK) return res;
  314. +        return ZE_MISS;
  315. +    }
  316. +
  317. +    /* Clear encrypted bit and local header bit, and write local header to
  318. +       output file */
  319. +    if ((offset = ftell(dest)) == -1L) return ZE_TEMP;
  320. +    z->off = offset;
  321. +    flag = z->flg;
  322. +    z->flg &= ~9;
  323. +    z->lflg &= ~9;
  324. +    z->siz -= RAND_HEAD_LEN;
  325. +    if ((res = putlocal(z, dest)) != ZE_OK) return res;
  326. +
  327. +    /* Decrypt data */
  328. +    for (size = z->siz; size; size--) {
  329. +        if ((c1 = getc(source)) == EOF) {
  330. +            return ferror(source) ? ZE_READ : ZE_EOF;
  331. +        }
  332. +        zdecode(c1);
  333. +        putc(c1, dest);
  334. +    }
  335. +    /* Skip extended local header in input file if there is one */
  336. +    if ((flag & 8) != 0 && fseek(source, 16L, SEEK_CUR)) {
  337. +        return ferror(source) ? ZE_READ : ZE_EOF;
  338. +    }
  339. +    if (fflush(dest) == EOF) return ZE_TEMP;
  340. +
  341. +    return ZE_OK;
  342. +}
  343. +
  344. +
  345. +#else /* !UTIL */
  346. +
  347. +/***********************************************************************
  348. + * If requested, encrypt the data in buf, and in any case call fwrite()
  349. + * with the arguments to zfwrite().  Return what fwrite() returns.
  350. + */
  351. +unsigned zfwrite(buf, item_size, nb, f)
  352. +    zvoid *buf;                /* data buffer */
  353. +    extent item_size;          /* size of each item in bytes */
  354. +    extent nb;                 /* number of items */
  355. +    FILE *f;                   /* file to write to */
  356. +{
  357. +    int t;                    /* temporary */
  358. +
  359. +    if (key != (char *)NULL) { /* key is the global password pointer */
  360. +        ulg size;              /* buffer size */
  361. +        char *p = (char*)buf;  /* steps through buffer */
  362. +
  363. +        /* Encrypt data in buffer */
  364. +        for (size = item_size*(ulg)nb; size != 0; p++, size--) {
  365. +            *p = (char)zencode(*p, t);
  366. +        }
  367. +    }
  368. +    /* Write the buffer out */
  369. +    return fwrite(buf, item_size, nb, f);
  370. +}
  371. +
  372. +#endif /* ?UTIL */
  373. +#endif /* ZIP */
  374. +
  375. +
  376. +#if (defined(UNZIP) && !defined(FUNZIP))
  377. +
  378. +/***********************************************************************
  379. + * Get the password and set up keys for current zipfile member.  Return
  380. + * PK_ class error.
  381. + */
  382. +int decrypt(__G)
  383. +    __GDEF
  384. +{
  385. +    ush b;
  386. +    int n, r;
  387. +    uch h[RAND_HEAD_LEN];
  388. +
  389. +    Trace((stdout, "\n[incnt = %d]: ", GLOBAL(incnt)));
  390. +
  391. +    /* get header once (turn off "encrypted" flag temporarily so we don't
  392. +     * try to decrypt the same data twice) */
  393. +    GLOBAL(pInfo->encrypted) = FALSE;
  394. +    defer_leftover_input(__G);
  395. +    for (n = 0; n < RAND_HEAD_LEN; n++) {
  396. +        b = NEXTBYTE;
  397. +        h[n] = (uch)b;
  398. +        Trace((stdout, " (%02x)", h[n]));
  399. +    }
  400. +    undefer_input(__G);
  401. +    GLOBAL(pInfo->encrypted) = TRUE;
  402. +
  403. +    if (GLOBAL(newzip)) { /* this is first encrypted member in this zipfile */
  404. +        GLOBAL(newzip) = FALSE;
  405. +        if (GLOBAL(P_flag)) {     /* user gave password on command line */
  406. +            if (!GLOBAL(key)) {
  407. +                if ((GLOBAL(key) = (char *)malloc(PWLEN+1)) == (char *)NULL)
  408. +                    return PK_MEM2;
  409. +                strncpy(GLOBAL(key), GLOBAL(pwdarg), PWLEN);
  410. +                GLOBAL(nopwd) = TRUE;  /* inhibit password prompting! */
  411. +            }
  412. +        } else if (GLOBAL(key)) { /* get rid of previous zipfile's key */
  413. +            free(GLOBAL(key));
  414. +            GLOBAL(key) = (char *)NULL;
  415. +        }
  416. +    }
  417. +
  418. +    /* if have key already, test it; else allocate memory for it */
  419. +    if (GLOBAL(key)) {
  420. +        if (!testp(__G__ h))
  421. +            return PK_COOL;   /* existing password OK (else prompt for new) */
  422. +        else if (GLOBAL(nopwd))
  423. +            return PK_WARN;   /* user indicated no more prompting */
  424. +    } else if ((GLOBAL(key) = (char *)malloc(PWLEN+1)) == (char *)NULL)
  425. +        return PK_MEM2;
  426. +
  427. +    /* try a few keys */
  428. +    n = 0;
  429. +    do {
  430. +        r = (*G.decr_passwd)((zvoid *)&G, &n, GLOBAL(key), PWLEN+1,
  431. +                             GLOBAL(zipfn), GLOBAL(filename));
  432. +        if (r == IZ_PW_ERROR) {         /* internal error in fetch of PW */
  433. +            free (GLOBAL(key));
  434. +            GLOBAL(key) = NULL;
  435. +            return PK_MEM2;
  436. +        }
  437. +        if (r != IZ_PW_ENTERED) {       /* user replied "skip" or "skip all" */
  438. +            *GLOBAL(key) = '\0';        /*   We try the NIL password, ... */
  439. +            n = 0;                      /*   and cancel fetch for this item. */
  440. +        }
  441. +        if (!testp(__G__ h))
  442. +            return PK_COOL;
  443. +        if (r == IZ_PW_CANCELALL)       /* User replied "Skip all" */
  444. +            GLOBAL(nopwd) = TRUE;       /*   inhibit any further PW prompt! */
  445. +    } while (n > 0);
  446. +
  447. +    return PK_WARN;
  448. +
  449. +} /* end function decrypt() */
  450. +
  451. +
  452. +
  453. +/***********************************************************************
  454. + * Test the password.  Return -1 if bad, 0 if OK.
  455. + */
  456. +local int testp(__G__ h)
  457. +    __GDEF
  458. +    uch *h;
  459. +{
  460. +    int r;
  461. +    char *key_translated;
  462. +
  463. +    /* On systems with "obscure" native character coding (e.g., EBCDIC),
  464. +     * the first test translates the password to the "main standard"
  465. +     * character coding. */
  466. +
  467. +#ifdef STR_TO_CP1
  468. +    /* allocate buffer for translated password */
  469. +    if ((key_translated = malloc(strlen(GLOBAL(key)) + 1)) == (char *)NULL)
  470. +        return -1;
  471. +    /* first try, test password translated "standard" charset */
  472. +    r = testkey(__G__ h, STR_TO_CP1(key_translated, GLOBAL(key)));
  473. +#else /* !STR_TO_CP1 */
  474. +    /* first try, test password as supplied on the extractor's host */
  475. +    r = testkey(__G__ h, GLOBAL(key));
  476. +#endif /* ?STR_TO_CP1 */
  477. +
  478. +#ifdef STR_TO_CP2
  479. +    if (r != 0) {
  480. +#ifndef STR_TO_CP1
  481. +        /* now prepare for second (and maybe third) test with translated pwd */
  482. +        if ((key_translated = malloc(strlen(GLOBAL(key)) + 1)) == (char *)NULL)
  483. +            return -1;
  484. +#endif
  485. +        /* second try, password translated to alternate ("standard") charset */
  486. +        r = testkey(__G__ h, STR_TO_CP2(key_translated, GLOBAL(key)));
  487. +#ifdef STR_TO_CP3
  488. +        if (r != 0)
  489. +            /* third try, password translated to another "standard" charset */
  490. +            r = testkey(__G__ h, STR_TO_CP3(key_translated, GLOBAL(key)));
  491. +#endif
  492. +#ifndef STR_TO_CP1
  493. +        free(key_translated);
  494. +#endif
  495. +    }
  496. +#endif /* STR_TO_CP2 */
  497. +
  498. +#ifdef STR_TO_CP1
  499. +    free(key_translated);
  500. +    if (r != 0) {
  501. +        /* last resort, test password as supplied on the extractor's host */
  502. +        r = testkey(__G__ h, GLOBAL(key));
  503. +    }
  504. +#endif /* STR_TO_CP1 */
  505. +
  506. +    return r;
  507. +
  508. +} /* end function testp() */
  509. +
  510. +
  511. +local int testkey(__G__ h, key)
  512. +    __GDEF
  513. +    uch *h;             /* decrypted header */
  514. +    char *key;          /* decryption password to test */
  515. +{
  516. +    ush b;
  517. +#ifdef ZIP10
  518. +    ush c;
  519. +#endif
  520. +    int n;
  521. +    uch *p;
  522. +    uch hh[RAND_HEAD_LEN]; /* decrypted header */
  523. +
  524. +    /* set keys and save the encrypted header */
  525. +    init_keys(__G__ key);
  526. +    memcpy(hh, h, RAND_HEAD_LEN);
  527. +
  528. +    /* check password */
  529. +    for (n = 0; n < RAND_HEAD_LEN; n++) {
  530. +        zdecode(hh[n]);
  531. +        Trace((stdout, " %02x", hh[n]));
  532. +    }
  533. +
  534. +    Trace((stdout,
  535. +      "\n  lrec.crc= %08lx  crec.crc= %08lx  pInfo->ExtLocHdr= %s\n",
  536. +      GLOBAL(lrec.crc32), GLOBAL(pInfo->crc),
  537. +      GLOBAL(pInfo->ExtLocHdr) ? "true":"false"));
  538. +    Trace((stdout, "  incnt = %d  unzip offset into zipfile = %ld\n",
  539. +      GLOBAL(incnt),
  540. +      GLOBAL(cur_zipfile_bufstart)+(GLOBAL(inptr)-GLOBAL(inbuf))));
  541. +
  542. +    /* same test as in zipbare(): */
  543. +
  544. +#ifdef ZIP10 /* check two bytes */
  545. +    c = hh[RAND_HEAD_LEN-2], b = hh[RAND_HEAD_LEN-1];
  546. +    Trace((stdout,
  547. +      "  (c | (b<<8)) = %04x  (crc >> 16) = %04x  lrec.time = %04x\n",
  548. +      (ush)(c | (b<<8)), (ush)(GLOBAL(lrec.crc32) >> 16),
  549. +      GLOBAL(lrec.last_mod_file_time)));
  550. +    if ((ush)(c | (b<<8)) != (GLOBAL(pInfo->ExtLocHdr) ?
  551. +                              GLOBAL(lrec.last_mod_file_time) :
  552. +                              (ush)(GLOBAL(lrec.crc32) >> 16)))
  553. +        return -1;  /* bad */
  554. +#else
  555. +    b = hh[RAND_HEAD_LEN-1];
  556. +    Trace((stdout, "  b = %02x  (crc >> 24) = %02x  (lrec.time >> 8) = %02x\n",
  557. +      b, (ush)(GLOBAL(lrec.crc32) >> 24),
  558. +      (GLOBAL(lrec.last_mod_file_time) >> 8)));
  559. +    if (b != (GLOBAL(pInfo->ExtLocHdr) ? GLOBAL(lrec.last_mod_file_time) >> 8 :
  560. +        (ush)(GLOBAL(lrec.crc32) >> 24)))
  561. +        return -1;  /* bad */
  562. +#endif
  563. +    /* password OK:  decrypt current buffer contents before leaving */
  564. +    for (n = (long)GLOBAL(incnt) > GLOBAL(csize) ?
  565. +             (int)GLOBAL(csize) : GLOBAL(incnt),
  566. +         p = GLOBAL(inptr); n--; p++)
  567. +        zdecode(*p);
  568. +    return 0;       /* OK */
  569. +
  570. +} /* end function testkey() */
  571. +
  572. +#endif /* UNZIP && !FUNZIP */
  573. diff -urP origsrc/crypt.h src/crypt.h
  574. --- origsrc/crypt.h    Mon Oct  6 04:05:44 1997
  575. +++ src/crypt.h    Tue Apr 22 22:59:00 1997
  576. @@ -1,11 +1,8 @@
  577.  /*
  578. -   crypt.h (dummy version) by Info-ZIP.      Last revised:  5 Oct 97
  579. +   crypt.h (full version) by Info-ZIP.   Last revised:  [see CR_VERSION_DATE]
  580.  
  581. -   This is a non-functional version of Info-ZIP's crypt.h encryption/
  582. -   decryption header file for Zip, ZipCloak, UnZip and fUnZip.  This
  583. -   file is not copyrighted and may be distributed without restriction.
  584. -   See the "WHERE" file for sites from which to obtain the full crypt
  585. -   sources (zcrypt27.zip or later).
  586. +   This header file is not copyrighted, and non-beta versions may be
  587. +   distributed without restriction.
  588.   */
  589.  
  590.  #ifndef __crypt_h   /* don't include more than once */
  591. @@ -14,11 +11,89 @@
  592.  #ifdef CRYPT
  593.  #  undef CRYPT
  594.  #endif
  595. -#define CRYPT  0    /* dummy version */
  596. +#define CRYPT  1    /* full version */
  597.  
  598. -#define zencode
  599. -#define zdecode
  600. +#define CR_MAJORVER        2
  601. +#define CR_MINORVER        7
  602. +#ifdef CR_BETA
  603. +#  define CR_BETA_VER      "m BETA"
  604. +#  define CR_VERSION_DATE  "13 April 1997"     /* last real code change */
  605. +#else
  606. +#  define CR_BETA_VER      ""
  607. +#  define CR_VERSION_DATE  "22 April 1997"     /* last public release date */
  608. +#  define CR_RELEASE
  609. +#endif
  610. +
  611. +#ifndef __G         /* UnZip only, for now (DLL stuff) */
  612. +#  define __G
  613. +#  define __G__
  614. +#  define __GDEF
  615. +#  define __GPRO    void
  616. +#  define __GPRO__
  617. +#endif
  618. +
  619. +#if defined(MSDOS) || defined(OS2) || defined(WIN32)
  620. +#  ifndef DOS_OS2_W32
  621. +#    define DOS_OS2_W32
  622. +#  endif
  623. +#endif
  624. +
  625. +#if defined(DOS_OS2_W32) || defined(__human68k__)
  626. +#  ifndef DOS_H68_OS2_W32
  627. +#    define DOS_H68_OS2_W32
  628. +#  endif
  629. +#endif
  630. +
  631. +#if defined(VM_CMS) || defined(MVS)
  632. +#  ifndef CMS_MVS
  633. +#    define CMS_MVS
  634. +#  endif
  635. +#endif
  636. +
  637. +#ifdef REALLY_SHORT_SYMS
  638. +#  define decrypt_byte   dcrbyt
  639. +#endif
  640. +
  641. +#define PWLEN  80   /* input buffer size for reading encryption key */
  642. +#define RAND_HEAD_LEN  12    /* length of encryption random header */
  643. +
  644. +/* the crc_32_tab array has to be provided externally for the crypt calculus */
  645. +#ifndef UNZIP                   /* UnZip provides this in globals.h */
  646. +   extern ulg near *crc_32_tab;
  647. +#endif /* !UNZIP */
  648. +
  649. +/* encode byte c, using temp t.  Warning: c must not have side effects. */
  650. +#define zencode(c,t)  (t=decrypt_byte(__G), update_keys(c), t^(c))
  651. +
  652. +/* decode byte c in place */
  653. +#define zdecode(c)   update_keys(__G__ c ^= decrypt_byte(__G))
  654. +
  655. +int  decrypt_byte OF((__GPRO));
  656. +int  update_keys OF((__GPRO__ int c));
  657. +void init_keys OF((__GPRO__ char *passwd));
  658. +
  659. +#ifdef ZIP
  660. +   void crypthead OF((char *, ulg, FILE *));
  661. +#  ifdef UTIL
  662. +     int zipcloak OF((struct zlist far *, FILE *, FILE *, char *));
  663. +     int zipbare OF((__GPRO__ struct zlist far *, FILE *, FILE *, char *));
  664. +#  else
  665. +     unsigned zfwrite OF((zvoid *, extent, extent, FILE *));
  666. +     extern char *key;
  667. +#  endif
  668. +#endif /* ZIP */
  669. +
  670. +#if (defined(UNZIP) && !defined(FUNZIP))
  671. +   int  decrypt OF((__GPRO));
  672. +#endif
  673.  
  674. -#define zfwrite  fwrite
  675. +#ifdef FUNZIP
  676. +   extern int encrypted;
  677. +#  ifdef NEXTBYTE
  678. +#    undef NEXTBYTE
  679. +#  endif
  680. +#  define NEXTBYTE \
  681. +   (encrypted? update_keys(__G__ getc(G.in)^decrypt_byte(__G)) : getc(G.in))
  682. +#endif /* FUNZIP */
  683.  
  684.  #endif /* !__crypt_h */
  685. diff -urP origsrc/debug/aaa/aiueo.txt src/debug/aaa/aiueo.txt
  686. --- origsrc/debug/aaa/aiueo.txt    Wed Dec 31 19:00:00 1969
  687. +++ src/debug/aaa/aiueo.txt    Sun Oct 11 00:40:58 1998
  688. @@ -0,0 +1 @@
  689. +aiueo
  690. Binary files origsrc/debug/aiueo.exe and src/debug/aiueo.exe differ
  691. diff -urP origsrc/debug/aiueo.txt src/debug/aiueo.txt
  692. --- origsrc/debug/aiueo.txt    Wed Dec 31 19:00:00 1969
  693. +++ src/debug/aiueo.txt    Sun Oct 11 00:40:58 1998
  694. @@ -0,0 +1 @@
  695. +aiueo
  696. Binary files origsrc/debug/aiueo.zip and src/debug/aiueo.zip differ
  697. Binary files origsrc/debug/apihelp.obj and src/debug/apihelp.obj differ
  698. Binary files origsrc/debug/crc32.obj and src/debug/crc32.obj differ
  699. Binary files origsrc/debug/crc_i386.obj and src/debug/crc_i386.obj differ
  700. Binary files origsrc/debug/crctab.obj and src/debug/crctab.obj differ
  701. Binary files origsrc/debug/crypt.obj and src/debug/crypt.obj differ
  702. Binary files origsrc/debug/envargs.obj and src/debug/envargs.obj differ
  703. Binary files origsrc/debug/explode.obj and src/debug/explode.obj differ
  704. Binary files origsrc/debug/extract.obj and src/debug/extract.obj differ
  705. Binary files origsrc/debug/fileio.obj and src/debug/fileio.obj differ
  706. Binary files origsrc/debug/funzip.obj and src/debug/funzip.obj differ
  707. Binary files origsrc/debug/globals.obj and src/debug/globals.obj differ
  708. Binary files origsrc/debug/inflate.obj and src/debug/inflate.obj differ
  709. Binary files origsrc/debug/match.obj and src/debug/match.obj differ
  710. Binary files origsrc/debug/nt.obj and src/debug/nt.obj differ
  711. Binary files origsrc/debug/process.obj and src/debug/process.obj differ
  712. Binary files origsrc/debug/ttyio.obj and src/debug/ttyio.obj differ
  713. Binary files origsrc/debug/unreduce.obj and src/debug/unreduce.obj differ
  714. Binary files origsrc/debug/unshrink.obj and src/debug/unshrink.obj differ
  715. Binary files origsrc/debug/unzip.obj and src/debug/unzip.obj differ
  716. Binary files origsrc/debug/unzipsfx.exe and src/debug/unzipsfx.exe differ
  717. diff -urP origsrc/debug/unzipsfx.ilk src/debug/unzipsfx.ilk
  718. --- origsrc/debug/unzipsfx.ilk    Wed Dec 31 19:00:00 1969
  719. +++ src/debug/unzipsfx.ilk    Sun Oct 11 03:55:36 1998
  720. @@ -0,0 +1,2 @@
  721. +Microsoft Linker Database
  722. +
  723. \ No newline at end of file
  724. Binary files origsrc/debug/unzipsfx.pch and src/debug/unzipsfx.pch differ
  725. diff -urP origsrc/debug/unzipsfx.pdb src/debug/unzipsfx.pdb
  726. --- origsrc/debug/unzipsfx.pdb    Wed Dec 31 19:00:00 1969
  727. +++ src/debug/unzipsfx.pdb    Sun Oct 11 03:55:36 1998
  728. @@ -0,0 +1 @@
  729. +Microsoft C/C++ program database 2.00
  730. Binary files origsrc/debug/unzipsfx.res and src/debug/unzipsfx.res differ
  731. Binary files origsrc/debug/unzipstb.obj and src/debug/unzipstb.obj differ
  732. diff -urP origsrc/debug/vc50.idb src/debug/vc50.idb
  733. --- origsrc/debug/vc50.idb    Wed Dec 31 19:00:00 1969
  734. +++ src/debug/vc50.idb    Sun Oct 11 03:56:20 1998
  735. @@ -0,0 +1 @@
  736. +Microsoft C/C++ program database 2.00
  737. diff -urP origsrc/debug/vc50.pdb src/debug/vc50.pdb
  738. --- origsrc/debug/vc50.pdb    Wed Dec 31 19:00:00 1969
  739. +++ src/debug/vc50.pdb    Sun Oct 11 03:55:34 1998
  740. @@ -0,0 +1 @@
  741. +Microsoft C/C++ program database 2.00
  742. Binary files origsrc/debug/win32.obj and src/debug/win32.obj differ
  743. Binary files origsrc/debug/wingui.obj and src/debug/wingui.obj differ
  744. Binary files origsrc/debug/zipinfo.obj and src/debug/zipinfo.obj differ
  745. diff -urP origsrc/extract.c src/extract.c
  746. --- origsrc/extract.c    Tue Oct 21 12:42:32 1997
  747. +++ src/extract.c    Sun Oct 11 14:28:08 1998
  748. @@ -758,7 +758,11 @@
  749.                          break;
  750.                  }
  751.                  if (query) {
  752. -#ifdef WINDLL
  753. +#if defined(WIN32) && defined(GUI)
  754. +                    /* Replace None */
  755. +                    G.overwrite_none = TRUE;
  756. +                    G.overwrite_all = FALSE;  /* make sure */
  757. +#elif defined(WINDLL)
  758.                      switch (G.replace != NULL ?
  759.                              (*G.replace)(G.filename) : IDM_REPLACE_NONE) {
  760.                          case IDM_REPLACE_RENAME:
  761. diff -urP origsrc/fileio.c src/fileio.c
  762. --- origsrc/fileio.c    Sun Oct 12 12:01:38 1997
  763. +++ src/fileio.c    Sun Oct 11 02:46:06 1998
  764. @@ -38,8 +38,6 @@
  765.               zfstrcpy()               (SMALL_MEM only)
  766.  
  767.    ---------------------------------------------------------------------------*/
  768. -
  769. -
  770.  #define FILEIO_C
  771.  #define UNZIP_INTERNAL
  772.  #include "unzip.h"
  773. @@ -49,6 +47,11 @@
  774.  #include "crypt.h"
  775.  #include "ttyio.h"
  776.  
  777. +#if defined(GUI) && defined(WIN32)
  778. +#    include "wingui.h"
  779. +#endif
  780. +
  781. +
  782.  /* setup of codepage conversion for decryption passwords */
  783.  #if CRYPT
  784.  #  if (defined(CRYP_USES_ISO2OEM) && !defined(IZ_ISO2OEM_ARRAY))
  785. @@ -971,7 +974,9 @@
  786.      To turn off *all* messages, use the UzpMessageNull() function instead
  787.      of this one.
  788.    ---------------------------------------------------------------------------*/
  789. -
  790. +#if defined(GUI) && defined(WIN32)
  791. +    return WinGuiUzpMessagePrnt(pG,buf,size,flag);
  792. +#endif
  793.  #if (defined(OS2) && defined(DLL))
  794.      if (MSG_NO_DLL2(flag))  /* if OS/2 DLL bit is set, do NOT print this msg */
  795.          return 0;
  796. @@ -1214,6 +1219,9 @@
  797.  
  798.      /* tell picky compilers to shut up about "unused variable" warnings */
  799.      pG = pG;
  800. +#if defined(GUI) && defined(WIN32)
  801. +    return WinGuiUzpPassword (pG, rcnt, pwbuf, size, zfn, efn);
  802. +#endif
  803.  
  804.      if (*rcnt == 0) {           /* First call for current entry */
  805.          *rcnt = 2;
  806. diff -urP origsrc/readme.cr src/readme.cr
  807. --- origsrc/readme.cr    Wed Dec 31 19:00:00 1969
  808. +++ src/readme.cr    Thu Oct 16 15:58:10 1997
  809. @@ -0,0 +1,103 @@
  810. +__________________________________________________________________________
  811. +
  812. +  This is the Info-ZIP README.CR for zcrypt27.zip, last updated 16 Oct 97.
  813. +__________________________________________________________________________
  814. +
  815. +
  816. +The files described below contain the encryption code for Zip 2.2 and
  817. +UnZip 5.3 (and later).  They constitute only an add-on to the exportable
  818. +versions (generally named zip22.zip and unzip53.tar.Z) and cannot be 
  819. +used without the complete Zip or UnZip packages.
  820. +
  821. +This encryption code is not copyrighted and is put in the public domain.
  822. +It was originally written in Europe and can be freely distributed from
  823. +any country except the U.S.A.  If this code is imported into the US, it
  824. +cannot be re-exported from the US to another country.  (This restriction
  825. +might seem curious but this is what US law requires.)  However, Phil Katz
  826. +has said that he got an export license for his algorithm, so this hassle
  827. +of separate distribution may cease one day.
  828. +
  829. +    LIKE ANYTHING ELSE THAT IS FREE, ZIP, UNZIP AND THEIR ASSOCIATED
  830. +    UTILITIES ARE PROVIDED AS IS AND COME WITH NO WARRANTY OF ANY KIND,
  831. +    EITHER EXPRESSED OR IMPLIED. IN NO EVENT WILL THE AUTHORS BE LIABLE
  832. +    FOR ANY DAMAGES RESULTING FROM THE USE OF THIS SOFTWARE.
  833. +
  834. +The encryption code is a direct transcription of the algorithm from
  835. +Roger Schlafly, described by Phil Katz in the file appnote.txt.  This
  836. +file is distributed with the PKZIP program (even in the version without
  837. +encryption capabilities).  Note that the encryption will probably resist
  838. +attacks by amateurs if the password is well chosen and long enough (at 
  839. +least 8 characters) but it will probably not resist attacks by experts.
  840. +Paul Kocher has made available information concerning a known-plaintext
  841. +attack for the PKWARE encryption scheme; see http://www.cryptography.com/
  842. +for details.)  Short passwords consisting of lowercase letters only can be
  843. +recovered in a few hours on any workstation.  But for casual cryptography
  844. +designed to keep your mother from reading your mail, it's OK.
  845. +
  846. +For more serious encryption, check into PGP (Pretty Good Privacy), a
  847. +public-key-based encryption system available from various Internet sites.
  848. +PGP has Zip and UnZip built into it.  The most recent version at the time
  849. +this was written was 5.0, although the previous 2.6.2 release (and 2.6.3i
  850. +for non-US users) still seems to be in greater use.
  851. +
  852. +Zip 2.2x and UnZip 5.3x are compatible with PKZIP 2.04g.  (Thanks to Phil
  853. +Katz for accepting our suggested minor changes to the zipfile format.)
  854. +
  855. +IMPORTANT NOTE:
  856. +
  857. +  Zip archives produced by Zip 2.0 or later must not be *updated* by
  858. +  Zip 1.1 or PKZIP 1.10 or PKZIP 1.93a, if they contain encrypted members
  859. +  or if they have been produced in a pipe or on a non-seekable device.
  860. +  The old versions of Zip or PKZIP would destroy the zip structure.  The
  861. +  old versions can list the contents of the zipfile but cannot extract
  862. +  it anyway (because of the new compression algorithm).  If you do not
  863. +  use encryption and compress regular disk files, you need not worry about
  864. +  this problem.
  865. +
  866. +
  867. +Contents:
  868. +
  869. +  file           what it is
  870. +  ----           ----------
  871. +  README.CR      this file
  872. +  WHERE          where Zip/UnZip and related utilities can be found
  873. +  crypt.c        code for encryption and decryption (for Zip and UnZip)
  874. +  crypt.h        code for encryption and decryption (for Zip and UnZip)
  875. +  file_id.diz    description file for some BBSes
  876. +
  877. +All of the files are in Unix (LF only) format.  On MSDOS systems, you
  878. +can use the -a option of UnZip to convert the source files to CRLF
  879. +format.  This is only necessary if you wish to edit the files -- they
  880. +will compile as is with Microsoft C and Turbo/Borland C++ 1.0 or
  881. +later.  However, you will have to convert the files (using "unzip -a")
  882. +to the CRLF format to compile with the older Turbo C 1.0 or 2.0.  You
  883. +should be able to find Zip and UnZip in the same place you found this 
  884. +(see http://www.cdrom.com/pub/infozip/ or the file "WHERE" for details).
  885. +
  886. +To use the zcrypt sources:
  887. +
  888. +  (1) Get the main sources (e.g., Zip 2.2 or UnZip 5.32) and unpack into
  889. +      a working directory, as usual.
  890. +
  891. +  (2) Overwrite the dummy crypt.c and crypt.h from the main sources with 
  892. +      the versions from this package.  If you want to overwrite directly
  893. +      out of the zcrypt27 archive, do not use UnZip's freshen/updating
  894. +      option; the dummy files may be newer than the real sources in
  895. +      zcrypt27.  ("unzip -o zcrypt27 -d /your/working/dir -x WHERE" will
  896. +      do the Right Thing without overwriting the existing WHERE file, which
  897. +      is likely to be the same or newer in the Zip and UnZip distributions.)
  898. +
  899. +  (3) Read the main INSTALL document and compile normally!  No makefile
  900. +      changes are necessary on account of the zcrypt sources.  You can
  901. +      check that the version you just compiled has encryption or decryption
  902. +      support enabled by typing "zip -v" or "unzip -v" and verifying that
  903. +      the last "special compilation option" says encryption or decryption
  904. +      is included.
  905. +
  906. +Encryption enables new "-e" and "-P password" options in Zip, and a new
  907. +"-P password" option in UnZip--see the normal Zip and UnZip documentation
  908. +for details.  (Note that passing a plaintext password on the command line
  909. +is potentially much more insecure than being prompted for it interactively,
  910. +which is the default for UnZip and for Zip with "-e".  Also note that the
  911. +interactive method allows UnZip to deal with archives that use different
  912. +passwords for different files.)
  913. Binary files origsrc/release/aiueo.exe and src/release/aiueo.exe differ
  914. Binary files origsrc/release/aiueo.zip and src/release/aiueo.zip differ
  915. Binary files origsrc/release/apihelp.obj and src/release/apihelp.obj differ
  916. Binary files origsrc/release/crc32.obj and src/release/crc32.obj differ
  917. Binary files origsrc/release/crctab.obj and src/release/crctab.obj differ
  918. Binary files origsrc/release/crypt/a.exe and src/release/crypt/a.exe differ
  919. Binary files origsrc/release/crypt/a.zip and src/release/crypt/a.zip differ
  920. diff -urP origsrc/release/crypt/aiueo.txt src/release/crypt/aiueo.txt
  921. --- origsrc/release/crypt/aiueo.txt    Wed Dec 31 19:00:00 1969
  922. +++ src/release/crypt/aiueo.txt    Sun Oct 11 00:40:58 1998
  923. @@ -0,0 +1 @@
  924. +aiueo
  925. Binary files origsrc/release/crypt.obj and src/release/crypt.obj differ
  926. Binary files origsrc/release/envargs.obj and src/release/envargs.obj differ
  927. Binary files origsrc/release/explode.obj and src/release/explode.obj differ
  928. Binary files origsrc/release/extract.obj and src/release/extract.obj differ
  929. Binary files origsrc/release/fileio.obj and src/release/fileio.obj differ
  930. Binary files origsrc/release/globals.obj and src/release/globals.obj differ
  931. Binary files origsrc/release/inflate.obj and src/release/inflate.obj differ
  932. Binary files origsrc/release/match.obj and src/release/match.obj differ
  933. Binary files origsrc/release/nt.obj and src/release/nt.obj differ
  934. Binary files origsrc/release/process.obj and src/release/process.obj differ
  935. Binary files origsrc/release/ttyio.obj and src/release/ttyio.obj differ
  936. Binary files origsrc/release/unreduce.obj and src/release/unreduce.obj differ
  937. Binary files origsrc/release/unshrink.obj and src/release/unshrink.obj differ
  938. Binary files origsrc/release/unzip.obj and src/release/unzip.obj differ
  939. Binary files origsrc/release/unzipsfx.exe and src/release/unzipsfx.exe differ
  940. Binary files origsrc/release/unzipsfx.pch and src/release/unzipsfx.pch differ
  941. Binary files origsrc/release/unzipsfx.res and src/release/unzipsfx.res differ
  942. diff -urP origsrc/release/vc50.idb src/release/vc50.idb
  943. --- origsrc/release/vc50.idb    Wed Dec 31 19:00:00 1969
  944. +++ src/release/vc50.idb    Sun Oct 11 14:28:12 1998
  945. @@ -0,0 +1 @@
  946. +Microsoft C/C++ program database 2.00
  947. Binary files origsrc/release/win32.obj and src/release/win32.obj differ
  948. Binary files origsrc/release/wingui.obj and src/release/wingui.obj differ
  949. Binary files origsrc/release/zipinfo.obj and src/release/zipinfo.obj differ
  950. diff -urP origsrc/resource.h src/resource.h
  951. --- origsrc/resource.h    Wed Dec 31 19:00:00 1969
  952. +++ src/resource.h    Sun Oct 11 14:24:52 1998
  953. @@ -0,0 +1,23 @@
  954. +//{{NO_DEPENDENCIES}}
  955. +// Microsoft Developer Studio generated include file.
  956. +// Used by unzipsfx.rc
  957. +//
  958. +#define IDD_DIALOG_LOG                  101
  959. +#define IDD_DIALOG_PASSWORD             102
  960. +#define IDD_DIALOG_FOLDER               103
  961. +#define IDC_EDIT_LOG                    1000
  962. +#define IDC_EDIT_PASSWORD               1001
  963. +#define IDC_EDIT_ARCHIVE                1002
  964. +#define IDC_EDIT_EXTRACTING             1003
  965. +#define IDC_EDIT_FOLDER                 1004
  966. +
  967. +// Next default values for new objects
  968. +// 
  969. +#ifdef APSTUDIO_INVOKED
  970. +#ifndef APSTUDIO_READONLY_SYMBOLS
  971. +#define _APS_NEXT_RESOURCE_VALUE        105
  972. +#define _APS_NEXT_COMMAND_VALUE         40001
  973. +#define _APS_NEXT_CONTROL_VALUE         1010
  974. +#define _APS_NEXT_SYMED_VALUE           101
  975. +#endif
  976. +#endif
  977. diff -urP origsrc/unzip.c src/unzip.c
  978. --- origsrc/unzip.c    Sun Oct 19 06:54:26 1997
  979. +++ src/unzip.c    Sun Oct 11 03:55:34 1998
  980. @@ -482,16 +482,85 @@
  981.  /*  main() / UzpMain() stub  */
  982.  /*****************************/
  983.  
  984. +#if defined(GUI) && defined(WIN32)
  985. +#include <windows.h>
  986. +#include "resource.h"
  987. +
  988. +BOOL CALLBACK FolderDialogFunc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
  989. +{
  990. +    int ret;
  991. +    char *p;
  992. +    char folder[1000];
  993. +
  994. +    switch(msg){
  995. +    case WM_INITDIALOG:
  996. +        GetModuleFileName(GetModuleHandle(NULL),folder,1000);
  997. +        if((p=strrchr(folder,'\\'))){
  998. +            *(p+1)='\0';
  999. +        }
  1000. +        SetDlgItemText(hwnd,IDC_EDIT_FOLDER,folder);
  1001. +        return 1;
  1002. +    case WM_COMMAND:
  1003. +        switch(LOWORD(wParam)){
  1004. +        case IDOK:
  1005. +            GetDlgItemText(hwnd,IDC_EDIT_FOLDER,folder,1000);
  1006. +            if(chdir(folder)==-1){
  1007. +                char buf[1000];
  1008. +                sprintf(buf,"Can't change directory to[%s]. Make directory?",folder); 
  1009. +                ret = MessageBox(hwnd,buf,"UNZIPSFX",MB_YESNO);
  1010. +                if(ret==IDYES){
  1011. +                    if(mkdir(folder)==-1){
  1012. +                        MessageBox(hwnd,"Can't make directory","UNZIPSFX",0);
  1013. +                        exit(1);
  1014. +                    }
  1015. +                    if(chdir(folder)==-1){
  1016. +                        MessageBox(hwnd,"Can't change directory","UNZIPSFX",0);
  1017. +                        exit(1);
  1018. +                    }
  1019. +                }else{
  1020. +                    exit(1);
  1021. +                }
  1022. +            }
  1023. +            EndDialog(hwnd,0);
  1024. +            return 1;
  1025. +        case IDCANCEL:
  1026. +            SendMessage(hwnd,WM_CLOSE,0,0);
  1027. +            return 1;
  1028. +        }
  1029. +        break;
  1030. +    case WM_CLOSE:
  1031. +        ret = MessageBox(hwnd,"Abort Really?","UNZIPSFX",MB_YESNO);
  1032. +        if(ret==IDYES){
  1033. +            exit(1);
  1034. +        }
  1035. +        break;
  1036. +    }
  1037. +    return 0;
  1038. +}
  1039. +int WINAPI WinMain(HANDLE hInst,HANDLE hPrev,char *cmd,int mode)
  1040. +{
  1041. +    int argc=1;
  1042. +    char *argv[2];
  1043. +    char progname[1000];
  1044. +
  1045. +    GetModuleFileName(GetModuleHandle(NULL),progname,1000);
  1046. +    argv[0]=progname;
  1047. +    argv[1]=NULL;
  1048. +    DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG_FOLDER),0,FolderDialogFunc);
  1049. +#else
  1050.  int MAIN(argc, argv)   /* return PK-type error code (except under VMS) */
  1051.      int argc;
  1052.      char *argv[];
  1053.  {
  1054. -    int r;
  1055. +#endif
  1056. +    {
  1057. +        int r;
  1058.  
  1059. -    CONSTRUCTGLOBALS();
  1060. -    r = unzip(__G__ argc, argv);
  1061. -    DESTROYGLOBALS()
  1062. -    RETURN(r);
  1063. +        CONSTRUCTGLOBALS();
  1064. +        r = unzip(__G__ argc, argv);
  1065. +        DESTROYGLOBALS()
  1066. +        RETURN(r);
  1067. +    }
  1068.  }
  1069.  
  1070.  
  1071. Binary files origsrc/unzipsfx.aps and src/unzipsfx.aps differ
  1072. diff -urP origsrc/unzipsfx.dsp src/unzipsfx.dsp
  1073. --- origsrc/unzipsfx.dsp    Wed Dec 31 19:00:00 1969
  1074. +++ src/unzipsfx.dsp    Sun Oct 11 04:02:22 1998
  1075. @@ -0,0 +1,211 @@
  1076. +# Microsoft Developer Studio Project File - Name="unzipsfx" - Package Owner=<4>
  1077. +# Microsoft Developer Studio Generated Build File, Format Version 5.00
  1078. +# ** 編集しないでください **
  1079. +
  1080. +# TARGTYPE "Win32 (x86) Console Application" 0x0103
  1081. +
  1082. +CFG=unzipsfx - Win32 Debug
  1083. +!MESSAGE これは有効なメイクファイルではありません。 このプロジェクトをビルドするためには NMAKE を使用してください。
  1084. +!MESSAGE [メイクファイルのエクスポート] コマンドを使用して実行してください
  1085. +!MESSAGE 
  1086. +!MESSAGE NMAKE /f "unzipsfx.mak".
  1087. +!MESSAGE 
  1088. +!MESSAGE NMAKE の実行時に構成を指定できます
  1089. +!MESSAGE コマンド ライン上でマクロの設定を定義します。例:
  1090. +!MESSAGE 
  1091. +!MESSAGE NMAKE /f "unzipsfx.mak" CFG="unzipsfx - Win32 Debug"
  1092. +!MESSAGE 
  1093. +!MESSAGE 選択可能なビルド モード:
  1094. +!MESSAGE 
  1095. +!MESSAGE "unzipsfx - Win32 Release" ("Win32 (x86) Console Application" 用)
  1096. +!MESSAGE "unzipsfx - Win32 Debug" ("Win32 (x86) Console Application" 用)
  1097. +!MESSAGE 
  1098. +
  1099. +# Begin Project
  1100. +# PROP Scc_ProjName ""
  1101. +# PROP Scc_LocalPath ""
  1102. +CPP=cl.exe
  1103. +RSC=rc.exe
  1104. +
  1105. +!IF  "$(CFG)" == "unzipsfx - Win32 Release"
  1106. +
  1107. +# PROP BASE Use_MFC 0
  1108. +# PROP BASE Use_Debug_Libraries 0
  1109. +# PROP BASE Output_Dir "Release"
  1110. +# PROP BASE Intermediate_Dir "Release"
  1111. +# PROP BASE Target_Dir ""
  1112. +# PROP Use_MFC 0
  1113. +# PROP Use_Debug_Libraries 0
  1114. +# PROP Output_Dir "Release"
  1115. +# PROP Intermediate_Dir "Release"
  1116. +# PROP Ignore_Export_Lib 0
  1117. +# PROP Target_Dir ""
  1118. +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
  1119. +# ADD CPP /nologo /W3 /GX /O2 /I ".." /I "." /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "SFX" /D "CRYPT" /D "GUI" /YX /FD /c
  1120. +# ADD BASE RSC /l 0x411 /d "NDEBUG"
  1121. +# ADD RSC /l 0x411 /d "NDEBUG"
  1122. +BSC32=bscmake.exe
  1123. +# ADD BASE BSC32 /nologo
  1124. +# ADD BSC32 /nologo
  1125. +LINK32=link.exe
  1126. +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
  1127. +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
  1128. +# SUBTRACT LINK32 /pdb:none
  1129. +
  1130. +!ELSEIF  "$(CFG)" == "unzipsfx - Win32 Debug"
  1131. +
  1132. +# PROP BASE Use_MFC 0
  1133. +# PROP BASE Use_Debug_Libraries 1
  1134. +# PROP BASE Output_Dir "Debug"
  1135. +# PROP BASE Intermediate_Dir "Debug"
  1136. +# PROP BASE Target_Dir ""
  1137. +# PROP Use_MFC 0
  1138. +# PROP Use_Debug_Libraries 1
  1139. +# PROP Output_Dir "Debug"
  1140. +# PROP Intermediate_Dir "Debug"
  1141. +# PROP Ignore_Export_Lib 0
  1142. +# PROP Target_Dir ""
  1143. +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
  1144. +# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "." /I ".." /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "SFX" /D "CRYPT" /D "GUI" /YX /FD /c
  1145. +# ADD BASE RSC /l 0x411 /d "_DEBUG"
  1146. +# ADD RSC /l 0x411 /d "_DEBUG"
  1147. +BSC32=bscmake.exe
  1148. +# ADD BASE BSC32 /nologo
  1149. +# ADD BSC32 /nologo
  1150. +LINK32=link.exe
  1151. +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
  1152. +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
  1153. +# SUBTRACT LINK32 /pdb:none
  1154. +
  1155. +!ENDIF 
  1156. +
  1157. +# Begin Target
  1158. +
  1159. +# Name "unzipsfx - Win32 Release"
  1160. +# Name "unzipsfx - Win32 Debug"
  1161. +# Begin Source File
  1162. +
  1163. +SOURCE=.\consts.h
  1164. +# End Source File
  1165. +# Begin Source File
  1166. +
  1167. +SOURCE=.\crc32.c
  1168. +# End Source File
  1169. +# Begin Source File
  1170. +
  1171. +SOURCE=.\crctab.c
  1172. +# End Source File
  1173. +# Begin Source File
  1174. +
  1175. +SOURCE=.\crypt.c
  1176. +# End Source File
  1177. +# Begin Source File
  1178. +
  1179. +SOURCE=.\crypt.h
  1180. +# End Source File
  1181. +# Begin Source File
  1182. +
  1183. +SOURCE=.\ebcdic.h
  1184. +# End Source File
  1185. +# Begin Source File
  1186. +
  1187. +SOURCE=.\extract.c
  1188. +# End Source File
  1189. +# Begin Source File
  1190. +
  1191. +SOURCE=.\fileio.c
  1192. +# End Source File
  1193. +# Begin Source File
  1194. +
  1195. +SOURCE=.\globals.c
  1196. +# End Source File
  1197. +# Begin Source File
  1198. +
  1199. +SOURCE=.\globals.h
  1200. +# End Source File
  1201. +# Begin Source File
  1202. +
  1203. +SOURCE=.\inflate.c
  1204. +# End Source File
  1205. +# Begin Source File
  1206. +
  1207. +SOURCE=.\inflate.h
  1208. +# End Source File
  1209. +# Begin Source File
  1210. +
  1211. +SOURCE=.\match.c
  1212. +# End Source File
  1213. +# Begin Source File
  1214. +
  1215. +SOURCE=.\win32\nt.c
  1216. +# End Source File
  1217. +# Begin Source File
  1218. +
  1219. +SOURCE=.\win32\nt.h
  1220. +# End Source File
  1221. +# Begin Source File
  1222. +
  1223. +SOURCE=.\process.c
  1224. +# End Source File
  1225. +# Begin Source File
  1226. +
  1227. +SOURCE=.\win32\rsxntwin.h
  1228. +# End Source File
  1229. +# Begin Source File
  1230. +
  1231. +SOURCE=.\tables.h
  1232. +# End Source File
  1233. +# Begin Source File
  1234. +
  1235. +SOURCE=.\ttyio.c
  1236. +# End Source File
  1237. +# Begin Source File
  1238. +
  1239. +SOURCE=.\ttyio.h
  1240. +# End Source File
  1241. +# Begin Source File
  1242. +
  1243. +SOURCE=.\unreduce.c
  1244. +# End Source File
  1245. +# Begin Source File
  1246. +
  1247. +SOURCE=.\unzip.c
  1248. +# End Source File
  1249. +# Begin Source File
  1250. +
  1251. +SOURCE=.\unzip.h
  1252. +# End Source File
  1253. +# Begin Source File
  1254. +
  1255. +SOURCE=.\Unzipsfx.rc
  1256. +# End Source File
  1257. +# Begin Source File
  1258. +
  1259. +SOURCE=.\unzpriv.h
  1260. +# End Source File
  1261. +# Begin Source File
  1262. +
  1263. +SOURCE=.\version.h
  1264. +# End Source File
  1265. +# Begin Source File
  1266. +
  1267. +SOURCE=.\win32\w32cfg.h
  1268. +# End Source File
  1269. +# Begin Source File
  1270. +
  1271. +SOURCE=.\win32\win32.c
  1272. +# End Source File
  1273. +# Begin Source File
  1274. +
  1275. +SOURCE=.\wingui.c
  1276. +# End Source File
  1277. +# Begin Source File
  1278. +
  1279. +SOURCE=.\wingui.h
  1280. +# End Source File
  1281. +# Begin Source File
  1282. +
  1283. +SOURCE=.\zip.h
  1284. +# End Source File
  1285. +# End Target
  1286. +# End Project
  1287. diff -urP origsrc/unzipsfx.dsw src/unzipsfx.dsw
  1288. --- origsrc/unzipsfx.dsw    Wed Dec 31 19:00:00 1969
  1289. +++ src/unzipsfx.dsw    Sat Oct 10 22:33:10 1998
  1290. @@ -0,0 +1,29 @@
  1291. +Microsoft Developer Studio Workspace File, Format Version 5.00
  1292. +# 警告: このワークスペース ファイル を編集または削除しないでください!
  1293. +
  1294. +###############################################################################
  1295. +
  1296. +Project: "unzipsfx"=.\unzipsfx.dsp - Package Owner=<4>
  1297. +
  1298. +Package=<5>
  1299. +{{{
  1300. +}}}
  1301. +
  1302. +Package=<4>
  1303. +{{{
  1304. +}}}
  1305. +
  1306. +###############################################################################
  1307. +
  1308. +Global:
  1309. +
  1310. +Package=<5>
  1311. +{{{
  1312. +}}}
  1313. +
  1314. +Package=<3>
  1315. +{{{
  1316. +}}}
  1317. +
  1318. +###############################################################################
  1319. +
  1320. diff -urP origsrc/unzipsfx.ncb src/unzipsfx.ncb
  1321. --- origsrc/unzipsfx.ncb    Wed Dec 31 19:00:00 1969
  1322. +++ src/unzipsfx.ncb    Sun Oct 11 14:28:32 1998
  1323. @@ -0,0 +1 @@
  1324. +Microsoft C/C++ program database 2.00
  1325. diff -urP origsrc/unzipsfx.opt src/unzipsfx.opt
  1326. --- origsrc/unzipsfx.opt    Wed Dec 31 19:00:00 1969
  1327. +++ src/unzipsfx.opt    Sun Oct 11 14:28:34 1998
  1328. @@ -0,0 +1 @@
  1329. +ミマ爍ア
  1330. \ No newline at end of file
  1331. diff -urP origsrc/unzipsfx.plg src/unzipsfx.plg
  1332. --- origsrc/unzipsfx.plg    Wed Dec 31 19:00:00 1969
  1333. +++ src/unzipsfx.plg    Sun Oct 11 14:28:12 1998
  1334. @@ -0,0 +1,43 @@
  1335. +--------------------構成: unzipsfx - Win32 Release--------------------
  1336. +Begining build with project "C:\Home\Lang\Vc5\unzip\src\unzipsfx.dsp", at root.
  1337. +Active configuration is Win32 (x86) Console Application (based on Win32 (x86) Console Application)
  1338. +
  1339. +Project's tools are:
  1340. +            "32-bit C/C++ Compiler for 80x86" with flags "/nologo /ML /W3 /GX /O2 /I ".." /I "." /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "SFX" /D "CRYPT" /D "GUI" /Fp"Release/unzipsfx.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c "
  1341. +            "Win32 Resource Compiler" with flags "/l 0x411 /fo"Release/Unzipsfx.res" /d "NDEBUG" "
  1342. +            "Browser Database Maker" with flags "/nologo /o"Release/unzipsfx.bsc" "
  1343. +            "COFF Linker for 80x86" with flags "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:no /pdb:"Release/unzipsfx.pdb" /machine:I386 /out:"Release/unzipsfx.exe" "
  1344. +            "カスタム ビルド" with flags ""
  1345. +            "<Component 0xa>" with flags ""
  1346. +
  1347. +Creating temp file "C:\TMP\RSPC075.TMP" with contents </nologo /ML /W3 /GX /O2 /I ".." /I "." /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "SFX" /D "CRYPT" /D "GUI" /Fp"Release/unzipsfx.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c 
  1348. +"C:\Home\Lang\Vc5\unzip\src\extract.c"
  1349. +>
  1350. +Creating command line "cl.exe @C:\TMP\RSPC075.TMP" 
  1351. +Creating temp file "C:\TMP\RSPC076.TMP" with contents <kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:no /pdb:"Release/unzipsfx.pdb" /machine:I386 /out:"Release/unzipsfx.exe" 
  1352. +.\Release\crc32.obj
  1353. +.\Release\crctab.obj
  1354. +.\Release\crypt.obj
  1355. +.\Release\extract.obj
  1356. +.\Release\fileio.obj
  1357. +.\Release\globals.obj
  1358. +.\Release\inflate.obj
  1359. +.\Release\match.obj
  1360. +.\Release\nt.obj
  1361. +.\Release\process.obj
  1362. +.\Release\ttyio.obj
  1363. +.\Release\unreduce.obj
  1364. +.\Release\unzip.obj
  1365. +.\Release\win32.obj
  1366. +.\Release\wingui.obj
  1367. +.\Release\Unzipsfx.res>
  1368. +Creating command line "link.exe @C:\TMP\RSPC076.TMP" 
  1369. +コンパイル中...
  1370. +extract.c
  1371. +C:\Home\Lang\Vc5\unzip\src\extract.c(1074) : warning C4102: 'startover' : ラベルは 1 度も参照されません。
  1372. +C:\Home\Lang\Vc5\unzip\src\extract.c(1074) : warning C4101: 'len' : ローカル変数は 1 度も使われません。
  1373. +リンク中...
  1374. +
  1375. +
  1376. +
  1377. +unzipsfx.exe - エラー 0、警告 2
  1378. diff -urP origsrc/unzipsfx.rc src/unzipsfx.rc
  1379. --- origsrc/unzipsfx.rc    Wed Dec 31 19:00:00 1969
  1380. +++ src/unzipsfx.rc    Sun Oct 11 14:24:52 1998
  1381. @@ -0,0 +1,147 @@
  1382. +//Microsoft Developer Studio generated resource script.
  1383. +//
  1384. +#include "resource.h"
  1385. +
  1386. +#define APSTUDIO_READONLY_SYMBOLS
  1387. +/////////////////////////////////////////////////////////////////////////////
  1388. +//
  1389. +// Generated from the TEXTINCLUDE 2 resource.
  1390. +//
  1391. +#include "afxres.h"
  1392. +
  1393. +/////////////////////////////////////////////////////////////////////////////
  1394. +#undef APSTUDIO_READONLY_SYMBOLS
  1395. +
  1396. +/////////////////////////////////////////////////////////////////////////////
  1397. +// 日本語 resources
  1398. +
  1399. +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN)
  1400. +#ifdef _WIN32
  1401. +LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
  1402. +#pragma code_page(932)
  1403. +#endif //_WIN32
  1404. +
  1405. +/////////////////////////////////////////////////////////////////////////////
  1406. +//
  1407. +// Dialog
  1408. +//
  1409. +
  1410. +IDD_DIALOG_LOG DIALOG DISCARDABLE  0, 0, 235, 179
  1411. +STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_CENTER | WS_POPUP | WS_CAPTION | 
  1412. +    WS_SYSMENU
  1413. +CAPTION "UNZIPSFX(WIN32/GUI)"
  1414. +FONT 9, "MS Pゴシック"
  1415. +BEGIN
  1416. +    DEFPUSHBUTTON   "OK",IDOK,60,165,50,14
  1417. +    PUSHBUTTON      "Cancel",IDCANCEL,120,165,50,14
  1418. +    EDITTEXT        IDC_EDIT_LOG,5,5,225,155,ES_MULTILINE | ES_AUTOVSCROLL | 
  1419. +                    ES_WANTRETURN | WS_VSCROLL
  1420. +END
  1421. +
  1422. +IDD_DIALOG_PASSWORD DIALOG DISCARDABLE  0, 0, 275, 69
  1423. +STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_CENTER | WS_POPUP | WS_CAPTION | 
  1424. +    WS_SYSMENU
  1425. +CAPTION "UNZIPSFX(WIN32/GUI)"
  1426. +FONT 9, "MS Pゴシック"
  1427. +BEGIN
  1428. +    DEFPUSHBUTTON   "OK",IDOK,225,40,50,14
  1429. +    PUSHBUTTON      "Cancel",IDCANCEL,225,55,50,14
  1430. +    EDITTEXT        IDC_EDIT_PASSWORD,35,40,185,12,ES_PASSWORD | 
  1431. +                    ES_AUTOHSCROLL
  1432. +    EDITTEXT        IDC_EDIT_ARCHIVE,35,5,185,12,ES_AUTOHSCROLL | 
  1433. +                    ES_READONLY
  1434. +    LTEXT           "Archive:",IDC_STATIC,0,5,30,10
  1435. +    LTEXT           "Extracting:",IDC_STATIC,0,20,30,10
  1436. +    EDITTEXT        IDC_EDIT_EXTRACTING,35,20,185,12,ES_AUTOHSCROLL | 
  1437. +                    ES_READONLY
  1438. +    LTEXT           "Password:",IDC_STATIC,0,40,30,15
  1439. +END
  1440. +
  1441. +IDD_DIALOG_FOLDER DIALOG DISCARDABLE  0, 0, 234, 79
  1442. +STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_CENTER | WS_POPUP | WS_CAPTION | 
  1443. +    WS_SYSMENU
  1444. +CAPTION "UNZIPSFX(WIN32/GUI)"
  1445. +FONT 9, "MS Pゴシック"
  1446. +BEGIN
  1447. +    DEFPUSHBUTTON   "OK",IDOK,180,40,50,14
  1448. +    PUSHBUTTON      "Cancel",IDCANCEL,180,60,50,14
  1449. +    EDITTEXT        IDC_EDIT_FOLDER,5,20,225,15,ES_AUTOHSCROLL
  1450. +    LTEXT           "Extract Folder:",IDC_STATIC,5,5,45,15
  1451. +END
  1452. +
  1453. +
  1454. +/////////////////////////////////////////////////////////////////////////////
  1455. +//
  1456. +// DESIGNINFO
  1457. +//
  1458. +
  1459. +#ifdef APSTUDIO_INVOKED
  1460. +GUIDELINES DESIGNINFO DISCARDABLE 
  1461. +BEGIN
  1462. +    IDD_DIALOG_LOG, DIALOG
  1463. +    BEGIN
  1464. +        LEFTMARGIN, 7
  1465. +        RIGHTMARGIN, 228
  1466. +        TOPMARGIN, 7
  1467. +        BOTTOMMARGIN, 172
  1468. +    END
  1469. +
  1470. +    IDD_DIALOG_PASSWORD, DIALOG
  1471. +    BEGIN
  1472. +        LEFTMARGIN, 7
  1473. +        RIGHTMARGIN, 268
  1474. +        TOPMARGIN, 7
  1475. +        BOTTOMMARGIN, 62
  1476. +    END
  1477. +
  1478. +    IDD_DIALOG_FOLDER, DIALOG
  1479. +    BEGIN
  1480. +        LEFTMARGIN, 7
  1481. +        RIGHTMARGIN, 227
  1482. +        TOPMARGIN, 7
  1483. +        BOTTOMMARGIN, 72
  1484. +    END
  1485. +END
  1486. +#endif    // APSTUDIO_INVOKED
  1487. +
  1488. +
  1489. +#ifdef APSTUDIO_INVOKED
  1490. +/////////////////////////////////////////////////////////////////////////////
  1491. +//
  1492. +// TEXTINCLUDE
  1493. +//
  1494. +
  1495. +1 TEXTINCLUDE DISCARDABLE 
  1496. +BEGIN
  1497. +    "resource.h\0"
  1498. +END
  1499. +
  1500. +2 TEXTINCLUDE DISCARDABLE 
  1501. +BEGIN
  1502. +    "#include ""afxres.h""\r\n"
  1503. +    "\0"
  1504. +END
  1505. +
  1506. +3 TEXTINCLUDE DISCARDABLE 
  1507. +BEGIN
  1508. +    "\r\n"
  1509. +    "\0"
  1510. +END
  1511. +
  1512. +#endif    // APSTUDIO_INVOKED
  1513. +
  1514. +#endif    // 日本語 resources
  1515. +/////////////////////////////////////////////////////////////////////////////
  1516. +
  1517. +
  1518. +
  1519. +#ifndef APSTUDIO_INVOKED
  1520. +/////////////////////////////////////////////////////////////////////////////
  1521. +//
  1522. +// Generated from the TEXTINCLUDE 3 resource.
  1523. +//
  1524. +
  1525. +
  1526. +/////////////////////////////////////////////////////////////////////////////
  1527. +#endif    // not APSTUDIO_INVOKED
  1528. +
  1529. diff -urP origsrc/wingui.c src/wingui.c
  1530. --- origsrc/wingui.c    Wed Dec 31 19:00:00 1969
  1531. +++ src/wingui.c    Sun Oct 11 03:32:00 1998
  1532. @@ -0,0 +1,121 @@
  1533. +/*
  1534. +    wingui.c
  1535. +*/
  1536. +
  1537. +#include "wingui.h"
  1538. +#include "resource.h"
  1539. +#include <windows.h>
  1540. +#include <process.h>
  1541. +
  1542. +HWND LogDialogHwnd = NULL;
  1543. +HANDLE LogDialogEvent = NULL;
  1544. +HANDLE LogThread = 0;
  1545. +
  1546. +BOOL CALLBACK LogDialogFunc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
  1547. +{
  1548. +    int ret;
  1549. +
  1550. +    switch(msg){
  1551. +    case WM_INITDIALOG:
  1552. +        LogDialogHwnd = hwnd;
  1553. +        SetEvent(LogDialogEvent);
  1554. +        return 1;
  1555. +    case WM_COMMAND:
  1556. +        switch(LOWORD(wParam)){
  1557. +        case IDCANCEL:
  1558. +            SendMessage(hwnd,WM_CLOSE,0,0);
  1559. +            return 1;
  1560. +        }
  1561. +        break;
  1562. +    case WM_CLOSE:
  1563. +        ret = MessageBox(hwnd,"Abort Really?","UNZIPSFX",MB_YESNO);
  1564. +        if(ret==IDYES){
  1565. +            exit(1);
  1566. +        }
  1567. +    }
  1568. +    return 0;
  1569. +}
  1570. +DWORD WINAPI LogThreadFunc(void *dummy)
  1571. +{
  1572. +    int ret;
  1573. +
  1574. +    HINSTANCE hInst = GetModuleHandle(NULL);
  1575. +    ret =  DialogBox(hInst,MAKEINTRESOURCE(IDD_DIALOG_LOG),NULL,LogDialogFunc);
  1576. +    return 0;
  1577. +}
  1578. +int UZ_EXP WinGuiUzpMessagePrnt(zvoid *pG,uch *buf,ulg size,int flag)
  1579. +{
  1580. +    DWORD threadid;
  1581. +    if(LogThread == 0){
  1582. +        LogDialogEvent = CreateEvent(NULL,0,0,NULL);
  1583. +        //LogThread = _beginthread(LogThreadFunc,0,NULL);
  1584. +        
  1585. +        LogThread = CreateThread(NULL,0,LogThreadFunc,0,0,&threadid);
  1586. +        
  1587. +        WaitForSingleObject(LogDialogEvent,INFINITE);
  1588. +        CloseHandle(LogDialogEvent);
  1589. +    }
  1590. +    if(LogDialogHwnd){
  1591. +        char buf2[1000];
  1592. +        char *ptr=buf,*ptr2=buf2;
  1593. +        while(*ptr){
  1594. +            if(*ptr=='\n'){*ptr2++='\r';}
  1595. +            *ptr2++ = *ptr++;
  1596. +        }
  1597. +        *ptr2='\0';
  1598. +        SendDlgItemMessage(LogDialogHwnd,IDC_EDIT_LOG,EM_REPLACESEL,1,(DWORD)buf2);
  1599. +        //SendDlgItemMessage(LogDialogHwnd,IDC_EDIT_LOG,EM_FMTLINES,TRUE,0);
  1600. +    }
  1601. +    return 0;
  1602. +}
  1603. +typedef struct PasswordDialogStruct
  1604. +{
  1605. +    zvoid *pG;int *rcnt;char *pwbuf;int size;ZCONST char *zfn;char *efn;
  1606. +}PasswordDialogStruct;
  1607. +
  1608. +PasswordDialogStruct *s;
  1609. +BOOL CALLBACK PasswordDialogFunc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
  1610. +{
  1611. +    int ret;
  1612. +
  1613. +    switch(msg){
  1614. +    case WM_INITDIALOG:
  1615. +        s = (PasswordDialogStruct*)lParam;
  1616. +        SetDlgItemText(hwnd,IDC_EDIT_ARCHIVE,s->zfn);
  1617. +        SetDlgItemText(hwnd,IDC_EDIT_EXTRACTING,s->zfn);
  1618. +        return 1;
  1619. +    case WM_COMMAND:
  1620. +        switch(LOWORD(wParam)){
  1621. +        case IDOK:
  1622. +            GetDlgItemText(hwnd,IDC_EDIT_PASSWORD,s->pwbuf,s->size);
  1623. +            EndDialog(hwnd,IZ_PW_ENTERED/*0*/);
  1624. +            return 1;
  1625. +        case IDCANCEL:
  1626. +            EndDialog(hwnd,IZ_PW_CANCEL/*-1*/);
  1627. +            return 1;
  1628. +            break;
  1629. +        }
  1630. +        break;
  1631. +    case WM_CLOSE:
  1632. +        ret = MessageBox(hwnd,"Abort Really?","UNZIPSFX",MB_YESNO);
  1633. +        if(ret==IDYES){
  1634. +            exit(1);
  1635. +        }
  1636. +        break;
  1637. +    }
  1638. +    return 0;
  1639. +}
  1640. +int UZ_EXP WinGuiUzpPassword(zvoid *pG,int *rcnt,char *pwbuf,int size,ZCONST char *zfn,ZCONST char *efn)
  1641. +{
  1642. +    int ret;
  1643. +    HMODULE hInst = GetModuleHandle(NULL);
  1644. +    PasswordDialogStruct s = {pG,rcnt,pwbuf,size,zfn,efn};
  1645. +
  1646. +    if(*rcnt==0){*rcnt=2;}else{(*rcnt)--;}
  1647. +    ret = DialogBoxParam(hInst
  1648. +        ,MAKEINTRESOURCE(IDD_DIALOG_PASSWORD)
  1649. +        ,NULL
  1650. +        ,PasswordDialogFunc
  1651. +        ,(DWORD)&s);
  1652. +    return 0;
  1653. +}
  1654. diff -urP origsrc/wingui.h src/wingui.h
  1655. --- origsrc/wingui.h    Wed Dec 31 19:00:00 1969
  1656. +++ src/wingui.h    Sun Oct 11 02:48:30 1998
  1657. @@ -0,0 +1,9 @@
  1658. +/*
  1659. +    wingui.h
  1660. +*/
  1661. +#include "unzip.h"
  1662. +
  1663. +int UZ_EXP WinGuiUzpMessagePrnt(zvoid *pG,uch *buf,ulg size,int flag);
  1664. +int UZ_EXP WinGuiUzpPassword(zvoid *pG,int *rcnt,char *pwbuf,int size,ZCONST char *zfn,ZCONST char *efn);
  1665. +
  1666. +
  1667. Binary files origsrc/zcrypt27.zip and src/zcrypt27.zip differ
  1668.