@@ -296,7 +296,7 @@ int ConfGetValue(char *key) {
296
296
297
297
} // End of ConfGetValue
298
298
299
- static void ConfPrintValue (toml_table_t * sectionConf , const char * tableName , const char * entry ) {
299
+ static void ConfPrintTableValue (toml_table_t * sectionConf , const char * tableName , const char * entry ) {
300
300
toml_value_t val ;
301
301
val = toml_table_string (sectionConf , entry );
302
302
if (val .ok ) {
@@ -319,7 +319,34 @@ static void ConfPrintValue(toml_table_t *sectionConf, const char *tableName, con
319
319
// printf("%10s time : %s\n", entry, val.u.ts);
320
320
}
321
321
322
- } // End of ConfPrintValue
322
+ } // End of ConfTablePrintValue
323
+
324
+ static void ConfPrintArrayValue (toml_array_t * sectionConf , const char * arrayName , int entry ) {
325
+ toml_value_t val ;
326
+ val = toml_array_string (sectionConf , entry );
327
+ if (val .ok ) {
328
+ printf ("%s:[%d] string : %s\n" , arrayName , entry , val .u .s );
329
+ }
330
+ val = toml_array_bool (sectionConf , entry );
331
+ if (val .ok ) {
332
+ printf ("%s:[%d] bool : %i\n" , arrayName , entry , val .u .b );
333
+ }
334
+ val = toml_array_int (sectionConf , entry );
335
+ if (val .ok ) {
336
+ printf ("%s:[%d] int : %lld\n" , arrayName , entry , val .u .i );
337
+ }
338
+ val = toml_array_double (sectionConf , entry );
339
+ if (val .ok ) {
340
+ printf ("%s:[%d] double : %f\n" , arrayName , entry , val .u .d );
341
+ }
342
+ val = toml_array_timestamp (sectionConf , entry );
343
+ if (val .ok ) {
344
+ // printf("%10s time : %s\n", entry, val.u.ts);
345
+ }
346
+
347
+ } // End of ConfPrintArrayValue
348
+
349
+ static void ConfPrintArray (toml_array_t * sectionConf , const char * arrayName );
323
350
324
351
static void ConfPrintTable (toml_table_t * sectionConf , const char * tableName ) {
325
352
int len = toml_table_len (sectionConf );
@@ -332,15 +359,33 @@ static void ConfPrintTable(toml_table_t *sectionConf, const char *tableName) {
332
359
toml_array_t * a = toml_table_array (sectionConf , entry );
333
360
toml_table_t * t = toml_table_table (sectionConf , entry );
334
361
if (a ) {
335
- printf ("%s:%s is an array\n" , tableName , entry );
362
+ printf ("%s:%s is an array " , tableName , entry );
363
+ ConfPrintArray (a , entry );
336
364
} else if (t ) {
337
365
printf ("\n%s:%s is a table " , tableName , entry );
338
366
ConfPrintTable (t , entry );
339
367
} else {
340
- ConfPrintValue (sectionConf , tableName , entry );
368
+ ConfPrintTableValue (sectionConf , tableName , entry );
369
+ }
370
+ }
371
+ } // End of ConfPrintTable
372
+
373
+ static void ConfPrintArray (toml_array_t * sectionConf , const char * arrayName ) {
374
+ int len = toml_array_len (sectionConf );
375
+ printf ("with %d entries:\n" , len );
376
+ for (int i = 0 ; i < len ; i ++ ) {
377
+ toml_array_t * a = toml_array_array (sectionConf , i );
378
+ toml_table_t * t = toml_array_table (sectionConf , i );
379
+ if (a ) {
380
+ printf ("%s:[%d] is an array " , arrayName , i );
381
+ } else if (t ) {
382
+ printf ("\n%s:[%d] is a table " , arrayName , i );
383
+ ConfPrintTable (t , "anonymous" );
384
+ } else {
385
+ ConfPrintArrayValue (sectionConf , arrayName , i );
341
386
}
342
387
}
343
- }
388
+ } // End of ConfPrintArray
344
389
345
390
void ConfInventory (char * confFile ) {
346
391
if (!confFile ) return ;
0 commit comments