home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!usc!orion.oac.uci.edu!unogate!mvb.saic.com!vmsnet-sources
- From: goathunter@wkuvx1.bitnet
- Newsgroups: vmsnet.sources
- Subject: Zip v1.9 & UnZip v5.0, part 06/22
- Message-ID: <8009613@MVB.SAIC.COM>
- Date: Tue, 01 Sep 1992 22:50:05 GMT
- Organization: Western Kentucky University, Bowling Green, KY
- Lines: 1397
- Approved: Mark.Berryman@Mvb.Saic.Com
-
- Submitted-by: goathunter@wkuvx1.bitnet
- Posting-number: Volume 3, Issue 128
- Archive-name: zip_unzip/part06
-
- -+-+-+-+-+-+-+-+ START OF PART 6 -+-+-+-+-+-+-+-+
- X /* A directory was extracted. It had a trailing /,`20
- X * don't report the error below. */
- X if (created) `7B
- X printf(" Creating: %s", filename);
- X#ifdef OS2
- X SetPathInfo(filename, lrec.last_mod_file_date,
- X lrec.last_mod_file_time, -1);
- X if (extra_field)
- X SetEAs(filename, extra_field);
- X#endif
- X printf("\n");
- X `7D
- X return 2; /* but skip file */
- X `7D
- X
- X if (*name == '\0') `7B
- X fprintf(stderr, "mapname: conversion of `5B%s`5D failed\n", filenam
- Ve);
- X return 3;
- X `7D
- X
- X#ifdef OS2
- X if (!longname && ((longname = !IsFileNameValid(name)) != 0)) `7B
- X /* in case of second call after user renamed the file, skip this */
- X last = strrchr(name, '/'); /* THIS time, save for file_io */
- X last = last ? last + 1 : name; /* only last component */
- X strcpy(longfilename, last);
- X fprintf(stderr, "renaming \"%s\"", name);
- X ChangeNameForFAT(last);
- X fprintf(stderr, " to \"%s\"\n", name);
- X `7D
- X#endif /* OS2 */
- X
- X#ifdef VMS
- X /* convert filename to legal VMS one, substituting underscores for
- X * all invalid characters */
- X for (np = name; *np; ++np)
- X if (!(isdigit(*np) `7C`7C isalpha(*np) `7C`7C (*np == '$') `7C`7C
- X (*np == '-') `7C`7C (*np == '_') `7C`7C (*np == '.') `7C`7C (*np
- V == ';')))
- X *np = '_';
- X#endif /* VMS */
- X
- X if (!jflag) `7B
- X#ifdef VMS
- X *xp++ = '`5D'; /* proper end-of-dir-name delimiter *
- V/
- X if (xp == cdp) `7B /* no path-name stuff, so... */
- X strcpy(filename, name); /* copy file name into global */
- X cdp -= 2; /* prepare to free malloc'd space */
- X `7D else `7B /* we've added path-name stuff... *
- V/
- X *xp = '\0'; /* so terminate and convert to */
- X dp = cdp; /* VMS subdir separators (skip */
- X while (*++dp) /* first char: better not be */
- X if (*dp == '/') /* "/"): change all slashes */
- X *dp = '.'; /* to dots */
- X cdp -= 2; /* include leading bracket and dot */
- X strcpy(filename, cdp); /* copy VMS-style path name into global
- V */
- X strcat(filename, name); /* concatenate file name to global */
- X `7D
- X#else /* !VMS */
- X strcpy(filename, cdp); /* either "" or slash-terminated path *
- V/
- X strcat(filename, name); /* append file name to path name */
- X#endif /* ?VMS */
- X free(cdp);
- X `7D else
- X strcpy(filename, name); /* copy converted name into global */
- X
- X#if PATH_MAX < (FILNAMSIZ - 1)
- X /* check the length of the file name and truncate if necessary */
- X if (PATH_MAX < strlen(filename)) `7B
- X fprintf(stderr, "caution: truncating filename\n");
- X filename`5BPATH_MAX`5D = '\0';
- X fprintf(stderr, "`5B %s `5D\n", filename);
- X return 1; /* 1: warning error */
- X `7D
- X#endif
- X
- X return 0;
- X`7D
- $ CALL UNPACK [.UNZIP50]MAPNAME.C;1 1631201166
- $ create 'f'
- X/*--------------------------------------------------------------------------
- V-
- X
- X match.c
- X
- X The match() routine recursively compares a string to a "pattern" (regular
- X expression), returning TRUE if a match is found or FALSE if not. This
- X version is specifically for use with unzip.c: as did the previous match()
- X from SEA, it leaves the case (upper, lower, or mixed) of the string alone,
- X but converts any uppercase characters in the pattern to lowercase if indi-
- X cated by the global var pInfo->lcflag (which is to say, string is assumed
- X to have been converted to lowercase already, if such was necessary).
- X
- X --------------------------------------------------------------------------
- V-*/
- X
- X
- X#ifdef ZIPINFO
- X# undef ZIPINFO /* make certain there is only one version of match.o */
- X#endif /* ZIPINFO */
- X#include "unzip.h"
- X
- Xstatic int matche __((register char *p, register char *t));
- Xstatic int matche_after_star __((register char *p, register char *t));
- X
- X/* #include "filmatch.h": */
- X#ifndef BOOLEAN
- X# define BOOLEAN short int /* v1.2 made it short */
- X#endif
- X
- X/* match defines */
- X#define MATCH_PATTERN 6 /* bad pattern */
- X#define MATCH_LITERAL 5 /* match failure on literal match */
- X#define MATCH_RANGE 4 /* match failure on `5B..`5D construct */
- X#define MATCH_ABORT 3 /* premature end of text string */
- X#define MATCH_END 2 /* premature end of pattern string */
- X#define MATCH_VALID 1 /* valid match */
- X
- X/* pattern defines */
- X#define PATTERN_VALID 0 /* valid pattern */
- X#define PATTERN_ESC -1 /* literal escape at end of pattern */
- X#define PATTERN_RANGE -2 /* malformed range in `5B..`5D construct */
- X#define PATTERN_CLOSE -3 /* no end bracket in `5B..`5D construct */
- X#define PATTERN_EMPTY -4 /* `5B..`5D contstruct is empty */
- X
- X/*--------------------------------------------------------------------------
- V--
- X*
- X* Match the pattern PATTERN against the string TEXT;
- X*
- X* match() returns TRUE if pattern matches, FALSE otherwise.
- X* matche() returns MATCH_VALID if pattern matches, or an errorcode
- X* as follows otherwise:
- X*
- X* MATCH_PATTERN - bad pattern
- X* MATCH_RANGE - match failure on `5B..`5D construct
- X* MATCH_ABORT - premature end of text string
- X* MATCH_END - premature end of pattern string
- X* MATCH_VALID - valid match
- X*
- X*
- X* A match means the entire string TEXT is used up in matching.
- X*
- X* In the pattern string:
- X* `60*' matches any sequence of characters (zero or more)
- X* `60?' matches any character
- X* `5BSET`5D matches any character in the specified set,
- X* `5B!SET`5D or `5B`5ESET`5D matches any character not in the specifie
- Vd set.
- X*
- X* A set is composed of characters or ranges; a range looks like
- X* character hyphen character (as in 0-9 or A-Z). `5B0-9a-zA-Z_`5D is the
- X* minimal set of characters allowed in the `5B..`5D pattern construct.
- X* Other characters are allowed (ie. 8 bit characters) if your system
- X* will support them.
- X*
- X* To suppress the special syntactic significance of any of `60`5B`5D*?!`5E-
- V\',
- X* in a `5B..`5D construct and match the character exactly, precede it
- X* with a `60\'.
- X*
- X----------------------------------------------------------------------------
- V*/
- X
- X/*--------------------------------------------------------------------------
- V--
- X*
- X* Match the pattern PATTERN against the string TEXT;
- X*
- X* returns MATCH_VALID if pattern matches, or an errorcode as follows
- X* otherwise:
- X*
- X* MATCH_PATTERN - bad pattern
- X* MATCH_RANGE - match failure on `5B..`5D construct
- X* MATCH_ABORT - premature end of text string
- X* MATCH_END - premature end of pattern string
- X* MATCH_VALID - valid match
- X*
- X*
- X* A match means the entire string TEXT is used up in matching.
- X*
- X* In the pattern string:
- X* `60*' matches any sequence of characters (zero or more)
- X* `60?' matches any character
- X* `5BSET`5D matches any character in the specified set,
- X* `5B!SET`5D or `5B`5ESET`5D matches any character not in the specifie
- Vd set.
- X* \ is allowed within a set to escape a character like '`5D' or '-'
- X*
- X* A set is composed of characters or ranges; a range looks like
- X* character hyphen character (as in 0-9 or A-Z). `5B0-9a-zA-Z_`5D is the
- X* minimal set of characters allowed in the `5B..`5D pattern construct.
- X* Other characters are allowed (ie. 8 bit characters) if your system
- X* will support them.
- X*
- X* To suppress the special syntactic significance of any of `60`5B`5D*?!`5E-
- V\',
- X* within a `5B..`5D construct and match the character exactly, precede it
- X* with a `60\'.
- X*
- X----------------------------------------------------------------------------
- V*/
- X
- Xstatic int matche(p, t)
- Xregister char *p;
- Xregister char *t;
- X`7B
- X register char range_start, range_end; /* start and end in range */
- X
- X BOOLEAN invert; /* is this `5B..`5D or `5B!..`5D */
- X BOOLEAN member_match; /* have I matched the `5B..`5D construct? */
- X BOOLEAN loop; /* should I terminate? */
- X
- X for (; *p; p++, t++) `7B
- X
- X /* if this is the end of the text then this is the end of the match
- V */
- X if (!*t)
- X return ((*p == '*') && (*++p == '\0'))? MATCH_VALID : MATCH_ABO
- VRT;
- X
- X /* determine and react to pattern type */
- X switch (*p) `7B
- X
- X /* single any character match */
- X case '?':
- X break;
- X
- X /* multiple any character match */
- X case '*':
- X return matche_after_star (p, t);
- X
- X /* `5B..`5D construct, single member/exclusion character match *
- V/
- X case '`5B': `7B
- X
- X /* move to beginning of range */
- X p++;
- X
- X /* check if this is a member match or exclusion match */
- X invert = FALSE;
- X if ((*p == '!') `7C`7C (*p == '`5E')) `7B
- X invert = TRUE;
- X p++;
- X `7D
- X
- X /* if closing bracket here or at range start then we have a
- X malformed pattern */
- X if (*p == '`5D')
- X return MATCH_PATTERN;
- X
- X member_match = FALSE;
- X loop = TRUE;
- X
- X while (loop) `7B
- X
- X /* if end of construct then loop is done */
- X if (*p == '`5D') `7B
- X loop = FALSE;
- X continue;
- X `7D
- X
- X /* matching a '!', '`5E', '-', '\' or a '`5D' */
- X if (*p == '\\')
- X range_start = range_end = *++p;
- X else
- X range_start = range_end = *p;
- X
- X /* if end of pattern then bad pattern (Missing '`5D') */
- X if (!*p)
- X return MATCH_PATTERN;
- X
- X /* check for range bar */
- X if (*++p == '-') `7B
- X
- X /* get the range end */
- X range_end = *++p;
- X
- X /* if end of pattern or construct then bad pattern *
- V/
- X if ((range_end == '\0') `7C`7C (range_end == '`5D'))
- X return MATCH_PATTERN;
- X
- X /* special character range end */
- X if (range_end == '\\') `7B
- X range_end = *++p;
- X
- X /* if end of text then we have a bad pattern */
- X if (!range_end)
- X return MATCH_PATTERN;
- X `7D
- X
- X /* move just beyond this range */
- X p++;
- X `7D
- X
- X /* if the text character is in range then match found.
- X * make sure the range letters have the proper
- X * relationship to one another before comparison
- X */
- X if (range_start < range_end) `7B
- X if ((*t >= range_start) && (*t <= range_end)) `7B
- X member_match = TRUE;
- X loop = FALSE;
- X `7D
- X `7D else `7B
- X if ((*t >= range_end) && (*t <= range_start)) `7B
- X member_match = TRUE;
- X loop = FALSE;
- X `7D
- X `7D
- X `7D
- X
- X /* if there was a match in an exclusion set then no match */
- X /* if there was no match in a member set then no match */
- X if ((invert && member_match) `7C`7C
- X !(invert `7C`7C member_match))
- X return MATCH_RANGE;
- X
- X /* if this is not an exclusion then skip the rest of the `5B
- V...`5D
- X construct that already matched. */
- X if (member_match) `7B
- X while (*p != '`5D') `7B
- X
- X /* bad pattern (Missing '`5D') */
- X if (!*p)
- X return MATCH_PATTERN;
- X
- X /* skip exact match */
- X if (*p == '\\') `7B
- X p++;
- X
- X /* if end of text then we have a bad pattern */
- X if (!*p)
- X return MATCH_PATTERN;
- X `7D
- X
- X /* move to next pattern char */
- X p++;
- X `7D
- X `7D
- X
- X break;
- X `7D /* switch '`5B' */
- X
- X /* must match this character exactly */
- X default:
- X#ifdef OLDSTUFF
- X if (*p != *t)
- X#else /* !OLDSTUFF */
- X /* do it like arcmatch() (old unzip) did it (v1.2) */
- X if (*t != (char) ((pInfo->lcflag && isupper((int)(*p)))?
- X tolower((int)(*p)) : *p))
- X#endif /* ?OLDSTUFF */
- X return MATCH_LITERAL;
- X
- X `7D /* switch */
- X `7D /* for */
- X
- X /* if end of text not reached then the pattern fails */
- X if (*t)
- X return MATCH_END;
- X else
- X return MATCH_VALID;
- X`7D
- X
- X
- X/*--------------------------------------------------------------------------
- V--
- X*
- X* recursively call matche() with final segment of PATTERN and of TEXT.
- X*
- X----------------------------------------------------------------------------
- V*/
- X
- Xstatic int matche_after_star (p,t)
- Xregister char *p;
- Xregister char *t;
- X`7B
- X register int match = 0;
- X register int nextp;
- X
- X /* pass over existing ? and * in pattern */
- X while ((*p == '?') `7C`7C (*p == '*')) `7B
- X
- X /* take one char for each ? and +; if end of text then no match */
- X if ((*p == '?') && (!*t++))
- X return MATCH_ABORT;
- X
- X /* move to next char in pattern */
- X p++;
- X `7D
- X
- X /* if end of pattern we have matched regardless of text left */
- X if (!*p)
- X return MATCH_VALID;
- X
- X /* get the next character to match which must be a literal or '`5B' */
- X nextp = *p;
- X
- X /* Continue until we run out of text or definite result seen */
- X do `7B
- X /* a precondition for matching is that the next character
- X * in the pattern match the next character in the text or that
- X * the next pattern char is the beginning of a range. Increment
- X * text pointer as we go here.
- X */
- X if ((nextp == *t) `7C`7C (nextp == '`5B'))
- X match = matche(p, t);
- X
- X /* if the end of text is reached then no match */
- X if (!*t++)
- X match = MATCH_ABORT;
- X
- X `7D while ((match != MATCH_VALID) &&
- X (match != MATCH_ABORT) &&
- X (match != MATCH_PATTERN));
- X
- X /* return result */
- X return match;
- X`7D
- X
- X
- X/*--------------------------------------------------------------------------
- V--
- X*
- X* match() is a shell to matche() to return only BOOLEAN values.
- X*
- X----------------------------------------------------------------------------
- V*/
- X
- Xint match(string,pattern)
- Xchar *string;
- Xchar *pattern;
- X`7B
- X int error_type;
- X error_type = matche(pattern,string);
- X return (error_type == MATCH_VALID ) ? TRUE : FALSE;
- X`7D
- X
- X
- X#ifdef TEST_MATCH
- X
- X/*--------------------------------------------------------------------------
- V--
- X*
- X* Return TRUE if PATTERN has any special wildcard characters
- X*
- X----------------------------------------------------------------------------
- V*/
- X
- XBOOLEAN is_pattern (char *pattern);
- X
- X/*--------------------------------------------------------------------------
- V--
- X*
- X* Return TRUE if PATTERN has is a well formed regular expression according
- X* to the above syntax
- X*
- X* error_type is a return code based on the type of pattern error. Zero is
- X* returned in error_type if the pattern is a valid one. error_type return
- X* values are as follows:
- X*
- X* PATTERN_VALID - pattern is well formed
- X* PATTERN_RANGE - `5B..`5D construct has a no end range in a '-' pair (ie
- V `5Ba-`5D)
- X* PATTERN_CLOSE - `5B..`5D construct has no end bracket (ie `5Babc-g )
- X* PATTERN_EMPTY - `5B..`5D construct is empty (ie `5B`5D)
- X*
- X----------------------------------------------------------------------------
- V*/
- X
- XBOOLEAN is_valid_pattern (char *pattern, int *error_type);
- Xint fast_match_after_star (register char *pattern, register char *text);
- X
- X/*--------------------------------------------------------------------------
- V--
- X*
- X* Return TRUE if PATTERN has any special wildcard characters
- X*
- X----------------------------------------------------------------------------
- V*/
- X
- XBOOLEAN is_pattern (char *p)
- X`7B
- X while (*p)
- X switch (*p++) `7B
- X case '?':
- X case '*':
- X case '`5B':
- X return TRUE;
- X `7D
- X return FALSE;
- X`7D
- X
- X
- X/*--------------------------------------------------------------------------
- V--
- X*
- X* Return TRUE if PATTERN has is a well formed regular expression according
- X* to the above syntax
- X*
- X* error_type is a return code based on the type of pattern error. Zero is
- X* returned in error_type if the pattern is a valid one. error_type return
- X* values are as follows:
- X*
- X* PATTERN_VALID - pattern is well formed
- X* PATTERN_RANGE - `5B..`5D construct has a no end range in a '-' pair (ie
- V `5Ba-`5D)
- X* PATTERN_CLOSE - `5B..`5D construct has no end bracket (ie `5Babc-g )
- X* PATTERN_EMPTY - `5B..`5D construct is empty (ie `5B`5D)
- X*
- X----------------------------------------------------------------------------
- V*/
- X
- XBOOLEAN is_valid_pattern (char *p, int *error_type)
- X`7B
- X /* init error_type */
- X *error_type = PATTERN_VALID;
- X
- X /* loop through pattern to EOS */
- X while (*p) `7B
- X
- X /* determine pattern type */
- X switch (*p) `7B
- X
- X /* the `5B..`5D construct must be well formed */
- X case '`5B':
- X p++;
- X
- X /* if the next character is '`5D' then bad pattern */
- X if (*p == '`5D') `7B
- X *error_type = PATTERN_EMPTY;
- X return FALSE;
- X `7D
- X
- X /* if end of pattern here then bad pattern */
- X if (!*p) `7B
- X *error_type = PATTERN_CLOSE;
- X return FALSE;
- X `7D
- X
- X /* loop to end of `5B..`5D construct */
- X while (*p != '`5D') `7B
- X
- X /* check for literal escape */
- X if (*p == '\\') `7B
- X p++;
- X
- X /* if end of pattern here then bad pattern */
- X if (!*p++) `7B
- X *error_type = PATTERN_ESC;
- X return FALSE;
- X `7D
- X `7D else
- X p++;
- X
- X /* if end of pattern here then bad pattern */
- X if (!*p) `7B
- X *error_type = PATTERN_CLOSE;
- X return FALSE;
- X `7D
- X
- X /* if this a range */
- X if (*p == '-') `7B
- X
- X /* we must have an end of range */
- X if (!*++p `7C`7C (*p == '`5D')) `7B
- X *error_type = PATTERN_RANGE;
- X return FALSE;
- X `7D else `7B
- X
- X /* check for literal escape */
- X if (*p == '\\')
- X p++;
- X
- X /* if end of pattern here then bad pattern */
- X if (!*p++) `7B
- X *error_type = PATTERN_ESC;
- X return FALSE;
- X `7D
- X `7D
- X `7D
- X `7D
- X break;
- X
- X /* all other characters are valid pattern elements */
- X case '*':
- X case '?':
- X default:
- X p++; /* "normal" character */
- X break;
- X `7D /* switch */
- X `7D
- X
- X return TRUE;
- X`7D
- X
- X
- X /*
- X * This test main expects as first arg the pattern and as second arg
- X * the match string. Output is yay or nay on match. If nay on
- X * match then the error code is parsed and written.
- X */
- X
- X#include <stdio.h>
- X
- Xint main(int argc, char *argv`5B`5D)
- X`7B
- X int error;
- X int is_valid_error;
- X
- X if (argc != 3)
- X printf("Usage: MATCH Pattern Text\n");
- X else `7B
- X printf("Pattern: %s\n", argv`5B1`5D);
- X printf("Text : %s\n", argv`5B2`5D);
- X
- X if (!is_pattern(argv`5B1`5D))
- X printf(" First Argument Is Not A Pattern\n");
- X else `7B
- X match(argv`5B1`5D,argv`5B2`5D) ? printf("TRUE") : printf("FALSE"
- V);
- X error = matche(argv`5B1`5D,argv`5B2`5D);
- X is_valid_pattern(argv`5B1`5D,&is_valid_error);
- X
- X switch (error) `7B
- X case MATCH_VALID:
- X printf(" Match Successful");
- X if (is_valid_error != PATTERN_VALID)
- X printf(" -- is_valid_pattern() is complaining\n");
- X else
- X printf("\n");
- X break;
- X case MATCH_RANGE:
- X printf(" Match Failed on `5B..`5D\n");
- X break;
- X case MATCH_ABORT:
- X printf(" Match Failed on Early Text Termination\n");
- X break;
- X case MATCH_END:
- X printf(" Match Failed on Early Pattern Termination\n"
- V);
- X break;
- X case MATCH_PATTERN:
- X switch (is_valid_error) `7B
- X case PATTERN_VALID:
- X printf(" Internal Disagreement On Pattern\n")
- V;
- X break;
- X case PATTERN_RANGE:
- X printf(" No End of Range in `5B..`5D Construc
- Vt\n");
- X break;
- X case PATTERN_CLOSE:
- X printf(" `5B..`5D Construct is Open\n");
- X break;
- X case PATTERN_EMPTY:
- X printf(" `5B..`5D Construct is Empty\n");
- X break;
- X default:
- X printf(" Internal Error in is_valid_pattern()
- V\n");
- X `7D
- X break;
- X default:
- X printf(" Internal Error in matche()\n");
- X break;
- X `7D /* switch */
- X `7D
- X
- X `7D
- X return(0);
- X`7D
- X
- X#endif /* TEST_MATCH */
- $ CALL UNPACK [.UNZIP50]MATCH.C;1 119022413
- $ create 'f'
- X/*--------------------------------------------------------------------------
- V-
- X
- X misc.c
- X
- X This file contains a number of useful but not particularly closely related
- X functions; their main claim to fame is that they don't change much, so thi
- Vs
- X file should rarely need to be recompiled. The CRC-32 stuff is from crc32.
- Vc;
- X do_string() is from nunzip.c; makeword() and makelong() are from unzip.c;
- X memset() and memcpy() are from zmemset.c and zmemcpy.c, respectively; and
- X dos_to_unix_time() is from set_file_time_and_close() in file_io.c. ebcdic
- V`5B`5D,
- X check_for_newer(), dateformat(), and return_VMS() are new. Things lumped
- X together here to cut down on the size of unzip.c and the number of associ-
- X ated files floating around.
- X
- X --------------------------------------------------------------------------
- V-
- X
- X Copyrights: see accompanying file "COPYING" in UnZip source distribution.
- X
- X --------------------------------------------------------------------------
- V-*/
- X
- X
- X#include "unzip.h"
- X#ifdef MSWIN
- X# include "wizunzip.h"
- X#endif
- X
- X
- X
- X#ifndef ZIPINFO /* no need to calculate CRCs */
- X
- X/**************************/
- X/* Function UpdateCRC() */
- X/**************************/
- X
- X /*--------------------------------------------------------------------
- X
- X First, the polynomial itself and its table of feedback terms. The
- X polynomial is
- X X`5E32+X`5E26+X`5E23+X`5E22+X`5E16+X`5E12+X`5E11+X`5E10+X`5E8+X`5E7+X`5E5
- V+X`5E4+X`5E2+X`5E1+X`5E0
- X
- X Note that we take it "backwards" and put the highest-order term in
- X the lowest-order bit. The X`5E32 term is "implied"; the LSB is the
- X X`5E31 term, etc. The X`5E0 term (usually shown as "+1") results in
- X the MSB being 1.
- X
- X Note that the usual hardware shift register implementation, which
- X is what we're using (we're merely optimizing it by doing eight-bit
- X chunks at a time) shifts bits into the lowest-order term. In our
- X implementation, that means shifting towards the right. Why do we
- X do it this way? Because the calculated CRC must be transmitted in
- X order from highest-order term to lowest-order term. UARTs transmit
- X characters in order from LSB to MSB. By storing the CRC this way,
- X we hand it to the UART in the order low-byte to high-byte; the UART
- X sends each low-bit to hight-bit; and the result is transmission bit
- X by bit from highest- to lowest-order term without requiring any bit
- X shuffling on our part. Reception works similarly.
- X
- X The feedback terms table consists of 256, 32-bit entries. Notes:
- X
- X The table can be generated at runtime if desired; code to do so
- X is shown later. It might not be obvious, but the feedback
- X terms simply represent the results of eight shift/xor opera-
- X tions for all combinations of data and CRC register values.
- X
- X The values must be right-shifted by eight bits by the "updcrc"
- X logic; the shift must be unsigned (bring in zeroes). On some
- X hardware you could probably optimize the shift in assembler by
- X using byte-swap instructions.
- X polynomial $edb88320
- X
- X --------------------------------------------------------------------*/
- X
- XULONG crc_32_tab`5B`5D =
- X`7B
- X 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
- X 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
- X 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
- X 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
- X 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
- X 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
- X 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
- X 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
- X 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
- X 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
- X 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
- X 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
- X 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
- X 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
- X 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
- X 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
- X 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
- X 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
- X 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
- X 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
- X 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
- X 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
- X 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
- X 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
- X 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
- X 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
- X 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
- X 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
- X 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
- X 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
- X 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
- X 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
- X 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
- X 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
- X 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
- X 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
- X 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
- X 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
- X 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
- X 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
- X 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
- X 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
- X 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
- X 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
- X 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
- X 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
- X 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
- X 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
- X 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
- X 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
- X 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
- X 0x2d02ef8dL
- X`7D; /* end crc_32_tab`5B`5D */
- X
- X
- Xvoid UpdateCRC(s, len)
- X register byte *s;
- X register int len;
- X`7B
- X register ULONG crcval = crc32val;
- X
- X /* update running CRC calculation with contents of a buffer */
- X while (len--)
- X crcval = crc_32_tab`5B((byte) crcval `5E (*s++)) & 0xff`5D `5E (crcv
- Val >> 8);
- X crc32val = crcval;
- X`7D
- X
- X#endif /* !ZIPINFO */
- X
- X
- X
- X
- X
- X/**************************/
- X/* Function do_string() */
- X/**************************/
- X
- Xint do_string(len, option) /* return PK-type error code */
- X unsigned int len; /* without prototype, UWORD converted to thi
- Vs */
- X int option;
- X`7B
- X int block_length, error = 0;
- X UWORD comment_bytes_left, extra_len;
- X
- X
- X/*--------------------------------------------------------------------------
- V-
- X This function processes arbitrary-length (well, usually) strings. Three
- X options are allowed: SKIP, wherein the string is skipped pretty logical
- V,
- X eh?); DISPLAY, wherein the string is printed to standard output after un
- V-
- X dergoing any necessary or unnecessary character conversions; and FILENAM
- VE,
- X wherein the string is put into the filename`5B`5D array after undergoing
- V ap-
- X propriate conversions (including case-conversion, if that is indicated:
- X see the global variable pInfo->lcflag). The latter option should be OK,
- X since filename is now dimensioned at 1025, but we check anyway.
- X
- X The string, by the way, is assumed to start at the current file-pointer
- X position; its length is given by len. So start off by checking length
- X of string: if zero, we're already set.
- X --------------------------------------------------------------------------
- V-*/
- X
- X if (!len)
- X return (0); /* 0: no error */
- X
- X switch (option) `7B
- X
- X /*
- X * First case: print string on standard output. First set loop vari-
- X * ables, then loop through the comment in chunks of OUTBUFSIZ bytes,
- X * converting formats and printing as we go. The second half of the
- X * loop conditional was added because the file might be truncated, in
- X * which case comment_bytes_left will remain at some non-zero value for
- X * all time. outbuf is used as a scratch buffer because it is avail-
- X * able (we should be either before or in between any file processing).
- X * `5BThe typecast in front of the MIN() macro was added because of the
- X * new promotion rules under ANSI C; readbuf() wants an int, but MIN()
- X * returns a signed long, if I understand things correctly. The proto-
- X * type should handle it, but just in case...`5D
- X */
- X
- X case DISPLAY:
- X comment_bytes_left = len;
- X block_length = OUTBUFSIZ; /* for the while statement, first time
- V */
- X while (comment_bytes_left > 0 && block_length > 0) `7B
- X if ((block_length = readbuf((char *)outbuf,
- X (int) MIN(OUTBUFSIZ, comment_bytes_left))) <= 0)
- X return 51; /* 51: unexpected EOF */
- X comment_bytes_left -= block_length;
- X NUKE_CRs(outbuf, block_length); /* (modifies block_length) *
- V/
- X
- X /* this is why we allocated an extra byte for outbuf: */
- X outbuf`5Bblock_length`5D = '\0'; /* terminate w/zero: AS
- VCIIZ */
- X
- X A_TO_N(outbuf); /* translate string to native */
- X
- X printf("%s", outbuf);
- X `7D
- X#ifdef MSWIN
- X /* ran out of local mem -- had to cheat */
- X WriteStringToMsgWin(outbuf, bRealTimeMsgUpdate);
- X#else /* !MSWIN */
- X printf("\n"); /* assume no newline at end */
- X#endif /* ?MSWIN */
- X break;
- X
- X /*
- X * Second case: read string into filename`5B`5D array. The filename sh
- Vould
- X * never ever be longer than FILNAMSIZ-1 (1024), but for now we'll check
- V,
- X * just to be sure.
- X */
- X
- X case FILENAME:
- X extra_len = 0;
- X if (len >= FILNAMSIZ) `7B
- X fprintf(stderr, "warning: filename too long--truncating.\n");
- X error = 1; /* 1: warning error */
- X extra_len = len - FILNAMSIZ + 1;
- X len = FILNAMSIZ - 1;
- X `7D
- X if (readbuf(filename, len) <= 0)
- X return 51; /* 51: unexpected EOF */
- X filename`5Blen`5D = '\0'; /* terminate w/zero: ASCIIZ */
- X
- X A_TO_N(filename); /* translate string to native */
- X
- X#ifndef ZIPINFO
- X if (pInfo->lcflag)
- X TOLOWER(filename, filename); /* replace with lowercase filename
- V */
- X#endif
- X
- X if (!extra_len) /* we're done here */
- X break;
- X
- X /*
- X * We truncated the filename, so print what's left and then fall
- X * through to the SKIP routine.
- X */
- X fprintf(stderr, "`5B %s `5D\n", filename);
- X len = extra_len;
- X /* FALL THROUGH... */
- X
- X /*
- X * Third case: skip string, adjusting readbuf's internal variables
- X * as necessary (and possibly skipping to and reading a new block of
- X * data).
- X */
- X
- X case SKIP:
- X LSEEK(cur_zipfile_bufstart + (inptr-inbuf) + len)
- X break;
- X
- X /*
- X * Fourth case: assume we're at the start of an "extra field"; malloc
- X * storage for it and read data into the allocated space.
- X */
- X
- X case EXTRA_FIELD:
- X if (extra_field != (byte *)NULL)
- X free(extra_field);
- X if ((extra_field = (byte *)malloc(len)) == (byte *)NULL) `7B
- X fprintf(stderr,
- X "warning: extra field too long (%d). Ignoring...\n", len);
- X LSEEK(cur_zipfile_bufstart + (inptr-inbuf) + len)
- X `7D else
- X if (readbuf((char *)extra_field, len) <= 0)
- X return 51; /* 51: unexpected EOF */
- X break;
- X
- X `7D /* end switch (option) */
- X return error;
- X
- X`7D /* end function do_string() */
- X
- X
- X
- X
- X
- X#ifndef ZIPINFO
- X#ifndef VMS
- X
- X/*********************************/
- X/* Function dos_to_unix_time() */
- X/*********************************/
- X
- Xtime_t dos_to_unix_time(ddate, dtime)
- X unsigned ddate, dtime;
- X`7B
- X static short yday`5B`5D=`7B0, 31, 59, 90, 120, 151, 181, 212, 243, 273,
- V 304, 334`7D;
- X int yr, mo, dy, hh, mm, ss, leap;
- X long m_time, days=0;
- X#if (!defined(MACOS) && !defined(MSC) && !defined(__GO32__))
- X#if (defined(BSD) `7C`7C defined(MTS))
- X#ifndef __386BSD__
- X static struct timeb tbp;
- X#endif /* __386BSD__ */
- X#else /* !(BSD `7C`7C MTS) */
- X extern long timezone; /* declared in <time.h> for MSC (& Borland?) */
- X#endif /* ?(BSD `7C`7C MTS) */
- X#endif /* !MACOS && !MSC && !__GO32__ */
- X
- X# define YRBASE 1970
- X
- X /* dissect date */
- X yr = ((ddate >> 9) & 0x7f) + (1980 - YRBASE);
- X mo = ((ddate >> 5) & 0x0f) - 1;
- X dy = (ddate & 0x1f) - 1;
- X
- X /* dissect time */
- X hh = (dtime >> 11) & 0x1f;
- X mm = (dtime >> 5) & 0x3f;
- X ss = (dtime & 0x1f) * 2;
- X
- X /* leap = # of leap years from BASE up to but not including current year
- V */
- X leap = ((yr + YRBASE - 1) / 4); /* leap year base factor */
- X
- X /* How many days from BASE to this year? (& add expired days this year)
- V */
- X days = (yr * 365) + (leap - 492) + yday`5Bmo`5D;
- X
- X /* if year is a leap year and month is after February, add another day *
- V/
- X if ((mo > 1) && ((yr+YRBASE)%4 == 0) && ((yr+YRBASE) != 2100))
- X ++days; /* OK through 2199 */
- X
- X /* convert date & time to seconds relative to 00:00:00, 01/01/YRBASE */
- X m_time = ((long)(days + dy) * 86400L) + ((long)hh * 3600) + (mm * 60) +
- V ss;
- X /* - 1; MS-DOS times always rounded up to nearest even second */
- X
- X#if (!defined(MACOS) && !defined(__GO32__))
- X#if (defined(BSD) `7C`7C defined(MTS))
- X#ifndef __386BSD__
- X ftime(&tbp);
- X m_time += tbp.timezone * 60L;
- X#endif
- X#else /* !(BSD `7C`7C MTS) */
- X#ifdef WIN32
- X /* later... */
- X#else /* !WIN32 */
- X tzset(); /* set `60timezone' */
- X#endif /* ?WIN32 */
- X m_time += timezone; /* account for timezone differences */
- X#endif /* ?(BSD `7C`7C MTS) */
- X#endif /* !MACOS && !__GO32__ */
- X
- X#ifdef __386BSD__
- X m_time += localtime((time_t *) &m_time))->tm_gmtoff;
- X#else
- X if (localtime((time_t *)&m_time)->tm_isdst)
- X m_time -= 60L * 60L; /* adjust for daylight savings time */
- X#endif /* __386BSD__ */
- X
- X return m_time;
- X
- X`7D /* end function dos_to_unix_time() */
- X
- X#endif /* !VMS */
- X
- X
- X
- X
- X
- X/********************************/
- X/* Function check_for_newer() */ /* could make this into a macro for Unix
- V */
- X/********************************/
- X
- Xint check_for_newer(filename) /* return 1 if existing file newer or equal;
- V */
- X char *filename; /* 0 if older; -1 if doesn't exist yet */
- X`7B
- X#ifdef VMS
- X unsigned short timbuf`5B7`5D;
- X int dy, mo, yr, hh, mm, ss, dy2, mo2, yr2, hh2, mm2, ss2;
- X struct FAB fab;
- X struct XABDAT xdat;
- X
- X
- X if (stat(filename, &statbuf))
- X return DOES_NOT_EXIST;
- X
- X fab = cc$rms_fab;
- X xdat = cc$rms_xabdat;
- X
- X fab.fab$l_xab = &xdat;
- X fab.fab$l_fna = filename;
- X fab.fab$b_fns = strlen(filename);
- X fab.fab$l_fop = FAB$M_GET `7C FAB$M_UFO;
- X
- X if ((sys$open(&fab) & 1) == 0) /* open failure: report exists and
- V */
- X return EXISTS_AND_OLDER; /* older so new copy will be made
- V */
- X sys$numtim(&timbuf,&xdat.xab$q_cdt);
- X fab.fab$l_xab = 0L;
- X
- X sys$dassgn(fab.fab$l_stv);
- X sys$close(&fab); /* be sure file is closed and RMS knows about it */
- X
- X yr = timbuf`5B0`5D;
- X yr2 = ((lrec.last_mod_file_date >> 9) & 0x7f) + 1980;
- X if (yr > yr2)
- X return EXISTS_AND_NEWER;
- X else if (yr < yr2)
- X return EXISTS_AND_OLDER;
- X
- X mo = timbuf`5B1`5D;
- X mo2 = ((lrec.last_mod_file_date >> 5) & 0x0f);
- X if (mo > mo2)
- X return EXISTS_AND_NEWER;
- X else if (mo < mo2)
- X return EXISTS_AND_OLDER;
- X
- X dy = timbuf`5B2`5D;
- X dy2 = (lrec.last_mod_file_date & 0x1f);
- X if (dy > dy2)
- X return EXISTS_AND_NEWER;
- X else if (dy < dy2)
- X return EXISTS_AND_OLDER;
- X
- X hh = timbuf`5B3`5D;
- X hh2 = (lrec.last_mod_file_time >> 11) & 0x1f;
- X if (hh > hh2)
- X return EXISTS_AND_NEWER;
- X else if (hh < hh2)
- X return EXISTS_AND_OLDER;
- X
- X mm = timbuf`5B4`5D;
- X mm2 = (lrec.last_mod_file_time >> 5) & 0x3f;
- X if (mm > mm2)
- X return EXISTS_AND_NEWER;
- X else if (mm < mm2)
- X return EXISTS_AND_OLDER;
- X
- X /* round to nearest 2 secs--may become 60, but doesn't matter for compar
- Ve */
- X ss = (int)((float)timbuf`5B5`5D + (float)timbuf`5B6`5D*.01 + 1.) & -2;
- X ss2 = (lrec.last_mod_file_time & 0x1f) * 2;
- X if (ss >= ss2)
- X return EXISTS_AND_NEWER;
- X
- X return EXISTS_AND_OLDER;
- X
- X#else /* !VMS */
- X#ifdef OS2
- X long existing, archive;
- X
- X if ((existing = GetFileTime(filename)) == -1)
- X return DOES_NOT_EXIST;
- X archive = ((long) lrec.last_mod_file_date) << 16 `7C lrec.last_mod_file_
- Vtime;
- X
- X return (existing >= archive);
- X#else /* !OS2 */
- X time_t existing, archive;
- X
- X if (stat(filename, &statbuf))
- X return DOES_NOT_EXIST;
- X
- X /* round up existing filetime to nearest 2 seconds for comparison */
- X existing = (statbuf.st_mtime & 1) ? statbuf.st_mtime+1 : statbuf.st_mtim
- Ve;
- X archive = dos_to_unix_time(lrec.last_mod_file_date,
- X lrec.last_mod_file_time);
- X
- X return (existing >= archive);
- X#endif /* ?OS2 */
- X#endif /* ?VMS */
- X
- X`7D /* end function check_for_newer() */
- X
- X
- X
- X
- X
- X/***************************/
- X/* Function dateformat() */
- X/***************************/
- X
- Xint dateformat()
- X`7B
- X
- X/*--------------------------------------------------------------------------
- V---
- X For those operating systems which support it, this function returns a valu
- Ve
- X which tells how national convention says that numeric dates are displayed.
- X
- X Return values are DF_YMD, DF_DMY and DF_MDY. The meanings should be fairl
- Vy
- X obvious.
- X ---------------------------------------------------------------------------
- V--*/
- X
- X#ifdef OS2
- X switch (GetCountryInfo()) `7B
- X case 0 /* DATEFMT_MM_DD_YY */ :
- X return DF_MDY;
- X case 1 /* DATEFMT_DD_MM_YY */ :
- X return DF_DMY;
- X case 2 /* DATEFMT_YY_MM_DD */ :
- X return DF_YMD;
- X `7D
- X#else /* !OS2 */
- X#if (defined(MSDOS) && !defined(MSWIN))
- X unsigned short _CountryInfo`5B18`5D;
- X#ifdef __GO32__
- X unsigned short *CountryInfo = _CountryInfo;
- X
- X bdos(0x38, (unsigned)CountryInfo, 0);
- X#else /* !__GO32__ */
- X unsigned short far *CountryInfo = _CountryInfo;
- X union REGS regs;
- X struct SREGS sregs;
- X
- X regs.x.ax = 0x3800;
- X regs.x.dx = FP_OFF(CountryInfo);
- X sregs.ds = FP_SEG(CountryInfo);
- X int86x(0x21, ®s, ®s, &sregs);
- X#endif /* ?__GO32__ */
- X
- X switch(CountryInfo`5B0`5D) `7B
- X case 0:
- X return DF_MDY;
- X case 1:
- X return DF_DMY;
- X case 2:
- X return DF_YMD;
- X `7D
- X#endif /* MSDOS && !MSWIN */
- X#endif /* ?OS2 */
- X
- X return DF_MDY; /* default for Unix, VMS, etc. */
- X
- X`7D /* end function dateformat() */
- X
- X#endif /* !ZIPINFO */
- X
- X
- X
- X
- X
- X#ifdef EBCDIC
- X
- X/*
- X * This is the MTS ASCII->EBCDIC translation table. It provides a 1-1
- X * translation from ISO 8859/1 8-bit ASCII to IBM Code Page 37 EBCDIC.
- X */
- X
- Xunsigned char ebcdic`5B`5D =
- X`7B
- X 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f,
- X 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- X 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26,
- X 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,
- X 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
- X 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61,
- X 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
- X 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f,
- X 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
- X 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
- X 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
- X 0xe7, 0xe8, 0xe9, 0xba, 0xe0, 0xbb, 0xb0, 0x6d,
- X 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- X 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
- X 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
- X 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07,
- X 0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17,
- X 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x1b,
- X 0x30, 0x31, 0x1a, 0x33, 0x34, 0x35, 0x36, 0x08,
- X 0x38, 0x39, 0x3a, 0x3b, 0x04, 0x14, 0x3e, 0xff,
- X 0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5,
- X 0xbd, 0xb4, 0x9a, 0x8a, 0x5f, 0xca, 0xaf, 0xbc,
- X 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3,
- X 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab,
- X 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68,
- X 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77,
- X 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf,
- X 0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xad, 0xae, 0x59,
- X 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48,
- X 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57,
- X 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1,
- X 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf
- X`7D; /* end ebcdic`5B`5D */
- X
- X#endif /* EBCDIC */
- X
- X
- X
- X
- X
- X/*************************/
- X/* Function makeword() */
- X/*************************/
- X
- XUWORD makeword(b)
- X byte *b;
- X`7B
- X /*
- X * Convert Intel style 'short' integer to non-Intel non-16-bit
- X * host format. This routine also takes care of byte-ordering.
- X */
- X return ((b`5B1`5D << 8) `7C b`5B0`5D);
- X`7D
- X
- X
- X
- X
- X
- X/*************************/
- X/* Function makelong() */
- X/*************************/
- X
- XULONG makelong(sig)
- X byte *sig;
- X`7B
- X /*
- X * Convert intel style 'long' variable to non-Intel non-16-bit
- X * host format. This routine also takes care of byte-ordering.
- X */
- X return (((ULONG) sig`5B3`5D) << 24)
- X + (((ULONG) sig`5B2`5D) << 16)
- X + (((ULONG) sig`5B1`5D) << 8)
- X + ((ULONG) sig`5B0`5D);
- X`7D
- X
- X
- X
- X
- X
- X#ifdef VMS
- X
- X/***************************/
- X/* Function return_VMS() */
- X/***************************/
- X
- Xvoid return_VMS(zip_error)
- X int zip_error;
- X`7B
- X#ifdef RETURN_CODES
- X/*--------------------------------------------------------------------------
- V-
- X Do our own, explicit processing of error codes and print message, since
- X VMS misinterprets return codes as rather obnoxious system errors ("acces
- Vs
- X violation," for example).
- X --------------------------------------------------------------------------
- V-*/
- X
- X switch (zip_error) `7B
- X
- X case 0:
- X break; /* life is fine... */
- X case 1:
- X fprintf(stderr, "\n`5Breturn-code 1: warning error \
- X(e.g., failed CRC or unknown compression method)`5D\n");
- X break;
- X case 2:
- X case 3:
- X fprintf(stderr, "\n`5Breturn-code %d: error in zipfile \
- X(e.g., can't find local file header sig)`5D\n",
- X zip_error);
- X break;
- X case 4:
- X case 5:
- X case 6:
- X case 7:
- X case 8:
- X fprintf(stderr, "\n`5Breturn-code %d: insufficient memory`5D\n",
- X zip_error);
- X break;
- +-+-+-+-+-+-+-+- END OF PART 6 +-+-+-+-+-+-+-+-
-