[Mplayer-cvslog] CVS: main cfg-mplayer-def.h,NONE,1.1 cfg-mplayer.h,1.3,1.4 cfgparser.c,1.2,1.3 cfgparser.h,1.2,1.3 mplayer.c,1.18,1.19

Szabolcs Berecz szabii at users.sourceforge.net
Mon Mar 19 03:24:45 CET 2001


Update of /cvsroot/mplayer/main
In directory usw-pr-cvs1:/tmp/cvs-serv21603

Modified Files:
	cfg-mplayer.h cfgparser.c cfgparser.h mplayer.c 
Added Files:
	cfg-mplayer-def.h 
Log Message:
cfgparser fix

--- NEW FILE ---
static char* default_config=
"nosound=nem"
"\n";


Index: cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** cfg-mplayer.h	2001/03/19 01:49:44	1.3
--- cfg-mplayer.h	2001/03/19 02:24:43	1.4
***************
*** 42,47 ****
  	{"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},
  	{NULL, NULL, 0, 0, 0, 0}
  };
--- 42,47 ----
  	{"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},
  	{NULL, NULL, 0, 0, 0, 0}
  };

Index: cfgparser.c
===================================================================
RCS file: /cvsroot/mplayer/main/cfgparser.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** cfgparser.c	2001/03/19 01:49:44	1.2
--- cfgparser.c	2001/03/19 02:24:43	1.3
***************
*** 81,85 ****
  				    !strcmp(param, "1"))
  					*((int *) config[i].p) = config[i].max;
! 				if (!strcasecmp(param, "no") ||
  				    !strcasecmp(param, "nein") ||
  				    !strcasecmp(param, "nicht") ||
--- 81,85 ----
  				    !strcmp(param, "1"))
  					*((int *) config[i].p) = config[i].max;
! 				else if (!strcasecmp(param, "no") ||
  				    !strcasecmp(param, "nein") ||
  				    !strcasecmp(param, "nicht") ||
***************
*** 88,91 ****
--- 88,93 ----
  				    !strcmp(param, "0"))
  					*((int *) config[i].p) = config[i].min;
+ 				else
+ 					return ERR_OUT_OF_RANGE;
  				need_param = 1;
  			} else {	/* parser_mode == COMMAND_LINE */
***************
*** 147,162 ****
  			need_param = 1;
  			break;
  		case CONF_TYPE_FUNC:
! 			if (config[i].flags & CONF_FUNC_PARAM) {
! 				if (param == NULL)
! 					return ERR_MISSING_PARAM;
! 				if ((((cfg_func_param_t) config[i].p)(config + i, param)) < 0)
! 					return ERR_FUNC_ERR;
! 				need_param = 1;
! 			} else {
! 				if ((((cfg_func_t) config[i].p)(config + i)) < 0)
! 					return ERR_FUNC_ERR;
! 				need_param = 0;
! 			}
  			break;
  		default:
--- 149,163 ----
  			need_param = 1;
  			break;
+ 		case CONF_TYPE_FUNC_PARAM:
+ 			if (param == NULL)
+ 				return ERR_MISSING_PARAM;
+ 			if ((((cfg_func_param_t) config[i].p)(config + i, param)) < 0)
+ 				return ERR_FUNC_ERR;
+ 			need_param = 1;
+ 			break;
  		case CONF_TYPE_FUNC:
! 			if ((((cfg_func_t) config[i].p)(config + i)) < 0)
! 				return ERR_FUNC_ERR;
! 			need_param = 0;
  			break;
  		default:

Index: cfgparser.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfgparser.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** cfgparser.h	2001/03/19 01:49:44	1.2
--- cfgparser.h	2001/03/19 02:24:43	1.3
***************
*** 11,20 ****
  #define CONF_TYPE_STRING	3
  #define CONF_TYPE_FUNC		4
  
  #define CONF_CHK_MIN		(1<<0)
  #define CONF_CHK_MAX		(1<<1)
! #define CONF_FUNC_PARAM		(1<<2)
! #define CONF_NOCFG		(1<<3)
! #define CONF_NOCMD		(1<<4)
  
  struct config {
--- 11,20 ----
  #define CONF_TYPE_STRING	3
  #define CONF_TYPE_FUNC		4
+ #define CONF_TYPE_FUNC_PARAM	5
  
  #define CONF_CHK_MIN		(1<<0)
  #define CONF_CHK_MAX		(1<<1)
! #define CONF_NOCFG		(1<<2)
! #define CONF_NOCMD		(1<<3)
  
  struct config {
***************
*** 22,26 ****
  	void *p;
  	unsigned int type :3;
! 	unsigned int flags:5;
  	float min,max;
  };
--- 22,26 ----
  	void *p;
  	unsigned int type :3;
! 	unsigned int flags:4;
  	float min,max;
  };

Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** mplayer.c	2001/03/19 01:49:44	1.18
--- mplayer.c	2001/03/19 02:24:43	1.19
***************
*** 37,40 ****
--- 37,41 ----
  #include "cfgparser.h"
  #include "cfg-mplayer-func.h"
+ #include "cfg-mplayer-def.h"
  
  #include "libvo/video_out.h"
***************
*** 375,378 ****
--- 376,381 ----
  char *homedir;
  char conffile[100];
+ char confdir[100];
+ int conffile_fd;
  #include "cfg-mplayer.h"
  
***************
*** 384,388 ****
    printf("Can't find HOME dir\n");
  } else {
!   snprintf(conffile, 100, "%s/.mplayerrc", homedir);
    if (parse_config_file(conf, conffile) < 0)
      exit(1);
--- 387,397 ----
    printf("Can't find HOME dir\n");
  } else {
!   snprintf(confdir, 100, "%s/.mplayer", homedir);
!   mkdir(confdir, 0777);
!   snprintf(conffile, 100, "%s/config", confdir);
!   if ((conffile_fd = open(conffile, O_CREAT | O_EXCL | O_WRONLY, 0644)) != -1) {
!     write(conffile_fd, default_config, strlen(default_config));
!     close(conffile_fd);
!   }
    if (parse_config_file(conf, conffile) < 0)
      exit(1);


_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog



More information about the MPlayer-cvslog mailing list