aboutsummaryrefslogtreecommitdiff
path: root/unix/boot/bootlib/ossymlink.c
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /unix/boot/bootlib/ossymlink.c
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'unix/boot/bootlib/ossymlink.c')
-rw-r--r--unix/boot/bootlib/ossymlink.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/unix/boot/bootlib/ossymlink.c b/unix/boot/bootlib/ossymlink.c
new file mode 100644
index 00000000..991b8359
--- /dev/null
+++ b/unix/boot/bootlib/ossymlink.c
@@ -0,0 +1,35 @@
+/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+ */
+
+#include <unistd.h>
+#include <iraf.h>
+
+#ifndef VMS
+#include <sys/types.h>
+#include <sys/stat.h>
+#endif
+
+/* OS_SYMLINK -- Determine if a file is a symbolic link.
+ */
+int
+os_symlink (
+ char *fname, /* file to be tested */
+ char *valbuf, /* buffer to receive link path, else NULL */
+ int maxch
+)
+{
+#ifndef VMS
+ struct stat fi;
+ int n;
+
+ if (lstat (fname, &fi) == 0)
+ if ((fi.st_mode & S_IFMT) == S_IFLNK) {
+ if (valbuf && maxch)
+ if ((n = readlink (fname, valbuf, maxch)) > 0)
+ valbuf[n] = '\0';
+ return (1);
+ }
+#endif
+
+ return (0);
+}