tidying up RISC OS stuff

This commit is contained in:
Stefan Bellon 2002-08-06 06:54:55 +00:00
parent 8298145729
commit 181dcc69f4
8 changed files with 121 additions and 148 deletions

View File

@ -1,3 +1,7 @@
2002-08-06 Stefan Bellon <sbellon@sbellon.de>
* util.h [__riscos__]: Added riscos_getchar().
2002-06-21 Stefan Bellon <sbellon@sbellon.de>
* util.h [__riscos__]: Further moving away of RISC OS specific

View File

@ -270,6 +270,7 @@ void riscos_set_filetype(const char *filename, const char *mimetype);
pid_t riscos_getpid(void);
int riscos_kill(pid_t pid, int sig);
int riscos_access(const char *path, int amode);
int riscos_getchar(void);
int fdopenfile(const char *filename, const int allow_write);
void close_fds(void);
int renamefile(const char *old, const char *new);

View File

@ -1,3 +1,9 @@
2002-08-06 Stefan Bellon <sbellon@sbellon.de>
* conf-riscos/include/config.h: Changed #define FOO to
#define FOO 1.
* conf-riscos/include/g10defs.h: Likewise.
2002-08-03 Stefan Bellon <sbellon@sbellon.de>
* conf-riscos/include/g10defs.h: Added GNUPG_LIBEXECDIR.

View File

