cfg.h (config layer 0 discussion)

Arpi <[email protected]>
Newsgroups gmane.comp.video.mplayer.g2.devel
Message-ID <[email protected]>
Hi,

Here's an updated/modified/extended/stipped :) version of Andriy's cfg.h:


#ifndef __CFG_H
#define __CFG_H 1


/* type (menu field)	->p		->min	->max	->priv */
typedef enum {
// flag (checkbox)	int*		reset	set	-
  CONF_TYPE_FLAG=1,
// integer (slider)	int*		min	max	-
  CONF_TYPE_INT,
// float (slider)	float*		min	max	-
  CONF_TYPE_FLOAT,
// position (slider)	off_t*		min	max	-
  CONF_TYPE_POSITION,
// string (input box)	char**		min	max	- (min/max length)
  CONF_TYPE_STRING,
// select list (combobox)  int*		-	-	config_select_list_t*
  CONF_TYPE_SELECT,
// string list          char***         min     max     - (min/max nr. of strings)
// (comma-seperated list of strings, to be parsed later or to pass ordered list of strings)
  CONF_TYPE_STRING_LIST,
// function		void*		arg1	arg2	(*parser_func)(void*,arg1,arg2)
// (custom parser func for 3rd party plugins or special applications)
  CONF_TYPE_FUNC,
// removed option	-		-	-	-
// (removed option, parser should fail with error, with message from *desc, gui should ignore this)
  CONF_TYPE_OBSOLETE,
// group separator	-		-	-	config_group_info_t*
// (this is NOT a real option, but an option group definition, for gui use)
  CONF_TYPE_GROUP,
//*** this is not a valid type, but the number of types:
  CONF_TYPE_MAX
} config_type_t;

typedef struct {
  int value;
  char* name;
  char* desc;
} config_select_list_t;

typedef struct {
  // TODO!!!!
  int dummy;
} config_group_info_t;

/* flags for options */
// 'min' value is given in config_t
#define CONF_MIN		(1<<0)
// 'max' value is given in config_t
#define CONF_MAX		(1<<1)
// both 'min' and 'max' value is given in config_t
#define CONF_RANGE		(CONF_MIN|CONF_MAX)
// This option cannot be in config file
#define CONF_NOCFG		(1<<2)
// This option cannot be in command line
#define CONF_NOCMD		(1<<3)
// This option cannot (shouldn't) be visible in gui:
#define CONF_NOGUI		(1<<4)
// This option can be used without explicit naming:
#define CONF_UNNAMED		(1<<5)

typedef struct {
  char *name;
  void *p; /* pointer to variable where store result to, type specific */
  config_type_t type;
  unsigned int flags;
  float min, max; /* valid range */
  void *priv; /* additional pointer, type specific */
  char *desc; /* short description for help and gui */
} config_t;

/* note: version has to be first in ModuleInfo struct in loadable module
   to allow us always do validation/version check of module */
typedef struct {
  unsigned short type, version; // for loadable plugins
  char *name;
  char *desc; // short description for commandline help and gui
  char *maintainer;
  char *author;
  char *comment;
  config_t *config;
  void *config_defaults;
  int  *config_size;
//  void *handle;
} module_info_t;

#endif /* __CFG_H */

Any questions/suggestions?
(I've tried to apply the ideas/comments from that thread)

Problem:
we should store some reference inside the module_info_t struct to the
actual module entry point (maybe the addess of the open() func? or the
functions_t struct? do we need to store dlopen() handle there?)

I'm trying to avoid the unification of all layer's API, but maybe we should
decide between the open()-only (vo2, vf) and functions_t (ao2, ad, vd) style,
and convert the looser.


A'rpi / Astral & ESP-team

--
Developer of MPlayer G2, the Movie Framework for all - http://www.MPlayerHQ.hu
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.