1 /*
2 * LASH
3 *
4 * Copyright (C) 2002 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 #include <lash/types.h>
22 #include <lash/client.h>
23 #include <lash/list.h>
24 #include <lash/internal.h>
25
26 lash_client_t *
lash_client_new()27 lash_client_new()
28 {
29 lash_client_t *client;
30
31 client = lash_malloc0(sizeof(lash_client_t));
32 pthread_mutex_init(&client->configs_in_lock, NULL);
33 pthread_mutex_init(&client->events_in_lock, NULL);
34 pthread_mutex_init(&client->comm_events_out_lock, NULL);
35 pthread_cond_init(&client->send_conditional, NULL);
36 return client;
37 }
38
39 void
lash_client_destroy(lash_client_t * client)40 lash_client_destroy(lash_client_t * client)
41 {
42 pthread_mutex_destroy(&client->configs_in_lock);
43 pthread_mutex_destroy(&client->events_in_lock);
44 pthread_mutex_destroy(&client->comm_events_out_lock);
45 pthread_cond_destroy(&client->send_conditional);
46
47 lash_client_set_class(client, NULL);
48
49 lash_args_destroy(client->args);
50
51 free(client);
52 }
53
54 const char *
lash_client_get_class(const lash_client_t * client)55 lash_client_get_class(const lash_client_t * client)
56 {
57 return client->class;
58 }
59
60 void
lash_client_set_class(lash_client_t * client,const char * class)61 lash_client_set_class(lash_client_t * client, const char *class)
62 {
63 set_string_property(client->class, class);
64 }
65
66 /* EOF */
67