aboutsummaryrefslogtreecommitdiff
path: root/pkg/tbtables/tbepp.x
blob: 69cd0b519b88e49e512b699501c896e7ea25e651 (plain) (blame)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
include <mach.h>		# for packing strings in tbeppt
include "tbtables.h"

# tbepp[tbirds] -- primitive put element
# This procedure writes one element (i.e. row, column) into a table.
# No type conversion is performed, and the location in the output file
# must already exist (i.e. must not be beyond the EOF).  Character
# strings will be packed by tbeptt, however.
#
# Phil Hodge, 15-Sep-1987  Subroutine created.
# Phil Hodge, 31-Mar-1993  Include short datatype.
# Phil Hodge, 13-Sep-1994  In tbegpt, use tbeszt for length of string to write.

procedure tbeppb (tp, cptr, offset, rownum, buffer)

pointer tp			# i: pointer to table descriptor
pointer cptr			# i: pointer to column descriptor
long	offset			# i: offset in char to location for reading
int	rownum			# i: row number
bool	buffer			# i: buffer containing value
#--
errchk	seek, write

begin
	call seek (TB_FILE(tp), offset)
	call write (TB_FILE(tp), buffer, SZ_BOOL)
end

procedure tbeppd (tp, cptr, offset, rownum, buffer)

pointer tp			# i: pointer to table descriptor
pointer cptr			# i: pointer to column descriptor
long	offset			# i: offset in char to location for reading
int	rownum			# i: row number
double	buffer			# i: buffer containing value
#--
errchk	seek, write

begin
	call seek (TB_FILE(tp), offset)
	call write (TB_FILE(tp), buffer, SZ_DOUBLE)
end

procedure tbeppr (tp, cptr, offset, rownum, buffer)

pointer tp			# i: pointer to table descriptor
pointer cptr			# i: pointer to column descriptor
long	offset			# i: offset in char to location for reading
int	rownum			# i: row number
real	buffer			# i: buffer containing value
#--
errchk	seek, write

begin
	call seek (TB_FILE(tp), offset)
	call write (TB_FILE(tp), buffer, SZ_REAL)
end

procedure tbeppi (tp, cptr, offset, rownum, buffer)

pointer tp			# i: pointer to table descriptor
pointer cptr			# i: pointer to column descriptor
long	offset			# i: offset in char to location for reading
int	rownum			# i: row number
int	buffer			# i: buffer containing value
#--
errchk	seek, write

begin
	call seek (TB_FILE(tp), offset)
        if (SZ_INT != SZ_INT32)
            call ipak32 (buffer, buffer, 1)
	call write (TB_FILE(tp), buffer, SZ_INT32)
end

procedure tbepps (tp, cptr, offset, rownum, buffer)

pointer tp			# i: pointer to table descriptor
pointer cptr			# i: pointer to column descriptor
long	offset			# i: offset in char to location for reading
int	rownum			# i: row number
short	buffer			# i: buffer containing value
#--
errchk	seek, write

begin
	call seek (TB_FILE(tp), offset)
	call write (TB_FILE(tp), buffer, SZ_SHORT)
end

procedure tbeppt (tp, cptr, offset, rownum, buffer)

pointer tp			# i: pointer to table descriptor
pointer cptr			# i: pointer to column descriptor
long	offset			# i: offset in char to location for reading
int	rownum			# i: row number
char	buffer[ARB]		# i: buffer containing value
#--
char	cbuf[SZ_LINE]		# buffer for packed string
int	nchar			# number of char to write
int	tbeszt()
errchk	seek, write

begin
	nchar = min (tbeszt (cptr), SZ_LINE)
	call strpak (buffer, cbuf, SZ_LINE)	# pack the string
	call seek (TB_FILE(tp), offset)
	call write (TB_FILE(tp), cbuf, nchar)
end