Allow merge on merged content
[pazpar2-moved-to-github.git] / src / client.h
1 /* This file is part of Pazpar2.
2    Copyright (C) 2006-2012 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 #include "facet_limit.h"
28 #include "reclists.h"
29
30 struct client;
31 struct connection;
32
33 enum client_state
34 {
35     Client_Connecting,
36     Client_Idle,
37     Client_Working,
38     Client_Error,
39     Client_Failed,
40     Client_Disconnected
41 };
42
43 int client_show_raw_begin(struct client *cl, int position,
44                           const char *syntax, const char *esn,
45                           void *data,
46                           void (*error_handler)(void *data, const char *addinfo),
47                           void (*record_handler)(void *data, const char *buf,
48                                                  size_t sz),
49                           int binary,
50                           const char *nativesyntax);
51
52 void client_show_raw_remove(struct client *cl, void *rr);
53
54 const char *client_get_state_str(struct client *cl);
55 enum client_state client_get_state(struct client *cl);
56 void client_set_state(struct client *cl, enum client_state st);
57 void client_set_state_nb(struct client *cl, enum client_state st);
58 struct connection *client_get_connection(struct client *cl);
59 struct session_database *client_get_database(struct client *cl);
60 void client_set_database(struct client *cl, struct session_database *db);
61 struct session *client_get_session(struct client *cl);
62 const char *client_get_pquery(struct client *cl);
63
64 void client_init_response(struct client *cl, Z_APDU *a);
65 void client_search_response(struct client *cl);
66 void client_record_response(struct client *cl);
67 void client_close_response(struct client *cl, Z_APDU *a);
68
69 int client_is_our_response(struct client *cl);
70
71 void client_continue(struct client *cl);
72
73 struct client *client_create(const char *url);
74 int client_destroy(struct client *c);
75
76 void client_set_connection(struct client *cl, struct connection *con);
77 void client_disconnect(struct client *cl);
78 int client_prep_connection(struct client *cl,
79                            int operation_timeout, int session_timeout,
80                            iochan_man_t iochan,
81                            const struct timeval *abstime);
82 int client_start_search(struct client *cl);
83 int client_parse_init(struct client *cl, int same_search);
84 int client_parse_range(struct client *cl, const char *startrecs, const char *maxrecs);
85 int client_parse_sort(struct client *cl, struct reclist_sortparms *sp);
86 void client_set_session(struct client *cl, struct session *se);
87 int client_is_active(struct client *cl);
88 int client_is_active_preferred(struct client *cl);
89 struct client *client_next_in_session(struct client *cl);
90
91 int client_parse_query(struct client *cl, const char *query,
92                        facet_limits_t facet_limits);
93 Odr_int client_get_hits(struct client *cl);
94 Odr_int client_get_approximation(struct client *cl);
95 int client_get_num_records(struct client *cl);
96 int client_get_num_records_filtered(struct client *cl);
97 int client_get_diagnostic(struct client *cl,
98                           const char **message, const char **addinfo);
99 void client_set_diagnostic(struct client *cl, int diagnostic,
100                            const char *message, const char *addinfo);
101 void client_set_database(struct client *cl, struct session_database *db);
102 const char *client_get_id(struct client *cl);
103 int  client_get_maxrecs(struct client *cl);
104 void client_remove_from_session(struct client *c);
105 void client_incref(struct client *c);
106 void client_got_records(struct client *c);
107 void client_lock(struct client *c);
108 void client_unlock(struct client *c);
109
110 int client_has_facet(struct client *cl, const char *name);
111 void client_check_preferred_watch(struct client *cl);
112 int client_reingest(struct client *cl);
113 const char *client_get_facet_limit_local(struct client *cl,
114                                          struct session_database *sdb,
115                                          int *l,
116                                          NMEM nmem, int *num, char ***values);
117
118 int client_test_sort_order(struct client *cl, struct reclist_sortparms *sp);
119
120 #endif
121
122 /*
123  * Local variables:
124  * c-basic-offset: 4
125  * c-file-style: "Stroustrup"
126  * indent-tabs-mode: nil
127  * End:
128  * vim: shiftwidth=4 tabstop=8 expandtab
129  */
130