#include <config.h>#include <ctype.h>#include "tailor.h"#include "gzip.h"#include "crypt.h"Go to the source code of this file.
Functions | |
| int | zip (int in, int out) |
| int | file_read (char *buf, unsigned size) |
Variables | |
| local ulg | crc |
| off_t | header_bytes |
|
||||||||||||
|
Definition at line 119 of file zip.c. References Assert, bytes_in, crc, ifd, insize, read_buffer(), read_error(), and updcrc(). Referenced by bi_init(). 00122 { 00123 unsigned len; 00124 00125 Assert(insize == 0, "inbuf not empty"); 00126 00127 len = read_buffer (ifd, buf, size); 00128 if (len == 0) return (int)len; 00129 if (len == (unsigned)-1) { 00130 read_error(); 00131 return EOF; 00132 } 00133 00134 crc = updcrc((uch*)buf, len); 00135 bytes_in += (off_t)len; 00136 return (int)len; 00137 }
|
|
||||||||||||
|
Definition at line 46 of file zip.c. References bi_init(), bytes_in, crc, ct_init(), deflate(), DEFLATED, flags, flush_outbuf(), gzip_base_name(), GZIP_MAGIC, header_bytes, ifd, ifile_size, ifname, level, lm_init(), method, ofd, OK, ORIG_NAME, OS_CODE, outcnt, program_name, put_byte, put_char, put_long, save_orig_name, time_stamp, timespec::tv_sec, and updcrc(). 00048 { 00049 uch flags = 0; /* general purpose bit flags */ 00050 ush attr = 0; /* ascii/binary flag */ 00051 ush deflate_flags = 0; /* pkzip -es, -en or -ex equivalent */ 00052 ulg stamp; 00053 00054 ifd = in; 00055 ofd = out; 00056 outcnt = 0; 00057 00058 /* Write the header to the gzip file. See algorithm.doc for the format */ 00059 00060 method = DEFLATED; 00061 put_byte(GZIP_MAGIC[0]); /* magic header */ 00062 put_byte(GZIP_MAGIC[1]); 00063 put_byte(DEFLATED); /* compression method */ 00064 00065 if (save_orig_name) { 00066 flags |= ORIG_NAME; 00067 } 00068 put_byte(flags); /* general flags */ 00069 stamp = (0 <= time_stamp.tv_sec && time_stamp.tv_sec <= 0xffffffff 00070 ? (ulg) time_stamp.tv_sec 00071 : (ulg) 0); 00072 put_long (stamp); 00073 00074 /* Write deflated file to zip file */ 00075 crc = updcrc(0, 0); 00076 00077 bi_init(out); 00078 ct_init(&attr, &method); 00079 lm_init(level, &deflate_flags); 00080 00081 put_byte((uch)deflate_flags); /* extra flags */ 00082 put_byte(OS_CODE); /* OS identifier */ 00083 00084 if (save_orig_name) { 00085 char *p = gzip_base_name (ifname); /* Don't save the directory part. */ 00086 do { 00087 put_char(*p); 00088 } while (*p++); 00089 } 00090 header_bytes = (off_t)outcnt; 00091 00092 (void)deflate(); 00093 00094 #if !defined(NO_SIZE_CHECK) && !defined(RECORD_IO) 00095 /* Check input size (but not in VMS -- variable record lengths mess it up) 00096 * and not on MSDOS -- diet in TSR mode reports an incorrect file size) 00097 */ 00098 if (ifile_size != -1L && bytes_in != ifile_size) { 00099 fprintf(stderr, "%s: %s: file size changed while zipping\n", 00100 program_name, ifname); 00101 } 00102 #endif 00103 00104 /* Write the crc and uncompressed size */ 00105 put_long(crc); 00106 put_long((ulg)bytes_in); 00107 header_bytes += 2*sizeof(long); 00108 00109 flush_outbuf(); 00110 return OK; 00111 }
|
|
|
Definition at line 38 of file zip.c. Referenced by do_list(), file_read(), updcrc(), and zip(). |
|
|
Definition at line 39 of file zip.c. Referenced by do_list(), get_method(), treat_file(), treat_stdin(), and zip(). |