home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / gnu / emacs-19.28-src.lha / emacs-19.28 / unixlib / src / readlink.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-27  |  747 b   |  39 lines

  1. #include "amiga.h"
  2. #include <string.h>
  3.  
  4. int readlink(char *path, char *buf, int bufsiz)
  5. {
  6.   struct DevProc *dev = NULL;
  7.  
  8.   chkabort();
  9.  
  10.   while (1)
  11.     {
  12.       struct DevProc *newdev = GetDeviceProc(path, dev);
  13.       long err;
  14.       
  15.       FreeDeviceProc(dev);
  16.       if (!(dev = newdev)) ERROR;
  17.  
  18.       buf[0] = '\0';
  19.       if (ReadLink(dev->dvp_Port, dev->dvp_Lock, path, buf, bufsiz + 1))
  20.     {
  21.       FreeDeviceProc(dev);
  22.       if (!buf[0])
  23.         {
  24.           /* Play games with apparent 2.x ram: bug */
  25.           errno = ENOENT;
  26.           return -1;
  27.         }
  28.       return strlen(buf);
  29.     }
  30.       err = IoErr();
  31.       if (!(err == ERROR_OBJECT_NOT_FOUND && (dev->dvp_Flags & DVPF_ASSIGN)))
  32.     {
  33.       FreeDeviceProc(dev);
  34.       errno = convert_oserr(err);
  35.       return -1;
  36.     }
  37.     }
  38. }
  39.