Changeset e5295a in git
- Timestamp:
- Nov 6, 1999, 4:49:45 PM (24 years ago)
- Branches:
- (u'spielwiese', '91fdef05f09f54b8d58d92a472e9c4a43aa4656f')
- Children:
- c53894fdfe805579de2fbdddd799c04fc841c494
- Parents:
- 698457f6f46700a65e8096f211292da37a6d4278
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/find_exec.c
r698457 re5295a 150 150 151 151 #ifdef HAVE_READLINK 152 153 #define MAX_LINK_LEVEL 10 154 /* similar to readlink (cf. man readlink), except that symbolic links are 155 followed up to MAX_LINK_LEVEL 156 */ 157 158 int full_readlink(const char* name, char* buf, size_t bufsize) 159 { 160 int ret; 161 162 if ((ret=readlink(name, buf, bufsize)) > 0) 163 { 164 char buf2[MAXPATHLEN]; 165 int ret2, i = 0; 166 167 do 168 { 169 buf[ret] = '\0'; 170 if ((ret2 = readlink(buf, buf2, MAXPATHLEN)) > 0) 171 { 172 i++; 173 buf2[ret2] = '\0'; 174 strcpy(buf, buf2); 175 ret = ret2; 176 } 177 else 178 { 179 return ret; 180 } 181 } 182 while (i<MAX_LINK_LEVEL); 183 } 184 return -1; 185 } 186 187 152 188 char * find_executable (const char *name) 153 189 { … … 156 192 int ret; 157 193 158 if (link == NULL && (ret= readlink(name, buf, MAXPATHLEN)) > 0)194 if (link == NULL && (ret=full_readlink(name, buf, MAXPATHLEN)) > 0) 159 195 { 160 196 buf[ret] ='\0'; 161 197 link = find_executable_link(buf); 162 198 } 163 if (link != NULL && (ret=readlink(link, buf, MAXPATHLEN)) > 0) 164 { 199 if (link != NULL && (ret=full_readlink(link, buf, MAXPATHLEN)) > 0) 200 { 201 /* follow link further until you reach the end of it, or unitl 202 MAX_SYMBOLIC_LINKS are encountered */ 165 203 char *p = strrchr(link, '/'); 166 204 char *executable;
Note: See TracChangeset
for help on using the changeset viewer.