summaryrefslogtreecommitdiffhomepage
path: root/mixlib/xmix_device.c
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2004-06-08 22:33:40 +0000
committerJose Antonio Ortega Ruiz <jao@gnu.org>2004-06-08 22:33:40 +0000
commitc9ec7506c10d4e12778d165e93545342a5faabeb (patch)
tree4055005ecbc113cc63b72a76d7b452e96dfc9a14 /mixlib/xmix_device.c
parent44c49815bb6d5eb765462fbb9a98d3d1ac5b3ab1 (diff)
downloadmdk-c9ec7506c10d4e12778d165e93545342a5faabeb.tar.gz
mdk-c9ec7506c10d4e12778d165e93545342a5faabeb.tar.bz2
the console is now in/out.
Diffstat (limited to 'mixlib/xmix_device.c')
-rw-r--r--mixlib/xmix_device.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/mixlib/xmix_device.c b/mixlib/xmix_device.c
index 92d9c4f..73c0485 100644
--- a/mixlib/xmix_device.c
+++ b/mixlib/xmix_device.c
@@ -3,7 +3,7 @@
* ------------------------------------------------------------------
* Last change: Time-stamp: "2001-05-10 01:10:25 jao"
* ------------------------------------------------------------------
- * Copyright (C) 2001 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2004 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,6 +23,7 @@
#include "xmix_device.h"
+#include "mix_types.h"
gchar *DEV_DIR_ = NULL;
@@ -53,7 +54,7 @@ const mix_fmode_t FMODES_[] = {
mix_io_RDWRT, mix_io_RDWRT, mix_io_RDWRT, mix_io_RDWRT,
mix_io_RDWRT, mix_io_RDWRT, mix_io_RDWRT, mix_io_RDWRT,
mix_io_RDWRT, mix_io_RDWRT, mix_io_RDWRT, mix_io_RDWRT,
- mix_io_READ, mix_io_WRITE, mix_io_WRITE, mix_io_WRITE, mix_io_WRITE
+ mix_io_READ, mix_io_WRITE, mix_io_WRITE, mix_io_RDWRT, mix_io_WRITE
};
/* constructors */
@@ -78,12 +79,13 @@ construct_device_with_name_ (mix_device_t *result,
result->file = MIX_IOCHANNEL(mix_file_new_with_def_ext (name,
FMODES_[type],
DEV_EXT_));
+ result->vtable = DEF_DEV_VTABLE_;
}
else
{
result->file = mix_io_new (stdout);
+ result->vtable = CONSOLE_DEV_VTABLE_;
}
- result->vtable = DEF_DEV_VTABLE_;
}
@@ -121,6 +123,13 @@ write_ (mix_device_t *dev, const mix_word_t *block)
}
static gboolean
+read_cons_ (mix_device_t *dev, mix_word_t *block)
+{
+ return mix_io_read_word_array_as_char (mix_io_new (stdin), block,
+ SIZES_[mix_dev_CONSOLE]);
+}
+
+static gboolean
read_ (mix_device_t *dev, mix_word_t *block)
{
gboolean result;
@@ -130,14 +139,6 @@ read_ (mix_device_t *dev, mix_word_t *block)
{
result = mix_io_read_word_array_as_char (GET_CHANNEL_ (dev),
block, SIZES_[dev->type]);
- if (result)
- {
- int c;
- FILE *f = mix_io_to_FILE (GET_CHANNEL_ (dev));
- do {
- c = getc (f);
- } while (c != EOF && c != '\n');
- }
}
else
result = mix_io_read_word_array (GET_CHANNEL_ (dev),
@@ -164,12 +165,12 @@ ioc_ (mix_device_t *dev, mix_short_t arg)
}
if (dev->type >= mix_dev_DISK_0 && dev->type <= mix_dev_DISK_7)
{
- g_return_val_if_fail (m == 0, FALSE);
+ if (m == 0) return FALSE;
// position disk
}
if (dev->type == mix_dev_PAPER_TAPE)
{
- g_return_val_if_fail (m == 0, FALSE);
+ if (m == 0) return FALSE;
rewind (file);
}
return TRUE;
@@ -193,3 +194,9 @@ static mix_device_vtable_t VTABLE_ = {
};
const mix_device_vtable_t * DEF_DEV_VTABLE_ = &VTABLE_;
+
+static mix_device_vtable_t CVTABLE_ = {
+ write_, read_cons_, ioc_, busy_, destroy_
+};
+
+const mix_device_vtable_t * CONSOLE_DEV_VTABLE_ = &CVTABLE_;