[Mplayer-cvslog] CVS: main cfg-mplayer-func.c,NONE,1.1 cfg-mplayer-func.h,NONE,1.1 Makefile,1.6,1.7 cfg-mplayer.h,1.2,1.3 cfgparser.c,1.1,1.2 cfgparser.h,1.1,1.2 mplayer.c,1.17,1.18
Szabolcs Berecz
szabii at users.sourceforge.net
Mon Mar 19 02:49:47 CET 2001
- Previous message: [Mplayer-cvslog] CVS: main Makefile,1.5,1.6
- Next message: [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
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/mplayer/main
In directory usw-pr-cvs1:/tmp/cvs-serv18252
Modified Files:
Makefile cfg-mplayer.h cfgparser.c cfgparser.h mplayer.c
Added Files:
cfg-mplayer-func.c cfg-mplayer-func.h
Log Message:
cfgparse fixes
--- NEW FILE ---
#include "cfgparser.h"
#include "version.h"
#include "help_mp.h"
int cfg_func_help(struct config *conf)
{
printf("%s", help_text);
exit(0);
}
--- NEW FILE ---
int cfg_func_help(struct config *conf);
Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/Makefile,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** Makefile 2001/03/19 01:04:03 1.6
--- Makefile 2001/03/19 01:49:44 1.7
***************
*** 18,23 ****
BINDIR = ${prefix}/bin
# BINDIR = /usr/local/bin
! SRCS = linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c lirc_mp.c cfgparser.c
! OBJS = linux/getch2.o linux/timer-lx.o linux/shmem.o xa/xa_gsm.o lirc_mp.o cfgparser.o
CFLAGS = $(OPTFLAGS) -Iloader -Ilibvo # -Wall
A_LIBS = -Lmp3lib -lMP3 -Llibac3 -lac3
--- 18,25 ----
BINDIR = ${prefix}/bin
# BINDIR = /usr/local/bin
! SRCS = linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c lirc_mp.c cfgparser.c\
! cfg-mplayer-func.c
! OBJS = linux/getch2.o linux/timer-lx.o linux/shmem.o xa/xa_gsm.o lirc_mp.o cfgparser.o\
! cfg-mplayer-func.o
CFLAGS = $(OPTFLAGS) -Iloader -Ilibvo # -Wall
A_LIBS = -Lmp3lib -lMP3 -Llibac3 -lac3
Index: cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** cfg-mplayer.h 2001/03/19 00:13:24 1.2
--- cfg-mplayer.h 2001/03/19 01:49:44 1.3
***************
*** 3,6 ****
--- 3,8 ----
*/
+ #include "cfg-mplayer-func.h"
+
struct config conf[]={
/* name, pointer, type, flags, min, max */
***************
*** 40,43 ****
--- 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.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** cfgparser.c 2001/03/18 23:32:31 1.1
--- cfgparser.c 2001/03/19 01:49:44 1.2
***************
*** 15,18 ****
--- 15,19 ----
#define ERR_MISSING_PARAM -2
#define ERR_OUT_OF_RANGE -3
+ #define ERR_FUNC_ERR -4
#define COMMAND_LINE 0
***************
*** 24,29 ****
#include "cfgparser.h"
- #include "version.h"
- #include "help_mp.h"
static struct config *config;
--- 25,28 ----
***************
*** 44,48 ****
#ifdef DEBUG
if (mode != COMMAND_LINE && mode != CONFIG_FILE) {
! printf("init_conf: wrong flag!\n");
return -1;
}
--- 43,47 ----
#ifdef DEBUG
if (mode != COMMAND_LINE && mode != CONFIG_FILE) {
! printf("init_conf: wrong mode!\n");
return -1;
}
***************
*** 66,69 ****
--- 65,73 ----
return ERR_NOT_AN_OPTION;
+ if (config[i].flags & CONF_NOCFG && parser_mode == CONFIG_FILE)
+ return ERR_NOT_AN_OPTION;
+ if (config[i].flags & CONF_NOCMD && parser_mode == COMMAND_LINE)
+ return ERR_NOT_AN_OPTION;
+
switch (config[i].type) {
case CONF_TYPE_FLAG:
***************
*** 143,146 ****
--- 147,163 ----
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:
printf("picsaba\n");
***************
*** 291,294 ****
--- 308,317 ----
continue;
/* break; */
+ case ERR_FUNC_ERR:
+ PRINT_LINENUM;
+ printf("parser function returned error: %s\n", opt);
+ ret = -1;
+ continue;
+ /* break */
}
}
***************
*** 322,326 ****
/* remove trailing '-' */
opt++;
!
/* check for --help, -h, and --version */
if (!strcasecmp(opt, "-help") || !strcasecmp(opt, "h")) {
--- 345,349 ----
/* remove trailing '-' */
opt++;
! #if 0
/* check for --help, -h, and --version */
if (!strcasecmp(opt, "-help") || !strcasecmp(opt, "h")) {
***************
*** 332,335 ****
--- 355,359 ----
continue;
}
+ #endif
tmp = read_option(opt, argv[i + 1]);
***************
*** 356,359 ****
--- 380,387 ----
case ERR_OUT_OF_RANGE:
printf("parse_command_line: parameter of '%s' is out of range\n", argv[i]);
+ return -1;
+ /* break; */
+ case ERR_FUNC_ERR:
+ printf("parse_command_line: parser function returned error: %s\n", argv[i]);
return -1;
/* break; */
Index: cfgparser.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfgparser.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** cfgparser.h 2001/03/18 23:32:31 1.1
--- cfgparser.h 2001/03/19 01:49:44 1.2
***************
*** 10,24 ****
#define CONF_TYPE_FLOAT 2
#define CONF_TYPE_STRING 3
! #define CONF_CHK_MIN 1<<0
! #define CONF_CHK_MAX 1<<1
struct config {
char *name;
void *p;
! unsigned int type :2;
! unsigned int flags:2;
float min,max;
};
/* parse_config_file returns:
--- 10,31 ----
#define CONF_TYPE_FLOAT 2
#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 {
char *name;
void *p;
! unsigned int type :3;
! unsigned int flags:5;
float min,max;
};
+
+ typedef int (*cfg_func_param_t)(struct config *, char *);
+ typedef int (*cfg_func_t)(struct config *);
/* parse_config_file returns:
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** mplayer.c 2001/03/19 00:13:24 1.17
--- mplayer.c 2001/03/19 01:49:44 1.18
***************
*** 36,39 ****
--- 36,40 ----
#include "cfgparser.h"
+ #include "cfg-mplayer-func.h"
#include "libvo/video_out.h"
_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog
- Previous message: [Mplayer-cvslog] CVS: main Makefile,1.5,1.6
- Next message: [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
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the MPlayer-cvslog
mailing list