aboutsummaryrefslogtreecommitdiff
path: root/sys/qpoe/gen/qpputi.x
blob: 528e6bc7942795a6b76f25dda3b648ae56f43de9 (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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<syserr.h>
include	"../qpoe.h"

# QP_PUT -- Set the value of the named header parameter.  Automatic type
# conversion is performed where possible.  While only scalar values can be
# set by this function, the scalar may be an element of a one-dimensional
# array, e.g., "param[N]".

procedure qp_puti (qp, param, value)

pointer	qp			#I QPOE descriptor
char	param[ARB]		#I parameter name
int	value			#I scalar parameter value

pointer	pp
bool	indef
int	dtype
int	qp_putparam()
errchk	qp_putparam, syserrs

begin
	# Lookup the parameter and get a pointer to the value buffer.
	dtype = qp_putparam (qp, param, pp)
	if (pp == NULL)
	    call syserrs (SYS_QPNOVAL, param)

	if (QP_DEBUG(qp) > 1) {
	    call eprintf ("qp_put: `%s', TYP=(%d->%d), new value %g\n")
		call pargstr (param)
		call pargi (TY_INT)
		call pargi (dtype)
		call pargi (value)
	}

	indef = IS_INDEFI(value)

	# Set the parameter value.
	switch (dtype) {
	case TY_CHAR:
	    Memc[pp] = value
	case TY_SHORT:
	    if (indef)
		Mems[pp] = INDEFS
	    else
		Mems[pp] = value
	case TY_INT:
	    if (indef)
		Memi[pp] = INDEFI
	    else
		Memi[pp] = value
	case TY_LONG:
	    if (indef)
		Meml[pp] = INDEFL
	    else
		Meml[pp] = value
	case TY_REAL:
	    if (indef)
		Memr[pp] = INDEFR
	    else
		Memr[pp] = value
	case TY_DOUBLE:
	    if (indef)
		Memd[pp] = INDEFD
	    else
		Memd[pp] = value
	default:
	    call syserrs (SYS_QPBADCONV, param)
	}

	# Update the parameter in the datafile.
	call qp_flushpar (qp)
end