aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Bellon <[email protected]>2002-10-28 13:26:44 +0000
committerStefan Bellon <[email protected]>2002-10-28 13:26:44 +0000
commit557f65836d2ad527840db5ecd5550786db55b244 (patch)
tree84b6e6392fb4bf2614614634bc7f2a28fd30e2fb
parent* gnupg.spec.in: Use new path for keyserver helpers, /usr/lib is no longer (diff)
downloadgnupg-557f65836d2ad527840db5ecd5550786db55b244.tar.gz
gnupg-557f65836d2ad527840db5ecd5550786db55b244.zip
filetype support for RISC OS
-rw-r--r--g10/ChangeLog8
-rw-r--r--g10/build-packet.c24
-rw-r--r--g10/mainproc.c2
-rw-r--r--g10/plaintext.c40
-rw-r--r--include/ChangeLog4
-rw-r--r--include/util.h3
-rw-r--r--scripts/ChangeLog4
-rw-r--r--scripts/conf-riscos/include/config.h24
-rw-r--r--util/ChangeLog9
-rw-r--r--util/fileutil.c6
-rw-r--r--util/riscos.c48
11 files changed, 137 insertions, 35 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 296f74afe..e1fc824e2 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,11 @@
+2002-10-28 Stefan Bellon <[email protected]>
+
+ * 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 David Shaw <[email protected]>
* main.h, import.c (sec_to_pub_keyblock, import_secret_one,
diff --git a/g10/build-packet.c b/g10/build-packet.c
index da1cbbe39..a1f93094e 100644
--- a/g10/build-packet.c
+++ b/g10/build-packet.c
@@ -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;
diff --git a/g10/mainproc.c b/g10/mainproc.c
index f9be17600..0fc3a8546 100644
--- a/g10/mainproc.c
+++ b/g10/mainproc.c
@@ -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;
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",
diff --git a/include/ChangeLog b/include/ChangeLog
index 1837f51c5..cebe4c1ac 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,7 @@
+2002-10-28 Stefan Bellon <[email protected]>
+
+ * util.h [__riscos__]: Added prototypes for new filetype support.
+
2002-10-19 David Shaw <[email protected]>
* distfiles, _regex.h: Add _regex.h from glibc 2.3.1.
diff --git a/include/util.h b/include/util.h
index 8f7363908..4ac2b1537 100644
--- a/include/util.h
+++ b/include/util.h
@@ -271,6 +271,9 @@ int vasprintf ( char **result, const char *format, va_list args);
#include <unixlib/features.h>
void riscos_global_defaults(void);
#define RISCOS_GLOBAL_STATICS(a) const char *__dynamic_da_name = (a);
+int riscos_get_filetype_from_string(const char *string, int len);
+int riscos_get_filetype(const char *filename);
+void riscos_set_filetype_by_number(const char *filename, int type);
void riscos_set_filetype(const char *filename, const char *mimetype);
pid_t riscos_getpid(void);
int riscos_kill(pid_t pid, int sig);
diff --git a/scripts/ChangeLog b/scripts/ChangeLog
index 914ef671b..871e83816 100644
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,7 @@
+2002-10-28 Stefan Bellon <[email protected]>
+
+ * conf-riscos/include/config.h: Updated to reflect latest changes.
+
2002-10-26 David Shaw <[email protected]>
* gnupg.spec.in: Use new path for keyserver helpers, /usr/lib is
diff --git a/scripts/conf-riscos/include/config.h b/scripts/conf-riscos/include/config.h
index b95bef608..de5609ba2 100644
--- a/scripts/conf-riscos/include/config.h
+++ b/scripts/conf-riscos/include/config.h
@@ -86,6 +86,8 @@
/* Define if your locale.h file contains LC_MESSAGES. */
#define HAVE_LC_MESSAGES 1
+#define LOCALEDIR ""
+
/* Define to 1 if NLS is requested. */
#define ENABLE_NLS 1
@@ -154,7 +156,8 @@
#define SIZEOF_UNSIGNED_LONG 4
/* The number of bytes in a unsigned long long. */
-#define SIZEOF_UNSIGNED_LONG_LONG 0
+/* Is defined later on */
+/* #define SIZEOF_UNSIGNED_LONG_LONG 0 */
/* The number of bytes in a unsigned short. */
#define SIZEOF_UNSIGNED_SHORT 2
@@ -361,29 +364,30 @@
/* define if compiled symbols have a leading underscore */
#define WITH_SYMBOL_UNDERSCORE 1
-#ifdef IS_DEVELOPMENT_VERSION
- #define DEBUG 1
-/* #define M_DEBUG */
- #define M_GUARD 1
-#endif
-
-#define USE_RNDRISCOS 1
-
/* RISC OS specifica */
#if (__CC_NORCROFT == 1) /* Norcroft */
# undef __GNUC__
# define __GNUC_MINOR__ 0
# define __GLIBC__ 0
# define __attribute__(x)
+# define SIZEOF_UNSIGNED_LONG_LONG 0
# if (__CC_NORCROFT_VERSION < 544) /* old version of Norcroft */
# define inline __inline
# define STR(a) #a
# define __func__ "[" __FILE__ ":" STR(__LINE__) "]"
# endif
#else /* gcc */
+# define SIZEOF_UNSIGNED_LONG_LONG 8
#endif
-/* #define USE_EXTERNAL_HKP */
+#define USE_RNDRISCOS 1
+#define HAVE_LDAP_GET_OPTION 1
+
+#ifdef IS_DEVELOPMENT_VERSION
+# define DEBUG 1
+/*# define M_DEBUG */
+# define M_GUARD 1
+#endif
#include "g10defs.h"
diff --git a/util/ChangeLog b/util/ChangeLog
index 6dfab1fb1..82d47901c 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,12 @@
+2002-10-28 Stefan Bellon <[email protected]>
+
+ * fileutil.c (make_basename) [__riscos__]: Cut off RISC OS' filing
+ systems from filepath.
+
+ * riscos.c (riscos_get_filetype_from_string, riscos_get_filetype):
+ Added.
+ (riscos_set_filetype_by_number): Made public.
+
2002-10-19 David Shaw <[email protected]>
* Makefile.am, regcomp.c, regex.c, regex_internal.c,
diff --git a/util/fileutil.c b/util/fileutil.c
index c2a2a9df2..0d49ef513 100644
--- a/util/fileutil.c
+++ b/util/fileutil.c
@@ -44,10 +44,12 @@ make_basename(const char *filepath)
char *p;
if ( !(p=strrchr(filepath, DIRSEP_C)) )
- #ifdef HAVE_DRIVE_LETTERS
+#ifdef HAVE_DRIVE_LETTERS
if ( !(p=strrchr(filepath, '\\')) )
if ( !(p=strrchr(filepath, ':')) )
- #endif
+#elif defined(__riscos__)
+ if ( !(p=strrchr(filepath, ':')) )
+#endif
{
return m_strdup(filepath);
}
diff --git a/util/riscos.c b/util/riscos.c
index c64da3751..a66a05ad3 100644
--- a/util/riscos.c
+++ b/util/riscos.c
@@ -36,15 +36,9 @@
#define __UNIXLIB_INTERNALS
#include <unixlib/unix.h>
+#include <unixlib/swiparams.h>
#undef __UNIXLIB_INTERNALS
-/* RISC OS specific defines that are not yet in UnixLib */
-
-#define MimeMap_Translate 0x50B00
-#define MMM_TYPE_RISCOS 0
-#define MMM_TYPE_RISCOS_STRING 1
-#define MMM_TYPE_MIME 2
-#define MMM_TYPE_DOT_EXTN 3
/* RISC OS file open descriptor control list */
@@ -76,14 +70,6 @@ is_read_only(const char *filename)
return 0;
}
-static void
-riscos_set_filetype_by_number(const char *filename, int type)
-{
- if (_swix(OS_File, _INR(0,2), 18, filename, type))
- log_fatal("Can't set filetype for file %s!\n"
- "Is the file on a read-only file system?\n", filename);
-}
-
/* exported RISC OS functions */
void
@@ -93,6 +79,38 @@ riscos_global_defaults(void)
__feature_imagefs_is_file = 1;
}
+int
+riscos_get_filetype_from_string(const char *string, int len)
+{
+ int result = 0xfff;
+
+ if (string[len - 4] != ',')
+ return 0xfff;
+
+ sscanf(string+len-3, "%3x", &result);
+
+ return result;
+}
+
+int
+riscos_get_filetype(const char *filename)
+{
+ int result;
+
+ if (_swix(OS_File, _INR(0,1) | _OUT(6), 23, filename, &result))
+ log_fatal("Can't get filetype for file %s!\n", filename);
+
+ return result;
+}
+
+void
+riscos_set_filetype_by_number(const char *filename, int type)
+{
+ if (_swix(OS_File, _INR(0,2), 18, filename, type))
+ log_fatal("Can't set filetype for file %s!\n"
+ "Is the file on a read-only file system?\n", filename);
+}
+
void
riscos_set_filetype(const char *filename, const char *mimetype)
{