aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/lib/cserve/evas_cs.h
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/evas/src/lib/cserve/evas_cs.h')
-rw-r--r--libraries/evas/src/lib/cserve/evas_cs.h285
1 files changed, 285 insertions, 0 deletions
diff --git a/libraries/evas/src/lib/cserve/evas_cs.h b/libraries/evas/src/lib/cserve/evas_cs.h
new file mode 100644
index 0000000..73bbaed
--- /dev/null
+++ b/libraries/evas/src/lib/cserve/evas_cs.h
@@ -0,0 +1,285 @@
1#ifndef EVAS_CS_H
2#define EVAS_CS_H 1
3
4#ifdef EVAS_CSERVE
5
6#include <sys/select.h>
7#include <sys/time.h>
8#include <sys/types.h>
9#include <sys/socket.h>
10#include <sys/mman.h>
11#include <sys/stat.h>
12#include <sys/param.h>
13#include <fcntl.h>
14#include <stdio.h>
15#include <stdlib.h>
16#include <unistd.h>
17#include <string.h>
18#include <netinet/in.h>
19#include <sys/un.h>
20#include <arpa/inet.h>
21#include <errno.h>
22
23#include "evas_common.h"
24#include "evas_private.h"
25
26#ifdef EAPI
27# undef EAPI
28#endif
29
30#ifdef _WIN32
31# ifdef EFL_EVAS_BUILD
32# ifdef DLL_EXPORT
33# define EAPI __declspec(dllexport)
34# else
35# define EAPI
36# endif /* ! DLL_EXPORT */
37# else
38# define EAPI __declspec(dllimport)
39# endif /* ! EFL_EVAS_BUILD */
40#else
41# ifdef __GNUC__
42# if __GNUC__ >= 4
43# define EAPI __attribute__ ((visibility("default")))
44# else
45# define EAPI
46# endif
47# else
48# define EAPI
49# endif
50#endif /* ! _WIN32 */
51
52#define LENGTH_OF_SOCKADDR_UN(s) (strlen((s)->sun_path) + (size_t)(((struct sockaddr_un *)NULL)->sun_path))
53
54typedef struct _Server Server;
55typedef struct _Client Client;
56typedef struct _Mem Mem;
57
58struct _Server
59{
60 char *socket_path;
61 Eina_List *clients;
62 int (*func) (void *fdata, Server *s, Client *c, int opcode, int size, unsigned char *data);
63 void *data;
64 pid_t pid;
65 int server_id;
66 // for channel 2;
67 struct {
68 int fd;
69 int req_from, req_to;
70 } ch[2];
71 void *main_handle;
72};
73
74struct _Client
75{
76 Server *server;
77 unsigned char *buf;
78 Client *client_main;
79 int bufsize, bufalloc;
80 int fd;
81 unsigned char *inbuf;
82 int inbufsize, inbufalloc;
83 unsigned char dead : 1;
84 void (*func) (void *fdata, Client *c);
85 void *data;
86 pid_t pid;
87 int req_from, req_to;
88 LK(lock);
89};
90
91struct _Mem
92{
93 unsigned char *data;
94 char *name;
95 int fd;
96 int id;
97 int offset;
98 int size;
99 int ref;
100 Eina_Bool write : 1;
101};
102
103//// for comms
104enum
105{
106 OP_NOP, // 0
107
108 OP_INIT, // 1
109 OP_LOAD, // 2
110 OP_UNLOAD, // 3
111 OP_LOADDATA, // 4
112 OP_UNLOADDATA, // 5
113 OP_USELESSDATA, // 6
114 OP_PRELOAD, // 7
115 OP_FORCEDUNLOAD, // 8
116
117 OP_GETCONFIG, // 9
118 OP_SETCONFIG, // 10
119 OP_GETSTATS, // 11
120 OP_GETINFO, // 12
121
122 OP_INVALID // 13
123};
124
125typedef struct
126{
127 pid_t pid;
128 int server_id;
129 void *handle;
130} Op_Init;
131typedef struct
132{
133 struct {
134 int scale_down_by;
135 double dpi;
136 int w, h;
137 struct {
138 int x, y, w, h;
139 } region;
140 Eina_Bool orientation;
141 } lopt;
142} Op_Load; // +"file""key"
143typedef struct
144{
145 void *handle;
146 int server_id;
147 struct {
148 int id;
149 int offset;
150 int size;
151 } mem;
152 struct {
153 int w, h;
154 Eina_Bool alpha : 1;
155 } image;
156} Op_Load_Reply;
157typedef struct
158{
159 void *handle;
160 int server_id;
161} Op_Unload;
162typedef struct
163{
164 void *handle;
165 int server_id;
166} Op_Unloaddata;
167typedef struct
168{
169 void *handle;
170 int server_id;
171} Op_Loaddata;
172typedef struct
173{
174 struct {
175 int id;
176 int offset;
177 int size;
178 } mem;
179} Op_Loaddata_Reply;
180typedef struct
181{
182 void *handle;
183 int server_id;
184} Op_Preload;
185typedef struct
186{
187 void *handle;
188 struct {
189 int id;
190 int offset;
191 int size;
192 } mem;
193} Op_Preload_Reply;
194typedef struct
195{
196 void *handle;
197 int server_id;
198} Op_Forcedunload;
199typedef struct
200{
201 int cache_max_usage;
202 int cache_item_timeout;
203 int cache_item_timeout_check;
204} Op_Getconfig_Reply;
205typedef struct
206{
207 int cache_max_usage;
208 int cache_item_timeout;
209 int cache_item_timeout_check;
210} Op_Setconfig;
211typedef struct
212{
213 int saved_memory;
214 int wasted_memory;
215 int saved_memory_peak;
216 int wasted_memory_peak;
217 double saved_time_image_header_load;
218 double saved_time_image_data_load;
219} Op_Getstats_Reply;
220typedef struct
221{
222 struct {
223 int mem_total;
224 int count;
225 } active, cached;
226} Op_Getinfo_Reply; // + N active Info Items + N cached items
227typedef struct
228{
229 int file_key_size;
230 int w, h;
231 time_t file_mod_time;
232 time_t file_checked_time;
233 time_t cached_time;
234 int refcount;
235 int data_refcount;
236 int memory_footprint;
237 double head_load_time;
238 double data_load_time;
239 Eina_Bool alpha : 1;
240 Eina_Bool data_loaded : 1;
241 Eina_Bool active : 1;
242 Eina_Bool dead : 1;
243 Eina_Bool useless : 1;
244} Op_Getinfo_Item; // + "file""key"
245
246
247// for clients to connect to cserve
248EAPI Eina_Bool evas_cserve_init(void);
249EAPI int evas_cserve_use_get(void);
250EAPI Eina_Bool evas_cserve_have_get(void);
251EAPI void evas_cserve_shutdown(void);
252EAPI void evas_cserve_discon(void);
253EAPI Eina_Bool evas_cserve_image_load(Image_Entry *ie, const char *file, const char *key, RGBA_Image_Loadopts *lopt);
254EAPI Eina_Bool evas_cserve_image_data_load(Image_Entry *ie);
255EAPI void evas_cserve_image_unload(Image_Entry *ie);
256EAPI void evas_cserve_image_useless(Image_Entry *ie);
257EAPI void evas_cserve_image_free(Image_Entry *ie);
258EAPI Eina_Bool evas_cserve_raw_config_get(Op_Getconfig_Reply *config);
259EAPI Eina_Bool evas_cserve_raw_config_set(Op_Setconfig *config);
260EAPI Eina_Bool evas_cserve_raw_stats_get(Op_Getstats_Reply *stats);
261EAPI Op_Getinfo_Reply *evas_cserve_raw_info_get(void);
262
263// for the server
264EAPI Server *evas_cserve_server_add(void);
265EAPI void evas_cserve_server_del(Server *s);
266EAPI void evas_cserve_client_send(Client *c, int opcode, int size, unsigned char *data);
267EAPI void evas_cserve_server_message_handler_set(Server *s, int (*func) (void *fdata, Server *s, Client *c, int opcode, int size, unsigned char *data), void *data);
268EAPI void evas_cserve_server_wait(Server *s, int timeout);
269
270//// for memory
271// for server
272EAPI Mem *evas_cserve_mem_new(int size, const char *name);
273EAPI void evas_cserve_mem_free(Mem *m);
274
275// for client
276EAPI Mem *evas_cserve_mem_open(int pid, int id, const char *name, int size, int do_write);
277EAPI void evas_cserve_mem_close(Mem *m);
278
279// for both
280EAPI Eina_Bool evas_cserve_mem_resize(Mem *m, int size);
281EAPI void evas_cserve_mem_del(int pid, int id);
282
283#endif
284
285#endif