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