Annotation of pgp/src/zfile_io.c, revision 1.1.1.3

1.1.1.2   root        1: /*---------------------------------------------------------------------------
                      2: 
                      3:   file_io.c
                      4: 
                      5:   This file contains routines for doing direct input/output, file-related
                      6:   sorts of things.  Most of the system-specific code for unzip is contained
                      7:   here, including the non-echoing password code for decryption (bottom).
                      8: 
                      9:   Modified: 24 Jun 92 - HAJK
                     10:   Fix VMS support
                     11:   ---------------------------------------------------------------------------*/
                     12: 
                     13: 
                     14: #include "zunzip.h"
                     15: 
                     16: /****************************/
                     17: /* Function FillBitBuffer() */
                     18: /****************************/
                     19: 
                     20: int FillBitBuffer()
                     21: {
                     22:     /*
                     23:      * Fill bitbuf, which is 32 bits.  This function is only used by the
                     24:      * READBIT and PEEKBIT macros (which are used by all of the uncompression
                     25:      * routines).
                     26:      */
                     27:     UWORD temp;
                     28: 
                     29:     zipeof = 1;
                     30:     while (bits_left < 25 && ReadByte(&temp) == 8)
                     31:     {
                     32:       bitbuf |= (ULONG)temp << bits_left;
                     33:       bits_left += 8;
                     34:       zipeof = 0;
                     35:     }
                     36:     return 0;
                     37: }
                     38: 
                     39: /***********************/
                     40: /* Function ReadByte() */
                     41: /***********************/
                     42: 
                     43: int ReadByte(x)
                     44: UWORD *x;
                     45: {
                     46:     /*
                     47:      * read a byte; return 8 if byte available, 0 if not
                     48:      */
                     49: 
                     50: 
                     51:     if (csize-- <= 0)
                     52:         return 0;
                     53: 
                     54:     if (incnt == 0) {
1.1.1.3 ! root       55:         if ((incnt = read(zipfd, (char *) inbuf, INBUFSIZ)) <= 0)
1.1.1.2   root       56:             return 0;
                     57:         /* buffer ALWAYS starts on a block boundary:  */
                     58:         inptr = inbuf;
                     59:     }
                     60:     *x = *inptr++;
                     61:     --incnt;
                     62:     return 8;
                     63: }
                     64: 
                     65: 
                     66: /**************************/
                     67: /* Function FlushOutput() */
                     68: /**************************/
                     69: 
                     70: int FlushOutput()
                     71: {
                     72:     /*
                     73:      * flush contents of output buffer; return PK-type error code
                     74:      */
                     75:     int len;
                     76: 
                     77:     if (outcnt) {
                     78:                        len = outcnt;
1.1.1.3 ! root       79:             if (write(outfd, (char *) outout, len) != len)
1.1.1.2   root       80: #ifdef MINIX
                     81:                 if (errno == EFBIG)
                     82:                     if (write(fd, outout, len/2) != len/2  ||
                     83:                         write(fd, outout+len/2, len/2) != len/2)
                     84: #endif /* MINIX */
                     85:                 {
                     86:                     return 50;    /* 50:  disk full */
                     87:                 }
                     88:         outpos += outcnt;
                     89:         outcnt = 0;
                     90:         outptr = outbuf;
                     91:     }
                     92:     return (0);                 /* 0:  no error */
                     93: }

unix.superglobalmegacorp.com

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