Annotation of pgp/src/zipup.c, revision 1.1.1.4

1.1.1.4 ! root        1: /*
        !             2: 
        !             3:  Copyright (C) 1990,1991 Mark Adler, Richard B. Wales, and Jean-loup Gailly.
        !             4:  Permission is granted to any individual or institution to use, copy, or
        !             5:  redistribute this software so long as all of the original files are included
        !             6:  unmodified, that it is not sold for profit, and that this copyright notice
        !             7:  is retained.
        !             8: 
        !             9: */
        !            10: 
        !            11: /*
        !            12:  *  zipup.c by Mark Adler. Includes modifications by Jean-loup Gailly.
        !            13:  */
        !            14: 
        !            15: #define NOCPYRT         /* this is not a main module */
        !            16: #include <ctype.h>
        !            17: #include "zip.h"
        !            18: #include "zrevisio.h"
        !            19: 
        !            20: /* Use the raw functions for MSDOS and Unix to save on buffer space.
        !            21:    They're not used for VMS since it doesn't work (raw is weird on VMS).
        !            22:    (This sort of stuff belongs in fileio.c, but oh well.) */
        !            23: #ifdef VMS
        !            24:    typedef FILE *ftype;
        !            25: #  define fhow FOPR
        !            26: #  define fbad NULL
        !            27: #  define zopen(n,p) fopen(n,p)
        !            28: #  define zread(f,b,n) fread(b,1,n,f)
        !            29: #  define zclose(f) fclose(f)
        !            30: #  define zerr(f) ferror(f)
        !            31: #  define zrew(f) rewind(f)
        !            32: #  define zstdin stdin
        !            33: #else /* !VMS */
        !            34: #  ifdef MSDOS
        !            35: #    include <io.h>
        !            36: #    include <fcntl.h>
        !            37: #    define fhow (O_RDONLY|O_BINARY)
        !            38: #  else /* !MSDOS */
        !            39: #ifndef AMIGA
        !            40:      long lseek();
        !            41: #endif /* AMIGA */
        !            42: #    define fhow 0
        !            43: #  endif /* ?MSDOS */
        !            44:    typedef int ftype;
        !            45: #  define fbad (-1)
        !            46: #  define zopen(n,p) open(n,p)
        !            47: #  define zread(f,b,n) read(f,b,n)
        !            48: #  define zclose(f) close(f)
        !            49: #  define zerr(f) (k==(extent)(-1L))
        !            50: #  define zrew(f) lseek(f,0L,0)
        !            51: #  define zstdin 0
        !            52: #endif /* ?VMS */
        !            53: 
        !            54: /* Local data */
        !            55: 
        !            56: local ftype ifile;             /* file to compress */
        !            57: 
        !            58: void lm_free();
        !            59: void ct_free();
        !            60: 
        !            61: int zipup(FILE *inFile, FILE *y)
        !            62: /* Compress the file fileName and write it to the file *y. Return an error
        !            63:    code in the ZE_ class.  Also, update tempzn by the number of bytes written. */
        !            64: /* ??? Does not yet handle non-seekable y */
        !            65: {
        !            66:   int m;                               /* method for this entry */
        !            67:   long q = -1L;                        /* size returned by filetime */
        !            68:   ush att;                             /* internal file attributes (dummy only) */
        !            69:   ush flg;                             /* gp compresion flags (dummy only) */
        !            70: 
        !            71:        /* Set input file and find its size */
        !            72: #ifdef VMS
        !            73:        ifile = inFile;
        !            74:        fseek(ifile, 0L, SEEK_END);
        !            75:        q = ftell(ifile);
        !            76:        fseek(ifile, 0L, SEEK_SET);
        !            77: #else
        !            78:        ifile = fileno( inFile );
        !            79:        q = lseek(ifile, 0L, SEEK_END);
        !            80:        lseek(ifile, 0L, SEEK_SET);
        !            81: #endif /* VMS */
        !            82: 
        !            83:        m = (q == 0) ? STORE : DEFLATE;
        !            84: 
        !            85:   if (m == DEFLATE) {
        !            86:         bi_init(y);
        !            87:         att = UNKNOWN;
        !            88:         ct_init(&att, &m);
        !            89:         lm_init(level, &flg);
        !            90:         /* s = */ deflate();
        !            91:   }
        !            92:   lm_free();
        !            93:   ct_free();
        !            94: 
        !            95:   return(0);
        !            96: }
        !            97: 
        !            98: int read_buf(buf, size)
        !            99:   char far *buf;
        !           100:   unsigned size;
        !           101: /* Read a new buffer from the current input file, and update the crc and
        !           102:  * input file size.
        !           103:  * IN assertion: size >= 2 (for end-of-line translation) */
        !           104: {
        !           105:   unsigned len;
        !           106: 
        !           107:   len = zread(ifile, buf, size);
        !           108:   if (len == (unsigned)EOF || len == 0) return len;
        !           109:   return len;
        !           110: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.