1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

filetype support for RISC OS

This commit is contained in:
Stefan Bellon 2002-10-28 13:27:18 +00:00
parent 875363153e
commit 191795d14b
13 changed files with 153 additions and 35 deletions

View file

@ -1,3 +1,11 @@
2002-10-28 Stefan Bellon <sbellon@sbellon.de>
* build-packet.c (calc_plaintext, do_plaintext): Added filetype
handling for RISC OS' file types.
* plaintext.c (handle_plaintext) [__riscos__]: Added filetype
handling for RISC OS' file types.
2002-10-23 Werner Koch <wk@gnupg.org>
* pubkey-enc.c (get_it): Fix segv, test for revoked only when PK

View file

@ -528,7 +528,14 @@ 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
@ -541,9 +548,26 @@ 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;

View file

@ -1110,7 +1110,7 @@ do_proc_packets( CTX c, IOBUF a )
any_data = 1;
if( rc ) {
free_packet(pkt);
/* stop processing hwne an invalid packet has been encountered
/* stop processing when an invalid packet has been encountered
* but don't do so when we are doing a --list-packet. */
if( rc == G10ERR_INVALID_PACKET && opt.list_packets != 2 )
break;

View file

@ -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",