@ -38,11 +38,11 @@
/* Define if you have alloca, as a function or macro. */
/* #undef HAVE_ALLOCA */
#define HAVE_ALLOCA
#define HAVE_ALLOCA 1
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
/* #undef HAVE_ALLOCA_H */
#define HAVE_ALLOCA_H
#define HAVE_ALLOCA_H 1
/* #undef _LIBC */
@ -50,7 +50,7 @@
#undef HAVE_DOPRNT
/* Define if you have the vprintf function. */
#define HAVE_VPRINTF
#define HAVE_VPRINTF 1
/* Define to `long' if <sys/types.h> doesn't define. */
#undef off_t
@ -74,26 +74,26 @@
#undef STACK_DIRECTION
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS
#define STDC_HEADERS 1
/* Define if `sys_siglist' is declared by <signal.h>. */
#define SYS_SIGLIST_DECLARED
#define SYS_SIGLIST_DECLARED 1
#undef M_DEBUG
#undef M_GUARD
#define PRINTABLE_OS_NAME "RISC OS"
/* Define if your locale.h file contains LC_MESSAGES. */
#define HAVE_LC_MESSAGES
#define HAVE_LC_MESSAGES 1
/* Define to 1 if NLS is requested. */
#define ENABLE_NLS 1
/* Define as 1 if you have catgets and don't want to use GNU gettext. */
#define HAVE_CATGETS 0
#undef HAVE_CATGETS
/* Define as 1 if you have gettext and don't want to use GNU gettext. */
#define HAVE_GETTEXT 0
#undef HAVE_GETTEXT
#undef BIG_ENDIAN_HOST
#define LITTLE_ENDIAN_HOST 1
@ -169,13 +169,13 @@
#undef HAVE___ARGZ_STRINGIFY
/* Define if you have the atexit function. */
#define HAVE_ATEXIT
#define HAVE_ATEXIT 1
/* Define if you have the clock_gettime function. */
#undef HAVE_CLOCK_GETTIME
/* Define if you have the dcgettext function. */
#define HAVE_DCGETTEXT 0
#undef HAVE_DCGETTEXT
/* Define if you have the dlopen function. */
#undef HAVE_DLOPEN
@ -187,25 +187,25 @@
#undef HAVE_FSTAT64
/* Define if you have the getcwd function. */
#define HAVE_GETCWD
#define HAVE_GETCWD 1
/* Define if you have the gethrtime function. */
#undef HAVE_GETHRTIME
/* Define if you have the getpagesize function. */
#define HAVE_GETPAGESIZE
#define HAVE_GETPAGESIZE 1
/* Define if you have the getrusage function. */
#define HAVE_GETRUSAGE
#define HAVE_GETRUSAGE 1
/* Define if you have the gettimeofday function. */
#define HAVE_GETTIMEOFDAY
#define HAVE_GETTIMEOFDAY 1
/* Define if you have the memicmp function. */
#undef HAVE_MEMICMP
/* Define if you have the memmove function. */
#define HAVE_MEMMOVE
#define HAVE_MEMMOVE 1
/* Define if you have the mlock function. */
#undef HAVE_MLOCK
@ -220,64 +220,64 @@
#undef HAVE_NL_LANGINFO
/* Define if you have the putenv function. */
#define HAVE_PUTENV
#define HAVE_PUTENV 1
/* Define if you have the raise function. */
#define HAVE_RAISE
#define HAVE_RAISE 1
/* Define if you have the rand function. */
#define HAVE_RAND
#define HAVE_RAND 1
/* Define if you have the setenv function. */
#define HAVE_SETENV
#define HAVE_SETENV 1
/* Define if you have the setlocale function. */
#define HAVE_SETLOCALE
#define HAVE_SETLOCALE 1
/* Define if you have the setrlimit function. */
#define HAVE_SETRLIMIT
#define HAVE_SETRLIMIT 1
/* Define if you have the sigaction function. */
#define HAVE_SIGACTION
#define HAVE_SIGACTION 1
/* Define if you have the sigprocmask function. */
#define HAVE_SIGPROCMASK
#define HAVE_SIGPROCMASK 1
/* Define if you have the stpcpy function. */
#define HAVE_STPCPY
#define HAVE_STPCPY 1
/* Define if you have the strcasecmp function. */
#define HAVE_STRCASECMP
#define HAVE_STRCASECMP 1
/* Define if you have the strchr function. */
#define HAVE_STRCHR
#define HAVE_STRCHR 1
/* Define if you have the strdup function. */
#define HAVE_STRDUP
#define HAVE_STRDUP 1
/* Define if you have the strerror function. */
#define HAVE_STRERROR
#define HAVE_STRERROR 1
/* Define if you have the strftime function. */
#define HAVE_STRFTIME
#define HAVE_STRFTIME 1
/* Define if you have the stricmp function. */
#define HAVE_STRICMP
#define HAVE_STRICMP 1
/* Define if you have the strlwr function. */
#undef HAVE_STRLWR
/* Define if you have the strtoul function. */
#define HAVE_STRTOUL
#define HAVE_STRTOUL 1
/* Define if you have the tcgetattr function. */
#define HAVE_TCGETATTR
#undef HAVE_TCGETATTR
/* Define if you have the wait4 function. */
#define HAVE_WAIT4
#define HAVE_WAIT4 1
/* Define if you have the waitpid function. */
#define HAVE_WAITPID
#define HAVE_WAITPID 1
/* Define if you have the <argz.h> header file. */
#undef HAVE_ARGZ_H
@ -292,22 +292,22 @@
#undef HAVE_LANGINFO_H
/* Define if you have the <limits.h> header file. */
#define HAVE_LIMITS_H
#define HAVE_LIMITS_H 1
/* Define if you have the <linux/random.h> header file. */
#undef HAVE_LINUX_RANDOM_H
/* Define if you have the <locale.h> header file. */
#define HAVE_LOCALE_H
#define HAVE_LOCALE_H 1
/* Define if you have the <malloc.h> header file. */
#define HAVE_MALLOC_H
#define HAVE_MALLOC_H 1
/* Define if you have the <nl_types.h> header file. */
#undef HAVE_NL_TYPES_H
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H
#define HAVE_STRING_H 1
/* Define if you have the <sys/capability.h> header file. */
#undef HAVE_SYS_CAPABILITY_H
@ -316,25 +316,25 @@
#undef HAVE_SYS_IPC_H
/* Define if you have the <sys/mman.h> header file. */
#define HAVE_SYS_MMAN_H
#define HAVE_SYS_MMAN_H 1
/* Define if you have the <sys/param.h> header file. */
#define HAVE_SYS_PARAM_H
#define HAVE_SYS_PARAM_H 1
/* Define if you have the <sys/shm.h> header file. */
#undef HAVE_SYS_SHM_H
/* Define if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H
#define HAVE_SYS_STAT_H 1
/* Define if you have the <termio.h> header file. */
#define HAVE_TERMIO_H
#undef HAVE_TERMIO_H
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H
#define HAVE_UNISTD_H 1
/* Define if you have the <zlib.h> header file. */
#define HAVE_ZLIB_H
#define HAVE_ZLIB_H 1
/* Define if you have the dl library (-ldl). */
#undef HAVE_LIBDL
@ -359,15 +359,15 @@
/* define if compiled symbols have a leading underscore */
#define WITH_SYMBOL_UNDERSCORE
#define WITH_SYMBOL_UNDERSCORE 1
#ifdef IS_DEVELOPMENT_VERSION
#define DEBUG
#define DEBUG 1
/* #define M_DEBUG */
#define M_GUARD
#define M_GUARD 1
#endif
#define USE_RNDRISCOS
#define USE_RNDRISCOS 1
/* RISC OS specifica */
#if (__CC_NORCROFT == 1) /* Norcroft */
@ -383,6 +383,8 @@
#else /* gcc */
#endif
/* #define USE_EXTERNAL_HKP */
#include "g10defs.h"
#endif /*G10_CONFIG_H*/

View File

@ -38,5 +38,5 @@
/* External process spawning mechanism */
#if !(defined(HAVE_FORK) && defined(HAVE_PIPE) && defined(HAVE_WAITPID))
#define EXEC_TEMPFILE_ONLY
#define EXEC_TEMPFILE_ONLY 1
#endif

