1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <syserr.h>
include <gescape.h>
include <fset.h>
include <gio.h>
# GIM_IOMAPREAD -- Read a segment of the gterm widget iomap.
procedure gim_iomapread (gp, iomap, first, nelem)
pointer gp #I graphics descriptor
int iomap[ARB] #o iomap data
int first #I first iomap cell to be read
int nelem #I number of elements to read
int nchars
pointer sp, data
short gim[GIM_READIOMAP_LEN]
short retval[GIM_RET_RIOMAP_LEN]
int read()
string s_readiomap "gim_iomapread"
errchk flush, read, syserrs
begin
call smark (sp)
call gpl_flush()
gim[GIM_READIOMAP_FC] = first
gim[GIM_READIOMAP_NC] = nelem
call gescape (gp, GIM_READIOMAP, gim, GIM_READIOMAP_LEN)
call flush (GP_FD(gp))
# Get return value instruction header.
nchars = GIM_RET_RIOMAP_LEN * SZ_SHORT
if (read (GP_FD(gp), retval, nchars) != nchars) {
call fseti (GP_FD(gp), F_CANCEL, OK)
call syserrs (SYS_FREAD, s_readiomap)
}
if (retval[GIM_RET_RIOMAP_NC] != nelem)
call syserrs (SYS_FREAD, s_readiomap)
# Get the iomap data.
call salloc (data, nelem, TY_SHORT)
nchars = nelem * SZ_SHORT
if (read (GP_FD(gp), Mems[data], nchars) != nchars) {
call fseti (GP_FD(gp), F_CANCEL, OK)
call syserrs (SYS_FREAD, s_readiomap)
} else
call achtsi (Mems[data], iomap, nelem)
call fseti (GP_FD(gp), F_CANCEL, OK)
call sfree (sp)
end
|