1 /* This file is part of the yazpp toolkit.
2 * Copyright (C) 1998-2008 Index Data and Mike Taylor
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
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.
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.
28 #ifndef YAZ_Z_ASSOC_INCLUDED
29 #define YAZ_Z_ASSOC_INCLUDED
32 #include <yaz/proto.h>
34 #include <yazpp/pdu-observer.h>
37 /** Z39.50 Assocation.
38 This object implements the client - and server role of a generic
41 class YAZ_EXPORT Z_Assoc : public IPDU_Observer {
43 /// Create object using the PDU Observer specified
44 Z_Assoc(IPDU_Observable *the_PDU_Observable);
45 /// Destroy assocation and close PDU Observer
48 void recv_PDU(const char *buf, int len);
49 /// Connect notification
50 virtual void connectNotify() = 0;
51 /// Failure notification
52 virtual void failNotify() = 0;
53 /// Timeout notification
54 virtual void timeoutNotify() = 0;
56 void timeout(int timeout);
57 /// Begin Z39.50 client role
58 int client(const char *addr);
59 /// Begin Z39.50 server role
60 int server(const char *addr);
63 /// Decode Z39.50 PDU.
64 Z_GDU *decode_GDU(const char *buf, int len);
65 /// Encode Z39.50 PDU.
66 int encode_GDU(Z_GDU *apdu, char **buf, int *len);
68 int send_Z_PDU(Z_APDU *apdu, int *len);
69 int send_GDU(Z_GDU *apdu, int *len);
70 /// Receive Z39.50 PDU
71 virtual void recv_GDU(Z_GDU *apdu, int len) = 0;
72 /// Create Z39.50 PDU with reasonable defaults
73 Z_APDU *create_Z_PDU(int type);
79 void set_APDU_log(const char *fname);
80 const char *get_APDU_log();
83 void get_otherInfoAPDU(Z_APDU *apdu, Z_OtherInformation ***oip);
84 Z_OtherInformationUnit *update_otherInformation (
85 Z_OtherInformation **otherInformationP, int createFlag,
86 const Odr_oid *oid, int categoryValue, int deleteFlag);
87 void set_otherInformationString(
89 const Odr_oid *oid, int categoryValue, const char *str);
90 void set_otherInformationString (
91 Z_OtherInformation **otherInformationP,
92 const Odr_oid *oid, int categoryValue,
94 Z_ReferenceId *getRefID(char* str);
95 Z_ReferenceId **get_referenceIdP(Z_APDU *apdu);
96 void transfer_referenceId(Z_APDU *from, Z_APDU *to);
98 const char *get_hostname();
100 int set_APDU_yazlog(int v);
103 static int yaz_init_flag;
104 static int yaz_init_func();
105 IPDU_Observable *m_PDU_Observable;
121 * indent-tabs-mode: nil
123 * vim: shiftwidth=4 tabstop=8 expandtab