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