Mercurial > mplayer.hg
changeset 147:0a0d7dd8fb51
new command line/config file parser
author | szabii |
---|---|
date | Sun, 18 Mar 2001 23:32:31 +0000 |
parents | f3eb963d1370 |
children | 16a32ec6419d |
files | cfg-mplayer.h cfgparser.c cfgparser.h mplayer.c mplayerHQ.c |
diffstat | 5 files changed, 479 insertions(+), 110 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cfg-mplayer.h Sun Mar 18 23:32:31 2001 +0000 @@ -0,0 +1,44 @@ +/* + * config for cfgparser + */ + +struct config conf[]={ + /* name, pointer, type, flags, min, max */ + {"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}, + {"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}, + {"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}, + {"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}, + {"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_FLAG, 0, 0, 1}, + {"nov", &verbose, CONF_TYPE_FLAG, 0, 1, 0}, + {NULL, NULL, 0, 0, 0, 0} +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cfgparser.c Sun Mar 18 23:32:31 2001 +0000 @@ -0,0 +1,365 @@ +/* + * command line and config file parser + */ + +//#define DEBUG + +#include <stdlib.h> +#include <stdio.h> +#include <ctype.h> +#include <unistd.h> +#include <fcntl.h> +#include <string.h> + +#define ERR_NOT_AN_OPTION -1 +#define ERR_MISSING_PARAM -2 +#define ERR_OUT_OF_RANGE -3 + +#define COMMAND_LINE 0 +#define CONFIG_FILE 1 + +#ifdef DEBUG +#include <assert.h> +#endif + +#include "cfgparser.h" +#include "version.h" +#include "help_mp.h" + +static struct config *config; +static int nr_options; /* number of options in 'conf' */ +static int parser_mode; /* COMMAND_LINE or CONFIG_FILE */ + +static int init_conf(struct config *conf, int mode) +{ +#ifdef DEBUG + assert(conf != NULL); +#endif + + /* calculate the number of options in 'conf' */ + for (nr_options = 0; conf[nr_options].name != NULL; nr_options++) + /* NOTHING */; + + config = conf; +#ifdef DEBUG + if (mode != COMMAND_LINE && mode != CONFIG_FILE) { + printf("init_conf: wrong flag!\n"); + return -1; + } +#endif + parser_mode = mode; + return 1; +} + +static int read_option(char *opt, char *param) +{ + int i; + int need_param = -1; + int tmp_int; + float tmp_float; + + for (i = 0; i < nr_options; i++) { + if (!strcasecmp(opt, config[i].name)) + break; + } + if (i == nr_options) + return ERR_NOT_AN_OPTION; + + switch (config[i].type) { + case CONF_TYPE_FLAG: + /* flags need a parameter in config file */ + if (parser_mode == CONFIG_FILE) { + if (!strcasecmp(param, "yes") || /* any other language? */ + !strcasecmp(param, "ja") || + !strcasecmp(param, "igen") || + !strcasecmp(param, "y") || + !strcasecmp(param, "i") || + !strcmp(param, "1")) + *((int *) config[i].p) = config[i].max; + if (!strcasecmp(param, "no") || + !strcasecmp(param, "nein") || + !strcasecmp(param, "nicht") || + !strcasecmp(param, "nem") || + !strcasecmp(param, "n") || + !strcmp(param, "0")) + *((int *) config[i].p) = config[i].min; + need_param = 1; + } else { /* parser_mode == COMMAND_LINE */ + *((int *) config[i].p) = config[i].max; + need_param = 0; + } + break; + case CONF_TYPE_INT: + if (param == NULL) + return ERR_MISSING_PARAM; + if (!isdigit(*param)) + return ERR_MISSING_PARAM; + + tmp_int = atoi(param); + + if (config[i].flags & CONF_CHK_MIN) + if (tmp_int < config[i].min) + return ERR_OUT_OF_RANGE; + + if (config[i].flags & CONF_CHK_MAX) + if (tmp_int > config[i].max) + return ERR_OUT_OF_RANGE; + + *((int *) config[i].p) = tmp_int; + need_param = 1; + break; + case CONF_TYPE_FLOAT: + if (param == NULL) + return ERR_MISSING_PARAM; + if (!isdigit(*param)) + return ERR_MISSING_PARAM; + + tmp_float = atof(param); + + if (config[i].flags & CONF_CHK_MIN) + if (tmp_float < config[i].min) + return ERR_OUT_OF_RANGE; + + if (config[i].flags & CONF_CHK_MAX) + if (tmp_float > config[i].max) + return ERR_OUT_OF_RANGE; + + *((float *) config[i].p) = tmp_float; + need_param = 1; + break; + case CONF_TYPE_STRING: + if (param == NULL) + return ERR_MISSING_PARAM; + + if (config[i].flags & CONF_CHK_MIN) + if (strlen(param) < config[i].min) + return ERR_OUT_OF_RANGE; + + if (config[i].flags & CONF_CHK_MAX) + if (strlen(param) > config[i].max) + return ERR_OUT_OF_RANGE; + + *((char **) config[i].p) = strdup(param); + need_param = 1; + break; + default: + printf("picsaba\n"); + break; + } + return need_param; +} + +int parse_config_file(struct config *conf, char *conffile) +{ +#define PRINT_LINENUM printf("%s(%d): ", conffile, line_num) +#define MAX_LINE_LEN 1000 +#define MAX_OPT_LEN 100 +#define MAX_PARAM_LEN 100 + FILE *fp; + char *line; + char opt[MAX_OPT_LEN]; + char param[MAX_PARAM_LEN]; + int tmp; + int line_num = 0; + int line_pos; /* line pos */ + int opt_pos; /* opt pos */ + int param_pos; /* param pos */ + int ret = 1; + +#ifdef DEBUG + assert(conffile != NULL); +#endif + printf("Reading config file: %s\n", conffile); + + if (init_conf(conf, CONFIG_FILE) == -1) + return -1; + + if ((line = (char *) malloc(MAX_LINE_LEN)) == NULL) { + perror("parse_config_file: can't get memory for 'line'"); + return -1; + } + + if ((fp = fopen(conffile, "r")) == NULL) { + perror("parse_config_file: can't open filename"); + free(line); + return 0; + } + + while (fgets(line, MAX_LINE_LEN, fp)) { + line_num++; + line_pos = 0; + + /* skip whitespaces */ + while (isspace(line[line_pos])) + ++line_pos; + + /* EOL / comment */ + if (line[line_pos] == '\0' || line[line_pos] == '#') + continue; + + /* read option. accept char if isalnum(char) */ + for (opt_pos = 0; isalnum(line[line_pos]); /* NOTHING */) { + opt[opt_pos++] = line[line_pos++]; + if (opt_pos >= MAX_OPT_LEN) { + PRINT_LINENUM; + printf("too long option\n"); + ret = -1; + continue; + } + } + if (opt_pos == 0) { + PRINT_LINENUM; + printf("parse error\n"); + ret = -1; + continue; + } + opt[opt_pos] = '\0'; +#ifdef DEBUG + PRINT_LINENUM; + printf("option: %s\n", opt); +#endif + + /* skip whitespaces */ + while (isspace(line[line_pos])) + ++line_pos; + + /* check '=' */ + if (line[line_pos++] != '=') { + PRINT_LINENUM; + printf("option without parameter\n"); + ret = -1; + continue; + } + + /* whitespaces... */ + while (isspace(line[line_pos])) + ++line_pos; + + /* read the parameter */ + for (param_pos = 0; isalnum(line[line_pos]); /* NOTHING */) { + param[param_pos++] = line[line_pos++]; + if (param_pos >= MAX_PARAM_LEN) { + PRINT_LINENUM; + printf("too long parameter\n"); + ret = -1; + continue; + } + } + param[param_pos] = '\0'; + + /* did we read a parameter? */ + if (param_pos == 0) { + PRINT_LINENUM; + printf("option without parameter\n"); + ret = -1; + continue; + } +#ifdef DEBUG + PRINT_LINENUM; + printf("parameter: %s\n", param); +#endif + /* now, check if we have some more chars on the line */ + /* whitespace... */ + while (isspace(line[line_pos])) + ++line_pos; + + /* EOL / comment */ + if (line[line_pos] != '\0' && line[line_pos] != '#') { + PRINT_LINENUM; + printf("extra characters on line: %s\n", line+line_pos); + ret = -1; + } + + tmp = read_option(opt, param); + switch (tmp) { + case ERR_NOT_AN_OPTION: + PRINT_LINENUM; + printf("invalid option: %s\n", opt); + ret = -1; + continue; + /* break; */ + case ERR_MISSING_PARAM: + PRINT_LINENUM; + printf("missing parameter: %s\n", opt); + ret = -1; + continue; + /* break; */ + case ERR_OUT_OF_RANGE: + PRINT_LINENUM; + printf("parameter of %s out of range\n", opt); + ret = -1; + continue; + /* break; */ + } + } + + free(line); + fclose(fp); + return ret; +} + +int parse_command_line(struct config *conf, int argc, char **argv, char **envp, char **filename) +{ + int i; + int found_filename = 0; + int tmp; + char *opt; + +#ifdef DEBUG + assert(argv != NULL); + assert(envp != NULL); + assert(argc >= 1); +#endif + + if (init_conf(conf, COMMAND_LINE) == -1) + return -1; + + for (i = 1; i < argc; i++) { + opt = argv[i]; + if (*opt != '-') + goto not_an_option; + + /* remove trailing '-' */ + opt++; + + /* check for --help, -h, and --version */ + if (!strcasecmp(opt, "-help") || !strcasecmp(opt, "h")) { + printf("%s%s", banner_text, help_text); + continue; + } + if (!strcasecmp(opt, "-version")) { + printf("%s", banner_text); + continue; + } + + tmp = read_option(opt, argv[i + 1]); + + switch (tmp) { + case ERR_NOT_AN_OPTION: +not_an_option: + /* opt is not an option -> treat it as a filename */ + if (found_filename) { + /* we already have a filename */ + printf("parse_command_line: invalid option: %s\n", argv[i]); + return -1; + } else { + found_filename = 1; + *filename = argv[i]; + printf("parse_command_line: found filename: %s\n", *filename); + continue; /* next option */ + } + break; + case ERR_MISSING_PARAM: + printf("parse_command_line: missing parameter: %s\n", argv[i]); + return -1; + /* break; */ + case ERR_OUT_OF_RANGE: + printf("parse_command_line: parameter of '%s' is out of range\n", argv[i]); + return -1; + /* break; */ + } + + i += tmp; /* we already processed the params (if there was any) */ + } + return found_filename; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cfgparser.h Sun Mar 18 23:32:31 2001 +0000 @@ -0,0 +1,38 @@ +/* + * command line and config file parser + */ + +#ifndef __CONFIG_H +#define __CONFIG_H + +#define CONF_TYPE_FLAG 0 +#define CONF_TYPE_INT 1 +#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: + * -1 on error (can't malloc, invalid option...) + * 0 if can't open configfile + * 1 on success + */ +int parse_config_file(struct config *conf, char *conffile); + +/* parse_command_line reutrns: + * -1 on error (invalid option...) + * 0 if there was no filename on command line + * 1 if it found a filename + */ +int parse_command_line(struct config *conf, int argc, char **argv, char **envp, char **filename); + +#endif /* __CONFIG_H */
--- a/mplayer.c Sun Mar 18 22:12:33 2001 +0000 +++ b/mplayer.c Sun Mar 18 23:32:31 2001 +0000 @@ -34,6 +34,8 @@ #include "version.h" #include "config.h" +#include "cfgparser.h" + #include "libvo/video_out.h" // CODECS: @@ -320,7 +322,7 @@ int divx_quality=0; -int main(int argc,char* argv[]){ +int main(int argc,char* argv[], char *envp[]){ char* filename=NULL; //"MI2-Trailer.avi"; int i; int seek_to_sec=0; @@ -369,65 +371,24 @@ int out_fmt=0; char *dsp="/dev/dsp"; int force_ni=0; +char *homedir; +char conffile[100]; +#include "cfg-mplayer.h" printf("%s",banner_text); -/* CHKOPT(a): check, wether there is 'a' more options left */ -#define CHKOPT(a) if ((argc - i) < (a + 1)) missing_param(argv[i]); -if (argc == 1) - usage(); -for(i=1;i<argc;i++){ - if(strcmp(argv[i],"-o")==0){ - printf("Option -o has been renamed to -vo (video-out), use -vo !\n"); - exit(1); - } else - if(strcmp(argv[i],"-divxq")==0){ - printf("Option -divxq has been renamed to -pp (postprocessing), use -pp !\n"); +if (parse_config_file(conf, "/etc/mplayer.conf") < 0) + exit(1); +if ((homedir = getenv("HOME")) == NULL) { + printf("Can't find HOME dir\n"); + exit(1); +} else { + snprintf(conffile, 100, "%s/.mplayerrc", homedir); + if (parse_config_file(conf, conffile) < 0) exit(1); - } else - if(strcmp(argv[i],"-vo")==0) {CHKOPT(1); video_driver=argv[++i];} else - if(strcmp(argv[i],"-dsp")==0) {CHKOPT(1); dsp=argv[++i];} else - if(strcmp(argv[i],"-encode")==0) {CHKOPT(1); encode_name=argv[++i];} else - if(strcmp(argv[i],"-bg")==0) {play_in_bg=1;} else - if(strcmp(argv[i],"-sb")==0) {CHKOPT(1); seek_to_byte=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-ss")==0) {CHKOPT(1); seek_to_sec=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-nosound")==0) {has_audio=0;} else - if(strcmp(argv[i],"-abs")==0) {CHKOPT(1); audio_buffer_size=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-delay")==0) {CHKOPT(1); audio_delay=strtod(argv[++i],NULL);} else -#ifdef AVI_SYNC_BPS - if(strcmp(argv[i],"-nobps")==0) {pts_from_bps=0;} else -#else - if(strcmp(argv[i],"-bps")==0) {pts_from_bps=1;} else -#endif -#ifdef ALSA_TIMER - if(strcmp(argv[i],"-noalsa")==0) {alsa=0;} else -#else - if(strcmp(argv[i],"-alsa")==0) {alsa=1;} else -#endif - if(strcmp(argv[i],"-ni")==0) {force_ni=1;} else - if(strcmp(argv[i],"-aid")==0) {CHKOPT(1); audio_id=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-vid")==0) {CHKOPT(1); video_id=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-auds")==0) {CHKOPT(1); avi_header.audio_codec=argv[++i];} else - if(strcmp(argv[i],"-vids")==0) {CHKOPT(1); avi_header.video_codec=argv[++i];} else - if(strcmp(argv[i],"-mc")==0) {CHKOPT(1); default_max_pts_correction=strtod(argv[++i],NULL);} else - if(strcmp(argv[i],"-fps")==0) {CHKOPT(1); force_fps=strtod(argv[++i],NULL);} else - if(strcmp(argv[i],"-afm")==0) {CHKOPT(1); audio_format=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-vcd")==0) {CHKOPT(1); vcd_track=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-pp")==0) {CHKOPT(1); divx_quality=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-br")==0) {CHKOPT(1); encode_bitrate=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-x")==0) {CHKOPT(1); screen_size_x=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-y")==0) {CHKOPT(1); screen_size_y=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-xy")==0) {CHKOPT(1); screen_size_xy=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-fs")==0) {fullscreen=1;} else - if(strcmp(argv[i],"-noidx")==0) {no_index=1;} else - if(strcmp(argv[i],"-v")==0) {++verbose;} else - if(strcmp(argv[i],"-h")==0) {usage();} else - if(strcmp(argv[i],"--help")==0) {usage();} else - { if(filename){ printf("invalid option: %s\n",filename);exit(1);} - filename=argv[i]; - } } -#undef CHKOPT /* we don't need this anymore */ +if (parse_command_line(conf, argc, argv, envp, &filename) < 0) + exit(1); // Many users forget to include command line in bugreports... if(verbose){
--- a/mplayerHQ.c Sun Mar 18 22:12:33 2001 +0000 +++ b/mplayerHQ.c Sun Mar 18 23:32:31 2001 +0000 @@ -36,6 +36,8 @@ #include "version.h" #include "config.h" +#include "cfgparser.h" + #include "libvo/video_out.h" // CODECS: @@ -322,7 +324,7 @@ int divx_quality=0; -int main(int argc,char* argv[]){ +int main(int argc,char* argv[], char *envp[]){ char* filename=NULL; //"MI2-Trailer.avi"; int i; int seek_to_sec=0; @@ -371,65 +373,24 @@ int out_fmt=0; char *dsp="/dev/dsp"; int force_ni=0; +char *homedir; +char conffile[100]; +#include "cfg-mplayer.h" printf("%s",banner_text); -/* CHKOPT(a): check, wether there is 'a' more options left */ -#define CHKOPT(a) if ((argc - i) < (a + 1)) missing_param(argv[i]); -if (argc == 1) - usage(); -for(i=1;i<argc;i++){ - if(strcmp(argv[i],"-o")==0){ - printf("Option -o has been renamed to -vo (video-out), use -vo !\n"); - exit(1); - } else - if(strcmp(argv[i],"-divxq")==0){ - printf("Option -divxq has been renamed to -pp (postprocessing), use -pp !\n"); +if (parse_config_file(conf, "/etc/mplayer.conf") < 0) + exit(1); +if ((homedir = getenv("HOME")) == NULL) { + printf("Can't find HOME dir\n"); + exit(1); +} else { + snprintf(conffile, 100, "%s/.mplayerrc", homedir); + if (parse_config_file(conf, conffile) < 0) exit(1); - } else - if(strcmp(argv[i],"-vo")==0) {CHKOPT(1); video_driver=argv[++i];} else - if(strcmp(argv[i],"-dsp")==0) {CHKOPT(1); dsp=argv[++i];} else - if(strcmp(argv[i],"-encode")==0) {CHKOPT(1); encode_name=argv[++i];} else - if(strcmp(argv[i],"-bg")==0) {play_in_bg=1;} else - if(strcmp(argv[i],"-sb")==0) {CHKOPT(1); seek_to_byte=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-ss")==0) {CHKOPT(1); seek_to_sec=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-nosound")==0) {has_audio=0;} else - if(strcmp(argv[i],"-abs")==0) {CHKOPT(1); audio_buffer_size=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-delay")==0) {CHKOPT(1); audio_delay=strtod(argv[++i],NULL);} else -#ifdef AVI_SYNC_BPS - if(strcmp(argv[i],"-nobps")==0) {pts_from_bps=0;} else -#else - if(strcmp(argv[i],"-bps")==0) {pts_from_bps=1;} else -#endif -#ifdef ALSA_TIMER - if(strcmp(argv[i],"-noalsa")==0) {alsa=0;} else -#else - if(strcmp(argv[i],"-alsa")==0) {alsa=1;} else -#endif - if(strcmp(argv[i],"-ni")==0) {force_ni=1;} else - if(strcmp(argv[i],"-aid")==0) {CHKOPT(1); audio_id=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-vid")==0) {CHKOPT(1); video_id=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-auds")==0) {CHKOPT(1); avi_header.audio_codec=argv[++i];} else - if(strcmp(argv[i],"-vids")==0) {CHKOPT(1); avi_header.video_codec=argv[++i];} else - if(strcmp(argv[i],"-mc")==0) {CHKOPT(1); default_max_pts_correction=strtod(argv[++i],NULL);} else - if(strcmp(argv[i],"-fps")==0) {CHKOPT(1); force_fps=strtod(argv[++i],NULL);} else - if(strcmp(argv[i],"-afm")==0) {CHKOPT(1); audio_format=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-vcd")==0) {CHKOPT(1); vcd_track=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-pp")==0) {CHKOPT(1); divx_quality=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-br")==0) {CHKOPT(1); encode_bitrate=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-x")==0) {CHKOPT(1); screen_size_x=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-y")==0) {CHKOPT(1); screen_size_y=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-xy")==0) {CHKOPT(1); screen_size_xy=strtol(argv[++i],NULL,0);} else - if(strcmp(argv[i],"-fs")==0) {fullscreen=1;} else - if(strcmp(argv[i],"-noidx")==0) {no_index=1;} else - if(strcmp(argv[i],"-v")==0) {++verbose;} else - if(strcmp(argv[i],"-h")==0) {usage();} else - if(strcmp(argv[i],"--help")==0) {usage();} else - { if(filename){ printf("invalid option: %s\n",filename);exit(1);} - filename=argv[i]; - } } -#undef CHKOPT /* we don't need this anymore */ +if (parse_command_line(conf, argc, argv, envp, &filename) < 0) + exit(1); // Many users forget to include command line in bugreports... if(verbose){