summaryrefslogtreecommitdiff
path: root/firmware/common/pathfuncs.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/common/pathfuncs.c')
-rw-r--r--firmware/common/pathfuncs.c30
1 files changed, 29 insertions, 1 deletions
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)
127 VOL_START_TOK, voldec, volume, VOL_END_TOK); 127 VOL_START_TOK, voldec, volume, VOL_END_TOK);
128 DEBUGF("vol<%d> = %s ", volume, buffer); 128 DEBUGF("vol<%d> = %s ", volume, buffer);
129 } 129 }
130 DEBUGF("\n"); 130 DEBUGF("\n");
131}
132
133#include <stdio.h>
134
135int path_get_volume_id(const char *name)
136{
137 int v = -1;
138
139 if (!name || *name != VOL_START_TOK)
140 goto bail;
141
142 do {
143 switch (*name)
144 {
145 case '0' ... '9': /* digit; parse volume number */
146 v = (v * 10 + *name - '0') % VOL_NUM_MAX;
147 break;
148 case '\0':
149 case PATH_SEPCH: /* no closing bracket; no volume */
150 v = -1;
151 goto bail;
152 default: /* something else; reset volume */
153 v = 0;
154 }
155 } while (*++name != VOL_END_TOK); /* found end token? */
156
157bail:
158 return v;
131} 159}
132 160
133/* Returns on which volume this is and sets *nameptr to the portion of the 161/* Returns on which volume this is and sets *nameptr to the portion of the