summaryrefslogtreecommitdiffstats
path: root/mbbsd/io.c
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-12-22 10:50:27 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-12-22 10:50:27 +0800
commit01f06f84051aca22962c3019ebea0277d0c44f7b (patch)
treebd8e95a0fc96c49d1d1c6b3bebdcec49548c572c /mbbsd/io.c
parentfe54b6d2f8bb76b1f24a80c84fc85fc6da47d2ae (diff)
downloadpttbbs-01f06f84051aca22962c3019ebea0277d0c44f7b.tar
pttbbs-01f06f84051aca22962c3019ebea0277d0c44f7b.tar.gz
pttbbs-01f06f84051aca22962c3019ebea0277d0c44f7b.tar.bz2
pttbbs-01f06f84051aca22962c3019ebea0277d0c44f7b.tar.lz
pttbbs-01f06f84051aca22962c3019ebea0277d0c44f7b.tar.xz
pttbbs-01f06f84051aca22962c3019ebea0277d0c44f7b.tar.zst
pttbbs-01f06f84051aca22962c3019ebea0277d0c44f7b.zip
missing commit
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1423 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/io.c')
-rw-r--r--mbbsd/io.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/mbbsd/io.c b/mbbsd/io.c
index 13e313f4..f31d5f30 100644
--- a/mbbsd/io.c
+++ b/mbbsd/io.c
@@ -17,25 +17,35 @@ static int icurrchar = 0;
/* ----------------------------------------------------- */
/* convert routines */
/* ----------------------------------------------------- */
-#ifdef CONVERT
+#ifdef GB_CONVERT
typedef int (* read_write_type)(int, void *, size_t);
static read_write_type write_type = (read_write_type)write;
static read_write_type read_type = read;
+int converting_read(int fd, void *buf, size_t count)
+{
+ int len = read(fd, buf, count);
+ if (len >= 0)
+ gb2big(buf, len);
+ return len;
+}
+
+int converting_write(int fd, void *buf, size_t count)
+{
+ big2gb(buf, count);
+ return write(fd, buf, count);
+}
+
void set_converting_type(int which)
{
- if (which == NOCONVERT) {
+ if (which == 0) {
read_type = read;
write_type = (read_write_type)write;
}
- else if (which == GBCONVERT) {
- read_type = gb_converting_read;
- write_type = gb_converting_write;
- }
- else if (which == UCSCONVERT) {
- read_type = ucs_converting_read;
- write_type = ucs_converting_write;
+ else if (which == 1) {
+ read_type = converting_read;
+ write_type = converting_write;
}
}
@@ -55,7 +65,7 @@ void
oflush()
{
if (obufsize) {
-#ifdef CONVERT
+#ifdef GB_CONVERT
write_wrapper(1, outbuf, obufsize);
#else
write(1, outbuf, obufsize);
@@ -77,7 +87,7 @@ output(char *s, int len)
assert(len<OBUFSIZE);
if (obufsize + len > OBUFSIZE) {
-#ifdef CONVERT
+#ifdef GB_CONVERT
write_wrapper(1, outbuf, obufsize);
#else
write(1, outbuf, obufsize);
@@ -177,7 +187,7 @@ dogetch()
do{
#endif
-#ifdef CONVERT
+#ifdef GB_CONVERT
while ((len = read_wrapper(0, inbuf, IBUFSIZE)) <= 0) {
#else
while ((len = read(0, inbuf, IBUFSIZE)) <= 0) {