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

include	<syserr.h>
include	<mach.h>
include	"qpoe.h"
include	"qpex.h"

# QPEX_OPEN -- Open the expression evaluator.  If an expression is given it
# is compiled into the descriptor, otherwise a null (pass all) expression
# is compiled.  The compiled expression may be modified or read out at any
# time via calls to other routines in the QPEX package (e.g., qpex_modfilter,
# qpex_getfilter).

pointer procedure qpex_open (qp, expr)

pointer	qp			#I QPOE descriptor
char	expr[ARB]		#I selection expression (filter) 

pointer	ex, pb, db
int	pb_len, db_len
int	qpex_modfilter()
errchk	calloc

begin
	# Allocate the main QPEX descriptor.
	call calloc (ex, LEN_EXDES, TY_STRUCT)

	# Allocate the program buffer.
	pb_len = QP_EXPBLEN(qp)
	call calloc (pb, pb_len, TY_INT)

	# Allocate the data buffer.
	db_len = QP_EXDBLEN(qp)
	call calloc (db, db_len, TY_CHAR)

	# Initialize the descriptor.

	EX_QP(ex)	= qp
	EX_DEBUG(ex)	= QP_DEBUG(qp)
	EX_START(ex)	= pb

	EX_PB(ex)	= pb
	EX_PBTOP(ex)	= pb + pb_len
	EX_PBOP(ex)	= pb

	EX_DB(ex)	= db
	EX_DBTOP(ex)	= db + db_len
	EX_DBOP(ex)	= db

	EX_MAXFRLUTLEN(ex)  = QP_EXMAXFRLLEN(qp)
	EX_MAXRRLUTLEN(ex)  = QP_EXMAXRRLLEN(qp)
	EX_LUTMINRANGES(ex) = QP_EXLMINRANGES(qp)
	EX_LUTSCALE(ex)     = QP_EXLSCALE(qp)

	if (EX_DEBUG(ex) > 1) {
	    call eprintf ("QPEX activated, expr = `%s'\n")
		call pargstr (expr)
	}

	# If a selection expression was given, compile it into the descriptor.
	if (qpex_modfilter (ex, expr) == ERR) {
	    call qpex_close (ex)
	    call syserrs (SYS_QPEXSYN, QP_DFNAME(qp))
	}

	return (ex)
end