changeset 7114:79187bd813a6

64-bit -sb offsets patch by Andy Goth <unununium@openverse.com>
author alex
date Wed, 28 Aug 2002 16:55:40 +0000
parents 3c84ee5e7da1
children 55716603988c
files cfg-common.h cfgparser.c cfgparser.h
diffstat 3 files changed, 47 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-common.h	Wed Aug 28 16:22:02 2002 +0000
+++ b/cfg-common.h	Wed Aug 28 16:55:40 2002 +0000
@@ -54,7 +54,7 @@
 	{"frames", &play_n_frames_mf, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
 
 	// seek to byte/seconds position
-	{"sb", &seek_to_byte, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
+	{"sb", &seek_to_byte, CONF_TYPE_POSITION, CONF_MIN, 0, 0, NULL},
 	{"ss", &seek_to_sec, CONF_TYPE_STRING, CONF_MIN, 0, 0, NULL},
 
 	// AVI specific: force non-interleaved mode
--- a/cfgparser.c	Wed Aug 28 16:22:02 2002 +0000
+++ b/cfgparser.c	Wed Aug 28 16:55:40 2002 +0000
@@ -112,6 +112,9 @@
   case CONF_TYPE_STRING_LIST :
     save[sl].param.as_pointer = *((char***)conf->p);
     break;
+  case CONF_TYPE_POSITION :
+    save[sl].param.as_off_t = *((off_t*)conf->p);
+    break;
   default :
     mp_msg(MSGT_CFGPARSER,MSGL_ERR,"Should never append in m_config_save_option : conf->type=%d\n",conf->type);
   }
@@ -196,6 +199,9 @@
       break;
     }
     break;
+  case CONF_TYPE_POSITION :
+    *((off_t*)save->opt->p) = save->param.as_off_t;
+    break;
   default :
     mp_msg(MSGT_CFGPARSER,MSGL_WARN,"Why do we reverse this : name=%s type=%d ?\n",save->opt->name,save->opt->type);
   }
@@ -425,7 +431,9 @@
 {
 	int i=0,nconf = 0;
 	long tmp_int;
+	off_t tmp_off;
 	double tmp_float;
+	int dummy;
 	int ret = -1;
 	char *endptr;
 	config_t* conf=NULL;
@@ -731,6 +739,42 @@
 		case CONF_TYPE_PRINT:
 			mp_msg(MSGT_CFGPARSER, MSGL_INFO, "%s", (char *) conf[i].p);
 			exit(1);
+		case CONF_TYPE_POSITION:
+			if (param == NULL)
+				goto err_missing_param;
+
+			if (sscanf(param, sizeof(off_t) == sizeof(int) ?
+			"%d%c" : "%lld%c", &tmp_off, dummy) != 1) {
+				mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be an integer: %s\n", param);
+				ret = ERR_OUT_OF_RANGE;
+				goto out;
+			}
+
+			if (conf[i].flags & CONF_MIN)
+				if (tmp_off < conf[i].min) {
+					mp_msg(MSGT_CFGPARSER, MSGL_ERR,
+					(sizeof(off_t) == sizeof(int) ?
+					"parameter must be >= %d: %s\n" :
+					"parameter must be >= %lld: %s\n"),
+					(off_t) conf[i].min, param);
+					ret = ERR_OUT_OF_RANGE;
+					goto out;
+				}
+
+			if (conf[i].flags & CONF_MAX)
+				if (tmp_off > conf[i].max) {
+					mp_msg(MSGT_CFGPARSER, MSGL_ERR,
+					(sizeof(off_t) == sizeof(int) ?
+					"parameter must be <= %d: %s\n" :
+					"parameter must be <= %lld: %s\n"),
+					(off_t) conf[i].max, param);
+					ret = ERR_OUT_OF_RANGE;
+					goto out;
+				}
+
+			*((off_t *) conf[i].p) = tmp_off;
+			ret = 1;
+			break;
 		default:
 			mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Unknown config type specified in conf-mplayer.h!\n");
 			break;
--- a/cfgparser.h	Wed Aug 28 16:22:02 2002 +0000
+++ b/cfgparser.h	Wed Aug 28 16:55:40 2002 +0000
@@ -15,6 +15,7 @@
 #define CONF_TYPE_FUNC_FULL	7
 #define CONF_TYPE_SUBCONFIG	8
 #define CONF_TYPE_STRING_LIST           9
+#define CONF_TYPE_POSITION	10
 
 
 #define ERR_NOT_AN_OPTION	-1
@@ -73,6 +74,7 @@
     int as_int;
     float as_float;
     void* as_pointer;
+    off_t* as_off_t;
   } param;
   char* opt_name;
 };