1 /* This file is part of the yazpp toolkit.
2 * Copyright (C) 1998-2013 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>
39 /** Z39.50 Assocation.
40 This object implements the client - and server role of a generic
43 class YAZ_EXPORT Z_Assoc : public IPDU_Observer {
45 /// Create object using the PDU Observer specified
46 Z_Assoc(IPDU_Observable *the_PDU_Observable);
47 /// Destroy assocation and close PDU Observer
50 void recv_PDU(const char *buf, int len);
51 /// Connect notification
52 virtual void connectNotify() = 0;
53 /// Failure notification
54 virtual void failNotify() = 0;
55 /// Timeout notification
56 virtual void timeoutNotify() = 0;
58 void timeout(int timeout);
59 /// Begin Z39.50 client role
60 int client(const char *addr);
61 /// Begin Z39.50 server role
62 int server(const char *addr);
65 /// Decode Z39.50 PDU.
66 Z_GDU *decode_GDU(const char *buf, int len);
67 /// Encode Z39.50 PDU.
68 int encode_GDU(Z_GDU *apdu, char **buf, int *len);
70 int send_Z_PDU(Z_APDU *apdu, int *len);
71 int send_GDU(Z_GDU *apdu, int *len);
72 /// Receive Z39.50 PDU
73 virtual void recv_GDU(Z_GDU *apdu, int len) = 0;
74 /// Create Z39.50 PDU with reasonable defaults
75 Z_APDU *create_Z_PDU(int type);
81 void set_APDU_log(const char *fname);
82 const char *get_APDU_log();
85 void get_otherInfoAPDU(Z_APDU *apdu, Z_OtherInformation ***oip);
86 Z_OtherInformationUnit *update_otherInformation (
87 Z_OtherInformation **otherInformationP, int createFlag,
88 const Odr_oid *oid, int categoryValue, int deleteFlag);
89 void set_otherInformationString(
91 const Odr_oid *oid, int categoryValue, const char *str);
92 void set_otherInformationString (
93 Z_OtherInformation **otherInformationP,
94 const Odr_oid *oid, int categoryValue,
96 Z_ReferenceId *getRefID(char* str);
97 Z_ReferenceId **get_referenceIdP(Z_APDU *apdu);
98 void transfer_referenceId(Z_APDU *from, Z_APDU *to);
100 const char *get_hostname();
102 int set_APDU_yazlog(int v);
112 * c-file-style: "Stroustrup"
113 * indent-tabs-mode: nil
115 * vim: shiftwidth=4 tabstop=8 expandtab