Changeset 3df5b10 in git for omalloc/omFindExec.c
- Timestamp:
- Aug 14, 2000, 2:08:48 PM (24 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
- Children:
- 9d605984360cf5d30bdf13e295d63c41ae1bc952
- Parents:
- ecf4ca6ad75f235385946daeae249f3bc6fd13c8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
omalloc/omFindExec.c
recf4ca6 r3df5b10 4 4 * Author: obachman (Olaf Bachmann) 5 5 * Created: 11/99 6 * Version: $Id: omFindExec.c,v 1. 2 2000-05-31 13:34:31obachman Exp $6 * Version: $Id: omFindExec.c,v 1.3 2000-08-14 12:08:45 obachman Exp $ 7 7 *******************************************************************/ 8 8 … … 20 20 #define MAXPATHLEN 1024 21 21 #endif 22 23 22 24 23 /* ABSOLUTE_FILENAME_P (fname): True if fname is an absolute filename */ … … 36 35 char * omFindExec (const char *name, char* executable) 37 36 #else 38 char * omFindExec_link (const char *name, char* executable)37 static char * omFindExec_link (const char *name, char* executable) 39 38 #endif 40 39 { 41 40 char *search; 42 41 char *p; 42 #ifdef WINNT 43 char *extra = NULL; 44 #endif 43 45 char tbuf[MAXPATHLEN]; 44 46 … … 84 86 char *extra = NULL; 85 87 /* we are under msdos display */ 86 FIX ME 87 extra = (char*) AllocL((search != NULL ? strlen(search) : 0) + 3); 88 extra = (char*) omAlloc((search != NULL ? strlen(search) : 0) + 3); 88 89 strcpy(extra, ".:"); 89 90 if (search != NULL) strcat(extra, search); … … 125 126 #ifdef WINNT 126 127 if (extra != NULL) 127 FreeL(extra);128 omFree(extra); 128 129 #endif 129 130 strcpy(executable, tbuf); … … 142 143 } 143 144 } 144 145 return NULL; 146 } 145 return NULL; 146 } 147 147 148 148 #ifdef HAVE_READLINK 149 /* similar to readlink, but dont' mess up absolute pathnames */ 150 static int my_readlink(const char* name, char* buf, size_t bufsize) 151 { 152 char buf2[MAXPATHLEN]; 153 int ret; 154 155 if ((ret = readlink(name, buf2, bufsize)) > 0) 156 { 157 buf2[ret] = 0; 158 if (*name == '/' && *buf2 != '/') 159 { 160 char* last = strrchr(name, '/'); 161 int i = 0; 162 while (&(name[i]) != last) 163 { 164 buf[i] = name[i]; 165 i++; 166 } 167 buf[i] = '/'; 168 i++; 169 strcpy(&(buf[i]), buf2); 170 return i + ret; 171 } 172 else 173 { 174 strcpy(buf, buf2); 175 } 176 } 177 return ret; 178 } 149 179 150 180 #define MAX_LINK_LEVEL 10 … … 152 182 followed up to MAX_LINK_LEVEL 153 183 */ 154 int full_readlink(const char* name, char* buf, size_t bufsize)184 static int full_readlink(const char* name, char* buf, size_t bufsize) 155 185 { 156 186 int ret; 157 187 158 if ((ret= readlink(name, buf, bufsize)) > 0)188 if ((ret=my_readlink(name, buf, bufsize)) > 0) 159 189 { 160 190 char buf2[MAXPATHLEN]; … … 164 194 { 165 195 buf[ret] = '\0'; 166 if ((ret2 = readlink(buf, buf2, MAXPATHLEN)) > 0)196 if ((ret2 = my_readlink(buf, buf2, MAXPATHLEN)) > 0) 167 197 { 168 198 i++; … … 195 225 if (link != NULL && (ret=full_readlink(link, buf, MAXPATHLEN)) > 0) 196 226 { 227 char *p = strrchr(link, '/'); 228 229 230 if(p!=NULL) *(p+1)='\0'; 197 231 buf[ret]='\0'; 198 return omFindExec_link(buf, exec); 232 233 if (buf[0] != '/') 234 { 235 strcpy(exec, link); 236 strcat(exec, buf); 237 } 238 else 239 { 240 strcpy(exec, buf); 241 } 242 243 return exec; 199 244 } 200 245 return link;
Note: See TracChangeset
for help on using the changeset viewer.