annotate src/vmsmap.c @ 16703:c9ce47315e38

Update VERSION to 2.4.2.
author Richard M. Stallman <rms@gnu.org>
date Mon, 16 Dec 1996 21:49:21 +0000
parents ee40177f6c68
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* VMS mapping of data and alloc arena for GNU Emacs.
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2 Copyright (C) 1986, 1987 Free Software Foundation, Inc.
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 This file is part of GNU Emacs.
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
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: 4696
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 any later version.
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 GNU General Public License for more details.
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 12244
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 12244
diff changeset
19 Boston, MA 02111-1307, USA. */
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 /* Written by Mukesh Prasad. */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 #ifdef VMS
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24
4696
1fc792473491 Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents: 484
diff changeset
25 #include <config.h>
484
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 #include "lisp.h"
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 #include <rab.h>
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 #include <fab.h>
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 #include <rmsdef.h>
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 #include <secdef.h>
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 /* RMS block size */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 #define BLOCKSIZE 512
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 /* Maximum number of bytes to be written in one RMS write.
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 * Must be a multiple of BLOCKSIZE.
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 #define MAXWRITE (BLOCKSIZE * 30)
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 /* This funniness is to ensure that sdata occurs alphabetically BEFORE the
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 $DATA psect and that edata occurs after ALL Emacs psects. This is
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 because the VMS linker sorts all psects in a cluster alphabetically
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 during the linking, unless you use the cluster_psect command. Emacs
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 uses the cluster command to group all Emacs psects into one cluster;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 this keeps the dumped data separate from any loaded libraries. */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 globaldef {"$D$ATA"} char sdata[512]; /* Start of saved data area */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 globaldef {"__DATA"} char edata[512]; /* End of saved data area */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 /* Structure to write into first block of map file.
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 struct map_data
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 {
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 char * sdata; /* Start of data area */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 char * edata; /* End of data area */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 int datablk; /* Block in file to map data area from/to */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 };
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 static void fill_fab (), fill_rab ();
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 static int write_data ();
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 extern char *start_of_data ();
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 extern int vms_out_initial; /* Defined in malloc.c */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 /* Maps in the data and alloc area from the map file.
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 int
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 mapin_data (name)
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 char * name;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 {
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 struct FAB fab;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 struct RAB rab;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 int status, size;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 int inadr[2];
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 struct map_data map_data;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 /* Open map file. */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 fab = cc$rms_fab;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 fab.fab$b_fac = FAB$M_BIO|FAB$M_GET;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 fab.fab$l_fna = name;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 fab.fab$b_fns = strlen (name);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 status = sys$open (&fab);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 if (status != RMS$_NORMAL)
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 {
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 printf ("Map file not available, running bare Emacs....\n");
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 return 0; /* Map file not available */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 }
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 /* Connect the RAB block */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 rab = cc$rms_rab;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 rab.rab$l_fab = &fab;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 rab.rab$b_rac = RAB$C_SEQ;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 rab.rab$l_rop = RAB$M_BIO;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 status = sys$connect (&rab);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 if (status != RMS$_NORMAL)
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 lib$stop (status);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 /* Read the header data */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 rab.rab$l_ubf = &map_data;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 rab.rab$w_usz = sizeof (map_data);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 rab.rab$l_bkt = 0;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 status = sys$read (&rab);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 if (status != RMS$_NORMAL)
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 lib$stop (status);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 status = sys$close (&fab);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 if (status != RMS$_NORMAL)
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 lib$stop (status);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 if (map_data.sdata != start_of_data ())
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 {
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 printf ("Start of data area has moved: cannot map in data.\n");
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 return 0;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 }
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 if (map_data.edata != edata)
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 {
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 printf ("End of data area has moved: cannot map in data.\n");
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 return 0;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 }
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 fab.fab$l_fop |= FAB$M_UFO;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 status = sys$open (&fab);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 if (status != RMS$_NORMAL)
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 lib$stop (status);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 /* Map data area. */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 inadr[0] = map_data.sdata;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 inadr[1] = map_data.edata;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 status = sys$crmpsc (inadr, 0, 0, SEC$M_CRF | SEC$M_WRT, 0, 0, 0,
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 fab.fab$l_stv, 0, map_data.datablk, 0, 0);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 if (! (status & 1))
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 lib$stop (status);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 }
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 /* Writes the data and alloc area to the map file.
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 mapout_data (into)
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 char * into;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 {
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 struct FAB fab;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 struct RAB rab;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 int status;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 struct map_data map_data;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 int datasize, msize;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 if (vms_out_initial)
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 {
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 error ("Out of initial allocation. Must rebuild emacs with more memory (VMS_ALLOCATION_SIZE).");
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 return 0;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 }
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 map_data.sdata = start_of_data ();
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 map_data.edata = edata;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 datasize = map_data.edata - map_data.sdata + 1;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 map_data.datablk = 2 + (sizeof (map_data) + BLOCKSIZE - 1) / BLOCKSIZE;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 /* Create map file. */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 fab = cc$rms_fab;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 fab.fab$b_fac = FAB$M_BIO|FAB$M_PUT;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 fab.fab$l_fna = into;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 fab.fab$b_fns = strlen (into);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 fab.fab$l_fop = FAB$M_CBT;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 fab.fab$b_org = FAB$C_SEQ;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 fab.fab$b_rat = 0;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 fab.fab$b_rfm = FAB$C_VAR;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 fab.fab$l_alq = 1 + map_data.datablk +
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 ((datasize + BLOCKSIZE - 1) / BLOCKSIZE);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 status = sys$create (&fab);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 if (status != RMS$_NORMAL)
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 {
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 error ("Could not create map file");
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 return 0;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 }
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 /* Connect the RAB block */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 rab = cc$rms_rab;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 rab.rab$l_fab = &fab;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 rab.rab$b_rac = RAB$C_SEQ;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 rab.rab$l_rop = RAB$M_BIO;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 status = sys$connect (&rab);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 if (status != RMS$_NORMAL)
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 {
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 error ("RMS connect to map file failed");
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 return 0;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 }
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 /* Write the header */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 rab.rab$l_rbf = &map_data;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 rab.rab$w_rsz = sizeof (map_data);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 status = sys$write (&rab);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 if (status != RMS$_NORMAL)
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 {
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 error ("RMS write (header) to map file failed");
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 return 0;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 }
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 if (! write_data (&rab, map_data.datablk, map_data.sdata, datasize))
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 return 0;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 status = sys$close (&fab);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 if (status != RMS$_NORMAL)
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 {
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 error ("RMS close on map file failed");
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 return 0;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 }
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 return 1;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 }
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 static int
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 write_data (rab, firstblock, data, length)
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 struct RAB * rab;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 char * data;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 {
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 int status;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 rab->rab$l_bkt = firstblock;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 while (length > 0)
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 {
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 rab->rab$l_rbf = data;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 rab->rab$w_rsz = length > MAXWRITE ? MAXWRITE : length;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 status = sys$write (rab, 0, 0);
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 if (status != RMS$_NORMAL)
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 {
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 error ("RMS write to map file failed");
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 return 0;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 }
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 data = &data[MAXWRITE];
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 length -= MAXWRITE;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 rab->rab$l_bkt = 0;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 }
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 return 1;
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 } /* write_data */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 #endif /* VMS */
3165b2697c78 entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225