]> git.evergreen-ils.org Git - Evergreen.git/blob - OpenSRF/src/jserver/jserver-c.h
all opensrf related headers are shoved into opensrf/*.h
[Evergreen.git] / OpenSRF / src / jserver / jserver-c.h
1 #include "opensrf/utils.h"
2 #include "opensrf/logging.h"
3 #include "opensrf/socket_bundle.h"
4 #include "jserver-c_session.h"
5 #include "jstrings.h"
6
7
8
9 struct jclient_node_struct {
10         int id;
11         char* addr;
12         struct jclient_node_struct* next;
13         jserver_session* session;
14         struct jserver_struct* parent;
15 };
16 typedef struct jclient_node_struct jclient_node;
17
18 struct jserver_struct {
19         jclient_node* client;
20         socket_manager* mgr;
21 };
22 typedef struct jserver_struct jserver;
23
24 /* allocats and sets up a new jserver */
25 jserver* jserver_init();
26
27 void jserver_socket_closed(void* blob, int sock_id);
28
29 /* disconnects all client, deallocates the server and all clients */
30 void jserver_free();
31
32 /* opens the inet and unix sockets that we're listening on 
33         listen_ip is the IP address the server should listen on.
34         if listen_ip is NULL, jserver will bind to all local IP's. 
35         if(port < 1) no inet socket is opened
36         if unix_path == NULL no unix socket is opened
37         returns -1 on error */
38 int jserver_connect(jserver* js, int port, char* listen_ip, char* unix_path);
39
40 /* allocates a new client node */
41 jclient_node* _new_jclient_node(int id);
42
43 void _free_jclient_node(jclient_node* node);
44
45 int _jserver_push_client_data(jclient_node* node, char* data);
46
47 void jclient_on_parse_error(void* blob, jserver_session* session);
48
49 /* called when a newly connected client reveals its address */
50 void jserver_client_from_found(void* blob, char* from);
51 void jserver_client_login_init(void* blob, char* reply);
52 void jserver_client_login_ok(void* blob);
53 void jserver_client_finish(void* blob);
54
55 /* allocates a new client node and adds it to the set */
56 jclient_node* _jserver_add_client(jserver* js, int id);
57
58 /* removes and frees a client node */
59 void _jserver_remove_client(jserver* js, char* addr);
60
61 void _jserver_remove_client_id(jserver* js, int id);
62
63 /* finds a client node by addr */
64 jclient_node* jserver_find_client(jserver* js, char* addr);
65
66 jclient_node* jserver_find_client_id(jserver* js, int id);
67
68 /* sends msg to client at 'to_addr'. from_id is the id
69         of the sending client (if from_id > 0). used for error replies */
70 int jserver_send(jserver* js, int from_id, char* to_addr, const char* msg_xml);
71
72 /* send the data to the client with client_id */
73 int jserver_send_id(int client_id, const char* msg_xml);
74
75 /* waits for any incoming data */
76 int jserver_wait(jserver* js);
77
78 /* handles all incoming socket data */
79 void jserver_handle_request(void* js, 
80         socket_manager* mgr, int sock_id, char* data, int parent_id ); 
81
82
83 /* called by the jserver_session when any client has a 
84         complete message parsed and ready to forward on */
85 void jserver_client_handle_msg( 
86                 void* blob, char* xml, char* from, char* to );