diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
commit | fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch) | |
tree | bdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/imio/imaccess.x | |
download | iraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz |
Initial commit
Diffstat (limited to 'sys/imio/imaccess.x')
-rw-r--r-- | sys/imio/imaccess.x | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/sys/imio/imaccess.x b/sys/imio/imaccess.x new file mode 100644 index 00000000..cc6d450e --- /dev/null +++ b/sys/imio/imaccess.x @@ -0,0 +1,66 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include <syserr.h> + + +# IMACCESS -- Test if an image exists and is accessible with the given access +# mode. If the access mode given is NEW_IMAGE, test if the image name given +# is legal (has a legal extension, i.e., type). YES is returned if the named +# image exists, NO if no image exists with the given name, and ERR if the +# image name is ambiguous (multiple images, e.g. of different types, exist +# with the same name). + +int procedure imaccess (image, acmode) + +char image[ARB] # image name +int acmode # access mode + +int exists, cl_index, cl_size, mode, status +pointer sp, cluster, ksection, section, root, extn, im +int iki_access() +errchk syserrs +pointer immap() + +begin + call smark (sp) + call salloc (cluster, SZ_PATHNAME, TY_CHAR) + call salloc (ksection, SZ_FNAME, TY_CHAR) + call salloc (section, SZ_FNAME, TY_CHAR) + call salloc (root, SZ_PATHNAME, TY_CHAR) + call salloc (extn, SZ_FNAME, TY_CHAR) + + call iki_init() + + call imparse (image, + Memc[cluster], SZ_PATHNAME, + Memc[ksection], SZ_FNAME, + Memc[section], SZ_FNAME, cl_index, cl_size) + + # If an image section, kernel section, or cluster index was specified + # we must actually attempt to open the image to determine if the + # object specified by the full notation exists, otherwise we can just + # call the IKI access function to determine if the cluster exists. + + if (Memc[section] != EOS || Memc[ksection] != EOS || cl_index >= 0) { + mode = acmode + if (acmode == 0) + mode = READ_ONLY + iferr (im = immap (image, mode, 0)) + exists = NO + else { + exists = YES + call imunmap (im) + } + } else { + status = iki_access (image, Memc[root], Memc[extn], acmode) + if (status > 0) + exists = YES + else if (status == 0) + exists = NO + else + call syserrs (SYS_IKIAMBIG, image) + } + + call sfree (sp) + return (exists) +end |