[MPlayer-G2-dev] Re: g2 config - restart...
Andriy N. Gritsenko
andrej at lucky.net
Wed May 14 18:15:39 CEST 2003
Hi, Arpi!
So I misunderstood whole thing - I thought we were about common API
as for parser as for UIs. So we were speaking about different things, by
different languages almost. ;) Now I've get rid of that misunderstanding
so I could say - you did all I wanted with your level 0. I think it's
enough and I happy. ;)
BTW, did you wrote new config_t and module_info_t structures (I mean
API layer 0) yet? If you didn't then there is a draft here (from yours
API description, of course - you really fine generalized all). :) Also I
typed here some #define because they have values of fields of config_t.
I hope I did all correctly now. :) BTW, I'm not sure if filename must be
in module_info_t - plugin subsystem can have it in internal arrays. That
subsystem anyway has to keep bad filenames list to avoid trying its (in
cache also, I think) further. Bad filenames - if plugins are in plugin's
subdirectory but are not plugins or have incompatible version.
------------------------- begin of cfg.h
#ifndef __CFG_H
#define __CFG_H 1
typedef struct {
char *name;
void *p; /* variable pointer, type specific */
int type;
unsigned int flags;
float min, max; /* 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 char version[4]; // { PLUGIN_VERSION_MAJOR, PLUGIN_VERSION_MINOR, 'M', 'P' }
int type; // for loadable module identification
char *name;
char *desc; // short description for help and gui
char *maintainer;
char *author;
char *comment;
config_t *opts;
void *param_defaults;
size_t *param_size;
char *filename; // filled by plugin subsystem, NULL for internal
} module_info_t;
/* type (menu field) ->p ->min ->max ->priv */
enum {
// flag (checkbox) int* reset set -
CONF_TYPE_FLAG=0,
// 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 -
CONF_TYPE_STRING,
// string as list - must be obsoleted to CONF_TYPE_LIST
CONF_TYPE_STRING_LIST,
// function cfg_func* - - revert-cfg_func*
CONF_TYPE_FUNC,
CONF_TYPE_FUNC_PARAM,
CONF_TYPE_FUNC_FULL,
// text (none) char** - - -
CONF_TYPE_PRINT,
/*
all below this have
->priv as config_t*
*/
// subconfig (dialog) - - - config_t*
CONF_TYPE_SUBCONFIG,
// choose list char** - length config_t*
CONF_TYPE_CHOOSE,
// select list char*** - - config_t*
CONF_TYPE_LIST,
// config group (sep.) - - - config_t*
CONF_TYPE_DUMMY
};
/* these macros are very useful for parsers or UI */
#define CONF_TYPE_HAS_CHILD(x) (x>=CONF_TYPE_SUBCONFIG)
#define CONF_TYPE_ALLOW_WILDCARD(x) (x==CONF_TYPE_LIST||x==CONF_TYPE_CHAIN||x==CONF_TYPE_FUNC_FULL)
#define CONF_NUM_TYPES (CONF_TYPE_DUMMY+1)
/* flags for options */
#define CONF_MIN (1<<0)
#define CONF_MAX (1<<1)
#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 is global : it won't be saved and only the command line
// parser will set it when it's parsed (ie. it won't be set later)
// e.g options : -v, -quiet
#define CONF_GLOBAL (1<<4)
// Do not save this option : it won't be saved on config save
// or by UI on context change
#define CONF_NOSAVE (1<<5)
// This subconfig has unnamed parameters list (i.e. 0.3:-1:-1 for example)
// It looks like a regular subconfig but different in parsing a bit
#define CONF_SEQUENT (1<<6)
// It used for lists to reverse order of arguments in char***
#define CONF_REVERSE (1<<7)
/* macro to get relative address of x.y in struct x */
#define STRUCT_OFF(x,y) ((void *)(&x.y-x))
#endif /* __CFG_H */
------------------------- end of cfg.h
With best wishes.
Andriy.
More information about the MPlayer-G2-dev
mailing list