changeset 153:8e55121885b2

new configfile/cmdline parser
author arpi_esp
date Mon, 19 Mar 2001 03:45:49 +0000
parents 372a9a836e86
children 34e9f41cce6d
files cfg-mplayer-def.h cfg-mplayer.h cfgparser.c cfgparser.h mplayer.c mplayerHQ.c
diffstat 6 files changed, 49 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-mplayer-def.h	Mon Mar 19 02:29:37 2001 +0000
+++ b/cfg-mplayer-def.h	Mon Mar 19 03:45:49 2001 +0000
@@ -1,4 +1,6 @@
 static char* default_config=
-"nosound=nem"
+"# Write your default config options here!\n"
+"\n"
+//"nosound=nem"
 "\n";
 
--- a/cfg-mplayer.h	Mon Mar 19 02:29:37 2001 +0000
+++ b/cfg-mplayer.h	Mon Mar 19 03:45:49 2001 +0000
@@ -2,46 +2,50 @@
  * config for cfgparser
  */
 
-#include "cfg-mplayer-func.h"
-
 struct config conf[]={
 	/* name, pointer, type, flags, min, max */
+	{"o", "Option -o has been renamed to -vo (video-out), use -vo !\n",
+            CONF_TYPE_PRINT, CONF_NOCFG, 0, 0},
 	{"vo", &video_driver, CONF_TYPE_STRING, 0, 0, 0},
 	{"dsp", &dsp, CONF_TYPE_STRING, 0, 0, 0},
 	{"encode", &encode_name, CONF_TYPE_STRING, 0, 0, 0},
 	{"bg", &play_in_bg, CONF_TYPE_FLAG, 0, 0, 1},
 	{"nobg", &play_in_bg, CONF_TYPE_FLAG, 0, 1, 0},
-	{"sb", &seek_to_byte, CONF_TYPE_INT, 0, 0, 0},
-	{"ss", &seek_to_sec, CONF_TYPE_INT, 0, 0, 0},
+	{"sb", &seek_to_byte, CONF_TYPE_INT, CONF_MIN, 0, 0},
+	{"ss", &seek_to_sec, CONF_TYPE_INT, CONF_MIN, 0, 0},
 	{"sound", &has_audio, CONF_TYPE_FLAG, 0, 0, 1},
 	{"nosound", &has_audio, CONF_TYPE_FLAG, 0, 1, 0},
-	{"abs", &audio_buffer_size, CONF_TYPE_INT, 0, 0, 0},
-	{"delay", &audio_delay, CONF_TYPE_FLOAT, 0, 0, 0},
+	{"abs", &audio_buffer_size, CONF_TYPE_INT, CONF_MIN, 0, 0},
+	{"delay", &audio_delay, CONF_TYPE_FLOAT, CONF_RANGE, -10.0, 10.0},
 	{"bps", &pts_from_bps, CONF_TYPE_FLAG, 0, 0, 1},
 	{"nobps", &pts_from_bps, CONF_TYPE_FLAG, 0, 1, 0},
 	{"alsa", &alsa, CONF_TYPE_FLAG, 0, 0, 1},
 	{"noalsa", &alsa, CONF_TYPE_FLAG, 0, 1, 0},
 	{"ni", &force_ni, CONF_TYPE_FLAG, 0, 0, 1},
 	{"noni", &force_ni, CONF_TYPE_FLAG, 0, 1, 0},
-	{"aid", &audio_id, CONF_TYPE_INT, 0, 0, 0},
-	{"vid", &video_id, CONF_TYPE_INT, 0, 0, 0},
+	{"aid", &audio_id, CONF_TYPE_INT, CONF_RANGE, 0, 256},
+	{"vid", &video_id, CONF_TYPE_INT, CONF_RANGE, 0, 256},
 	{"auds", &avi_header.audio_codec, CONF_TYPE_STRING, 0, 0, 0},
 	{"vids", &avi_header.video_codec, CONF_TYPE_STRING, 0, 0, 0},
-	{"mc", &default_max_pts_correction, CONF_TYPE_FLOAT, 0, 0, 0},
-	{"fps", &force_fps, CONF_TYPE_FLOAT, 0, 0, 0},
-	{"afm", &audio_format, CONF_TYPE_INT, 0, 0, 0},
-	{"vcd", &vcd_track, CONF_TYPE_INT, 0, 0, 0},
-	{"pp", &divx_quality, CONF_TYPE_INT, 0, 0, 0},
-	{"br", &encode_bitrate, CONF_TYPE_INT, 0, 0, 0},
-	{"x", &screen_size_x, CONF_TYPE_INT, 0, 0, 0},
-	{"y", &screen_size_y, CONF_TYPE_INT, 0, 0, 0},
-	{"xy", &screen_size_xy, CONF_TYPE_INT, 0, 0, 0},
+	{"mc", &default_max_pts_correction, CONF_TYPE_FLOAT, CONF_RANGE, 0, 10},
+	{"fps", &force_fps, CONF_TYPE_FLOAT, CONF_MIN, 0, 0},
+	{"afm", &audio_format, CONF_TYPE_INT, CONF_RANGE, 1, 6},
+	{"vcd", &vcd_track, CONF_TYPE_INT, CONF_RANGE, 1, 99},
+	{"divxq", "Option -divxq has been renamed to -pp (postprocessing), use -pp !\n",
+            CONF_TYPE_PRINT, 0, 0, 0},
+	{"pp", &divx_quality, CONF_TYPE_INT, CONF_RANGE, 0, 63},
+	{"br", &encode_bitrate, CONF_TYPE_INT, CONF_RANGE, 10000, 10000000},
+	{"x", &screen_size_x, CONF_TYPE_INT, CONF_RANGE, 1, 4096},
+	{"y", &screen_size_y, CONF_TYPE_INT, CONF_RANGE, 1, 4096},
+	{"xy", &screen_size_xy, CONF_TYPE_INT, CONF_RANGE, 1, 4096},
 	{"fs", &fullscreen, CONF_TYPE_FLAG, 0, 0, 1},
 	{"nofs", &fullscreen, CONF_TYPE_FLAG, 0, 1, 0},
 	{"idx", &no_index, CONF_TYPE_FLAG, 0, 1, 0},
 	{"noidx", &no_index, CONF_TYPE_FLAG, 0, 0, 1},
-	{"v", &verbose, CONF_TYPE_INT, 0, 0, 0},
-	{"-help", cfg_func_help, CONF_TYPE_FUNC, CONF_NOCFG, 0, 0},
-	{"h", cfg_func_help, CONF_TYPE_FUNC, CONF_NOCFG, 0, 0},
+	{"verbose", &verbose, CONF_TYPE_INT, CONF_RANGE, 0, 100},
+	{"v", cfg_inc_verbose, CONF_TYPE_FUNC, 0, 0, 0},
+	{"-help", help_text, CONF_TYPE_PRINT, CONF_NOCFG, 0, 0},
+	{"help", help_text, CONF_TYPE_PRINT, CONF_NOCFG, 0, 0},
+	{"h", help_text, CONF_TYPE_PRINT, CONF_NOCFG, 0, 0},
 	{NULL, NULL, 0, 0, 0, 0}
 };
