aboutsummaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
Diffstat (limited to 'g10')
-rw-r--r--g10/ChangeLog14
-rw-r--r--g10/build-packet.c24
-rw-r--r--g10/encode.c7
-rw-r--r--g10/plaintext.c49
-rw-r--r--g10/sign.c3
5 files changed, 45 insertions, 52 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index e1fc824e2..75e750840 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,17 @@
+2002-10-29 Stefan Bellon <[email protected]>
+
+ * build-packet.c (calc_plaintext, do_plaintext): Removed RISC OS
+ specific filetype parts (it's now done in make_basename()).
+
+ * plaintext.c (handle_plaintext): Tidied up RISC OS specific
+ filetype parts.
+
+ * encode.c (encode_simple, encode_crypt): Added argument to
+ make_basename() call.
+
+ * sign.c (write_plaintext_packet): Added argument to
+ make_basename() call.
+
2002-10-28 Stefan Bellon <[email protected]>
* build-packet.c (calc_plaintext, do_plaintext): Added filetype
diff --git a/g10/build-packet.c b/g10/build-packet.c
index a1f93094e..da1cbbe39 100644
--- a/g10/build-packet.c
+++ b/g10/build-packet.c
@@ -528,14 +528,7 @@ do_pubkey_enc( IOBUF out, int ctb, PKT_pubkey_enc *enc )
static u32
calc_plaintext( PKT_plaintext *pt )
{
-#ifndef __riscos__
return pt->len? (1 + 1 + pt->namelen + 4 + pt->len) : 0;
-#else
- /* Under RISC OS, we add ",xxx" to the file name in order to
- be able to recreate the correct file type on the recipients'
- side. Therefore we need 4 bytes more. */
- return pt->len? (1 + 1 + pt->namelen + 4 + pt->len + 4) : 0;
-#endif
}
static int
@@ -548,26 +541,9 @@ do_plaintext( IOBUF out, int ctb, PKT_plaintext *pt )
write_header(out, ctb, calc_plaintext( pt ) );
iobuf_put(out, pt->mode );
-#ifndef __riscos__
iobuf_put(out, pt->namelen );
for(i=0; i < pt->namelen; i++ )
iobuf_put(out, pt->name[i] );
-#else
- /* Under RISC OS, we add ",xxx" to the file name in order to
- be able to recreate the correct file type on the recipients'
- side. Therefore we need 4 bytes more. */
- iobuf_put(out, pt->namelen + 4);
- for(i=0; i < pt->namelen; i++ )
- if( pt->name[i] != '/' )
- iobuf_put(out, pt->name[i] );
- else
- iobuf_put(out, '.' );
- i = riscos_get_filetype( iobuf_get_real_fname( pt->buf ) );
- iobuf_put(out, ',');
- iobuf_put(out, "0123456789abcdef"[(i >> 8) & 0xf]);
- iobuf_put(out, "0123456789abcdef"[(i >> 4) & 0xf]);
- iobuf_put(out, "0123456789abcdef"[(i >> 0) & 0xf]);
-#endif
if( write_32(out, pt->timestamp ) )
rc = G10ERR_WRITE_FILE;
diff --git a/g10/encode.c b/g10/encode.c
index 89d94278f..7991ef64a 100644
--- a/g10/encode.c
+++ b/g10/encode.c
@@ -267,7 +267,8 @@ encode_simple( const char *filename, int mode, int compat )
/* setup the inner packet */
if( filename || opt.set_filename ) {
char *s = make_basename( opt.set_filename ? opt.set_filename
- : filename );
+ : filename,
+ iobuf_get_real_fname( inp ) );
pt = m_alloc( sizeof *pt + strlen(s) - 1 );
pt->namelen = strlen(s);
memcpy(pt->name, s, pt->namelen );
@@ -503,7 +504,9 @@ encode_crypt( const char *filename, STRLIST remusr )
if (!opt.no_literal) {
/* setup the inner packet */
if( filename || opt.set_filename ) {
- char *s = make_basename( opt.set_filename ? opt.set_filename : filename );
+ char *s = make_basename( opt.set_filename ? opt.set_filename
+ : filename,
+ iobuf_get_real_fname( inp ) );
pt = m_alloc( sizeof *pt + strlen(s) - 1 );
pt->namelen = strlen(s);
memcpy(pt->name, s, pt->namelen );
diff --git a/g10/plaintext.c b/g10/plaintext.c
index ffb8a7053..141c63ccd 100644
--- a/g10/plaintext.c
+++ b/g10/plaintext.c
@@ -78,29 +78,9 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
rc = G10ERR_CREATE_FILE;
goto leave;
}
-#ifdef __riscos__
- /* If there's a ,xxx extension in the embedded filename,
- get filetype from it and use it later on */
- filetype = riscos_get_filetype_from_string( pt->name, pt->namelen );
- c = riscos_get_filetype_from_string( fname, strlen(fname) );
- if( c != 0xfff && filetype == 0xfff)
- filetype = c;
-#endif
}
else {
fname = make_printable_string( pt->name, pt->namelen, 0 );
-#ifdef __riscos__
- /* If there's a ,xxx extension in the embedded filename,
- get filetype from it and use it later on, remove ,xxx from
- actual filename */
- if( fname[strlen(fname) - 4] == ',' ) {
- filetype = riscos_get_filetype_from_string( pt->name, pt->namelen );
- fname[strlen(fname) - 4] = 0;
- }
- for( c=0; fname[c]; ++c)
- if( fname[c] == '.' )
- fname[c] = '/';
-#endif
}
if( nooutput )
@@ -125,20 +105,39 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
}
}
+#ifndef __riscos__
+ if( fp || nooutput )
+ ;
+ else if( !(fp = fopen(fname,"wb")) ) {
+ log_error(_("error creating `%s': %s\n"), fname, strerror(errno) );
+ rc = G10ERR_CREATE_FILE;
+ goto leave;
+ }
+#else /* __riscos__ */
+ /* Convert all '.' in fname to '/' -- we don't create directories! */
+ for( c=0; fname[c]; ++c )
+ if( fname[c] == '.' )
+ fname[c] = '/';
+
if( fp || nooutput )
;
else if( !(fp = fopen(fname,"wb")) ) {
log_error(_("error creating `%s': %s\n"), fname, strerror(errno) );
rc = G10ERR_CREATE_FILE;
-#ifdef __riscos__
if (errno == 106)
- log_info("perhaps the output file has the same name as the input file?\n");
-#endif /* __riscos__ */
+ log_info("Do output file and input file have the same name?\n");
goto leave;
}
-#ifdef __riscos__
+
+ /* If there's a ,xxx extension in the embedded filename,
+ use that, else check whether the user input (in fname)
+ has a ,xxx appended, then use that in preference */
+ if( (c = riscos_get_filetype_from_string( pt->name, pt->namelen )) != -1 )
+ filetype = c;
+ if( (c = riscos_get_filetype_from_string( fname, strlen(fname) )) != -1 )
+ filetype = c;
riscos_set_filetype_by_number(fname, filetype);
-#endif
+#endif /* __riscos__ */
if( !pt->is_partial ) {
/* we have an actual length (which might be zero). */
diff --git a/g10/sign.c b/g10/sign.c
index fe242b8da..b5314cccf 100644
--- a/g10/sign.c
+++ b/g10/sign.c
@@ -443,7 +443,8 @@ write_plaintext_packet (IOBUF out, IOBUF inp, const char *fname, int ptmode)
if (!opt.no_literal) {
if (fname || opt.set_filename) {
char *s = make_basename (opt.set_filename? opt.set_filename
- : fname);
+ : fname,
+ iobuf_get_real_fname(inp));
pt = m_alloc (sizeof *pt + strlen(s) - 1);
pt->namelen = strlen (s);
memcpy (pt->name, s, pt->namelen);