| Last change
 on this file since 576 was             551, checked in by Gregg Young, 19 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 | 
      
      
| Line |  | 
|---|
| 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 |  | 
|---|
| 11 | CHAR *first_path(CHAR * path, CHAR * ret) | 
|---|
| 12 | { | 
|---|
| 13 |  | 
|---|
| 14 | CHAR *p, *pp; | 
|---|
| 15 |  | 
|---|
| 16 | if (!path || !ret) | 
|---|
| 17 | return ret; | 
|---|
| 18 | strcpy(ret, path); | 
|---|
| 19 | p = strchr(ret, ';'); | 
|---|
| 20 | if (p) { | 
|---|
| 21 | *p = 0; | 
|---|
| 22 | p++; | 
|---|
| 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); | 
|---|
| 29 | } | 
|---|
| 30 | } | 
|---|
| 31 | return ret; | 
|---|
| 32 | } | 
|---|
| 33 |  | 
|---|
| 34 | CHAR *searchapath(CHAR * path, CHAR * filename) | 
|---|
| 35 | { | 
|---|
| 36 |  | 
|---|
| 37 | static CHAR fbuf[CCHMAXPATH]; | 
|---|
| 38 |  | 
|---|
| 39 | if (strchr(filename, '\\') || strchr(filename, '/') | 
|---|
| 40 | || strchr(filename, ':')) { | 
|---|
| 41 |  | 
|---|
| 42 | FILESTATUS3 fsa; | 
|---|
| 43 |  | 
|---|
| 44 | if (!DosQueryPathInfo(filename, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa))) | 
|---|
| 45 | return filename; | 
|---|
| 46 | *fbuf = 0; | 
|---|
| 47 | return fbuf; | 
|---|
| 48 | } | 
|---|
| 49 | *fbuf = 0; | 
|---|
| 50 | if (DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | | 
|---|
| 51 | SEARCH_CUR_DIRECTORY, | 
|---|
| 52 | path, filename, fbuf, CCHMAXPATH - 1)) | 
|---|
| 53 | *fbuf = 0; | 
|---|
| 54 | return fbuf; | 
|---|
| 55 | } | 
|---|
| 56 |  | 
|---|
| 57 | CHAR *searchpath(CHAR * filename) | 
|---|
| 58 | { | 
|---|
| 59 |  | 
|---|
| 60 | CHAR *found; | 
|---|
| 61 |  | 
|---|
| 62 | if (!filename) | 
|---|
| 63 | return ""; | 
|---|
| 64 | found = searchapath("PATH", filename); | 
|---|
| 65 | if (!*found) { | 
|---|
| 66 | found = searchapath("DPATH", filename); | 
|---|
| 67 | if (!*found) | 
|---|
| 68 | found = searchapath("XPATH", filename); | 
|---|
| 69 | } | 
|---|
| 70 | return found; | 
|---|
| 71 | } | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.