daemon: improve log
[ladish.git] / lash_compat / liblash / lash / lash.h
blob3b54203f0e42ccfe0b71ec82ad21faa2fd1f0243
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>
6 * Copyright (C) 2002 Robert Ham <rah@bash.sh>
8 **************************************************************************
9 * This file contains the liblash interface
10 **************************************************************************
12 * LADI Session Handler is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * LADI Session Handler is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
24 * or write to the Free Software Foundation, Inc.,
25 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28 #ifndef __LASH_H__
29 #define __LASH_H__
31 #include <uuid/uuid.h>
32 #include <stdint.h>
33 #include <stdlib.h>
34 #include <stdint.h>
35 #include <sys/types.h>
37 #define LASH_PROTOCOL_MAJOR 2
38 #define LASH_PROTOCOL_MINOR 0
39 #define LASH_PROTOCOL_MAJOR_MASK 0xFFFF0000
40 #define LASH_PROTOCOL_MINOR_MASK 0x0000FFFF
41 #define LASH_PROTOCOL(major, minor) ((lash_protocol_t)( ((major << 16) & LASH_PROTOCOL_MAJOR_MASK) | (minor & LASH_PROTOCOL_MINOR_MASK)))
42 #define LASH_PROTOCOL_VERSION (LASH_PROTOCOL (LASH_PROTOCOL_MAJOR, LASH_PROTOCOL_MINOR))
43 #define LASH_PROTOCOL_GET_MAJOR(protocol) ((lash_protocol_t) (((protocol & LASH_PROTOCOL_MAJOR_MASK) >> 16)))
44 #define LASH_PROTOCOL_GET_MINOR(protocol) ((lash_protocol_t) (protocol & LASH_PROTOCOL_MINOR_MASK))
45 #define LASH_PROTOCOL_IS_VALID(proto) ((LASH_PROTOCOL_GET_MAJOR (proto) == LASH_PROTOCOL_MAJOR) && (LASH_PROTOCOL_GET_MINOR (proto) <= LASH_PROTOCOL_MINOR))
46 #define LASH_DEFAULT_PORT 14541
47 #define lash_enabled(client) 0
48 #define LASH_PORT "14541"
50 typedef uint32_t lash_protocol_t;
52 enum LASH_Client_Flag
54 LASH_Config_Data_Set = 0x00000001,
55 LASH_Config_File = 0x00000002,
56 LASH_Server_Interface = 0x00000004,
57 LASH_No_Autoresume = 0x00000008,
58 LASH_Terminal = 0x00000010,
59 LASH_No_Start_Server = 0x00000020
62 enum LASH_Event_Type
64 LASH_Client_Name = 1,
65 LASH_Jack_Client_Name,
66 LASH_Alsa_Client_ID,
67 LASH_Save_File,
68 LASH_Restore_File,
69 LASH_Save_Data_Set,
70 LASH_Restore_Data_Set,
71 LASH_Save,
72 LASH_Quit,
73 LASH_Server_Lost,
74 LASH_Project_Add,
75 LASH_Project_Remove,
76 LASH_Project_Dir,
77 LASH_Project_Name,
78 LASH_Client_Add,
79 LASH_Client_Remove,
80 LASH_Percentage
83 typedef struct _lash_args lash_args_t;
84 typedef struct _lash_client lash_client_t;
85 typedef struct _lash_event lash_event_t;
86 typedef struct _lash_config lash_config_t;
88 #ifdef __cplusplus
89 extern "C" {
90 #if 0
92 #endif
93 #endif
95 const char * lash_protocol_string(lash_protocol_t protocol);
96 lash_event_t * lash_event_new(void);
97 lash_event_t * lash_event_new_with_type(enum LASH_Event_Type type);
98 lash_event_t * lash_event_new_with_all(enum LASH_Event_Type type, const char * string);
99 void lash_event_destroy(lash_event_t * event);
100 enum LASH_Event_Type lash_event_get_type(const lash_event_t * event);
101 const char * lash_event_get_string(const lash_event_t * event);
102 const char * lash_event_get_project(const lash_event_t * event);
103 void lash_event_get_client_id(const lash_event_t * event, uuid_t id);
104 void lash_event_set_type(lash_event_t * event, enum LASH_Event_Type type);
105 void lash_event_set_string(lash_event_t * event, const char * string);
106 void lash_event_set_project(lash_event_t * event, const char * project);
107 void lash_event_set_client_id(lash_event_t * event, uuid_t id);
108 void lash_event_set_alsa_client_id(lash_event_t * event, unsigned char alsa_id);
109 unsigned char lash_event_get_alsa_client_id(const lash_event_t * event);
110 void lash_str_set_alsa_client_id(char * str, unsigned char alsa_id);
111 unsigned char lash_str_get_alsa_client_id(const char * str);
112 lash_args_t * lash_extract_args(int * argc, char *** argv);
113 void lash_args_destroy(lash_args_t * args);
114 lash_client_t * lash_init(const lash_args_t * args, const char * client_class, int client_flags, lash_protocol_t protocol);
115 const char * lash_get_server_name(lash_client_t * client);
116 unsigned int lash_get_pending_event_count(lash_client_t * client);
117 lash_event_t * lash_get_event(lash_client_t * client);
118 unsigned int lash_get_pending_config_count(lash_client_t * client);
119 lash_config_t * lash_get_config(lash_client_t * client);
120 void lash_send_event(lash_client_t * client, lash_event_t * event);
121 void lash_send_config(lash_client_t * client, lash_config_t * config);
122 int lash_server_connected(lash_client_t * client);
123 void lash_jack_client_name(lash_client_t * client, const char * name);
124 void lash_alsa_client_id(lash_client_t * client, unsigned char id);
125 lash_event_t * lash_event_new(void);
126 lash_event_t * lash_event_new_with_type(enum LASH_Event_Type type);
127 lash_event_t * lash_event_new_with_all(enum LASH_Event_Type type, const char * string);
128 void lash_event_destroy(lash_event_t * event);
129 enum LASH_Event_Type lash_event_get_type(const lash_event_t * event);
130 const char * lash_event_get_string(const lash_event_t * event);
131 const char * lash_event_get_project(const lash_event_t * event);
132 void lash_event_get_client_id(const lash_event_t * event, uuid_t id);
133 void lash_event_set_type(lash_event_t * event, enum LASH_Event_Type type);
134 void lash_event_set_string(lash_event_t * event, const char * string);
135 void lash_event_set_project(lash_event_t * event, const char * project);
136 void lash_event_set_client_id(lash_event_t * event, uuid_t id);
137 void lash_event_set_alsa_client_id(lash_event_t * event, unsigned char alsa_id);
138 unsigned char lash_event_get_alsa_client_id(const lash_event_t * event);
139 void lash_str_set_alsa_client_id(char * str, unsigned char alsa_id);
140 unsigned char lash_str_get_alsa_client_id(const char * str);
141 lash_config_t * lash_config_new(void);
142 lash_config_t * lash_config_dup(const lash_config_t * config);
143 lash_config_t * lash_config_new_with_key(const char * key);
144 void lash_config_destroy(lash_config_t * config);
145 const char * lash_config_get_key(const lash_config_t * config);
146 const void * lash_config_get_value(const lash_config_t * config);
147 size_t lash_config_get_value_size(const lash_config_t * config);
148 void lash_config_set_key(lash_config_t * config, const char * key);
149 void lash_config_set_value(lash_config_t * config, const void * value, size_t value_size);
150 uint32_t lash_config_get_value_int(const lash_config_t * config);
151 float lash_config_get_value_float(const lash_config_t * config);
152 double lash_config_get_value_double(const lash_config_t * config);
153 const char * lash_config_get_value_string(const lash_config_t * config);
154 void lash_config_set_value_int(lash_config_t * config, uint32_t value);
155 void lash_config_set_value_float(lash_config_t * config, float value);
156 void lash_config_set_value_double(lash_config_t * config, double value);
157 void lash_config_set_value_string(lash_config_t * config, const char * value);
159 #ifdef __cplusplus
161 #endif
163 #endif /* __LASH_H__ */