fef4e6abfddcfb79446fae0ceca46fd2ac0a0d37
[pazpar2-moved-to-github.git] / src / client.h
1 /* $Id: client.h,v 1.6 2007-10-08 13:19:23 adam Exp $
2    Copyright (c) 2006-2007, Index Data.
3
4 This file is part of Pazpar2.
5
6 Pazpar2 is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
9 version.
10
11 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Pazpar2; see the file LICENSE.  If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA.
20  */
21
22 /** \file client.h
23     \brief Z39.50 client 
24 */
25
26 #ifndef CLIENT_H
27 #define CLIENT_H
28
29 struct client;
30 struct connection;
31
32 enum client_state
33 {
34     Client_Connecting,
35     Client_Connected,
36     Client_Idle,
37     Client_Initializing,
38     Client_Searching,
39     Client_Presenting,
40     Client_Error,
41     Client_Failed,
42     Client_Disconnected,
43     Client_Stopped,
44     Client_Continue
45 };
46
47 int client_show_raw_begin(struct client *cl, int position,
48                           const char *syntax, const char *esn,
49                           void *data,
50                           void (*error_handler)(void *data, const char *addinfo),
51                           void (*record_handler)(void *data, const char *buf,
52                                                  size_t sz),
53                           void **data2,
54                           int binary);
55 void client_show_raw_remove(struct client *cl, void *rr);
56
57 const char *client_get_state_str(struct client *cl);
58 enum client_state client_get_state(struct client *cl);
59 void client_set_state(struct client *cl, enum client_state st);
60 void client_fatal(struct client *cl);
61 struct connection *client_get_connection(struct client *cl);
62 struct session_database *client_get_database(struct client *cl);
63 void client_set_database(struct client *cl, struct session_database *db);
64 struct session *client_get_session(struct client *cl);
65 const char *client_get_pquery(struct client *cl);
66
67 void client_set_requestid(struct client *cl, int id);
68
69 void client_init_response(struct client *cl, Z_APDU *a);
70 void client_search_response(struct client *cl, Z_APDU *a);
71 void client_present_response(struct client *cl, Z_APDU *a);
72 void client_close_response(struct client *cl, Z_APDU *a);
73
74 int client_is_our_response(struct client *cl);
75
76 void client_continue(struct client *cl);
77
78 struct client *client_create(void);
79 void client_destroy(struct client *c);
80
81 void client_set_connection(struct client *cl, struct connection *con);
82 void client_disconnect(struct client *cl);
83 int client_prep_connection(struct client *cl);
84 void client_set_session(struct client *cl, struct session *se);
85 int client_is_active(struct client *cl);
86 struct client *client_next_in_session(struct client *cl);
87
88 int client_parse_query(struct client *cl, const char *query);
89 int client_get_hits(struct client *cl);
90 int client_get_num_records(struct client *cl);
91 int client_get_diagnostic(struct client *cl);
92 void client_set_database(struct client *cl, struct session_database *db);
93 struct host *client_get_host(struct client *cl);
94 const char *client_get_url(struct client *cl);
95
96 #endif
97
98 /*
99  * Local variables:
100  * c-basic-offset: 4
101  * indent-tabs-mode: nil
102  * End:
103  * vim: shiftwidth=4 tabstop=8 expandtab
104  */