aboutsummaryrefslogtreecommitdiff
path: root/sys/ki/kigchan.x
diff options
context:
space:
mode:
Diffstat (limited to 'sys/ki/kigchan.x')
-rw-r--r--sys/ki/kigchan.x38
1 files changed, 38 insertions, 0 deletions
diff --git a/sys/ki/kigchan.x b/sys/ki/kigchan.x
new file mode 100644
index 00000000..aa7c4332
--- /dev/null
+++ b/sys/ki/kigchan.x
@@ -0,0 +1,38 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <config.h>
+include "ki.h"
+
+# KI_GETCHAN -- Find the first empty slot in the channel descriptor table
+# and return its index, initializing the server and oschan fields with the
+# values given.
+
+int procedure ki_getchan (server, oschan)
+
+int server # kernel server node
+int oschan # os channel (iraf kernel channel)
+
+int i
+include "kichan.com"
+include "kinode.com"
+
+begin
+ # Server=0 if local node.
+ if (server > 0)
+ n_nrefs[server] = n_nrefs[server] + 1
+
+ do i = FIRST_CHAN, MAX_CHANNELS
+ if (k_oschan[i] == NULL) {
+ # Initialize channel descriptor.
+
+ k_node[i] = server
+ k_oschan[i] = oschan
+ k_status[i] = 0
+ k_bufp[i] = NULL
+
+ return (i)
+ }
+
+ # The following cannot happen unless something is very wrong.
+ call sys_panic (0, "ki_getchan: out of channel slots")
+end