Fixed serious bug regarding timeouts. Improved logging for proxy.
[yazpp-moved-to-github.git] / include / yaz-z-assoc.h
1 /*
2  * Copyright (c) 1998-1999, Index Data.
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  * 
6  * $Id: yaz-z-assoc.h,v 1.7 2000-08-07 14:19:59 adam Exp $
7  */
8
9 #include <yaz/proto.h>
10 #include <yaz/odr.h>
11 #include <yaz-pdu-observer.h>
12
13 /** Z39.50 Assocation.
14     This object implements the client - and server role of a generic
15     Z39.50 Association.
16 */
17 class YAZ_EXPORT Yaz_Z_Assoc : public IYaz_PDU_Observer {
18  public:
19     /// Create object using the PDU Observer specified
20     Yaz_Z_Assoc(IYaz_PDU_Observable *the_PDU_Observable);
21     /// Destroy assocation and close PDU Observer
22     virtual ~Yaz_Z_Assoc();
23     /// Receive PDU
24     void recv_PDU(const char *buf, int len);
25     /// Connect notification
26     virtual void connectNotify() = 0;
27     /// Failure notification
28     virtual void failNotify() = 0;
29     /// Timeout notification
30     virtual void timeoutNotify() = 0;
31     /// Timeout specify
32     void timeout(int timeout);
33     /// Begin Z39.50 client role
34     void client(const char *addr);
35     /// Begin Z39.50 server role
36     void server(const char *addr);
37     /// Close connection
38     void close();
39     /// Decode Z39.50 PDU.
40     Z_APDU *decode_Z_PDU(const char *buf, int len);
41     /// Encode Z39.50 PDU.
42     int encode_Z_PDU(Z_APDU *apdu, char **buf, int *len);
43     /// Send Z39.50 PDU
44     int send_Z_PDU(Z_APDU *apdu);
45     /// Receive Z39.50 PDU
46     virtual void recv_Z_PDU(Z_APDU *apdu) = 0;
47     /// Create Z39.50 PDU with reasonable defaults
48     Z_APDU *create_Z_PDU(int type);
49     /// Request Alloc
50     ODR odr_encode ();
51     ODR odr_decode ();
52     ODR odr_print ();
53
54     void set_APDU_log(const char *fname);
55     const char *get_APDU_log();
56
57     /// OtherInformation
58     void get_otherInfoAPDU(Z_APDU *apdu, Z_OtherInformation ***oip);
59     Z_OtherInformationUnit *update_otherInformation (
60         Z_OtherInformation **otherInformationP, int createFlag,
61         int *oid, int categoryValue, int deleteFlag);
62     void set_otherInformationString (
63         Z_OtherInformation **otherInformationP,
64         int *oid, int categoryValue,
65         const char *str);
66     void set_otherInformationString (
67         Z_OtherInformation **otherInformation,
68         int oidval, int categoryValue,
69         const char *str);
70     void set_otherInformationString (
71         Z_APDU *apdu,
72         int oidval, int categoryValue,
73         const char *str);
74
75     Z_ReferenceId* getRefID(char* str);
76
77     const char *get_hostname();
78
79  private:
80     static int yaz_init_flag;
81     static int yaz_init_func();
82     IYaz_PDU_Observable *m_PDU_Observable;
83     ODR m_odr_in;
84     ODR m_odr_out;
85     ODR m_odr_print;
86     int m_log;
87     FILE *m_APDU_file;
88     char *m_APDU_fname;
89     char *m_hostname;
90 };