--- a/cfgparser.c	Mon Mar 19 02:29:37 2001 +0000
+++ b/cfgparser.c	Mon Mar 19 03:45:49 2001 +0000
@@ -103,11 +103,11 @@
 
 			tmp_int = atoi(param);
 
-			if (config[i].flags & CONF_CHK_MIN)
+			if (config[i].flags & CONF_MIN)
 				if (tmp_int < config[i].min)
 					return ERR_OUT_OF_RANGE;
 
-			if (config[i].flags & CONF_CHK_MAX)
+			if (config[i].flags & CONF_MAX)
 				if (tmp_int > config[i].max)
 					return ERR_OUT_OF_RANGE;
 
@@ -122,11 +122,11 @@
 
 			tmp_float = atof(param);
 
-			if (config[i].flags & CONF_CHK_MIN)
+			if (config[i].flags & CONF_MIN)
 				if (tmp_float < config[i].min)
 					return ERR_OUT_OF_RANGE;
 
-			if (config[i].flags & CONF_CHK_MAX)
+			if (config[i].flags & CONF_MAX)
 				if (tmp_float > config[i].max)
 					return ERR_OUT_OF_RANGE;
 
@@ -137,11 +137,11 @@
 			if (param == NULL)
 				return ERR_MISSING_PARAM;
 
-			if (config[i].flags & CONF_CHK_MIN)
+			if (config[i].flags & CONF_MIN)
 				if (strlen(param) < config[i].min)
 					return ERR_OUT_OF_RANGE;
 
-			if (config[i].flags & CONF_CHK_MAX)
+			if (config[i].flags & CONF_MAX)
 				if (strlen(param) > config[i].max)
 					return ERR_OUT_OF_RANGE;
 
--- a/cfgparser.h	Mon Mar 19 02:29:37 2001 +0000
+++ b/cfgparser.h	Mon Mar 19 03:45:49 2001 +0000
@@ -13,8 +13,9 @@
 #define CONF_TYPE_FUNC_PARAM	5
 #define CONF_TYPE_PRINT		6
 
-#define CONF_CHK_MIN		(1<<0)
-#define CONF_CHK_MAX		(1<<1)
+#define CONF_MIN		(1<<0)
+#define CONF_MAX		(1<<1)
+#define CONF_RANGE		(CONF_MIN|CONF_MAX)
 #define CONF_NOCFG		(1<<2)
 #define CONF_NOCMD		(1<<3)
 
--- a/mplayer.c	Mon Mar 19 02:29:37 2001 +0000
+++ b/mplayer.c	Mon Mar 19 03:45:49 2001 +0000
@@ -79,6 +79,11 @@
 #define DEBUG if(0)
 static int verbose=0;
 
+static int cfg_inc_verbose(struct config *conf){
+    ++verbose;
+    return 0;
+}
+
 static int max_framesize=0;
 
 static int dbg_es_sent=0;
@@ -312,16 +317,6 @@
   exit_player(NULL);
 }
 
-void usage(void){
-  printf("%s",help_text);
-  exit(0);
-}
-
-void missing_param(char *s){
-  printf("Missing parameter: %s\n", s);
-  exit(1);
-}
-
 int divx_quality=0;
 
 int main(int argc,char* argv[], char *envp[]){
@@ -435,9 +430,9 @@
 
 if(!filename){
   if(vcd_track) filename="/dev/cdrom"; 
-  else
-  //filename="MI2-Trailer.avi";
-  usage();
+  else {
+    printf("%s",help_text); exit(0);
+  }
 }
 
 
--- a/mplayerHQ.c	Mon Mar 19 02:29:37 2001 +0000
+++ b/mplayerHQ.c	Mon Mar 19 03:45:49 2001 +0000
@@ -79,6 +79,11 @@
 #define DEBUG if(0)
 static int verbose=0;
 
+static int cfg_inc_verbose(struct config *conf){
+    ++verbose;
+    return 0;
+}
+
 static int max_framesize=0;
 
 static int dbg_es_sent=0;