mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
Added is_file_compressed
This commit is contained in:
parent
4011228458
commit
0d3b9f0245
@ -1,85 +1,7 @@
|
||||
2001-12-21 David Shaw <dshaw@jabberwocky.com>
|
||||
2001-12-22 Timo Schulz <ts@winpt.org>
|
||||
|
||||
* 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 <dshaw@jabberwocky.com>
|
||||
|
||||
* 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 <wk@gnupg.org>
|
||||
|
||||
* 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 <dshaw@jabberwocky.com>
|
||||
|
||||
@ -115,8 +37,7 @@
|
||||
|
||||
2001-12-19 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* 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 <dshaw@jabberwocky.com>
|
||||
|
||||
|
20
g10/encode.c
20
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]",
|
||||
|
@ -1,3 +1,7 @@
|
||||
2001-12-22 Timo Schulz <ts@winpt.org>
|
||||
|
||||
* util.h: Add is_file_compressed().
|
||||
|
||||
2001-12-19 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* util.h [CYGWIN32]: Allow this as an alias for MINGW32. Include
|
||||
|
@ -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 --*/
|
||||
|
@ -1,3 +1,7 @@
|
||||
2001-12-22 Timo Schulz <ts@winpt.org>
|
||||
|
||||
* fileutil.c (is_file_compressed): New.
|
||||
|
||||
2001-12-19 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* simple-gettext.c, w32reg.c [CYGWIN32]: Allow to use this file
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user