diff options
author | Stefan Bellon <[email protected]> | 2002-10-28 13:26:44 +0000 |
---|---|---|
committer | Stefan Bellon <[email protected]> | 2002-10-28 13:26:44 +0000 |
commit | 557f65836d2ad527840db5ecd5550786db55b244 (patch) | |
tree | 84b6e6392fb4bf2614614634bc7f2a28fd30e2fb /g10/plaintext.c | |
parent | * gnupg.spec.in: Use new path for keyserver helpers, /usr/lib is no longer (diff) | |
download | gnupg-557f65836d2ad527840db5ecd5550786db55b244.tar.gz gnupg-557f65836d2ad527840db5ecd5550786db55b244.zip |
filetype support for RISC OS
Diffstat (limited to 'g10/plaintext.c')
-rw-r--r-- | g10/plaintext.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/g10/plaintext.c b/g10/plaintext.c index b12fb0f11..ffb8a7053 100644 --- a/g10/plaintext.c +++ b/g10/plaintext.c @@ -25,7 +25,7 @@ #include <errno.h> #include <assert.h> #ifdef HAVE_DOSISH_SYSTEM - #include <fcntl.h> /* for setmode() */ +# include <fcntl.h> /* for setmode() */ #endif #include "util.h" @@ -55,6 +55,9 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, int rc = 0; int c; int convert = pt->mode == 't'; +#ifdef __riscos__ + int filetype = 0xfff; +#endif /* create the filename as C string */ if( nooutput ) @@ -75,9 +78,29 @@ 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 ) @@ -85,9 +108,9 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, else if( !*fname || (*fname=='-' && !fname[1])) { /* no filename or "-" given; write to stdout */ fp = stdout; - #ifdef HAVE_DOSISH_SYSTEM +#ifdef HAVE_DOSISH_SYSTEM setmode ( fileno(fp) , O_BINARY ); - #endif +#endif } else { while( !overwrite_filep (fname) ) { @@ -113,6 +136,9 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, #endif /* __riscos__ */ goto leave; } +#ifdef __riscos__ + riscos_set_filetype_by_number(fname, filetype); +#endif if( !pt->is_partial ) { /* we have an actual length (which might be zero). */ @@ -127,10 +153,10 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, } if( mfx->md ) md_putc(mfx->md, c ); - #ifndef HAVE_DOSISH_SYSTEM +#ifndef HAVE_DOSISH_SYSTEM if( c == '\r' ) /* convert to native line ending */ continue; /* fixme: this hack might be too simple */ - #endif +#endif if( fp ) { if( putc( c, fp ) == EOF ) { log_error("Error writing to `%s': %s\n", @@ -174,10 +200,10 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, while( (c = iobuf_get(pt->buf)) != -1 ) { if( mfx->md ) md_putc(mfx->md, c ); - #ifndef HAVE_DOSISH_SYSTEM +#ifndef HAVE_DOSISH_SYSTEM if( convert && c == '\r' ) continue; /* fixme: this hack might be too simple */ - #endif +#endif if( fp ) { if( putc( c, fp ) == EOF ) { log_error("Error writing to `%s': %s\n", |