View File

@ -1,3 +1,8 @@
2002-08-06 Stefan Bellon <sbellon@sbellon.de>
* ttyio.c [__riscos__]: Moved low-level RISC OS stuff to riscos.c.
* riscos.c: Use new SWI calling mechanism of UnixLib.
2002-08-03 Stefan Bellon <sbellon@sbellon.de>
* secmem.c (init_pool, secmem_term): Changed #if to #ifdef in

View File

@ -61,19 +61,16 @@ static int initialized = 0;
static int
is_read_only(const char *filename)
{
_kernel_swi_regs r;
int type, attr;
r.r[0] = 17;
r.r[1] = (int) filename;
if (_kernel_swi(OS_File, &r, &r))
if (_swix(OS_File, _INR(0,1) | _OUT(0) | _OUT(5),
17, filename, &type, &attr))
log_fatal("Can't get file attributes for %s!\n", filename);
if (r.r[0] == 0)
if (type == 0)
log_fatal("Can't find file %s!\n", filename);
r.r[0] = 4;
if (_kernel_swi(OS_File, &r, &r))
if (_swix(OS_File, _INR(0,1) | _IN(5), 4, filename, attr))
return 1;
return 0;
@ -82,13 +79,7 @@ is_read_only(const char *filename)
static void
riscos_set_filetype_by_number(const char *filename, int type)
{
_kernel_swi_regs r;
r.r[0] = 18;
r.r[1] = (int) filename;
r.r[2] = type;
if (_kernel_swi(OS_File, &r, &r))
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);
}
@ -105,55 +96,45 @@ riscos_global_defaults(void)
void
riscos_set_filetype(const char *filename, const char *mimetype)
{
_kernel_swi_regs r;
int result;
r.r[0] = MMM_TYPE_MIME;
r.r[1] = (int) mimetype;
r.r[2] = MMM_TYPE_RISCOS;
if (_kernel_swi(MimeMap_Translate, &r, &r))
if (_swix(MimeMap_Translate, _INR(0,2) | _OUT(3),
MMM_TYPE_MIME, mimetype, MMM_TYPE_RISCOS, &result))
log_fatal("Can't translate MIME type %s!\n", mimetype);
riscos_set_filetype_by_number(filename, r.r[3]);
riscos_set_filetype_by_number(filename, result);
}
pid_t
riscos_getpid(void)
{
_kernel_swi_regs r;
int state;
r.r[0] = 3;
if (_kernel_swi(Wimp_ReadSysInfo, &r, &r))
if (_swix(Wimp_ReadSysInfo, _IN(0) | _OUT(0), 3, &state))
log_fatal("Wimp_ReadSysInfo failed: Can't get WimpState (R0=3)!\n");
if (!r.r[0])
return (pid_t) 0;
if (state)
if (_swix(Wimp_ReadSysInfo, _IN(0) | _OUT(0), 5, &state))
log_fatal("Wimp_ReadSysInfo failed: Can't get task handle (R0=5)!\n");
r.r[0] = 5;
if (_kernel_swi(Wimp_ReadSysInfo, &r, &r))
log_fatal("Wimp_ReadSysInfo failed: Can't get task handle (R0=5)!\n");
return (pid_t) r.r[0];
return (pid_t) state;
}
int
riscos_kill(pid_t pid, int sig)
{
_kernel_swi_regs r;
int buf[4];
int buf[4], iter = 0;
if (sig)
kill(pid, sig);
r.r[0] = 0;
do {
r.r[1] = (int) buf;
r.r[2] = 16;
if (_kernel_swi(TaskManager_EnumerateTasks, &r, &r))
if (_swix(TaskManager_EnumerateTasks, _INR(0,2) | _OUT(0),
iter, buf, 16, &iter))
log_fatal("TaskManager_EnumerateTasks failed!\n");
if (buf[0] == pid)
return 0;
} while (r.r[0] >= 0);
} while (iter >= 0);
return __set_errno(ESRCH);
}
@ -167,6 +148,19 @@ riscos_access(const char *path, int amode)
return access(path, amode);
}
int
riscos_getchar(void)
{
int c, flags;
if (_swix(OS_ReadC, _OUT(0) | _OUT(_FLAGS), &c, &flags))
log_fatal("OS_ReadC failed: Couldn't read from keyboard!\n");
if (flags & _C)
log_fatal("OS_ReadC failed: Return Code = %i!\n", c);
return c;
}
#ifdef DEBUG
void
dump_fdlist(void)
@ -224,13 +218,9 @@ close_fds(void)
int
renamefile(const char *old, const char *new)
{
_kernel_swi_regs r;
_kernel_oserror *e;
r.r[0] = 25;
r.r[1] = (int) old;
r.r[2] = (int) new;
if (e = _kernel_swi(OS_FSControl, &r, &r)) {
if (e = _swix(OS_FSControl, _INR(0,2), 25, old, new)) {
if (e->errnum == 214)
return __set_errno(ENOENT);
if (e->errnum == 176)
@ -244,30 +234,23 @@ renamefile(const char *old, const char *new)
char *
gstrans(const char *old)
{
_kernel_swi_regs r;
int c = 0;
int size = 256;
int size = 256, last;
char *buf, *tmp;
buf = (char *) m_alloc(size);
if (!buf)
log_fatal("Can't claim memory for OS_GSTrans buffer!\n");
do {
r.r[0] = (int) old;
r.r[1] = (int) buf;
r.r[2] = size;
_kernel_swi_c(OS_GSTrans, &r, &r, &c);
if (c) {
size += 256;
tmp = (char *) m_realloc(buf, size);
if (!tmp)
log_fatal("Can't claim memory for OS_GSTrans buffer!\n");
buf = tmp;
}
} while (c);
while (_C & _swi(OS_GSTrans, _INR(0,2) | _OUT(2) | _RETURN(_FLAGS),
old, buf, size, &last)) {
size += 256;
tmp = (char *) m_realloc(buf, size);
if (!tmp)
log_fatal("Can't claim memory for OS_GSTrans buffer!\n");
buf = tmp;
}
buf[r.r[2]] = '\0';
tmp = (char *) m_realloc(buf, r.r[2] + 1);
buf[last] = '\0';
tmp = (char *) m_realloc(buf, last + 1);
if (!tmp)
log_fatal("Can't realloc memory after OS_GSTrans!\n");
@ -278,41 +261,30 @@ gstrans(const char *old)
void
list_openfiles(void)
{
_kernel_swi_regs r;
char *name;
int i;
int i, len;
for (i = 255; i >= 0; --i) {
r.r[0] = 7;
r.r[1] = i;
r.r[2] = 0;
r.r[5] = 0;
if (_kernel_swi(OS_Args, &r, &r))
if (_swix(OS_Args, _INR(0,2) | _IN(5) | _OUT(5), 7, i, 0, 0, &len))
continue;
name = (char *) m_alloc(1-r.r[5]);
name = (char *) m_alloc(1-len);
if (!name)
log_fatal("Can't claim memory for OS_Args buffer!\n");
r.r[0] = 7;
r.r[1] = i;
r.r[2] = (int) name;
r.r[5] = 1-r.r[5];
if (_kernel_swi(OS_Args, &r, &r)) {
if (_swix(OS_Args, _INR(0,2) | _IN(5), 7, i, name, 1-len)) {
m_free(name);
log_fatal("Error when calling OS_Args(7)!\n");
}
r.r[0] = 254;
r.r[1] = i;
if (_kernel_swi(OS_Args, &r, &r)) {
if (_swix(OS_Args, _INR(0,1) | _OUT(0), 254, i, &len)) {
m_free(name);
log_fatal("Error when calling OS_Args(254)!\n");
}
printf("%3i: %s (%c%c)\n", i, name,
(r.r[0] & 0x40) ? 'R' : 0,
(r.r[0] & 0x80) ? 'W' : 0);
(len & 0x40) ? 'R' : 0,
(len & 0x80) ? 'W' : 0);
m_free(name);
}
}

View File

@ -26,11 +26,6 @@
#include <unistd.h>
#ifdef HAVE_TCGETATTR
#include <termios.h>
#ifdef __riscos__
#include <kernel.h>
#include <swis.h>
#undef HAVE_TCGETATTR
#endif /* __riscos__ */
#else
#ifdef HAVE_TERMIO_H
/* simulate termios with termio */
@ -80,13 +75,8 @@ static int batchmode;
static int no_terminal;
#ifdef HAVE_TCGETATTR
#ifdef __riscos__
struct termios termsave;
int restore_termios;
#else
static struct termios termsave;
static int restore_termios;
#endif
#endif
@ -286,10 +276,7 @@ do_get( const char *prompt, int hidden )
char *buf;
#ifndef __riscos__
byte cbuf[1];
#else
int carry;
_kernel_swi_regs r;
#endif
#endif
int c, n, i;
if( batchmode ) {
@ -346,11 +333,7 @@ do_get( const char *prompt, int hidden )
#elif defined(__riscos__)
do {
if (_kernel_swi_c(OS_ReadC, &r, &r, &carry))
log_fatal("OS_ReadC failed: Couldn't read from keyboard!\n");
c = r.r[0];
if (carry != 0)
log_fatal("OS_ReadC failed: Return Code = %i!\n", c);
c = riscos_getchar();
if (c == 0xa || c == 0xd) { /* Return || Enter */
c = (int) '\n';
} else if (c == 0x8 || c == 0x7f) { /* Backspace || Delete */