8 __export
char ConfigName
[FILENAME_MAX
];
9 __export
char config_cwd
[FILENAME_MAX
];
12 * This searches for a specified set of filenames in a specified set
13 * of directories. If found, set the current working directory to
16 int search_dirs(struct com32_filedata
*filedata
,
17 const char *search_directories
[],
18 const char *filenames
[],
21 char namebuf
[FILENAME_MAX
];
22 const char *sd
, **sdp
;
23 const char *sf
, **sfp
;
25 for (sdp
= search_directories
; (sd
= *sdp
); sdp
++) {
26 for (sfp
= filenames
; (sf
= *sfp
); sfp
++) {
27 snprintf(namebuf
, sizeof namebuf
,
29 sd
, (*sd
&& sd
[strlen(sd
)-1] == '/') ? "" : "/",
31 if (realpath(realname
, namebuf
, FILENAME_MAX
) == (size_t)-1)
33 dprintf("Config search: %s\n", realname
);
34 if (open_file(realname
, O_RDONLY
, filedata
) >= 0) {
36 return 0; /* Got it */