Changeset e5295a in git for Singular


Ignore:
Timestamp:
Nov 6, 1999, 4:49:45 PM (25 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'fc741b6502fd8a97288eaa3eba6e5220f3c3df87')
Children:
c53894fdfe805579de2fbdddd799c04fc841c494
Parents:
698457f6f46700a65e8096f211292da37a6d4278
Message:
* follow symbolic links up to level MAX_LINK_LEVEL (10)


git-svn-id: file:///usr/local/Singular/svn/trunk@3812 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/find_exec.c

    r698457 re5295a  
    150150
    151151#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
     158int 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 
    152188char * find_executable (const char *name)
    153189{
     
    156192  int ret;
    157193
    158   if (link == NULL && (ret=readlink(name, buf, MAXPATHLEN)) > 0)
     194  if (link == NULL && (ret=full_readlink(name, buf, MAXPATHLEN)) > 0)
    159195  {
    160196    buf[ret] ='\0';
    161197    link = find_executable_link(buf);
    162198  }
    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 */
    165203    char *p = strrchr(link, '/');
    166204    char *executable;
Note: See TracChangeset for help on using the changeset viewer.