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