diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2008-11-19 15:30:46 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2008-11-19 15:30:46 +0000 |
commit | 8d94751a807c93fe8f2338f941c5d360aa6402f4 (patch) | |
tree | d2b3708c82209faf88c6773952a35376faeaa192 /riscos/stubs | |
parent | 5999efa3acaaa27764e5899a4329ecc50d4b4c7f (diff) | |
download | iconv-8d94751a807c93fe8f2338f941c5d360aa6402f4.tar.gz iconv-8d94751a807c93fe8f2338f941c5d360aa6402f4.tar.bz2 |
Move the declarations of iconv_initialise/iconv_finalise to a different header.
This keeps the public iconv.h free of such nonsense.
Move the source for the RISC OS stubs to the distribution template tree.
We will no longer shipped compiled stubs. People are quite capable of compiling this themselves. Also take the opportunity to tidy it up a bit.
Bump the version number to 0.09
Introduce a "riscos-dist" target in Makefile-riscos.
Update various bits of documentation.
svn path=/trunk/iconv/; revision=5734
Diffstat (limited to 'riscos/stubs')
-rw-r--r-- | riscos/stubs/ReadMe | 11 | ||||
-rw-r--r-- | riscos/stubs/stubs.c | 122 |
2 files changed, 133 insertions, 0 deletions
diff --git a/riscos/stubs/ReadMe b/riscos/stubs/ReadMe new file mode 100644 index 0000000..40c117a --- /dev/null +++ b/riscos/stubs/ReadMe @@ -0,0 +1,11 @@ +Iconv module stubs +================== + +This directory contains the source code required to build suitable stubs +for interfacing with the Iconv module from C. The stubs provide the standard +iconv_open, iconv, and iconv_close API entry points. + +UnixLib users should use the veneers provided by that library. These stubs are +provided for the convenience of those using the Shared C Library, or other +runtime. + diff --git a/riscos/stubs/stubs.c b/riscos/stubs/stubs.c new file mode 100644 index 0000000..aec8cf6 --- /dev/null +++ b/riscos/stubs/stubs.c @@ -0,0 +1,122 @@ +/* Iconv stubs */ + +#include <errno.h> + +#include <sys/errno.h> + +#include "swis.h" + +#include "iconv.h" + +/* SWI numbers */ +#define Iconv_Open (0x57540) +#define Iconv_Iconv (0x57541) +#define Iconv_Close (0x57542) +#define Iconv_Convert (0x57543) +#define Iconv_CreateMenu (0x57544) +#define Iconv_DecodeMenu (0x57545) + +/* Error numbers */ +#define ERROR_BASE 0x81b900 + +#define ICONV_NOMEM (ERROR_BASE+0) +#define ICONV_INVAL (ERROR_BASE+1) +#define ICONV_2BIG (ERROR_BASE+2) +#define ICONV_ILSEQ (ERROR_BASE+3) + +iconv_t iconv_open(const char *tocode, const char *fromcode) +{ + iconv_t ret; + _kernel_oserror *error; + + error = _swix(Iconv_Open, _INR(0,1) | _OUT(0), + tocode, fromcode, + &ret); + if (error) { + switch (error->errnum) { + case ICONV_NOMEM: + errno = ENOMEM; + break; + case ICONV_INVAL: + errno = EINVAL; + break; + case ICONV_2BIG: + errno = E2BIG; + break; + case ICONV_ILSEQ: + errno = EILSEQ; + break; + default: + errno = EINVAL; /* munge BAD_SWI to EINVAL */ + break; + } + return (iconv_t)(-1); + } + + return ret; +} + +size_t iconv(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, + size_t *outbytesleft) +{ + size_t ret; + _kernel_oserror *error; + + error = _swix(Iconv_Iconv, _INR(0,4) | _OUT(0), + cd, inbuf, inbytesleft, outbuf, outbytesleft, + &ret); + if (error) { + switch (error->errnum) { + case ICONV_NOMEM: + errno = ENOMEM; + break; + case ICONV_INVAL: + errno = EINVAL; + break; + case ICONV_2BIG: + errno = E2BIG; + break; + case ICONV_ILSEQ: + errno = EILSEQ; + break; + default: + errno = EINVAL; /* munge BAD_SWI to EINVAL */ + break; + } + return (size_t)(-1); + } + + return ret; +} + +int iconv_close(iconv_t cd) +{ + int ret; + _kernel_oserror *error; + + error = _swix(Iconv_Close, _IN(0) | _OUT(0), + cd, + &ret); + if (error) { + switch (error->errnum) { + case ICONV_NOMEM: + errno = ENOMEM; + break; + case ICONV_INVAL: + errno = EINVAL; + break; + case ICONV_2BIG: + errno = E2BIG; + break; + case ICONV_ILSEQ: + errno = EILSEQ; + break; + default: + errno = EINVAL; /* munge BAD_SWI to EINVAL */ + break; + } + return -1; + } + + return ret; +} |