Directive s=pw sets structure to phrase if term includes blank(s).
[yaz-moved-to-github.git] / asn / test.c
1 #include <stdio.h>
2 #include <yaz/odr.h>
3 #include <yaz/proto.h>
4
5 int main()
6 {
7     int i;
8     unsigned char buf[10000];
9     struct odr o;
10     Z_APDU apdu, *papdu, *papdu2;
11     Z_SearchRequest sreq;
12     int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10;
13     bool_t rep;
14     static char *names[] = {"Erik", "William", "George", "Bob"};
15     Z_Query query;
16     Z_RPNQuery rpnquery;
17     Odr_oid att[] = { 1, 2, 3, 4, 5, 6, -1};
18     Z_RPNStructure rpnstructure;
19     Z_Operand operand;
20     Z_AttributesPlusTerm apt;
21     Odr_oct term;
22
23     papdu = &apdu;
24     apdu.which = Z_APDU_searchRequest;
25     apdu.u.searchRequest = &sreq;
26     a1 = 1000; sreq.smallSetUpperBound = &a1;
27     a2 = 2000; sreq.largeSetLowerBound = &a2;
28     a3 = 100; sreq.mediumSetPresentNumber = &a3;
29     rep = 1; sreq.replaceIndicator = &rep;
30     sreq.resultSetName = "FOOBAR";
31     sreq.num_databaseNames = 4;
32     sreq.databaseNames = names;
33     sreq.smallSetElementSetNames = 0;
34     sreq.mediumSetElementSetNames = 0;
35     sreq.preferredRecordSyntax = 0;
36     query.which = Z_Query_type_1;
37     query.u.type_1 = &rpnquery;
38     sreq.query = &query;
39     rpnquery.attributeSetId = att;
40     rpnquery.RPNStructure = &rpnstructure;
41     rpnstructure.which = Z_RPNStructure_simple;
42     rpnstructure.u.simple = &operand;
43     operand.which = Z_Operand_APT;
44     operand.u.attributesPlusTerm = &apt;
45     apt.num_attributes=0;
46     apt.attributeList = 0;
47     apt.term = &term;
48     term.buf = (unsigned char*) "BARFOO";
49     term.len = term.size = strlen((char*)term.buf);
50
51     o.buf = buf;
52     o.bp=o.buf;
53     o.left = o.buflen = 10000;
54     o.direction = ODR_PRINT;
55     o.print = stdout;
56     o.indent = 0;
57     o.t_class = -1;
58
59     printf("status=%d\n", z_APDU(&o, &papdu, 0));
60
61     return 0;
62
63     o.direction = ODR_DECODE;
64     o.bp = o.buf;
65
66     z_APDU(&o, &papdu2, 0);
67 }