2 * Copyright (c) 1998-1999, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Log: yaz-client.cpp,v $
7 * Revision 1.3 1999-02-02 14:01:18 adam
8 * First WIN32 port of YAZ++.
10 * Revision 1.2 1999/01/28 13:08:42 adam
11 * Yaz_PDU_Assoc better encapsulated. Memory leak fix in
12 * yaz-socket-manager.cc.
14 * Revision 1.1.1.1 1999/01/28 09:41:07 adam
15 * First implementation of YAZ++.
20 #include <yaz-ir-assoc.h>
21 #include <yaz-pdu-assoc.h>
22 #include <yaz-socket-manager.h>
24 class YAZ_EXPORT MyClient : public Yaz_IR_Assoc {
26 MyClient(IYaz_PDU_Observable *the_PDU_Observable);
27 void recv_Z_PDU(Z_APDU *apdu);
28 IYaz_PDU_Observer *clone(IYaz_PDU_Observable *the_PDU_Observable);
32 void MyClient::recv_Z_PDU(Z_APDU *apdu)
34 logf (LOG_LOG, "recv_APDU");
37 case Z_APDU_initResponse:
38 logf (LOG_LOG, "got InitResponse");
40 case Z_APDU_searchResponse:
41 logf (LOG_LOG, "got searchResponse");
46 IYaz_PDU_Observer *MyClient::clone(IYaz_PDU_Observable *the_PDU_Observable)
48 return new MyClient(the_PDU_Observable);
51 MyClient::MyClient(IYaz_PDU_Observable *the_PDU_Observable) :
52 Yaz_IR_Assoc (the_PDU_Observable)
58 Z_APDU *apdu = create_Z_PDU(Z_APDU_initRequest);
59 Z_InitRequest *req = apdu->u.initRequest;
61 ODR_MASK_SET(req->options, Z_Options_search);
62 ODR_MASK_SET(req->options, Z_Options_present);
63 ODR_MASK_SET(req->options, Z_Options_namedResultSets);
64 ODR_MASK_SET(req->options, Z_Options_triggerResourceCtrl);
65 ODR_MASK_SET(req->options, Z_Options_scan);
66 ODR_MASK_SET(req->options, Z_Options_sort);
67 ODR_MASK_SET(req->options, Z_Options_extendedServices);
68 ODR_MASK_SET(req->options, Z_Options_delSet);
70 ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_1);
71 ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_2);
72 ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_3);
77 int main(int argc, char **argv)
79 Yaz_SocketManager mySocketManager;
80 Yaz_PDU_Assoc *some = new Yaz_PDU_Assoc(&mySocketManager, 0);
84 z.client(argc < 2 ? "localhost:9999" : argv[1]);
86 while (mySocketManager.processEvent() > 0)