Last change
on this file since 551 was 551, checked in by Gregg Young, 18 years ago |
Indentation cleanup
|
-
Property svn:eol-style
set to
native
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.3 KB
|
Rev | Line | |
---|
[2] | 1 | #define INCL_DOS
|
---|
| 2 |
|
---|
| 3 | #include <os2.h>
|
---|
| 4 | #include <stdlib.h>
|
---|
| 5 | #include <stdio.h>
|
---|
| 6 | #include <string.h>
|
---|
| 7 |
|
---|
| 8 | #pragma data_seg(DATA1)
|
---|
| 9 | #pragma alloc_text(MISC9,first_path,searchapath,searchpath)
|
---|
| 10 |
|
---|
[551] | 11 | CHAR *first_path(CHAR * path, CHAR * ret)
|
---|
| 12 | {
|
---|
[2] | 13 |
|
---|
[551] | 14 | CHAR *p, *pp;
|
---|
[2] | 15 |
|
---|
[551] | 16 | if (!path || !ret)
|
---|
[2] | 17 | return ret;
|
---|
[551] | 18 | strcpy(ret, path);
|
---|
| 19 | p = strchr(ret, ';');
|
---|
| 20 | if (p) {
|
---|
[2] | 21 | *p = 0;
|
---|
| 22 | p++;
|
---|
[551] | 23 | if (*ret == '.') { /* skip initial "cur dir" */
|
---|
| 24 | pp = strchr(p, ';');
|
---|
| 25 | if (pp)
|
---|
| 26 | *pp = 0;
|
---|
| 27 | if (*p)
|
---|
| 28 | memmove(ret, p, strlen(p) + 1);
|
---|
[2] | 29 | }
|
---|
| 30 | }
|
---|
| 31 | return ret;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
[551] | 34 | CHAR *searchapath(CHAR * path, CHAR * filename)
|
---|
| 35 | {
|
---|
[2] | 36 |
|
---|
| 37 | static CHAR fbuf[CCHMAXPATH];
|
---|
| 38 |
|
---|
[551] | 39 | if (strchr(filename, '\\') || strchr(filename, '/')
|
---|
| 40 | || strchr(filename, ':')) {
|
---|
[2] | 41 |
|
---|
| 42 | FILESTATUS3 fsa;
|
---|
| 43 |
|
---|
[551] | 44 | if (!DosQueryPathInfo(filename, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa)))
|
---|
[2] | 45 | return filename;
|
---|
| 46 | *fbuf = 0;
|
---|
| 47 | return fbuf;
|
---|
| 48 | }
|
---|
| 49 | *fbuf = 0;
|
---|
[551] | 50 | if (DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT |
|
---|
| 51 | SEARCH_CUR_DIRECTORY,
|
---|
| 52 | path, filename, fbuf, CCHMAXPATH - 1))
|
---|
[2] | 53 | *fbuf = 0;
|
---|
| 54 | return fbuf;
|
---|
| 55 | }
|
---|
| 56 |
|
---|
[551] | 57 | CHAR *searchpath(CHAR * filename)
|
---|
| 58 | {
|
---|
[2] | 59 |
|
---|
| 60 | CHAR *found;
|
---|
| 61 |
|
---|
[551] | 62 | if (!filename)
|
---|
[2] | 63 | return "";
|
---|
[551] | 64 | found = searchapath("PATH", filename);
|
---|
| 65 | if (!*found) {
|
---|
| 66 | found = searchapath("DPATH", filename);
|
---|
| 67 | if (!*found)
|
---|
| 68 | found = searchapath("XPATH", filename);
|
---|
[2] | 69 | }
|
---|
| 70 | return found;
|
---|
| 71 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.