Skip to content

Commit

Permalink
Removed the historic cfgparser and switched full to the new config pa…
Browse files Browse the repository at this point in the history
…rser (altought some macros still remain for compatibility). As a side effect 90% of the warning messages are gone from the core. Things should be cleaner now and less confusing for newbies.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10595 b3059339-0415-0410-9bf9-f77b7e298cf2
  • Loading branch information
alex committed Aug 13, 2003
1 parent 7dadaf5 commit 2283b63
Show file tree
Hide file tree
Showing 35 changed files with 109 additions and 2,003 deletions.
32 changes: 4 additions & 28 deletions Gui/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#include "../config.h"
#include "../mp_msg.h"
#include "../mplayer.h"
#include "../cfgparser.h"
#include "../m_config.h"
#include "../m_option.h"

#ifdef USE_SETLOCALE
#include <locale.h>
Expand Down Expand Up @@ -73,7 +74,7 @@ extern int frame_dropping;
extern int stop_xscreensaver;

static m_config_t * gui_conf;
static config_t gui_opts[] =
static m_option_t gui_opts[] =
{
{ "enable_audio_equ",&gtkEnableAudioEqualizer,CONF_TYPE_FLAG,0,0,1,NULL },

Expand Down Expand Up @@ -199,11 +200,7 @@ int cfg_read( void )

// -- read configuration
mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[cfg] read config file: %s\n",cfg );
gui_conf=m_config_new(
#ifndef NEW_CONFIG
play_tree_new()
#endif
);
gui_conf=m_config_new();
m_config_register_options( gui_conf,gui_opts );
if ( m_config_parse_config_file( gui_conf,cfg ) < 0 )
{
Expand Down Expand Up @@ -283,33 +280,12 @@ int cfg_write( void )
{
for ( i=0;gui_opts[i].name;i++ )
{
#ifdef NEW_CONFIG
char* v = m_option_print(&gui_opts[i],gui_opts[i].p);
if(v) {
fprintf( f,"%s = \"%s\"\n",gui_opts[i].name, v);
free(v);
} else if((int)v == -1)
mp_msg(MSGT_GPLAYER,MSGL_WARN,"Unable to save the %s option\n");
#else
switch ( gui_opts[i].type )
{
case CONF_TYPE_INT:
case CONF_TYPE_FLAG: fprintf( f,"%s = %d\n",gui_opts[i].name,*( (int *)gui_opts[i].p ) ); break;
case CONF_TYPE_FLOAT: fprintf( f,"%s = %f\n",gui_opts[i].name,*( (float *)gui_opts[i].p ) ); break;
case CONF_TYPE_STRING:
{
char * tmp = *( (char **)gui_opts[i].p );
if ( tmp && tmp[0] ) fprintf( f,"%s = \"%s\"\n",gui_opts[i].name,tmp );
break;
}
case CONF_TYPE_STRING_LIST:
{
char ** tmp = *( (char ***)gui_opts[i].p );
if ( tmp && tmp[0] && tmp[0][0] ) fprintf( f,"%s = \"%s\"\n",gui_opts[i].name,tmp[0] );
break;
}
}
#endif
}
fclose( f );
}
Expand Down
10 changes: 2 additions & 8 deletions Gui/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,8 @@
#include "../libmpdemux/stheader.h"
#include "../libmpcodecs/dec_video.h"


#ifdef NEW_CONFIG
#include "../m_option.h"
#include "../m_config.h"
#else
#include "../cfgparser.h"
#endif
#include "../cfg-mplayer-def.h"
#include "../m_config.h"
#include "../m_option.h"

guiInterface_t guiIntfStruct;
int guiWinID=-1;
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SUBDIRS += libdha vidix
DO_MAKE = @ for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done
endif

SRCS_COMMON = cpudetect.c codec-cfg.c cfgparser.c spudec.c playtree.c playtreeparser.c asxparser.c vobsub.c subreader.c sub_cc.c find_sub.c m_config.c m_option.c parser-cfg.c m_struct.c
SRCS_COMMON = cpudetect.c codec-cfg.c spudec.c playtree.c playtreeparser.c asxparser.c vobsub.c subreader.c sub_cc.c find_sub.c m_config.c m_option.c parser-cfg.c m_struct.c
SRCS_MENCODER = mencoder.c mp_msg-mencoder.c $(SRCS_COMMON) libao2/afmt.c divx4_vbr.c libvo/aclib.c libvo/osd.c libvo/sub.c libvo/font_load.c libvo/font_load_ft.c xvid_vbr.c parser-mecmd.c
SRCS_MPLAYER = mplayer.c mp_msg.c $(SRCS_COMMON) mixer.c parser-mpcmd.c

Expand Down
22 changes: 12 additions & 10 deletions cfg-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ extern int network_ipv4_only_proxy;

/* defined in libmpdemux: */
extern int hr_mp3_seek;
extern config_t demux_rawaudio_opts[];
extern config_t demux_rawvideo_opts[];
extern config_t cdda_opts[];
extern m_option_t demux_rawaudio_opts[];
extern m_option_t demux_rawvideo_opts[];
extern m_option_t cdda_opts[];

extern char* audio_stream;
extern char* sub_stream;
Expand All @@ -283,7 +283,7 @@ extern char* edl_output_filename;
#endif

#ifdef USE_TV
struct config tvopts_conf[]={
m_option_t tvopts_conf[]={
{"on", "-tv on is deprecated, use tv:// instead\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
#ifdef HAVE_TV_BSDBT848
{"immediatemode", &tv_param_immediate, CONF_TYPE_FLAG, 0, 0, 0, NULL},
Expand Down Expand Up @@ -345,7 +345,7 @@ extern float sws_lum_gblur;
extern float sws_chr_sharpen;
extern float sws_lum_sharpen;

struct config scaler_filter_conf[]={
m_option_t scaler_filter_conf[]={
{"lgb", &sws_lum_gblur, CONF_TYPE_FLOAT, 0, 0, 100.0, NULL},
{"cgb", &sws_chr_gblur, CONF_TYPE_FLOAT, 0, 0, 100.0, NULL},
{"cvs", &sws_chr_vshift, CONF_TYPE_INT, 0, 0, 0, NULL},
Expand All @@ -366,7 +366,7 @@ extern int vivo_param_height;
extern int vivo_param_vformat;
extern char *dvd_device, *cdrom_device;

struct config vivoopts_conf[]={
m_option_t vivoopts_conf[]={
{"version", &vivo_param_version, CONF_TYPE_INT, 0, 0, 0, NULL},
/* audio options */
{"acodec", &vivo_param_acodec, CONF_TYPE_STRING, 0, 0, 0, NULL},
Expand All @@ -387,7 +387,7 @@ extern char * mf_type;
extern m_obj_settings_t* vf_settings;
extern m_obj_list_t vf_obj_list;

struct config mfopts_conf[]={
m_option_t mfopts_conf[]={
{"on", "-mf on is deprecated, use mf://files instead\n", CONF_TYPE_PRINT, 0, 0, 1, NULL},
{"w", &mf_w, CONF_TYPE_INT, 0, 0, 0, NULL},
{"h", &mf_h, CONF_TYPE_INT, 0, 0, 0, NULL},
Expand All @@ -400,18 +400,20 @@ extern m_obj_settings_t* vo_plugin_args;

#include "libaf/af.h"
extern af_cfg_t af_cfg; // Audio filter configuration, defined in libmpcodecs/dec_audio.c
struct config audio_filter_conf[]={
m_option_t audio_filter_conf[]={
{"list", &af_cfg.list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
{"force", &af_cfg.force, CONF_TYPE_INT, CONF_RANGE, 0, 7, NULL},
{NULL, NULL, 0, 0, 0, 0, NULL}
};

#ifdef USE_LIBAVCODEC
extern struct config lavc_decode_opts_conf[];
extern m_option_t lavc_decode_opts_conf[];
#endif

#ifdef HAVE_XVID
extern struct config xvid_dec_opts[];
extern m_option_t xvid_dec_opts[];
#endif

int dvd_parse_chapter_range(m_option_t*, const char*);

#endif
22 changes: 11 additions & 11 deletions cfg-mencoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ extern void revertPPOpt(void *conf, char* opt);
extern char *pp_help;

#ifdef HAVE_DIVX4ENCORE
extern struct config divx4opts_conf[];
extern m_option_t divx4opts_conf[];
#endif

#ifdef HAVE_MP3LAME
struct config lameopts_conf[]={
m_option_t lameopts_conf[]={
{"q", &lame_param_quality, CONF_TYPE_INT, CONF_RANGE, 0, 9, NULL},
{"aq", &lame_param_algqual, CONF_TYPE_INT, CONF_RANGE, 0, 9, NULL},
{"vbr", &lame_param_vbr, CONF_TYPE_INT, CONF_RANGE, 0, vbr_max_indicator, NULL},
Expand All @@ -45,20 +45,20 @@ struct config lameopts_conf[]={
#endif

#ifdef USE_LIBAVCODEC
extern struct config lavcopts_conf[];
extern m_option_t lavcopts_conf[];
#endif

#ifdef USE_WIN32DLL
extern struct config vfwopts_conf[];
extern m_option_t vfwopts_conf[];
#endif

#ifdef HAVE_XVID
extern struct config xvidencopts_conf[];
extern m_option_t xvidencopts_conf[];
#endif

extern struct config nuvopts_conf[];
extern m_option_t nuvopts_conf[];

struct config ovc_conf[]={
m_option_t ovc_conf[]={
{"copy", &out_video_codec, CONF_TYPE_FLAG, 0, 0, VCODEC_COPY, NULL},
{"frameno", &out_video_codec, CONF_TYPE_FLAG, 0, 0, VCODEC_FRAMENO, NULL},
{"divx4", &out_video_codec, CONF_TYPE_FLAG, 0, 0, VCODEC_DIVX4, NULL},
Expand Down Expand Up @@ -99,7 +99,7 @@ struct config ovc_conf[]={
{NULL, NULL, 0, 0, 0, 0, NULL}
};

struct config oac_conf[]={
m_option_t oac_conf[]={
{"copy", &out_audio_codec, CONF_TYPE_FLAG, 0, 0, ACODEC_COPY, NULL},
{"pcm", &out_audio_codec, CONF_TYPE_FLAG, 0, 0, ACODEC_PCM, NULL},
#ifdef HAVE_MP3LAME
Expand All @@ -117,7 +117,7 @@ struct config oac_conf[]={
{NULL, NULL, 0, 0, 0, 0, NULL}
};

struct config info_conf[]={
m_option_t info_conf[]={
{"name", &info_name, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"artist", &info_artist, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"genre", &info_genre, CONF_TYPE_STRING, 0, 0, 0, NULL},
Expand All @@ -137,7 +137,7 @@ struct config info_conf[]={
{NULL, NULL, 0, 0, 0, 0, NULL}
};

struct config of_conf[]={
m_option_t of_conf[]={
{"avi", &out_file_format, CONF_TYPE_FLAG, 0, 0, MUXER_TYPE_AVI, NULL},
{"mpeg", &out_file_format, CONF_TYPE_FLAG, 0, 0, MUXER_TYPE_MPEG, NULL},
{"help", "\nAvailable output formats:\n"
Expand All @@ -147,7 +147,7 @@ struct config of_conf[]={
{NULL, NULL, 0, 0, 0, 0, NULL}
};

static config_t mencoder_opts[]={
m_option_t mencoder_opts[]={
/* name, pointer, type, flags, min, max */
{"include", cfg_include, CONF_TYPE_FUNC_PARAM, CONF_NOSAVE, 0, 0, NULL}, /* this must be the first!!! */

Expand Down
16 changes: 8 additions & 8 deletions cfg-mplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ extern char **vo_fstype_list;
#endif

#ifdef HAVE_AA
extern int vo_aa_parseoption(struct config * conf, char *opt, char * param);
extern void vo_aa_revertoption(config_t* opt,char* param);
extern int vo_aa_parseoption(m_option_t* conf, char *opt, char * param);
extern void vo_aa_revertoption(m_option_t* opt,char* param);
#endif

#ifdef HAVE_ZR
extern int vo_zr_parseoption(struct config * conf, char *opt, char * param);
extern void vo_zr_revertoption(config_t* opt,char* pram);
extern int vo_zr_parseoption(m_option_t* conf, char *opt, char * param);
extern void vo_zr_revertoption(m_option_t* opt,char* pram);
#endif

#ifdef HAVE_DXR2
extern config_t dxr2_opts[];
extern m_option_t dxr2_opts[];
#endif

#ifdef STREAMING_LIVE_DOT_COM
Expand Down Expand Up @@ -126,7 +126,7 @@ extern int nortc;
extern float monitor_aspect;

/* Options related to audio out plugins */
struct config ao_plugin_conf[]={
m_option_t ao_plugin_conf[]={
{"list", &ao_plugin_cfg.plugin_list, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"delay", &ao_plugin_cfg.pl_delay_len, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
{"format", &ao_plugin_cfg.pl_format_type, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
Expand All @@ -138,7 +138,7 @@ struct config ao_plugin_conf[]={
};

#ifdef HAVE_JPEG
struct config jpeg_conf[]={
m_option_t jpeg_conf[]={
{"progressive", &jpeg_progressive_mode, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"noprogressive", &jpeg_progressive_mode, CONF_TYPE_FLAG, 0, 1, 0, NULL},
{"baseline", &jpeg_baseline, CONF_TYPE_FLAG, 0, 0, 1, NULL},
Expand Down Expand Up @@ -169,7 +169,7 @@ extern char* pp_help;
* by Folke
*/

static config_t mplayer_opts[]={
m_option_t mplayer_opts[]={
/* name, pointer, type, flags, min, max */
{"include", cfg_include, CONF_TYPE_FUNC_PARAM, CONF_NOSAVE, 0, 0, NULL}, /* this don't need anymore to be the first!!! */

Expand Down
Loading

0 comments on commit 2283b63

Please sign in to comment.