1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/REC-html40/Transitional.dtd">
<html>
<head>
<title>[gstream.h] Generic Character ( Set ) & Stream Library</title>
<meta name="robots" content="noindex">
</head>
<body bgcolor=white>
<h1><font color="#008B8B">[gstream.h] Generic Character ( Set ) & Stream Library</font></h1>
<h2><font color="#008B8B"><a href="styx.html">contents</a></font></h2><br>
<br><a href="standard.htm">#include "standard.h"</a>
<br>
<br>
<br>
<br><pre>
[gstream] supports the conversion of strings from one character set to another.
Beside that it provides a generic stream library which is able to handle different
character sets.
Supported platforms are Unix and Windows.
</pre>
<br><hr width="100%" size=2><h2><b> Types and macros </b></h2>
<br> <b>Default multibyte and wide character sets</b>
<br><pre>#if defined( _MSDOS ) || defined( _WIN32 )
#define CS_ID_WCHAR "1200"
#else
#define CS_ID_WCHAR "UCS-4"
#endif
#define CS_ID_MBYTE "UTF-8"
</pre>
<br>
<table border=0 cellspacing=10>
<TR valign=top>
<td align=left><b>CSConv_T</b>
<td align=left> Character set conversion type
<TR valign=top>
<td align=left><b>GStream_T</b>
<td align=left> Generic stream type
</table>
<br> <b>Types of generic stream functions</b>
<br><pre>// read byte vector function (RC>=0 <==> bytes read, RC=-1 <==> error)
typedef int (*GS_getb_T)(GStream_T gstream, c_byte* b, int cnt);
// put byte vector function (RC>=0 <==> bytes written, RC=-1 <==> error)
typedef int (*GS_putb_T)(GStream_T gstream, c_byte* b, int cnt);
// fseek function
// (RC = new byte position = origin + offset <==> OK, RC=-1 <==> error)
typedef LONG_INT (*GS_seek_T)(GStream_T gstream, long offset, int origin);
// close and free function
typedef void (*GS_destruct_T)(GStream_T gstream);
</pre>
<br><hr width="100%" size=2><h2><b> Multibyte and wide character set support </b></h2>
<table border=0 cellspacing=20>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>int <b>GS_csconv_ucs4_utf8</b>
(
wc_string in, size_t insize,
c_string out, size_t outsize
)</pre>
<td bgcolor="#FFF0F5" align=left> ucs4 --> utf-8 ( RFC 2279 )<br>
'insize' contains the number of wide characters in 'in', L'\0' inclusive.<br>
'outsize' contains the number of bytes in 'out', '\0' inclusive.<br>
'out': utf-8 representation of 'in' or NULL<br>
RC: >=0 on O.K. ( number of written bytes )<br>
| =-1 on possible incomplete input<br>
| =-2 on error<br>
<br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>int <b>GS_csconv_utf8_ucs4</b>
(
c_string in, size_t insize,
wc_string out, size_t outsize
)</pre>
<td bgcolor="#FFF0F5" align=left> utf-8 --> ucs4 ( RFC 2279 )<br>
'insize' contains the number of bytes in 'in', '\0' inclusive.<br>
'outsize' contains the number of wide characters in 'out', L'\0' inclusive.<br>
'out': ucs4 representation of 'in' or NULL<br>
RC: >=0 on O.K. ( number of written wide characters )<br>
| =-1 on possible incomplete input<br>
| =-2 on error<br>
<br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>c_string <b>GS_ucs4_to_utf8</b>(wc_string in)</pre>
<td bgcolor="#FFF0F5" align=left> ucs4 --> utf-8 ( RFC 2279 )<br>
RC: utf-8 representation of 'in' or NULL; allocs memory<br>
<br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>wc_string <b>GS_utf8_to_ucs4</b>(c_string in)</pre>
<td bgcolor="#FFF0F5" align=left> utf-8 --> ucs4 ( RFC 2279 )<br>
RC: ucs4 representation of 'in' or NULL; allocs memory<br>
<br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>void <b>GS_fprint_utf8</b>(FILE* fp, c_string s, c_bool raw)</pre>
<td bgcolor="#FFF0F5" align=left> print utf-8 string 's' to file 'fp'<br>
raw --> printable ascii or hex<br>
<br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>void <b>GS_fprint_ucs4</b>(FILE* fp, wc_string ws, c_bool raw)</pre>
<td bgcolor="#FFF0F5" align=left> print ucs4 string 'ws' to file 'fp'<br>
raw --> printable ascii or hex<br>
<br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>CSConv_T <b>GS_csconv_new</b>(c_string ct, c_string cs)</pre>
<td bgcolor="#FFF0F5" align=left> create new character set conversion description ( RC=NULL on error ) <br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>void <b>GS_csconv_free</b>(CSConv_T csci)</pre>
<td bgcolor="#FFF0F5" align=left> free character set conversion description <br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>int <b>GS_csconv_string</b>
(
CSConv_T csci, c_string in, int insize,
c_string out, int* outsize
)</pre>
<td bgcolor="#FFF0F5" align=left> character set conversion of 'in' to 'out'<br>
'outsize' contains the number of bytes in 'out'.<br>
'in' and 'out' must be a valid character buffers with size > 0.<br>
RC: >=0 on O.K. ( number of conversions / characters )<br>
| =-1 on possible incomplete input<br>
| =-2 on error<br>
<br>
</table>
<br><hr width="100%" size=2><h2><b> Generic stream support </b></h2>
<table border=0 cellspacing=20>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>void <b>GS_stream_file_free</b>(GStream_T gstream)</pre>
<td bgcolor="#FFF0F5" align=left>free file stream 'gstream'
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>void <b>GS_stream_file_destruct</b>(GStream_T gstream)</pre>
<td bgcolor="#FFF0F5" align=left> close and free file stream 'gstream' <br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>GStream_T <b>GS_stream_file_new</b>
(
FILE* fp, c_string cs, c_bool close
)</pre>
<td bgcolor="#FFF0F5" align=left> create new generic stream on a file opened for binary I/O<br>
'cs' : character set name ( UCS4, UTF-8, MS:CodePage / GNU:iconv-based )<br>
'close': true <--> close file on stream destruction<br>
RC: stream on O.K. | NULL on error<br>
<br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>void <b>GS_stream_string_free</b>(GStream_T gstream)</pre>
<td bgcolor="#FFF0F5" align=left> free string stream 'gstream' <br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>GStream_T <b>GS_stream_string_new</b>
(
c_string s, unsigned int len, c_string cs
)</pre>
<td bgcolor="#FFF0F5" align=left> create new generic stream on a string buffer<br>
'len': string size in bytes, inclusive terminating bytes<br>
'cs' : character set name ( UCS4, UTF-8, MS:CodePage / GNU:iconv-based )<br>
RC: stream on O.K. | NULL on error<br>
Note: During write operations when reaching the end of the buffer<br>
's' will be deleted and recreated.<br>
<br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>c_bool <b>GS_stream_string_set</b>
(
GStream_T gstream, c_string s, unsigned int len
)</pre>
<td bgcolor="#FFF0F5" align=left> reset the string buffer of generic stream 'gstream'<br>
'len': string size in bytes, inclusive terminating bytes<br>
RC: True = O.K.<br>
Note: The character set of 's' and 'gstream' must be the same.<br>
<br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>c_bool <b>GS_stream_string_insert</b>
(
GStream_T gstream, c_string s, unsigned int len
)</pre>
<td bgcolor="#FFF0F5" align=left> insert 's' into the string buffer of generic stream 'gstream'<br>
'len': string size in bytes, exclusive terminating bytes<br>
RC: True = O.K.<br>
Note: The character set of 's' and 'gstream' must be the same.<br>
<br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>int <b>GS_stream_get_wcval</b>(GStream_T gstream, wc_int* wc)</pre>
<td bgcolor="#FFF0F5" align=left> get wide character 'wc' from 'gstream'<br>
RC: =1 on O.K. | =0 on O.K. and EOF | =-1 on error<br>
<br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>int <b>GS_stream_get_wcrc</b>(GStream_T gstream)</pre>
<td bgcolor="#FFF0F5" align=left> get wide character from 'gstream'<br>
RC: >=0 as wide character or =-1 on EOF | =-2 on error<br>
<br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>int <b>GS_stream_put_wcval</b>(GStream_T gstream, wc_int wc)</pre>
<td bgcolor="#FFF0F5" align=left> put wide character 'wc' to 'gstream'<br>
RC: >=0 on O.K. | =-1 on error<br>
<br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>int <b>GS_stream_bytepos</b>(GStream_T gstream, unsigned int* pos)</pre>
<td bgcolor="#FFF0F5" align=left> get ( relative ) stream position in bytes<br>
RC: =0 on O.K. | =-1 on error<br>
<br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>GS_getb_T <b>GS_fun_getb</b>(GStream_T gstream)</pre>
<td bgcolor="#FFF0F5" align=left> get byte function of 'gstream' or NULL <br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>GS_putb_T <b>GS_fun_putb</b>(GStream_T gstream)</pre>
<td bgcolor="#FFF0F5" align=left> put byte function of 'gstream' or NULL <br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>GS_seek_T <b>GS_fun_seek</b>(GStream_T gstream)</pre>
<td bgcolor="#FFF0F5" align=left> position function of 'gstream' or NULL <br>
<tr valign=top>
<td bgcolor="#FFF8DC" align=left><pre>GS_destruct_T <b>GS_fun_destruct</b>(GStream_T gstream)</pre>
<td bgcolor="#FFF0F5" align=left> close and free function of 'gstream' or NULL <br>
</table>
</body>
</html>
|