aboutsummaryrefslogtreecommitdiffstats
path: root/g10/openfile.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--g10/openfile.c48
1 files changed, 37 insertions, 11 deletions
diff --git a/g10/openfile.c b/g10/openfile.c
index 4d16db500..4f73334b8 100644
--- a/g10/openfile.c
+++ b/g10/openfile.c
@@ -39,6 +39,14 @@
#define SKELEXT ".skel"
#endif
+
+#ifdef HAVE_DRIVE_LETTERS
+ #define CMP_FILENAME(a,b) stricmp( (a), (b) )
+#else
+ #define CMP_FILENAME(a,b) strcmp( (a), (b) )
+#endif
+
+
/* FIXME: Implement opt.interactive. */
/****************
@@ -70,6 +78,7 @@ overwrite_filep( const char *fname )
}
+
/****************
* Strip know extensions from iname and return a newly allocated
* filename. Return NULL if we can't do that.
@@ -82,13 +91,11 @@ make_outfile_name( const char *iname )
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") ) ) {
+ if( n > 4 && ( !CMP_FILENAME(iname+n-4,".gpg")
+ || !CMP_FILENAME(iname+n-4,".pgp")
+ || !CMP_FILENAME(iname+n-4,".sig")
+ || !CMP_FILENAME(iname+n-4,".asc") ) ) {
char *buf = m_strdup( iname );
buf[n-4] = 0;
return buf;
@@ -169,11 +176,33 @@ open_outfile( const char *iname, int mode, IOBUF *a )
name = opt.outfile;
else {
#ifdef USE_ONLY_8DOT3
- #warning please implement 8.3 files
- #endif
+ /* It is quite common for DOS system to have only one dot in a
+ * a filename So if we have something like this, we simple
+ * replace the suffix execpt in cases where the suffix is
+ * larger than 3 characters and not the same as.
+ * We should really map the filenames to 8.3 but this tends to
+ * be more complicated and is probaly a duty of the filesystem
+ */
+ char *dot;
+ const char *newsfx = mode==1 ? ".asc" :
+ mode==2 ? ".sig" : ".gpg";
+
+ buf = m_alloc(strlen(iname)+4+1);
+ strcpy(buf,iname);
+ dot = strchr(buf, '.' );
+ if( dot && dot > buf && dot[1] && strlen(dot) <= 4
+ && CMP_FILENAME(newsfx, dot) ) {
+ strcpy(dot, newsfx );
+ }
+ else if( dot && !dot[1] ) /* don't duplicate a dot */
+ strcat( dot, newsfx+1 );
+ else
+ strcat( buf, newsfx );
+ #else
buf = m_alloc(strlen(iname)+4+1);
strcpy(stpcpy(buf,iname), mode==1 ? ".asc" :
mode==2 ? ".sig" : ".gpg");
+ #endif
name = buf;
}
@@ -204,9 +233,6 @@ open_sigfile( const char *iname )
IOBUF a = NULL;
size_t len;
- #ifdef USE_ONLY_8DOT3
- #warning please implement 8.3 files
- #endif
if( iname && !(*iname == '-' && !iname[1]) ) {
len = strlen(iname);
if( len > 4 && ( !strcmp(iname + len - 4, ".sig")