mkuzip.c (14e9c9161c36f9f16bcc5bd48baccc2537a6e15d) | mkuzip.c (d83e07789d1ee151ae564f9529828ddbdf0d31d7) |
---|---|
1/* 2 * Copyright (c) 2004-2016 Maxim Sobolev <sobomax@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 76 unchanged lines hidden (view full) --- 85 86static char *cleanfile = NULL; 87 88int main(int argc, char **argv) 89{ 90 char *iname, *oname, *obuf, *ibuf; 91 uint64_t *toc; 92 int fdr, fdw, i, opt, verbose, no_zcomp, tmp, en_dedup; | 1/* 2 * Copyright (c) 2004-2016 Maxim Sobolev <sobomax@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 76 unchanged lines hidden (view full) --- 85 86static char *cleanfile = NULL; 87 88int main(int argc, char **argv) 89{ 90 char *iname, *oname, *obuf, *ibuf; 91 uint64_t *toc; 92 int fdr, fdw, i, opt, verbose, no_zcomp, tmp, en_dedup; |
93 int summary; |
|
93 struct iovec iov[2]; 94 struct stat sb; 95 uint32_t destlen; 96 uint64_t offset, last_offset; 97 struct cloop_header hdr; 98 struct mkuz_blkcache_hit *chit; 99 const struct mkuz_format *handler; 100 101 memset(&hdr, 0, sizeof(hdr)); 102 hdr.blksz = DEFAULT_CLSTSIZE; 103 oname = NULL; 104 verbose = 0; 105 no_zcomp = 0; 106 en_dedup = 0; | 94 struct iovec iov[2]; 95 struct stat sb; 96 uint32_t destlen; 97 uint64_t offset, last_offset; 98 struct cloop_header hdr; 99 struct mkuz_blkcache_hit *chit; 100 const struct mkuz_format *handler; 101 102 memset(&hdr, 0, sizeof(hdr)); 103 hdr.blksz = DEFAULT_CLSTSIZE; 104 oname = NULL; 105 verbose = 0; 106 no_zcomp = 0; 107 en_dedup = 0; |
108 summary = 0; |
|
107 handler = &uzip_fmt; 108 | 109 handler = &uzip_fmt; 110 |
109 while((opt = getopt(argc, argv, "o:s:vZdL")) != -1) { | 111 while((opt = getopt(argc, argv, "o:s:vZdLS")) != -1) { |
110 switch(opt) { 111 case 'o': 112 oname = optarg; 113 break; 114 115 case 's': 116 tmp = atoi(optarg); 117 if (tmp <= 0) { --- 15 unchanged lines hidden (view full) --- 133 case 'd': 134 en_dedup = 1; 135 break; 136 137 case 'L': 138 handler = &ulzma_fmt; 139 break; 140 | 112 switch(opt) { 113 case 'o': 114 oname = optarg; 115 break; 116 117 case 's': 118 tmp = atoi(optarg); 119 if (tmp <= 0) { --- 15 unchanged lines hidden (view full) --- 135 case 'd': 136 en_dedup = 1; 137 break; 138 139 case 'L': 140 handler = &ulzma_fmt; 141 break; 142 |
143 case 'S': 144 summary = 1; 145 break; 146 |
|
141 default: 142 usage(); 143 /* Not reached */ 144 } 145 } 146 argc -= optind; 147 argv += optind; 148 --- 140 unchanged lines hidden (view full) --- 289 chit->blkno); 290 } 291 fprintf(stderr, "\n"); 292 293 } 294 } 295 close(fdr); 296 | 147 default: 148 usage(); 149 /* Not reached */ 150 } 151 } 152 argc -= optind; 153 argv += optind; 154 --- 140 unchanged lines hidden (view full) --- 295 chit->blkno); 296 } 297 fprintf(stderr, "\n"); 298 299 } 300 } 301 close(fdr); 302 |
297 if (verbose != 0) | 303 if (verbose != 0 || summary != 0) |
298 fprintf(stderr, "compressed data to %ju bytes, saved %lld " 299 "bytes, %.2f%% decrease.\n", offset, 300 (long long)(sb.st_size - offset), 301 100.0 * (long long)(sb.st_size - offset) / 302 (float)sb.st_size); 303 304 /* Convert to big endian */ 305 hdr.blksz = htonl(hdr.blksz); --- 26 unchanged lines hidden (view full) --- 332 } 333 return ibuf; 334} 335 336static void 337usage(void) 338{ 339 | 304 fprintf(stderr, "compressed data to %ju bytes, saved %lld " 305 "bytes, %.2f%% decrease.\n", offset, 306 (long long)(sb.st_size - offset), 307 100.0 * (long long)(sb.st_size - offset) / 308 (float)sb.st_size); 309 310 /* Convert to big endian */ 311 hdr.blksz = htonl(hdr.blksz); --- 26 unchanged lines hidden (view full) --- 338 } 339 return ibuf; 340} 341 342static void 343usage(void) 344{ 345 |
340 fprintf(stderr, "usage: mkuzip [-vZdL] [-o outfile] [-s cluster_size] " | 346 fprintf(stderr, "usage: mkuzip [-vZdLS] [-o outfile] [-s cluster_size] " |
341 "infile\n"); 342 exit(1); 343} 344 345void * 346mkuz_safe_malloc(size_t size) 347{ 348 void *retval; --- 25 unchanged lines hidden --- | 347 "infile\n"); 348 exit(1); 349} 350 351void * 352mkuz_safe_malloc(size_t size) 353{ 354 void *retval; --- 25 unchanged lines hidden --- |