aboutsummaryrefslogtreecommitdiff
path: root/pkg/xtools/catquery/cqgqpars.x
blob: 627dd0538d459fc954e4d4ec2404a980e792b3b9 (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
include "cqdef.h"


# CQ_GQPAR -- Get the default value, units, and format for a query parameter
# by name.

int procedure cq_gqpar (cq, name, pname, max_name, value, max_val, units,
	max_units, format, max_format)

pointer	cq				#I the catalog descriptor
char	name[ARB]			#I the input query parameter name
char	pname[ARB]			#I the output query parameter name
int	max_name			#I the max size of the parameter name
char	value[ARB]			#O the default value size
int	max_val				#I the max size of the parameter value
char	units[ARB]			#O the units string
int	max_units			#I the max size of the parameter units
char	format[ARB]			#O the format string
int	max_format			#I the max size of the parameter format

pointer	cc
int	parno
int	strdic(), cq_wrdstr()

begin
	# Check that the current catalog is defined.
	if (CQ_CAT(cq) == NULL)
	    return (0)
	if (CQ_CATNO(cq) < 1 || CQ_CATNO(cq) > CQ_NRECS(cq))
	    return (0)
	cc = CQ_CAT(cq)

	parno = strdic (name, pname, max_name, Memc[CQ_PQPNAMES(cc)])
	if (parno <= 0)
	    return (0)

	parno = cq_wrdstr (parno, value, max_val, Memc[CQ_PQPDVALUES(cc)])
	if (parno <= 0)
	    return (0)

	parno = cq_wrdstr (parno, units, max_units, Memc[CQ_PQPUNITS(cc)])
	if (parno <= 0)
	    return (0)

	parno = cq_wrdstr (parno, format, max_format, Memc[CQ_PQPFMTS(cc)])
	if (parno <= 0)
	    return (0)

	return (parno)
end


# CQ_GQPARN -- Get the default value, units, and format for a query parameter
# by number.

int procedure cq_gqparn (cq, parno, pname, max_name, value, max_val, units,
	max_units, format, max_format)

pointer	cq				#I the catalog descriptor
int	parno				#I the parameter number
char	pname[ARB]			#I the output query parameter name
int	max_name			#I the max size of the parameter name
char	value[ARB]			#O the default value size
int	max_val				#I the max size of the parameter value
char	units[ARB]			#O the units string
int	max_units			#I the max size of the parameter units
char	format[ARB]			#O the format string
int	max_format			#I the max size of the parameter format

pointer	cc
int	pnum
int	cq_wrdstr()

begin
	# Check that the current catalog is defined.
	if (CQ_CAT(cq) == NULL)
	    return (0)
	if (CQ_CATNO(cq) < 1 || CQ_CATNO(cq) > CQ_NRECS(cq))
	    return (0)
	cc = CQ_CAT(cq)

	pnum = cq_wrdstr (parno, pname, max_name, Memc[CQ_PQPNAMES(cc)])
	if (pnum <= 0)
	    return (0)

	pnum = cq_wrdstr (parno, value, max_val, Memc[CQ_PQPDVALUES(cc)])
	if (pnum <= 0)
	    return (0)

	pnum = cq_wrdstr (parno, units, max_units, Memc[CQ_PQPUNITS(cc)])
	if (pnum <= 0)
	    return (0)

	pnum = cq_wrdstr (parno, format, max_format, Memc[CQ_PQPFMTS(cc)])
	if (pnum <= 0)
	    return (0)

	return (pnum)
end