diff options
author | Timo Schulz <[email protected]> | 2001-12-22 12:46:47 +0000 |
---|---|---|
committer | Timo Schulz <[email protected]> | 2001-12-22 12:46:47 +0000 |
commit | 0d3b9f0245479d4b7f102aa628bf9f1e2542f45a (patch) | |
tree | 7a39bad43eb39402ec34cf3c4763dfd39ead6265 | |
parent | * configure.ac (AH_BOTTOM): Moved EXEC_TEMPFILE_ONLY to here. (diff) | |
download | gnupg-0d3b9f0245479d4b7f102aa628bf9f1e2542f45a.tar.gz gnupg-0d3b9f0245479d4b7f102aa628bf9f1e2542f45a.zip |
Added is_file_compressed
-rw-r--r-- | g10/ChangeLog | 87 | ||||
-rw-r--r-- | g10/encode.c | 20 | ||||
-rw-r--r-- | include/ChangeLog | 4 | ||||
-rw-r--r-- | include/util.h | 1 | ||||
-rw-r--r-- | util/ChangeLog | 4 | ||||
-rw-r--r-- | util/fileutil.c | 44 |
6 files changed, 75 insertions, 85 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog index ff6743ed2..da43ebe24 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,85 +1,7 @@ -2001-12-21 David Shaw <[email protected]> +2001-12-22 Timo Schulz <[email protected]> - * Makefile.am: add exec.c, exec.h, photoid.c, and photoid.h - - * build-packet.c (build_attribute_subpkt): new function to build - the raw attribute subpacket. Note that attribute subpackets have - the same format as signature subpackets. - - * exec.c: new file with generic exec-a-program functionality. - Used by both photo IDs and keyserver helpers. This is pretty much - the same code that used to be keyserver specific, with some - changes to be usable generically. - - * free-packet.c (free_attributes (new)): function to free an - attribute packet. - - * gpgv.c: added stub show_photo - - * keyedit.c (keyedit_menu, menu_adduid, menu_showphoto): can add a - photo (calls generate_photo_id), or display a photo (calls - show_photo) from the --edit menu. New commands are "addphoto", - and "delphoto" (same as "deluid"). - - * keylist.c (list_keyblock_print): show photos during key list if - --show-photos enabled. - - * keyserver.c (keyserver_spawn): use the generic exec_xxx - functions to call keyserver helper. - - * g10.c, options.h: three new options - --{no-}show-photos, and - --photo-viewer to give the command line to display a picture. - - * options.skel: instructions for the photo viewer - - * parse-packet.c (parse_user_id, setup_user_id (new)): common code - for both user IDs and attribute IDs moved to setup_user_id. - - * parse-packet.c (make_attribute_uidname (new)): constructs a fake - "name" for attribute packets (e.g. "[image of size ...]") - - * parse-packet.c (parse_attribute (replaces parse_photo_id), - parse_attribute_subpkts): Builds an array of individual - attributes. Currently only handles attribute image / type jpeg - subpackets. - - * sign.c (hash_uid): Fix bug in signing attribute (formerly - photo_id) packets. - - * packet.h, and callers: globally change "photo_id" to "attribute" - and add structures for attributes. The packet format is generic - attributes, even though the only attribute type thus far defined - is jpeg. - -2001-12-21 David Shaw <[email protected]> - - * parse-packet.c (can_handle_critical): Can handle critical - revocation subpackets now. - - * trustdb.c (mark_usable_uid_certs): Disregard revocations for - nonrevocable sigs. Note that this allows a newer revocable - signature to override an older nonrevocable signature. - - * sign.c (make_keysig_packet): add a duration field and change all - callers. This makes make_keysig_packet closer to - write_signature_packets and removes some duplicated expiration - code. - - * keyedit.c (keyedit_menu, menu_revsig, sign_uids, - sign_mk_attrib): Add nrsign command, don't allow revoking a - nonrevocable signature, - - * g10.c (main): Add --nrsign option to nonrevocably sign a key - from the command line. - - * build-packet.c (build_sig_subpkt_from_sig): Comment to explain - the use of CRITICAL. - -2001-12-21 Werner Koch <[email protected]> - - * g10.c. options.h : New option --show-keyring - * getkey.c (get_ctx_handle): New. - * keylist.c (list_one): Implement option here. By David Champion. + * encode.c (encode_simple, encode_crypt): Use is_file_compressed + to avoid to compress compressed files. 2001-12-20 David Shaw <[email protected]> @@ -115,8 +37,7 @@ 2001-12-19 Werner Koch <[email protected]> - * g10.c, passphrase.c, gpgv.c [CYGWIN32]: Allow this as an alias - for MINGW32. + * g10.c, passphrase.c [CYGWIN32]: Allow this as an alias for MINGW32. 2001-12-18 David Shaw <[email protected]> diff --git a/g10/encode.c b/g10/encode.c index 0b86f240c..7450e7344 100644 --- a/g10/encode.c +++ b/g10/encode.c @@ -85,6 +85,14 @@ encode_simple( const char *filename, int mode ) memset( &zfx, 0, sizeof zfx); memset( &tfx, 0, sizeof tfx); init_packet(&pkt); + + if (is_file_compressed(filename, &rc)) { + if (opt.verbose) + log_info("`%s' already compressed\n", filename); + do_compress = 0; + } + if (rc) + return rc; /* prepare iobufs */ if( !(inp = iobuf_open(filename)) ) { @@ -244,7 +252,7 @@ encode_crypt( const char *filename, STRLIST remusr ) IOBUF inp = NULL, out = NULL; PACKET pkt; PKT_plaintext *pt = NULL; - int rc = 0; + int rc = 0, rc2 = 0; u32 filesize; cipher_filter_context_t cfx; armor_filter_context_t afx; @@ -276,6 +284,16 @@ encode_crypt( const char *filename, STRLIST remusr ) } } + if (is_file_compressed(filename, &rc2)) { + if (opt.verbose) + log_info("`%s' already compressed\n", filename); + do_compress = 0; + } + if (rc2) { + rc = rc2; + goto leave; + } + /* prepare iobufs */ if( !(inp = iobuf_open(filename)) ) { log_error(_("can't open %s: %s\n"), filename? filename: "[stdin]", diff --git a/include/ChangeLog b/include/ChangeLog index b083e4b24..536be77d0 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +2001-12-22 Timo Schulz <[email protected]> + + * util.h: Add is_file_compressed(). + 2001-12-19 Werner Koch <[email protected]> * util.h [CYGWIN32]: Allow this as an alias for MINGW32. Include diff --git a/include/util.h b/include/util.h index b690eca82..295333552 100644 --- a/include/util.h +++ b/include/util.h @@ -150,6 +150,7 @@ char *make_filename( const char *first_part, ... ); int compare_filenames( const char *a, const char *b ); const char *print_fname_stdin( const char *s ); const char *print_fname_stdout( const char *s ); +int is_file_compressed(const char *s, int *r_status); /*-- miscutil.c --*/ diff --git a/util/ChangeLog b/util/ChangeLog index d2de7bb95..91e503803 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,7 @@ +2001-12-22 Timo Schulz <[email protected]> + + * fileutil.c (is_file_compressed): New. + 2001-12-19 Werner Koch <[email protected]> * simple-gettext.c, w32reg.c [CYGWIN32]: Allow to use this file diff --git a/util/fileutil.c b/util/fileutil.c index 30c2511b6..e0c0d1982 100644 --- a/util/fileutil.c +++ b/util/fileutil.c @@ -184,4 +184,46 @@ print_fname_stdin( const char *s ) return s; } - +/** + * Check if the file is compressed. + **/ +int +is_file_compressed(const char *s, int *r_status) +{ + IOBUF a; + int i, rc = 0; + byte buf[4]; + + const byte sigs[4][4] = { + {0x42, 0x5a, 0x68, 0x39}, /* bzip2 */ + {0x1f, 0x8b, 0x08, 0x08}, /* gzip */ + {0x50, 0x4b, 0x03, 0x04} /* (pk)zip */ + }; + + if (!s || *s == '-' || !r_status) + return 0; /* We can't check stdin or no file was given */ + + if ( (a = iobuf_open(s)) == NULL ) { + *r_status = G10ERR_OPEN_FILE; + return 0; + } + + if (iobuf_get_filelength(a) < 4) { + *r_status = 0; + goto leave; + } + + iobuf_read(a, buf, 4); + + for (i=0; i<DIM(sigs); i++) { + if (!memcmp(buf, sigs[i], 4)) { + *r_status = 0; + rc = 1; + break; + } + } + +leave: + iobuf_close(a); + return rc; +} |