MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / loadSystemConfig

Function loadSystemConfig

Trash/stringTable.c:474–518  ·  view source on GitHub ↗

Returns 0 if requested config files were loaded, * 1 if default files were loaded, * -1 if no files were loaded. * Prints error message if files cannot be loaded. */

Source from the content-addressed store, hash-verified

472 * Prints error message if files cannot be loaded.
473 */
474int
475loadSystemConfig(
476 char *which,
477 INTN size
478)
479{
480 char *buf, *bp, *cp;
481 INTN ret, len, doDefault=0;
482
483 buf = bp = malloc(256);
484 if (which && size)
485 {
486 for(cp = which, len = size; len && *cp && *cp != LP; cp++, len--) ;
487 if (*cp == LP) {
488 while (len-- && *cp && *cp++ != RP) ;
489 /* cp now points past device */
490 strncpy(buf,which,cp - which);
491 bp += cp - which;
492 } else {
493 cp = which;
494 len = size;
495 }
496 if (*cp != '/') {
497 strcpy(bp, IO_SYSTEM_CONFIG_DIR);
498 strncat(bp, cp, len);
499 if (strncmp(cp + len - strlen(IO_TABLE_EXTENSION),
500 IO_TABLE_EXTENSION, strlen(IO_TABLE_EXTENSION)) != 0)
501 strcat(bp, IO_TABLE_EXTENSION);
502 } else {
503 strncpy(bp, cp, len);
504 bp[size] = '\0';
505 }
506 if (strcmp(bp, SYSTEM_DEFAULT_FILE) == 0)
507 doDefault = 1;
508 ret = loadConfigFile(bp = buf, 0, 0);
509 } else {
510 ret = loadConfigDir((bp = SYSTEM_CONFIG), 0, 0, 0);
511 }
512 if (ret < 0) {
513 error("System config file '%s' not found\n", bp);
514 } else
515 sysConfigValid = 1;
516 free(buf);
517 return (ret < 0 ? ret : doDefault);
518}
519
520
521int

Callers

nothing calls this directly

Calls 12

strncatFunction · 0.85
strncmpFunction · 0.85
strcatFunction · 0.85
loadConfigFileFunction · 0.85
loadConfigDirFunction · 0.85
mallocFunction · 0.50
strncpyFunction · 0.50
strcpyFunction · 0.50
strlenFunction · 0.50
strcmpFunction · 0.50
errorFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected