aboutsummaryrefslogtreecommitdiff
path: root/sys/imio/iki/oif/oifdelete.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/imio/iki/oif/oifdelete.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'sys/imio/iki/oif/oifdelete.x')
-rw-r--r--sys/imio/iki/oif/oifdelete.x53
1 files changed, 53 insertions, 0 deletions
diff --git a/sys/imio/iki/oif/oifdelete.x b/sys/imio/iki/oif/oifdelete.x
new file mode 100644
index 00000000..758309a7
--- /dev/null
+++ b/sys/imio/iki/oif/oifdelete.x
@@ -0,0 +1,53 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <protect.h>
+include <error.h>
+include <imhdr.h>
+
+# OIF_DELETE -- Delete an image. A special operator is required since the
+# image is stored as two files.
+
+procedure oif_delete (kernel, root, extn, status)
+
+int kernel #I IKI kernel
+char root[ARB] #I root filename
+char extn[ARB] #U extension
+int status
+
+int junk
+pointer sp, fname, pixfile
+int access(), protect()
+pointer im, immapz()
+
+begin
+ call smark (sp)
+ call salloc (fname, SZ_PATHNAME, TY_CHAR)
+ call salloc (pixfile, SZ_PATHNAME, TY_CHAR)
+
+ # Generate filename.
+ call iki_mkfname (root, extn, Memc[fname], SZ_PATHNAME)
+
+ iferr (im = immapz (Memc[fname], READ_ONLY, 0)) {
+ call erract (EA_WARN)
+
+ } else {
+ if (IM_PIXFILE(im) != EOS) {
+ call oif_gpixfname (IM_PIXFILE(im), IM_HDRFILE(im),
+ Memc[pixfile], SZ_PATHNAME)
+ if (access (Memc[pixfile],0,0) == YES)
+ iferr (call delete (Memc[pixfile]))
+ call erract (EA_WARN)
+ }
+
+ call imunmap (im)
+
+ # Do not complain if the file is not protected.
+ iferr (junk = protect (Memc[fname], REMOVE_PROTECTION))
+ ;
+ iferr (call delete (Memc[fname]))
+ call erract (EA_WARN)
+ }
+
+ call sfree (sp)
+ status = OK
+end