summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Caujolle-Bert <f1rmb@users.sourceforge.net>2001-11-30 21:55:05 +0000
committerDaniel Caujolle-Bert <f1rmb@users.sourceforge.net>2001-11-30 21:55:05 +0000
commite83128d4e0e1882a53943c2df3f7e64885223a3a (patch)
treeedf1e49f9b1af43e9018bed75b596457b759262b /src
parent917fa5603cb9fa67c224846bcbf34bce4a8baa75 (diff)
downloadxine-lib-e83128d4e0e1882a53943c2df3f7e64885223a3a.tar.gz
xine-lib-e83128d4e0e1882a53943c2df3f7e64885223a3a.tar.bz2
Add an automatic way for input plugin to add extra valid mrls:
add at bottom of init_input_plugin() a line like this: REGISTER_VALID_MRLS(this->config, "mrl.mrls_mpeg_block", "xxx"); CVS patchset: 1147 CVS date: 2001/11/30 21:55:05
Diffstat (limited to 'src')
-rw-r--r--src/demuxers/demux_mpeg_block.c4
-rw-r--r--src/input/input_plugin.h36
-rw-r--r--src/xine-engine/configfile.c58
-rw-r--r--src/xine-engine/configfile.h11
4 files changed, 99 insertions, 10 deletions
diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c
index 8f4639b59..154c33464 100644
--- a/src/demuxers/demux_mpeg_block.c
+++ b/src/demuxers/demux_mpeg_block.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_mpeg_block.c,v 1.65 2001/11/30 00:53:51 f1rmb Exp $
+ * $Id: demux_mpeg_block.c,v 1.66 2001/11/30 21:55:05 f1rmb Exp $
*
* demultiplexer for mpeg 1/2 program streams
*
@@ -38,7 +38,7 @@
#include "xineutils.h"
#include "demux.h"
-#define VALID_MRLS "dvd,stdin,fifo,d4d,dmd"
+#define VALID_MRLS "dvd,stdin,fifo"
#define VALID_ENDS "vob"
#define NUM_PREVIEW_BUFFERS 250
diff --git a/src/input/input_plugin.h b/src/input/input_plugin.h
index eb9a597c3..f14edf5ab 100644
--- a/src/input/input_plugin.h
+++ b/src/input/input_plugin.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: input_plugin.h,v 1.16 2001/10/22 22:50:01 richwareham Exp $
+ * $Id: input_plugin.h,v 1.17 2001/11/30 21:55:05 f1rmb Exp $
*/
#ifndef HAVE_INPUT_PLUGIN_H
@@ -140,6 +140,40 @@ extern void *xmalloc(size_t);
} \
}
+#define REGISTER_VALID_MRLS(config, mrltype, mrls) { \
+ cfg_entry_t *entry; \
+ char *sticky; \
+ char *v_mrls; \
+ char *a_def = NULL; \
+ \
+ (config)->register_empty((config), (mrltype)); \
+ entry = (config)->lookup_entry((config), (mrltype)); \
+ \
+ sticky = entry->str_sticky; \
+ v_mrls = (entry->str_value) ? entry->str_value : entry->unknown_value; \
+ \
+ if(v_mrls) { \
+ a_def = strstr(v_mrls, (mrls)); \
+ if(a_def) \
+ goto __done; \
+ } \
+ \
+ if(!sticky) { \
+ sticky = (char *) xine_xmalloc(strlen((mrls)) + 2); \
+ sprintf(sticky, ",%s", (mrls)); \
+ entry->str_sticky = sticky; \
+ } \
+ else { \
+ a_def = strstr(sticky, (mrls)); \
+ if(!a_def) { \
+ sticky = (char *) realloc(sticky, strlen((mrls)) + 2); \
+ sprintf(sticky, "%s,%s", sticky, (mrls)); \
+ } \
+ } \
+__done: \
+}
+
+
typedef struct {
char *origin; /* Origin of grabbed mrls (eg: path for file plugin */
char *mrl; /* <type>://<location> */
diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c
index 86c775147..abde13c37 100644
--- a/src/xine-engine/configfile.c
+++ b/src/xine-engine/configfile.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: configfile.c,v 1.11 2001/11/20 19:13:28 guenter Exp $
+ * $Id: configfile.c,v 1.12 2001/11/30 21:55:06 f1rmb Exp $
*
* config file management - implementation
*
@@ -67,6 +67,7 @@ static cfg_entry_t *config_file_add (config_values_t *this, char *key) {
entry->config = this;
entry->key = copy_string (key);
entry->type = CONFIG_TYPE_UNKNOWN;
+ entry->str_sticky = NULL;
entry->next = NULL;
@@ -99,6 +100,28 @@ cfg_entry_t *config_file_lookup_entry (config_values_t *this, char *key) {
return entry;
}
+
+static void config_file_register_empty (config_values_t *this, char *key) {
+ cfg_entry_t *entry;
+
+ assert(key);
+
+#ifdef CONFIG_LOG
+ printf ("configfile: register empty %s\n", key);
+#endif
+
+ entry = config_file_lookup_entry (this, key);
+
+ /*
+ * Don't register as empty if entry already exist.
+ */
+ if(entry)
+ return;
+
+ entry = config_file_add (this, key);
+}
+
+
static char *config_file_register_string (config_values_t *this,
char *key, char *def_value,
char *description,
@@ -127,18 +150,35 @@ static char *config_file_register_string (config_values_t *this,
/* convert entry to string type if necessary */
if (entry->type != CONFIG_TYPE_STRING) {
- entry->type = CONFIG_TYPE_STRING;
- entry->str_value = entry->unknown_value;
+ entry->type = CONFIG_TYPE_STRING;
+ /*
+ * if there is no unknown_value (made with register_empty) set
+ * it to default value
+ */
+ if(!entry->unknown_value)
+ entry->unknown_value = strdup(def_value);
+
+ /*
+ * Check for sticky string
+ */
+ if(entry->str_sticky) {
+ entry->str_value = (char *) xine_xmalloc(strlen(entry->unknown_value) +
+ strlen(entry->str_sticky) + 1);
+ sprintf(entry->str_value, "%s%s", entry->unknown_value, entry->str_sticky);
+ }
+ else
+ entry->str_value = entry->unknown_value;
+
}
-
+
/* fill out rest of struct */
-
+
entry->str_default = copy_string(def_value);
entry->description = description;
entry->help = help;
entry->callback = changed_cb;
entry->callback_data = cb_data;
-
+
return entry->str_value;
}
@@ -554,6 +594,7 @@ config_values_t *config_file_init (char *filename) {
exit (1);
}
+ this->register_empty = config_file_register_empty;
this->register_string = config_file_register_string;
this->register_range = config_file_register_range;
this->register_enum = config_file_register_enum;
@@ -572,6 +613,11 @@ config_values_t *config_file_init (char *filename) {
/*
* $Log: configfile.c,v $
+ * Revision 1.12 2001/11/30 21:55:06 f1rmb
+ * Add an automatic way for input plugin to add extra valid mrls:
+ * add at bottom of init_input_plugin() a line like this:
+ * REGISTER_VALID_MRLS(this->config, "mrl.mrls_mpeg_block", "xxx");
+ *
* Revision 1.11 2001/11/20 19:13:28 guenter
* add more checks against incorrect configfile usage
*
diff --git a/src/xine-engine/configfile.h b/src/xine-engine/configfile.h
index 60ac2a4f5..4085098b8 100644
--- a/src/xine-engine/configfile.h
+++ b/src/xine-engine/configfile.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: configfile.h,v 1.5 2001/11/20 17:22:14 miguelfreitas Exp $
+ * $Id: configfile.h,v 1.6 2001/11/30 21:55:06 f1rmb Exp $
*
* config file management
*
@@ -50,6 +50,7 @@ struct cfg_entry_s {
/* type string */
char *str_value;
char *str_default;
+ char *str_sticky;
/* common to range, enum, num, bool: */
@@ -94,6 +95,9 @@ struct config_values_s {
* from the config file otherwise
*/
+ void (*register_empty) (config_values_t *this,
+ char *key);
+
char* (*register_string) (config_values_t *this,
char *key,
char *def_value,
@@ -187,6 +191,11 @@ config_values_t *config_file_init (char *filename);
/*
* $Log: configfile.h,v $
+ * Revision 1.6 2001/11/30 21:55:06 f1rmb
+ * Add an automatic way for input plugin to add extra valid mrls:
+ * add at bottom of init_input_plugin() a line like this:
+ * REGISTER_VALID_MRLS(this->config, "mrl.mrls_mpeg_block", "xxx");
+ *
* Revision 1.5 2001/11/20 17:22:14 miguelfreitas
* testing some configfile stuff...
*