annotate src/vmsfns.c @ 17380:ba0844956fde

(diary-astro-day-number): Change format string.
author Richard M. Stallman <rms@gnu.org>
date Fri, 11 Apr 1997 02:32:13 +0000
parents ee40177f6c68
children b7aa6ac26872
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
146
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 /* VMS subprocess and command interface.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 Copyright (C) 1987, 1988 Free Software Foundation, Inc.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 This file is part of GNU Emacs.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
12244
ac7375e60931 Update GPL to version 2.
Karl Heuer <kwzh@gnu.org>
parents: 9107
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
146
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 any later version.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 GNU General Public License for more details.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 12244
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 12244
diff changeset
19 Boston, MA 02111-1307, USA. */
146
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 /* Written by Mukesh Prasad. */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 /*
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 * INTERFACE PROVIDED BY EMACS FOR VMS SUBPROCESSES:
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 *
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 * Emacs provides the following functions:
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 *
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 * "spawn-subprocess", which takes as arguments:
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 *
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 * (i) an integer to identify the spawned subprocess in future
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 * operations,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 * (ii) A function to process input from the subprocess, and
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 * (iii) A function to be called upon subprocess termination.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 *
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 * First argument is required. If second argument is missing or nil,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 * the default action is to insert all received messages at the current
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 * location in the current buffer. If third argument is missing or nil,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 * no action is taken upon subprocess termination.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 * The input-handler is called as
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 * (input-handler num string)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 * where num is the identifying integer for the subprocess and string
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 * is a string received from the subprocess. exit-handler is called
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 * with the identifying integer as the argument.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 *
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 * "send-command-to-subprocess" takes two arguments:
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 *
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 * (i) Subprocess identifying integer.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 * (ii) String to send as a message to the subprocess.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 *
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 * "stop-subprocess" takes the subprocess identifying integer as
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 * argument.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 *
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 * Implementation is done by spawning an asynchronous subprocess, and
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 * communicating to it via mailboxes.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 #ifdef VMS
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 #include <stdio.h>
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 #include <ctype.h>
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 #undef NULL
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62
4696
1fc792473491 Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents: 484
diff changeset
63 #include <config.h>
146
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 #include "lisp.h"
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 #include <descrip.h>
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 #include <dvidef.h>
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 #include <prvdef.h>
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 /* #include <clidef.h> */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 #include <iodef.h>
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 #include <ssdef.h>
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 #include <errno.h>
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 #ifdef VMS4_4 /* I am being cautious; perhaps this exists in older versions */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 #include <jpidef.h>
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 #endif
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 /* #include <syidef.h> */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 #define CLI$M_NOWAIT 1 /* clidef.h is missing from C library */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 #define SYI$_VERSION 4096 /* syidef.h is missing from C library */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 #define JPI$_CLINAME 522 /* JPI$_CLINAME is missing from jpidef.h */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 #define JPI$_MASTER_PID 805 /* JPI$_MASTER_PID missing from jpidef.h */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 #define LIB$_NOSUCHSYM 1409892 /* libclidef.h missing */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 #define MSGSIZE 160 /* Maximum size for mailbox operations */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 #ifndef PRV$V_ACNT
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 /* these defines added as hack for VMS 5.1-1. SJones, 8-17-89 */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 /* this is _really_ nasty and needs to be changed ASAP - should see about
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 using the union defined in SYS$LIBRARY:PRVDEF.H under v5 */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 #define PRV$V_ACNT 0x09
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 #define PRV$V_ALLSPOOL 0x04
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 #define PRV$V_ALTPRI 0x0D
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 #define PRV$V_BUGCHK 0x17
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 #define PRV$V_BYPASS 0x1D
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 #define PRV$V_CMEXEC 0x01
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 #define PRV$V_CMKRNL 0x00
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 #define PRV$V_DETACH 0x05
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 #define PRV$V_DIAGNOSE 0x06
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 #define PRV$V_DOWNGRADE 0x21
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 #define PRV$V_EXQUOTA 0x13
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 #define PRV$V_GROUP 0x08
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 #define PRV$V_GRPNAM 0x03
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 #define PRV$V_GRPPRV 0x22
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 #define PRV$V_LOG_IO 0x07
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 #define PRV$V_MOUNT 0x11
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 #define PRV$V_NETMBX 0x14
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 #define PRV$V_NOACNT 0x09
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 #define PRV$V_OPER 0x12
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 #define PRV$V_PFNMAP 0x1A
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 #define PRV$V_PHY_IO 0x16
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 #define PRV$V_PRMCEB 0x0A
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 #define PRV$V_PRMGBL 0x18
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 #define PRV$V_PRMJNL 0x25
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 #define PRV$V_PRMMBX 0x0B
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 #define PRV$V_PSWAPM 0x0C
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 #define PRV$V_READALL 0x23
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 #define PRV$V_SECURITY 0x26
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 #define PRV$V_SETPRI 0x0D
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 #define PRV$V_SETPRV 0x0E
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 #define PRV$V_SHARE 0x1F
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 #define PRV$V_SHMEM 0x1B
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 #define PRV$V_SYSGBL 0x19
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 #define PRV$V_SYSLCK 0x1E
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 #define PRV$V_SYSNAM 0x02
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 #define PRV$V_SYSPRV 0x1C
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 #define PRV$V_TMPJNL 0x24
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 #define PRV$V_TMPMBX 0x0F
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 #define PRV$V_UPGRADE 0x20
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 #define PRV$V_VOLPRO 0x15
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 #define PRV$V_WORLD 0x10
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 #endif
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 /* IO status block for mailbox operations. */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 struct mbx_iosb
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 short status;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 short size;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 int pid;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 };
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 /* Structure for maintaining linked list of subprocesses. */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 struct process_list
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 int name; /* Numeric identifier for subprocess */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 int process_id; /* VMS process address */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 int process_active; /* 1 iff process has not exited yet */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 int mbx_chan; /* Mailbox channel to write to process */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 struct mbx_iosb iosb; /* IO status block for write operations */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 Lisp_Object input_handler; /* Input handler for subprocess */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 Lisp_Object exit_handler; /* Exit handler for subprocess */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 struct process_list * next; /* Linked list chain */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 };
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 /* Structure for privilege list. */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 struct privilege_list
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 char * name;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 int mask;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 };
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 /* Structure for finding VMS related information. */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 struct vms_objlist
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 char * name; /* Name of object */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 Lisp_Object (* objfn)(); /* Function to retrieve VMS object */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 };
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 static int exit_ast (); /* Called upon subprocess exit */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 static int create_mbx (); /* Creates mailbox */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 static void mbx_msg (); /* Writes null terminated string to mbx */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 static void write_to_mbx (); /* Writes message to string */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 static void start_mbx_input (); /* Queues I/O request to mailbox */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 static int input_mbx_chan = 0; /* Channel to read subprocess input on */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 static char input_mbx_name[20];
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 /* Storage for mailbox device name */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 static struct dsc$descriptor_s input_mbx_dsc;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 /* Descriptor for mailbox device name */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 static struct process_list * process_list = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 /* Linked list of subprocesses */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 static char mbx_buffer[MSGSIZE];
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 /* Buffer to read from subprocesses */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 static struct mbx_iosb input_iosb;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 /* IO status block for mailbox reads */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 int have_process_input, /* Non-zero iff subprocess input pending */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 process_exited; /* Non-zero iff suprocess exit pending */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 /* List of privilege names and mask offsets */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 static struct privilege_list priv_list[] = {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 { "ACNT", PRV$V_ACNT },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 { "ALLSPOOL", PRV$V_ALLSPOOL },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 { "ALTPRI", PRV$V_ALTPRI },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 { "BUGCHK", PRV$V_BUGCHK },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 { "BYPASS", PRV$V_BYPASS },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 { "CMEXEC", PRV$V_CMEXEC },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 { "CMKRNL", PRV$V_CMKRNL },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 { "DETACH", PRV$V_DETACH },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 { "DIAGNOSE", PRV$V_DIAGNOSE },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 { "DOWNGRADE", PRV$V_DOWNGRADE }, /* Isn't VMS as low as you can go? */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 { "EXQUOTA", PRV$V_EXQUOTA },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 { "GRPPRV", PRV$V_GRPPRV },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 { "GROUP", PRV$V_GROUP },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 { "GRPNAM", PRV$V_GRPNAM },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 { "LOG_IO", PRV$V_LOG_IO },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 { "MOUNT", PRV$V_MOUNT },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 { "NETMBX", PRV$V_NETMBX },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 { "NOACNT", PRV$V_NOACNT },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 { "OPER", PRV$V_OPER },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 { "PFNMAP", PRV$V_PFNMAP },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 { "PHY_IO", PRV$V_PHY_IO },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 { "PRMCEB", PRV$V_PRMCEB },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 { "PRMGBL", PRV$V_PRMGBL },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 { "PRMJNL", PRV$V_PRMJNL },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 { "PRMMBX", PRV$V_PRMMBX },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 { "PSWAPM", PRV$V_PSWAPM },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 { "READALL", PRV$V_READALL },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 { "SECURITY", PRV$V_SECURITY },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 { "SETPRI", PRV$V_SETPRI },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 { "SETPRV", PRV$V_SETPRV },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 { "SHARE", PRV$V_SHARE },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 { "SHMEM", PRV$V_SHMEM },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 { "SYSGBL", PRV$V_SYSGBL },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 { "SYSLCK", PRV$V_SYSLCK },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 { "SYSNAM", PRV$V_SYSNAM },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 { "SYSPRV", PRV$V_SYSPRV },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 { "TMPJNL", PRV$V_TMPJNL },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 { "TMPMBX", PRV$V_TMPMBX },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 { "UPGRADE", PRV$V_UPGRADE },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 { "VOLPRO", PRV$V_VOLPRO },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 { "WORLD", PRV$V_WORLD },
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 };
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 vms_account(), vms_cliname(), vms_owner(), vms_grp(), vms_image(),
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 vms_parent(), vms_pid(), vms_prcnam(), vms_terminal(), vms_uic_int(),
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 vms_uic_str(), vms_username(), vms_version_fn(), vms_trnlog(),
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 vms_symbol(), vms_proclist();
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 /* Table of arguments to Fvms_object, and the handlers that get the data. */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 static struct vms_objlist vms_object [] = {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 { "ACCOUNT", vms_account }, /* Returns account name as a string */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 { "CLINAME", vms_cliname }, /* Returns CLI name (string) */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 { "OWNER", vms_owner }, /* Returns owner process's PID (int) */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 { "GRP", vms_grp }, /* Returns group number of UIC (int) */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 { "IMAGE", vms_image }, /* Returns executing image (string) */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 { "PARENT", vms_parent }, /* Returns parent proc's PID (int) */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 { "PID", vms_pid }, /* Returns process's PID (int) */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 { "PRCNAM", vms_prcnam }, /* Returns process's name (string) */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 { "TERMINAL", vms_terminal }, /* Returns terminal name (string) */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 { "UIC", vms_uic_int }, /* Returns UIC as integer */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 { "UICGRP", vms_uic_str }, /* Returns UIC as string */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 { "USERNAME", vms_username }, /* Returns username (string) */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 { "VERSION", vms_version_fn },/* Returns VMS version (string) */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 { "LOGICAL", vms_trnlog }, /* Translates VMS logical name */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 { "DCL-SYMBOL", vms_symbol }, /* Translates DCL symbol */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 { "PROCLIST", vms_proclist }, /* Returns list of all PIDs on system */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 };
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 Lisp_Object Qdefault_subproc_input_handler;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 extern int process_ef; /* Event flag for subprocess operations */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 DEFUN ("default-subprocess-input-handler",
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 Fdefault_subproc_input_handler, Sdefault_subproc_input_handler,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 2, 2, 0,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 "Default input handler for input from spawned subprocesses.")
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (name, input)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 Lisp_Object name, input;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 /* Just insert in current buffer */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 insert1 (input);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 insert ("\n", 1);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 DEFUN ("spawn-subprocess", Fspawn_subprocess, Sspawn_subprocess, 1, 3, 0,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 "Spawn an asynchronous VMS suprocess for command processing.")
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 (name, input_handler, exit_handler)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 Lisp_Object name, input_handler, exit_handler;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 int status;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 char output_mbx_name[20];
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 struct dsc$descriptor_s output_mbx_dsc;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 struct process_list *ptr, *p, *prev;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 CHECK_NUMBER (name, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 if (! input_mbx_chan)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 if (! create_mbx (&input_mbx_dsc, input_mbx_name, &input_mbx_chan, 1))
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 return Qnil;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 start_mbx_input ();
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 ptr = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 prev = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 while (ptr)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 struct process_list *next = ptr->next;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 if (ptr->name == XFASTINT (name))
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 if (ptr->process_active)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 return Qt;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 /* Delete this process and run its exit handler. */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 if (prev)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 prev->next = next;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 else
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 process_list = next;
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 224
diff changeset
314 if (! NILP (ptr->exit_handler))
146
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 Feval (Fcons (ptr->exit_handler, Fcons (make_number (ptr->name),
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 Qnil)));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 sys$dassgn (ptr->mbx_chan);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 break;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 else
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 prev = ptr;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 ptr = next;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 if (! ptr)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 ptr = xmalloc (sizeof (struct process_list));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 if (! create_mbx (&output_mbx_dsc, output_mbx_name, &ptr->mbx_chan, 2))
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 free (ptr);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 return Qnil;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 }
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 224
diff changeset
331 if (NILP (input_handler))
146
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 input_handler = Qdefault_subproc_input_handler;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 ptr->input_handler = input_handler;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 ptr->exit_handler = exit_handler;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 message ("Creating subprocess...");
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 status = lib$spawn (0, &output_mbx_dsc, &input_mbx_dsc, &CLI$M_NOWAIT, 0,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 &ptr->process_id, 0, 0, exit_ast, &ptr->process_active);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 if (! (status & 1))
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 sys$dassgn (ptr->mbx_chan);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 free (ptr);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 error ("Unable to spawn subprocess");
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 return Qnil;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 ptr->name = XFASTINT (name);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 ptr->next = process_list;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 ptr->process_active = 1;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 process_list = ptr;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 message ("Creating subprocess...done");
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 return Qt;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 static void
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 mbx_msg (ptr, msg)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 struct process_list *ptr;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 char *msg;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 write_to_mbx (ptr, msg, strlen (msg));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 DEFUN ("send-command-to-subprocess",
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 Fsend_command_to_subprocess, Ssend_command_to_subprocess, 2, 2,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 "sSend command to subprocess: \nsSend subprocess %s command: ",
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 "Send to VMS subprocess named NAME the string COMMAND.")
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 (name, command)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 Lisp_Object name, command;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 struct process_list * ptr;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 CHECK_NUMBER (name, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 CHECK_STRING (command, 1);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 for (ptr = process_list; ptr; ptr = ptr->next)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 if (XFASTINT (name) == ptr->name)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 write_to_mbx (ptr, XSTRING (command)->data,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 XSTRING (command)->size);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 return Qt;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 return Qnil;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 DEFUN ("stop-subprocess", Fstop_subprocess, Sstop_subprocess, 1, 1,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 "sStop subprocess: ", "Stop VMS subprocess named NAME.")
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 (name)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 Lisp_Object name;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 struct process_list * ptr;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 CHECK_NUMBER (name, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 for (ptr = process_list; ptr; ptr = ptr->next)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 if (XFASTINT (name) == ptr->name)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 ptr->exit_handler = Qnil;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 if (sys$delprc (&ptr->process_id, 0) & 1)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 ptr->process_active = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 return Qt;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 return Qnil;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 static int
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 exit_ast (active)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 int * active;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 process_exited = 1;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 *active = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 sys$setef (process_ef);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 /* Process to handle input on the input mailbox.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 * Searches through the list of processes until the matching PID is found,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 * then calls its input handler.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 process_command_input ()
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 struct process_list * ptr;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 char * msg;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 int msglen;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 Lisp_Object expr;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 msg = mbx_buffer;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 msglen = input_iosb.size;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 /* Hack around VMS oddity of sending extraneous CR/LF characters for
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 * some of the commands (but not most).
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 if (msglen > 0 && *msg == '\r')
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 msg++;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 msglen--;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 if (msglen > 0 && msg[msglen - 1] == '\n')
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 msglen--;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 if (msglen > 0 && msg[msglen - 1] == '\r')
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 msglen--;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 /* Search for the subprocess in the linked list.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 expr = Qnil;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 for (ptr = process_list; ptr; ptr = ptr->next)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 if (ptr->process_id == input_iosb.pid)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 expr = Fcons (ptr->input_handler,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 Fcons (make_number (ptr->name),
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 Fcons (make_string (msg, msglen),
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 Qnil)));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 break;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 have_process_input = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 start_mbx_input ();
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 clear_waiting_for_input (); /* Otherwise Ctl-g will cause crash. JCB */
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 224
diff changeset
451 if (! NILP (expr))
146
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 Feval (expr);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 /* Searches process list for any processes which have exited. Calls their
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 * exit handlers and removes them from the process list.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 process_exit ()
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 struct process_list * ptr, * prev, * next;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 process_exited = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 prev = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 ptr = process_list;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 while (ptr)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 next = ptr->next;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 if (! ptr->process_active)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 if (prev)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 prev->next = next;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 else
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 process_list = next;
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 224
diff changeset
475 if (! NILP (ptr->exit_handler))
146
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 Feval (Fcons (ptr->exit_handler, Fcons (make_number (ptr->name),
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 Qnil)));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 sys$dassgn (ptr->mbx_chan);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 free (ptr);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 else
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 prev = ptr;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 ptr = next;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 /* Called at emacs exit.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 kill_vms_processes ()
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 struct process_list * ptr;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 for (ptr = process_list; ptr; ptr = ptr->next)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 if (ptr->process_active)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 sys$dassgn (ptr->mbx_chan);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 sys$delprc (&ptr->process_id, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 sys$dassgn (input_mbx_chan);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 process_list = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 input_mbx_chan = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 /* Creates a temporary mailbox and retrieves its device name in 'buf'.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 * Makes the descriptor pointed to by 'dsc' refer to this device.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 * 'buffer_factor' is used to allow sending messages asynchronously
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 * till some point.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 static int
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 create_mbx (dsc, buf, chan, buffer_factor)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 struct dsc$descriptor_s *dsc;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 char *buf;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 int *chan;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 int buffer_factor;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 int strval[2];
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 int status;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 status = sys$crembx (0, chan, MSGSIZE, MSGSIZE * buffer_factor, 0, 0, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 if (! (status & 1))
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 message ("Unable to create mailbox. Need TMPMBX privilege.");
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 return 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 strval[0] = 16;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 strval[1] = buf;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 status = lib$getdvi (&DVI$_DEVNAM, chan, 0, 0, strval,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 &dsc->dsc$w_length);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 if (! (status & 1))
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 return 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 dsc->dsc$b_dtype = DSC$K_DTYPE_T;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 dsc->dsc$b_class = DSC$K_CLASS_S;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 dsc->dsc$a_pointer = buf;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 return 1;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 } /* create_mbx */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 /* AST routine to be called upon receiving mailbox input.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 * Sets flag telling keyboard routines that input is available.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 static int
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 mbx_input_ast ()
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 have_process_input = 1;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 /* Issue a QIO request on the input mailbox.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 static void
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 start_mbx_input ()
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 sys$qio (process_ef, input_mbx_chan, IO$_READVBLK, &input_iosb,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 mbx_input_ast, 0, mbx_buffer, sizeof (mbx_buffer),
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 0, 0, 0, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 /* Send a message to the subprocess input mailbox, without blocking if
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 * possible.
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 static void
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 write_to_mbx (ptr, buf, len)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 struct process_list *ptr;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 char *buf;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 int len;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 sys$qiow (0, ptr->mbx_chan, IO$_WRITEVBLK | IO$M_NOW, &ptr->iosb,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 0, 0, buf, len, 0, 0, 0, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 DEFUN ("setprv", Fsetprv, Ssetprv, 1, 3, 0,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 "Set or reset a VMS privilege. First arg is privilege name.\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 Second arg is t or nil, indicating whether the privilege is to be\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 set or reset. Default is nil. Returns t if success, nil if not.\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 If third arg is non-nil, does not change privilege, but returns t\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 or nil depending upon whether the privilege is already enabled.")
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 (priv, value, getprv)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 Lisp_Object priv, value, getprv;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 int prvmask[2], prvlen, newmask[2];
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 char * prvname;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 int found, i;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 struct privilege_list * ptr;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 CHECK_STRING (priv, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 priv = Fupcase (priv);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 prvname = XSTRING (priv)->data;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 prvlen = XSTRING (priv)->size;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 found = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 prvmask[0] = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 prvmask[1] = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 for (i = 0; i < sizeof (priv_list) / sizeof (priv_list[0]); i++)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 ptr = &priv_list[i];
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 if (prvlen == strlen (ptr->name) &&
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597 bcmp (prvname, ptr->name, prvlen) == 0)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 if (ptr->mask >= 32)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 prvmask[1] = 1 << (ptr->mask % 32);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 else
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 prvmask[0] = 1 << ptr->mask;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 found = 1;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 break;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 if (! found)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 error ("Unknown privilege name %s", XSTRING (priv)->data);
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 224
diff changeset
609 if (NILP (getprv))
146
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 {
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 224
diff changeset
611 if (sys$setprv (NILP (value) ? 0 : 1, prvmask, 0, 0) == SS$_NORMAL)
146
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 return Qt;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 return Qnil;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 /* Get old priv value */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 if (sys$setprv (0, 0, 0, newmask) != SS$_NORMAL)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 return Qnil;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618 if ((newmask[0] & prvmask[0])
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 || (newmask[1] & prvmask[1]))
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 return Qt;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 return Qnil;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 /* Retrieves VMS system information. */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 #ifdef VMS4_4 /* I don't know whether these functions work in old versions */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 DEFUN ("vms-system-info", Fvms_system_info, Svms_system_info, 1, 3, 0,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 "Retrieve VMS process and system information.\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 The first argument (a string) specifies the type of information desired.\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 The other arguments depend on the type you select.\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 For information about a process, the second argument is a process ID\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 or a process name, with the current process as a default.\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 These are the possibilities for the first arg (upper or lower case ok):\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 account Returns account name\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636 cliname Returns CLI name\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 owner Returns owner process's PID\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 grp Returns group number\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 parent Returns parent process's PID\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 pid Returns process's PID\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641 prcnam Returns process's name\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 terminal Returns terminal name\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 uic Returns UIC number\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 uicgrp Returns formatted [UIC,GRP]\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 username Returns username\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 version Returns VMS version\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 logical Translates VMS logical name (second argument)\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 dcl-symbol Translates DCL symbol (second argument)\n\
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 proclist Returns list of all PIDs on system (needs WORLD privilege)." )
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 (type, arg1, arg2)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 Lisp_Object type, arg1, arg2;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 int i, typelen;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 char * typename;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 struct vms_objlist * ptr;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 CHECK_STRING (type, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 type = Fupcase (type);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 typename = XSTRING (type)->data;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 typelen = XSTRING (type)->size;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 for (i = 0; i < sizeof (vms_object) / sizeof (vms_object[0]); i++)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 ptr = &vms_object[i];
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 if (typelen == strlen (ptr->name)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 && bcmp (typename, ptr->name, typelen) == 0)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 return (* ptr->objfn)(arg1, arg2);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 error ("Unknown object type %s", typename);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 /* Given a reference to a VMS process, returns its process id. */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 static int
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 translate_id (pid, owner)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 Lisp_Object pid;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 int owner; /* if pid is null/0, return owner. If this
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 * flag is 0, return self. */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679 int status, code, id, i, numeric, size;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 char * p;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 int prcnam[2];
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 224
diff changeset
683 if (NILP (pid)
9107
46461644055b (translate_id): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 4696
diff changeset
684 || STRINGP (pid) && XSTRING (pid)->size == 0
46461644055b (translate_id): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 4696
diff changeset
685 || INTEGERP (pid) && XFASTINT (pid) == 0)
146
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 code = owner ? JPI$_OWNER : JPI$_PID;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 status = lib$getjpi (&code, 0, 0, &id);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 if (! (status & 1))
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 error ("Cannot find %s: %s",
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 owner ? "owner process" : "process id",
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 vmserrstr (status));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 return (id);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 }
9107
46461644055b (translate_id): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 4696
diff changeset
695 if (INTEGERP (pid))
146
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 return (XFASTINT (pid));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697 CHECK_STRING (pid, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 pid = Fupcase (pid);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 size = XSTRING (pid)->size;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 p = XSTRING (pid)->data;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 numeric = 1;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 id = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 for (i = 0; i < size; i++, p++)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 if (isxdigit (*p))
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 id *= 16;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707 if (*p >= '0' && *p <= '9')
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 id += *p - '0';
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 else
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710 id += *p - 'A' + 10;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 else
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 numeric = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 break;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 if (numeric)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 return (id);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 prcnam[0] = XSTRING (pid)->size;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 prcnam[1] = XSTRING (pid)->data;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 status = lib$getjpi (&JPI$_PID, 0, prcnam, &id);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 if (! (status & 1))
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 error ("Cannot find process id: %s",
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 vmserrstr (status));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 return (id);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 } /* translate_id */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 /* VMS object retrieval functions. */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731 getjpi (jpicode, arg, numeric)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 int jpicode; /* Type of GETJPI information */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733 Lisp_Object arg;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 int numeric; /* 1 if numeric value expected */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 int id, status, numval;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 char str[128];
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 int strdsc[2] = { sizeof (str), str };
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 short strlen;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 id = translate_id (arg, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 status = lib$getjpi (&jpicode, &id, 0, &numval, strdsc, &strlen);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 if (! (status & 1))
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 error ("Unable to retrieve information: %s",
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 vmserrstr (status));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 if (numeric)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 return (make_number (numval));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 return (make_string (str, strlen));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 vms_account (arg1, arg2)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 Lisp_Object arg1, arg2;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 return getjpi (JPI$_ACCOUNT, arg1, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 vms_cliname (arg1, arg2)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 Lisp_Object arg1, arg2;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 return getjpi (JPI$_CLINAME, arg1, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766 vms_grp (arg1, arg2)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 Lisp_Object arg1, arg2;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 return getjpi (JPI$_GRP, arg1, 1);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 vms_image (arg1, arg2)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774 Lisp_Object arg1, arg2;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 return getjpi (JPI$_IMAGNAME, arg1, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780 vms_owner (arg1, arg2)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781 Lisp_Object arg1, arg2;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783 return getjpi (JPI$_OWNER, arg1, 1);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
787 vms_parent (arg1, arg2)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788 Lisp_Object arg1, arg2;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 return getjpi (JPI$_MASTER_PID, arg1, 1);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794 vms_pid (arg1, arg2)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
795 Lisp_Object arg1, arg2;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
796 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797 return getjpi (JPI$_PID, arg1, 1);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
801 vms_prcnam (arg1, arg2)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802 Lisp_Object arg1, arg2;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
803 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 return getjpi (JPI$_PRCNAM, arg1, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808 vms_terminal (arg1, arg2)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
809 Lisp_Object arg1, arg2;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811 return getjpi (JPI$_TERMINAL, arg1, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
812 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 vms_uic_int (arg1, arg2)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 Lisp_Object arg1, arg2;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 return getjpi (JPI$_UIC, arg1, 1);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 vms_uic_str (arg1, arg2)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 Lisp_Object arg1, arg2;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 return getjpi (JPI$_UIC, arg1, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 vms_username (arg1, arg2)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 Lisp_Object arg1, arg2;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 return getjpi (JPI$_USERNAME, arg1, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 vms_version_fn (arg1, arg2)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837 Lisp_Object arg1, arg2;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 char str[40];
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 int status;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 int strdsc[2] = { sizeof (str), str };
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 short strlen;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 status = lib$getsyi (&SYI$_VERSION, 0, strdsc, &strlen, 0, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845 if (! (status & 1))
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846 error ("Unable to obtain version: %s", vmserrstr (status));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 return (make_string (str, strlen));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851 vms_trnlog (arg1, arg2)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 Lisp_Object arg1, arg2;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 {
224
7faa1846e8f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 146
diff changeset
854 char str[256]; /* Max logical translation is 255 bytes. */
146
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855 int status, symdsc[2];
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856 int strdsc[2] = { sizeof (str), str };
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 short length, level;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 CHECK_STRING (arg1, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 symdsc[0] = XSTRING (arg1)->size;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 symdsc[1] = XSTRING (arg1)->data;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 status = lib$sys_trnlog (symdsc, &length, strdsc);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 if (! (status & 1))
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 error ("Unable to translate logical name: %s", vmserrstr (status));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865 if (status == SS$_NOTRAN)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866 return (Qnil);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 return (make_string (str, length));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871 vms_symbol (arg1, arg2)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872 Lisp_Object arg1, arg2;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 {
224
7faa1846e8f8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 146
diff changeset
874 char str[1025]; /* Max symbol translation is 1024 bytes. */
146
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 int status, symdsc[2];
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
876 int strdsc[2] = { sizeof (str), str };
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 short length, level;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 CHECK_STRING (arg1, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 symdsc[0] = XSTRING (arg1)->size;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881 symdsc[1] = XSTRING (arg1)->data;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 status = lib$get_symbol (symdsc, strdsc, &length, &level);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 if (! (status & 1)) {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884 if (status == LIB$_NOSUCHSYM)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 return (Qnil);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 else
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887 error ("Unable to translate symbol: %s", vmserrstr (status));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889 return (make_string (str, length));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 static Lisp_Object
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 vms_proclist (arg1, arg2)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894 Lisp_Object arg1, arg2;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
896 Lisp_Object retval;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 int id, status, pid;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
898
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
899 retval = Qnil;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
900 pid = -1;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
901 for (;;)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
902 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
903 status = lib$getjpi (&JPI$_PID, &pid, 0, &id);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
904 if (status == SS$_NOMOREPROC)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
905 break;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
906 if (! (status & 1))
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907 error ("Unable to get process ID: %s", vmserrstr (status));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
908 retval = Fcons (make_number (id), retval);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
909 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910 return (Fsort (retval, intern ("<")));
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913 DEFUN ("shrink-to-icon", Fshrink_to_icon, Sshrink_to_icon, 0, 0, 0,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
914 "If emacs is running in a workstation window, shrink to an icon.")
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
915 ()
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
916 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
917 static char result[128];
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
918 static $DESCRIPTOR (result_descriptor, result);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
919 static $DESCRIPTOR (tt_name, "TT:");
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
920 static int chan = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
921 static int buf = 0x9d + ('2'<<8) + ('2'<<16) + (0x9c<<24);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
922 int status;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
923 static int temp = JPI$_TERMINAL;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
924
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925 status = lib$getjpi (&temp, 0, 0, 0, &result_descriptor, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
926 if (status != SS$_NORMAL)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
927 error ("Unable to determine terminal type.");
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928 if (result[0] != 'W' || result[1] != 'T') /* see if workstation */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929 error ("Can't shrink-to-icon on a non workstation terminal");
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 if (!chan) /* assign channel if not assigned */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
931 if ((status = sys$assign (&tt_name, &chan, 0, 0)) != SS$_NORMAL)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932 error ("Can't assign terminal, %d", status);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933 status = sys$qiow (0, chan, IO$_WRITEVBLK+IO$M_BREAKTHRU, 0, 0, 0,
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
934 &buf, 4, 0, 0, 0, 0);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935 if (status != SS$_NORMAL)
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936 error ("Can't shrink-to-icon, %d", status);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
938
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939 #endif /* VMS4_4 */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
940
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
941 init_vmsfns ()
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
942 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
943 process_list = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
944 input_mbx_chan = 0;
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
947 syms_of_vmsfns ()
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
948 {
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
949 defsubr (&Sdefault_subproc_input_handler);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
950 defsubr (&Sspawn_subprocess);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
951 defsubr (&Ssend_command_to_subprocess);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
952 defsubr (&Sstop_subprocess);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953 defsubr (&Ssetprv);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
954 #ifdef VMS4_4
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955 defsubr (&Svms_system_info);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956 defsubr (&Sshrink_to_icon);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957 #endif /* VMS4_4 */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958 Qdefault_subproc_input_handler = intern ("default-subprocess-input-handler");
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
959 staticpro (&Qdefault_subproc_input_handler);
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 }
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961 #endif /* VMS */
db0041ccc1e6 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
962