@@ -1312,6 +1312,7 @@ static int storef_hex ( struct settings *settings, struct setting *setting,
1312
1312
case '\0' :
1313
1313
return store_setting ( settings , setting , bytes , len );
1314
1314
case ':' :
1315
+ case '-' :
1315
1316
ptr ++ ;
1316
1317
break ;
1317
1318
default :
@@ -1327,10 +1328,11 @@ static int storef_hex ( struct settings *settings, struct setting *setting,
1327
1328
* @v setting Setting to fetch
1328
1329
* @v buf Buffer to contain formatted value
1329
1330
* @v len Length of buffer
1331
+ * @v delimiter Byte delimiter
1330
1332
* @ret len Length of formatted value, or negative error
1331
1333
*/
1332
1334
static int fetchf_hex ( struct settings * settings , struct setting * setting ,
1333
- char * buf , size_t len ) {
1335
+ char * buf , size_t len , const char * delimiter ) {
1334
1336
int raw_len ;
1335
1337
int check_len ;
1336
1338
int used = 0 ;
@@ -1353,18 +1355,55 @@ static int fetchf_hex ( struct settings *settings, struct setting *setting,
1353
1355
buf [0 ] = 0 ; /* Ensure that a terminating NUL exists */
1354
1356
for ( i = 0 ; i < raw_len ; i ++ ) {
1355
1357
used += ssnprintf ( ( buf + used ), ( len - used ),
1356
- "%s%02x" , ( used ? ":" : "" ),
1358
+ "%s%02x" , ( used ? delimiter : "" ),
1357
1359
raw [i ] );
1358
1360
}
1359
1361
return used ;
1360
1362
}
1361
1363
}
1362
1364
1363
- /** A hex-string setting */
1365
+ /**
1366
+ * Fetch and format value of hex string setting (using colon delimiter)
1367
+ *
1368
+ * @v settings Settings block, or NULL to search all blocks
1369
+ * @v setting Setting to fetch
1370
+ * @v buf Buffer to contain formatted value
1371
+ * @v len Length of buffer
1372
+ * @ret len Length of formatted value, or negative error
1373
+ */
1374
+ static int fetchf_hex_colon ( struct settings * settings ,
1375
+ struct setting * setting ,
1376
+ char * buf , size_t len ) {
1377
+ return fetchf_hex ( settings , setting , buf , len , ":" );
1378
+ }
1379
+
1380
+ /**
1381
+ * Fetch and format value of hex string setting (using hyphen delimiter)
1382
+ *
1383
+ * @v settings Settings block, or NULL to search all blocks
1384
+ * @v setting Setting to fetch
1385
+ * @v buf Buffer to contain formatted value
1386
+ * @v len Length of buffer
1387
+ * @ret len Length of formatted value, or negative error
1388
+ */
1389
+ static int fetchf_hex_hyphen ( struct settings * settings ,
1390
+ struct setting * setting ,
1391
+ char * buf , size_t len ) {
1392
+ return fetchf_hex ( settings , setting , buf , len , "-" );
1393
+ }
1394
+
1395
+ /** A hex-string setting (colon-delimited) */
1364
1396
struct setting_type setting_type_hex __setting_type = {
1365
1397
.name = "hex" ,
1366
1398
.storef = storef_hex ,
1367
- .fetchf = fetchf_hex ,
1399
+ .fetchf = fetchf_hex_colon ,
1400
+ };
1401
+
1402
+ /** A hex-string setting (hyphen-delimited) */
1403
+ struct setting_type setting_type_hexhyp __setting_type = {
1404
+ .name = "hexhyp" ,
1405
+ .storef = storef_hex ,
1406
+ .fetchf = fetchf_hex_hyphen ,
1368
1407
};
1369
1408
1370
1409
/**
0 commit comments