2 * Copyright (c) 1998-2000, Index Data.
3 * See the file LICENSE for details.
5 * $Id: z-assoc.h,v 1.6 2003-12-16 14:17:01 adam Exp $
8 #ifndef YAZ_Z_ASSOC_INCLUDED
9 #define YAZ_Z_ASSOC_INCLUDED
12 #include <yaz/proto.h>
14 #include <yaz++/pdu-observer.h>
16 /** Z39.50 Assocation.
17 This object implements the client - and server role of a generic
20 class YAZ_EXPORT Yaz_Z_Assoc : public IYaz_PDU_Observer {
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();
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;
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);
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);
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);
58 void set_APDU_log(const char *fname);
59 const char *get_APDU_log();
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,
70 void set_otherInformationString (
71 Z_OtherInformation **otherInformation,
72 int oidval, int categoryValue,
74 void set_otherInformationString (
76 int oidval, int categoryValue,
79 Z_ReferenceId *getRefID(char* str);
80 Z_ReferenceId **get_referenceIdP(Z_APDU *apdu);
81 void transfer_referenceId(Z_APDU *from, Z_APDU *to);
83 const char *get_hostname();
85 int set_APDU_yazlog(int v);
88 static int yaz_init_flag;
89 static int yaz_init_func();
90 IYaz_PDU_Observable *m_PDU_Observable;