aboutsummaryrefslogtreecommitdiffhomepage
path: root/options
diff options
context:
space:
mode:
authorGravatar Ricardo Constantino <wiiaboo@gmail.com>2018-01-03 19:47:12 +0000
committerGravatar Kevin Mitchell <kevmitch@gmail.com>2018-01-03 15:10:25 -0800
commit877775f84e86d750094ba0901d3c52fb5fa438ae (patch)
tree7ee8e772be9a5226a15c4d8babc8e5c5c2083b7b /options
parentc809b73db6ec1c70b9d46f33dd93a99ad005beb6 (diff)
m_option: add print callback to start/end/length
Diffstat (limited to 'options')
-rw-r--r--options/m_option.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/options/m_option.c b/options/m_option.c
index f4f79f772d..71744e1646 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -2431,10 +2431,28 @@ out:
return 1;
}
+static char *print_rel_time(const m_option_t *opt, const void *val)
+{
+ const struct m_rel_time *t = val;
+ switch(t->type) {
+ case REL_TIME_ABSOLUTE:
+ return talloc_asprintf(NULL, "%g", t->pos);
+ case REL_TIME_RELATIVE:
+ return talloc_asprintf(NULL, "%s%g",
+ (t->pos >= 0) ? "+" : "-", fabs(t->pos));
+ case REL_TIME_CHAPTER:
+ return talloc_asprintf(NULL, "#%g", t->pos);
+ case REL_TIME_PERCENT:
+ return talloc_asprintf(NULL, "%g%%", t->pos);
+ }
+ return talloc_strdup(NULL, "none");
+}
+
const m_option_type_t m_option_type_rel_time = {
.name = "Relative time or percent position",
.size = sizeof(struct m_rel_time),
.parse = parse_rel_time,
+ .print = print_rel_time,
.copy = copy_opt,
};