annotate src/vmsfns.c @ 64:a01e7a40045c r19-16-pre7

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