8 * Common implementation of load_config
10 * This searches for a specified set of filenames in a specified set
11 * of directories. If found, set the current working directory to
14 int search_config(const char *search_directories
[], const char *filenames
[])
16 char confignamebuf
[FILENAME_MAX
];
18 const char *sd
, **sdp
;
19 const char *sf
, **sfp
;
21 for (sdp
= search_directories
; (sd
= *sdp
); sdp
++) {
22 for (sfp
= filenames
; (sf
= *sfp
); sfp
++) {
23 memset(®s
, 0, sizeof regs
);
24 snprintf(confignamebuf
, sizeof confignamebuf
,
26 sd
, (*sd
&& sd
[strlen(sd
)-1] == '/') ? "" : "/",
28 realpath(ConfigName
, confignamebuf
, FILENAME_MAX
);
29 regs
.edi
.w
[0] = OFFS_WRT(ConfigName
, 0);
30 dprintf("Config search: %s\n", ConfigName
);
31 call16(core_open
, ®s
, ®s
);
32 if (!(regs
.eflags
.l
& EFLAGS_ZF
)) {
34 return 0; /* Got it */