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