Updated footer comment
[yazpp-moved-to-github.git] / zlint / zlint.h
1 /* This file is part of the yazpp toolkit.
2  * Copyright (C) 1998-2009 Index Data and Mike Taylor
3  * All rights reserved.
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  *     * Redistributions of source code must retain the above copyright
8  *       notice, this list of conditions and the following disclaimer.
9  *     * Redistributions in binary form must reproduce the above copyright
10  *       notice, this list of conditions and the following disclaimer in the
11  *       documentation and/or other materials provided with the distribution.
12  *     * Neither the name of Index Data nor the names of its contributors
13  *       may be used to endorse or promote products derived from this
14  *       software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27
28 #include <yazpp/z-assoc.h>
29
30 using namespace yazpp_1;
31
32 enum Zlint_code {
33     TEST_FINISHED,
34     TEST_CONTINUE,
35     TEST_REOPEN
36 };
37
38 class Zlint_test;
39 class Zlint_t;
40
41 class Zlint : public Z_Assoc {
42 public:
43     Zlint(IPDU_Observable *the_PDU_Observable);
44     ~Zlint();
45     void add_test(Zlint_test *i);
46     void set_host(const char *cp);
47     int initResponseGetVersion(Z_InitResponse *init);
48     Z_ReferenceId *mk_refid(const char *buf, int len);
49     void msg_check_for(const char *fmt, ...);
50     void msg_check_ok();
51     void msg_check_fail(const char *fmt, ...);
52     void msg_check_info(const char *fmt, ...);
53     void msg_check_notapp();
54     void getDatabase(char ***db, int *num);
55 private:
56     void connectNotify();
57     void timeoutNotify();
58     void failNotify();
59     void recv_GDU(Z_GDU *apdu, int len);
60     IPDU_Observable *m_PDU_Observable;
61     IPDU_Observer *sessionNotify(IPDU_Observable *the_PDU_Observable, int fd);
62     Zlint_t *m_tests;
63     Zlint_t *m_cur_test;
64     char *m_host;
65     char *m_database;
66     void close_goto_next();
67 };
68
69 class Zlint_test {
70 public:
71     virtual Zlint_code init(Zlint *z) = 0;
72     virtual Zlint_code recv_gdu(Zlint *z, Z_GDU *gdu) = 0;
73     virtual Zlint_code recv_fail(Zlint *z, int reason) = 0;
74     virtual ~Zlint_test();
75 };
76
77 class Zlint_test_simple : public Zlint_test {
78 public:
79     virtual Zlint_code init(Zlint *z) = 0;
80     virtual Zlint_code recv_gdu(Zlint *z, Z_GDU *gdu) = 0;
81     virtual Zlint_code recv_fail(Zlint *z, int reason);
82 };
83
84 class Zlint_test_init_01 : public Zlint_test_simple {
85 public:
86     Zlint_test_init_01();
87     virtual ~Zlint_test_init_01();
88     Zlint_code init(Zlint *z);
89     Zlint_code recv_gdu(Zlint *z, Z_GDU *gdu);
90 };
91
92 class Zlint_test_init_02 : public Zlint_test_simple {
93 public:
94     Zlint_test_init_02();
95     virtual ~Zlint_test_init_02();
96     Zlint_code init(Zlint *z);
97     Zlint_code recv_gdu(Zlint *z, Z_GDU *gdu);
98 };
99
100 class Zlint_test_init_03 : public Zlint_test_simple {
101 public:
102     Zlint_test_init_03();
103     virtual ~Zlint_test_init_03();
104     Zlint_code init(Zlint *z);
105     Zlint_code recv_gdu(Zlint *z, Z_GDU *gdu);
106 };
107
108 class Zlint_test_init_04 : public Zlint_test_simple {
109 public:
110     Zlint_test_init_04();
111     virtual ~Zlint_test_init_04();
112     Zlint_code init(Zlint *z);
113     Zlint_code recv_gdu(Zlint *z, Z_GDU *gdu);
114 };
115
116 class Zlint_test_init_05 : public Zlint_test_simple {
117     int m_init_response_no;
118 public:
119     Zlint_test_init_05();
120     virtual ~Zlint_test_init_05();
121     Zlint_code init(Zlint *z);
122     Zlint_code recv_gdu(Zlint *z, Z_GDU *gdu);
123 };
124
125 class Zlint_test_init_06 : public Zlint_test_simple {
126 public:
127     Zlint_test_init_06();
128     virtual ~Zlint_test_init_06();
129     Zlint_code init(Zlint *z);
130     Zlint_code recv_gdu(Zlint *z, Z_GDU *gdu);
131 };
132
133 class Zlint_test_init_07 : public Zlint_test_simple {
134 public:
135     Zlint_test_init_07();
136     virtual ~Zlint_test_init_07();
137     Zlint_code init(Zlint *z);
138     Zlint_code recv_gdu(Zlint *z, Z_GDU *gdu);
139 };
140
141 class Zlint_test_init_08 : public Zlint_test {
142     int m_no;
143 public:
144     Zlint_test_init_08();
145     virtual ~Zlint_test_init_08();
146     Zlint_code init(Zlint *z);
147     Zlint_code recv_gdu(Zlint *z, Z_GDU *gdu);
148     Zlint_code recv_fail(Zlint *z, int reason);
149 };
150
151 class Zlint_test_search_01 : public Zlint_test {
152     int m_query_no;
153     int m_got_result_set;
154     int m_record_syntax_no;
155     int m_sort_no;
156     Zlint_code sendTest(Zlint *z);
157 public:
158     Zlint_test_search_01();
159     virtual ~Zlint_test_search_01();
160     Zlint_code init(Zlint *z);
161     Zlint_code recv_gdu(Zlint *z, Z_GDU *gdu);
162     Zlint_code recv_fail(Zlint *z, int reason);
163 };
164
165 class Zlint_test_scan_01 : public Zlint_test {
166     int m_scan_no;
167     Zlint_code sendTest(Zlint *z);
168 public:
169     Zlint_test_scan_01();
170     virtual ~Zlint_test_scan_01();
171     Zlint_code init(Zlint *z);
172     Zlint_code recv_gdu(Zlint *z, Z_GDU *gdu);
173     Zlint_code recv_fail(Zlint *z, int reason);
174 };
175 /*
176  * Local variables:
177  * c-basic-offset: 4
178  * c-file-style: "Stroustrup"
179  * indent-tabs-mode: nil
180  * End:
181  * vim: shiftwidth=4 tabstop=8 expandtab
182  */
183