1
0
Fork 0
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:
Werner Koch 1999-06-01 14:08:57 +00:00
parent c34c676958
commit 3dddf602dd
19 changed files with 272 additions and 71 deletions

View file

@ -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.