From 78283bda64ee09502029cd2eee459fef1bd31385 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Fri, 26 Jul 2024 23:35:00 -0400 Subject: talk: Voice the volume name when browsing and when voicing full paths Change-Id: I56660e168edd135a09cd5c021504a58ec9d40093 --- firmware/common/pathfuncs.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'firmware/common') diff --git a/firmware/common/pathfuncs.c b/firmware/common/pathfuncs.c index db1935db8b..b5e5ecb0cf 100644 --- a/firmware/common/pathfuncs.c +++ b/firmware/common/pathfuncs.c @@ -127,7 +127,35 @@ void init_volume_names(void) VOL_START_TOK, voldec, volume, VOL_END_TOK); DEBUGF("vol<%d> = %s ", volume, buffer); } - DEBUGF("\n"); + DEBUGF("\n"); +} + +#include + +int path_get_volume_id(const char *name) +{ + int v = -1; + + if (!name || *name != VOL_START_TOK) + goto bail; + + do { + switch (*name) + { + case '0' ... '9': /* digit; parse volume number */ + v = (v * 10 + *name - '0') % VOL_NUM_MAX; + break; + case '\0': + case PATH_SEPCH: /* no closing bracket; no volume */ + v = -1; + goto bail; + default: /* something else; reset volume */ + v = 0; + } + } while (*++name != VOL_END_TOK); /* found end token? */ + +bail: + return v; } /* Returns on which volume this is and sets *nameptr to the portion of the -- cgit v1.2.3