mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
See ChangeLog: Tue Jun 1 16:01:46 CEST 1999 Werner Koch
This commit is contained in:
parent
c34c676958
commit
3dddf602dd
19 changed files with 272 additions and 71 deletions
|
@ -1,3 +1,10 @@
|
|||
Tue Jun 1 16:01:46 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
|
||||
|
||||
* openfile.c (make_outfile_name): New.
|
||||
* plaintext.c (handle_plaintext): Outputfile is now the inputfile
|
||||
without the suffix.
|
||||
* g10.c: New option --use-embedded-filename
|
||||
|
||||
Mon May 31 19:41:10 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
|
||||
|
||||
* g10.c (main): Fix for SHM init (Michael).
|
||||
|
|
|
@ -144,6 +144,7 @@ enum cmd_and_opt_values { aNull = 0,
|
|||
oRunAsShmCP,
|
||||
oSetFilename,
|
||||
oSetPolicyURL,
|
||||
oUseEmbeddedFilename,
|
||||
oComment,
|
||||
oThrowKeyid,
|
||||
oForceV3Sigs,
|
||||
|
@ -301,6 +302,7 @@ static ARGPARSE_OPTS opts[] = {
|
|||
{ oEscapeFrom, "escape-from-lines", 0, "@" },
|
||||
{ oLockOnce, "lock-once", 0, "@" },
|
||||
{ oLoggerFD, "logger-fd",1, "@" },
|
||||
{ oUseEmbeddedFilename, "use-embedded-filename", 0, "@" },
|
||||
{0} };
|
||||
|
||||
|
||||
|
@ -718,6 +720,7 @@ main( int argc, char **argv )
|
|||
break;
|
||||
case oSetFilename: opt.set_filename = pargs.r.ret_str; break;
|
||||
case oSetPolicyURL: opt.set_policy_url = pargs.r.ret_str; break;
|
||||
case oUseEmbeddedFilename: opt.use_embedded_filename = 1; break;
|
||||
case oComment: opt.comment_string = pargs.r.ret_str; break;
|
||||
case oThrowKeyid: opt.throw_keyid = 1; break;
|
||||
case oForceV3Sigs: opt.force_v3_sigs = 1; break;
|
||||
|
|
|
@ -96,6 +96,7 @@ int generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock );
|
|||
|
||||
/*-- openfile.c --*/
|
||||
int overwrite_filep( const char *fname );
|
||||
char *make_outfile_name( const char *iname );
|
||||
int open_outfile( const char *iname, int mode, IOBUF *a );
|
||||
IOBUF open_sigfile( const char *iname );
|
||||
void copy_options_file( const char *destdir );
|
||||
|
|
|
@ -70,6 +70,36 @@ overwrite_filep( const char *fname )
|
|||
}
|
||||
|
||||
|
||||
/****************
|
||||
* Strip know extensions from iname and return a newly allocated
|
||||
* filename. Return NULL if we can't do that.
|
||||
*/
|
||||
char *
|
||||
make_outfile_name( const char *iname )
|
||||
{
|
||||
size_t n;
|
||||
|
||||
if( (!iname || (*iname=='-' && !iname[1]) ))
|
||||
return m_strdup("-");
|
||||
|
||||
#ifdef HAVE_DRIVE_LETTERS
|
||||
#warning add case insensitive compare
|
||||
#endif
|
||||
n = strlen(iname);
|
||||
if( n > 4 && ( !strcmp(iname+n-4,".gpg")
|
||||
|| !strcmp(iname+n-4,".sig")
|
||||
|| !strcmp(iname+n-4,".asc") ) ) {
|
||||
char *buf = m_strdup( iname );
|
||||
buf[n-4] = 0;
|
||||
return buf;
|
||||
}
|
||||
|
||||
log_error(_("%s: unknown suffix\n"), iname );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************
|
||||
* Make an output filename for the inputfile INAME.
|
||||
* Returns an IOBUF and an errorcode
|
||||
|
@ -108,6 +138,7 @@ open_outfile( const char *iname, int mode, IOBUF *a )
|
|||
mode==2 ? ".sig" : ".gpg");
|
||||
name = buf;
|
||||
}
|
||||
|
||||
if( overwrite_filep( name ) ) {
|
||||
if( !(*a = iobuf_create( name )) ) {
|
||||
log_error(_("%s: can't create: %s\n"), name, strerror(errno) );
|
||||
|
@ -124,6 +155,7 @@ open_outfile( const char *iname, int mode, IOBUF *a )
|
|||
}
|
||||
|
||||
|
||||
|
||||
/****************
|
||||
* Try to open a file without the extension ".sig" or ".asc"
|
||||
* Return NULL if such a file is not available.
|
||||
|
|
|
@ -76,6 +76,7 @@ struct {
|
|||
int interactive;
|
||||
STRLIST notation_data;
|
||||
const char *set_policy_url;
|
||||
int use_embedded_filename;
|
||||
} opt;
|
||||
|
||||
|
||||
|
|
|
@ -63,6 +63,13 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
|
|||
log_info(_("data not saved; use option \"--output\" to save it\n"));
|
||||
nooutput = 1;
|
||||
}
|
||||
else if( !opt.use_embedded_filename ) {
|
||||
fname = make_outfile_name( iobuf_get_real_fname(pt->buf) );
|
||||
if( !fname ) {
|
||||
rc = G10ERR_CREATE_FILE;
|
||||
goto leave;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fname = m_alloc( pt->namelen +1 );
|
||||
memcpy( fname, pt->name, pt->namelen );
|
||||
|
@ -90,7 +97,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
|
|||
|
||||
if( pt->len ) {
|
||||
assert( !clearsig );
|
||||
if( convert ) { // text mode
|
||||
if( convert ) { /* text mode */
|
||||
for( ; pt->len; pt->len-- ) {
|
||||
if( (c = iobuf_get(pt->buf)) == -1 ) {
|
||||
log_error("Problem reading source (%u bytes remaining)\n",
|
||||
|
@ -112,7 +119,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
|
|||
}
|
||||
}
|
||||
}
|
||||
else { // binary mode
|
||||
else { /* binary mode */
|
||||
byte *buffer = m_alloc( 32768 );
|
||||
while( pt->len ) {
|
||||
int len = pt->len > 32768 ? 32768 : pt->len;
|
||||
|
@ -141,7 +148,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
|
|||
}
|
||||
}
|
||||
else if( !clearsig ) {
|
||||
if( convert ) { // text mode
|
||||
if( convert ) { /* text mode */
|
||||
while( (c = iobuf_get(pt->buf)) != -1 ) {
|
||||
if( mfx->md )
|
||||
md_putc(mfx->md, c );
|
||||
|
@ -157,7 +164,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
|
|||
}
|
||||
}
|
||||
}
|
||||
else { // binary mode
|
||||
else { /* binary mode */
|
||||
byte *buffer = m_alloc( 32768 );
|
||||
for( ;; ) {
|
||||
int len = iobuf_read( pt->buf, buffer, 32768 );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue