From 74342aaaa7bf55eddd07f19453f8b75902c07aa1 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Thu, 5 Jul 2001 23:38:41 +0000 Subject: externally provided device files directory --- mixlib/mix_device.c | 19 ++++++++++++++++++- mixlib/mix_device.h | 7 +++++++ mixlib/xmix_device.c | 15 +++++++-------- mixlib/xmix_device.h | 3 +++ 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/mixlib/mix_device.c b/mixlib/mix_device.c index 2f3f702..d40ea98 100644 --- a/mixlib/mix_device.c +++ b/mixlib/mix_device.c @@ -19,10 +19,27 @@ * */ - #include "mix_file.h" #include "xmix_device.h" +/* + Set the directory for mix device files (by default, it's ".") + If the dir does not exist, it is created. +*/ +gboolean +mix_device_set_dir (const gchar *dirname) +{ + if (mix_stat_dir (dirname, "devices")) + { + if (DEV_DIR_) g_free (DEV_DIR_); + DEV_DIR_ = g_strdup (dirname); + return TRUE; + } + else + return FALSE; +} + + mix_device_t * mix_device_new (mix_device_type_t type) { diff --git a/mixlib/mix_device.h b/mixlib/mix_device.h index 7248d72..9f37092 100644 --- a/mixlib/mix_device.h +++ b/mixlib/mix_device.h @@ -69,6 +69,13 @@ typedef enum { mix_dev_CHAR } mix_device_mode_t; +/* + Set the directory for mix device files (by default, it's ".") + If the dir does not exist, it is created. +*/ +extern gboolean +mix_device_set_dir (const gchar *dirname); + /* Create a new device with default name and given type. */ diff --git a/mixlib/xmix_device.c b/mixlib/xmix_device.c index b0ec547..47b6397 100644 --- a/mixlib/xmix_device.c +++ b/mixlib/xmix_device.c @@ -24,6 +24,8 @@ #include "xmix_device.h" +gchar *DEV_DIR_ = NULL; + const char *DEV_EXT_ = ".dev"; const char *DEF_NAMES_[] = { @@ -58,14 +60,11 @@ const mix_fmode_t FMODES_[] = { void construct_device_ (mix_device_t *result, mix_device_type_t type) { - result->type = type; - if (type != mix_dev_CONSOLE) { - result->file = MIX_IOCHANNEL(mix_file_new_with_def_ext (DEF_NAMES_[type], - FMODES_[type], - DEV_EXT_)); - } else - result->file = mix_io_new (stdout); - result->vtable = DEF_DEV_VTABLE_; + gchar *name; + name = DEV_DIR_ ? g_strdup_printf ("%s/%s", DEV_DIR_, DEF_NAMES_[type]) + : g_strdup (DEF_NAMES_[type]); + construct_device_with_name_ (result, type, name); + g_free (name); } diff --git a/mixlib/xmix_device.h b/mixlib/xmix_device.h index f44409f..faa8334 100644 --- a/mixlib/xmix_device.h +++ b/mixlib/xmix_device.h @@ -28,6 +28,9 @@ #include "mix_file.h" #include "mix_device.h" +/* device file directory */ +extern gchar *DEV_DIR_; + /* table of overridable device operations */ typedef gboolean (*mix_dev_write_func_t) (mix_device_t *, const mix_word_t *); typedef gboolean (*mix_dev_read_func_t) (mix_device_t *, mix_word_t *); -- cgit v1.2.3