diff options
author | Werner Koch <[email protected]> | 1997-12-23 17:30:18 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 1997-12-23 17:30:18 +0000 |
commit | c351df1dc5294dfd81619fea3c1ff6a7e25ba774 (patch) | |
tree | b0fa86a4d1455e53c3a51d696eac51abe0308b0d /g10/openfile.c | |
parent | Now created by config.links (diff) | |
download | gnupg-c351df1dc5294dfd81619fea3c1ff6a7e25ba774.tar.gz gnupg-c351df1dc5294dfd81619fea3c1ff6a7e25ba774.zip |
changed configuration stuff, replaced some Makefile.am by distfiles.
Diffstat (limited to 'g10/openfile.c')
-rw-r--r-- | g10/openfile.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/g10/openfile.c b/g10/openfile.c index 4b7331dcd..388c9bfa7 100644 --- a/g10/openfile.c +++ b/g10/openfile.c @@ -23,6 +23,7 @@ #include <stdlib.h> #include <string.h> #include <assert.h> +#include <errno.h> #include <unistd.h> #include "util.h" #include "memory.h" @@ -80,9 +81,12 @@ overwrite_filep( const char *fname ) /**************** * Make an output filename for the inputfile INAME. * Returns an IOBUF + * Mode 0 = use ".g10" + * 1 = use ".asc" + * 2 = use ".sig" */ IOBUF -open_outfile( const char *iname ) +open_outfile( const char *iname, int mode ) { IOBUF a = NULL; int rc; @@ -101,7 +105,8 @@ open_outfile( const char *iname ) name = opt.outfile; else { buf = m_alloc(strlen(iname)+4+1); - strcpy(stpcpy(buf,iname), ".g10"); + strcpy(stpcpy(buf,iname), mode==1 ? ".asc" : + mode==2 ? ".sig" : ".g10"); name = buf; } if( !(rc=overwrite_filep( name )) ) { @@ -117,3 +122,27 @@ open_outfile( const char *iname ) return a; } + +/**************** + * Try to open a file without the extension ".sig" + * Return NULL if such a file is not available. + */ +IOBUF +open_sigfile( const char *iname ) +{ + IOBUF a = NULL; + size_t len; + + if( iname ) { + len = strlen(iname); + if( len > 4 && !strcmp(iname + len - 4, ".sig") ) { + char *buf; + buf = m_strdup(iname); + buf[len-4] = 0 ; + a = iobuf_open( buf ); + m_free(buf); + } + } + return a; +} + |