static FILE * getCfgFile(int argc, char **argv) { FileName cfgFileName; FILE *file; char *name; name = getOption(argc, argv, "-Wconfig=", NULL); /* Should strip off any ".conf" */ if (!name) { cfgFileName = cfgFindFile(CONFFILE, ""); if (!cfgFileName) cfgFileName = cfgFindFile(OLDCONFFILE, ""); } else cfgFileName = fnameParse(name); if (!cfgFileName) { fprintf(stderr, "Can't find config file\n"); return NULL; } if ((file = fileTryOpen(cfgFileName, osIoRdMode)) == NULL) fprintf(stderr, "Can't open: %s\n", fnameUnparse(cfgFileName)); return file; }
String compRootFromCmdLine(String cwd, String file) { FileName fname = fnameParseStaticWithin(file, cwd); String binDir = fnameDir(fname); FileName rootDir = fnameNew(binDir, "..", ""); String root = fnameUnparse(rootDir); return root; }
Bool arHasBasicLib(Archive ar) { static String s = NULL; if (s == NULL) { FileName fn = fnameNew("", "basic", FTYPE_INTERMED); s = fnameUnparse(fn); fnameFree(fn); } return arFindEntry(ar, s) != NULL; }
static StringList uclExpandLibs(StringList path0, StringList libs, String ext) { StringList res = listNil(String); while (libs != listNil(String)) { String basename = car(libs); StringList path = path0; basename = strConcat("lib", basename); while (path != listNil(String)) { FileName name = fnameNew(car(path), basename, ext); if (fileIsOpenable(name, osIoRdMode)) { res = listCons(String)(fnameUnparse(name), res); break; } path = cdr(path); } if (path == listNil(String)) printf("Warning: %s not found\n", basename); strFree(basename); libs = cdr(libs); } return listNReverse(String)(res); }