1 /*
2  *   LASH
3  *
4  *   Copyright (C) 2002, 2003 Robert Ham <rah@bash.sh>
5  *
6  *   This program is free software; you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation; either version 2 of the License, or
9  *   (at your option) any later version.
10  *
11  *   This program is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *   GNU General Public License for more details.
15  *
16  *   You should have received a copy of the GNU General Public License
17  *   along with this program; if not, write to the Free Software
18  *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef __LASH_CLIENT_H__
22 #define __LASH_CLIENT_H__
23 
24 #include <pthread.h>
25 
26 #include <lash/lash.h>
27 #include <lash/internal_headers.h>
28 
29 
30 
31 struct _lash_client
32 {
33   lash_args_t      *args;
34   char             *class;
35 
36   short             server_connected;
37 
38   int               socket;
39 
40   pthread_mutex_t   events_in_lock;
41   lash_list_t       *events_in;
42   pthread_mutex_t   configs_in_lock;
43   lash_list_t       *configs_in;
44   pthread_mutex_t   comm_events_out_lock;
45   lash_list_t       *comm_events_out;
46 
47   pthread_cond_t    send_conditional;
48 
49   int               recv_close;
50   int               send_close;
51   pthread_t         recv_thread;
52   pthread_t         send_thread;
53 };
54 
55 lash_client_t * lash_client_new ();
56 void           lash_client_destroy (lash_client_t *);
57 
58 void lash_client_set_class (lash_client_t *, const char * class);
59 
60 
61 /* both of these return > 0 if a whole event was done, or
62    -1 if there was an error */
63 int lash_comm_send_event (int socket, lash_comm_event_t * event);
64 int lash_comm_recv_event (int socket, lash_comm_event_t * event);
65 
66 /* returns 0 on success, non-0 on error */
67 int lash_comm_connect_to_server (struct _lash_client *, const char * server, const char * service, struct _lash_connect_params *);
68 
69 void * lash_comm_recv_run (void * data);
70 void * lash_comm_send_run (void * data);
71 
72 
73 #endif /* __LASH_CLIENT_H__ */
74 
75