annotate src/vmsfns.c @ 13696:f89aa5a5c485

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