aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/lib/cserve
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-04 18:41:13 +1000
committerDavid Walter Seikel2012-01-04 18:41:13 +1000
commitdd7595a3475407a7fa96a97393bae8c5220e8762 (patch)
treee341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/evas/src/lib/cserve
parentAdd the skeleton. (diff)
downloadSledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to 'libraries/evas/src/lib/cserve')
-rw-r--r--libraries/evas/src/lib/cserve/Makefile.am32
-rw-r--r--libraries/evas/src/lib/cserve/Makefile.in688
-rw-r--r--libraries/evas/src/lib/cserve/evas_cs.h285
-rw-r--r--libraries/evas/src/lib/cserve/evas_cs_client.c528
-rw-r--r--libraries/evas/src/lib/cserve/evas_cs_main.c9
-rw-r--r--libraries/evas/src/lib/cserve/evas_cs_mem.c168
-rw-r--r--libraries/evas/src/lib/cserve/evas_cs_server.c380
7 files changed, 2090 insertions, 0 deletions
diff --git a/libraries/evas/src/lib/cserve/Makefile.am b/libraries/evas/src/lib/cserve/Makefile.am
new file mode 100644
index 0000000..6ff6e2a
--- /dev/null
+++ b/libraries/evas/src/lib/cserve/Makefile.am
@@ -0,0 +1,32 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I. \
5-I$(top_srcdir)/src/lib \
6-I$(top_srcdir)/src/lib/include \
7-I$(top_srcdir)/src/lib/cserve \
8-DPACKAGE_BIN_DIR=\"$(bindir)\" \
9-DPACKAGE_LIB_DIR=\"$(libdir)\" \
10-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
11@EINA_CFLAGS@ \
12@FREETYPE_CFLAGS@ \
13@FRIBIDI_CFLAGS@ \
14@EET_CFLAGS@ \
15@FONTCONFIG_CFLAGS@ \
16@pthread_cflags@ \
17@PIXMAN_CFLAGS@
18
19if EVAS_CSERVE
20
21noinst_LTLIBRARIES = libevas_cserve.la
22
23endif
24
25libevas_cserve_la_SOURCES = \
26evas_cs.h \
27evas_cs_main.c \
28evas_cs_server.c \
29evas_cs_client.c \
30evas_cs_mem.c
31
32libevas_cserve_la_LIBADD = @EINA_LIBS@ -lrt
diff --git a/libraries/evas/src/lib/cserve/Makefile.in b/libraries/evas/src/lib/cserve/Makefile.in
new file mode 100644
index 0000000..74b5ff9
--- /dev/null
+++ b/libraries/evas/src/lib/cserve/Makefile.in
@@ -0,0 +1,688 @@
1# Makefile.in generated by automake 1.11.1 from Makefile.am.
2# @configure_input@
3
4# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
6# Inc.
7# This Makefile.in is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it,
9# with or without modifications, as long as this notice is preserved.
10
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
13# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14# PARTICULAR PURPOSE.
15
16@SET_MAKE@
17
18VPATH = @srcdir@
19pkgdatadir = $(datadir)/@PACKAGE@
20pkgincludedir = $(includedir)/@PACKAGE@
21pkglibdir = $(libdir)/@PACKAGE@
22pkglibexecdir = $(libexecdir)/@PACKAGE@
23am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24install_sh_DATA = $(install_sh) -c -m 644
25install_sh_PROGRAM = $(install_sh) -c
26install_sh_SCRIPT = $(install_sh) -c
27INSTALL_HEADER = $(INSTALL_DATA)
28transform = $(program_transform_name)
29NORMAL_INSTALL = :
30PRE_INSTALL = :
31POST_INSTALL = :
32NORMAL_UNINSTALL = :
33PRE_UNINSTALL = :
34POST_UNINSTALL = :
35build_triplet = @build@
36host_triplet = @host@
37subdir = src/lib/cserve
38DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
39ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
40am__aclocal_m4_deps = $(top_srcdir)/m4/efl_attribute.m4 \
41 $(top_srcdir)/m4/efl_coverage.m4 \
42 $(top_srcdir)/m4/efl_doxygen.m4 \
43 $(top_srcdir)/m4/efl_fnmatch.m4 \
44 $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \
45 $(top_srcdir)/m4/evas_check_engine.m4 \
46 $(top_srcdir)/m4/evas_check_loader.m4 \
47 $(top_srcdir)/m4/evas_converter.m4 \
48 $(top_srcdir)/m4/evas_dither.m4 \
49 $(top_srcdir)/m4/evas_scaler.m4 $(top_srcdir)/m4/libtool.m4 \
50 $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
51 $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
52 $(top_srcdir)/configure.ac
53am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
54 $(ACLOCAL_M4)
55mkinstalldirs = $(install_sh) -d
56CONFIG_HEADER = $(top_builddir)/config.h
57CONFIG_CLEAN_FILES =
58CONFIG_CLEAN_VPATH_FILES =
59LTLIBRARIES = $(noinst_LTLIBRARIES)
60libevas_cserve_la_DEPENDENCIES =
61am_libevas_cserve_la_OBJECTS = evas_cs_main.lo evas_cs_server.lo \
62 evas_cs_client.lo evas_cs_mem.lo
63libevas_cserve_la_OBJECTS = $(am_libevas_cserve_la_OBJECTS)
64AM_V_lt = $(am__v_lt_$(V))
65am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
66am__v_lt_0 = --silent
67@EVAS_CSERVE_TRUE@am_libevas_cserve_la_rpath =
68DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
69depcomp = $(SHELL) $(top_srcdir)/depcomp
70am__depfiles_maybe = depfiles
71am__mv = mv -f
72COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
73 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
74LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
75 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
76 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
77 $(AM_CFLAGS) $(CFLAGS)
78AM_V_CC = $(am__v_CC_$(V))
79am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
80am__v_CC_0 = @echo " CC " $@;
81AM_V_at = $(am__v_at_$(V))
82am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
83am__v_at_0 = @
84CCLD = $(CC)
85LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
86 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
87 $(AM_LDFLAGS) $(LDFLAGS) -o $@
88AM_V_CCLD = $(am__v_CCLD_$(V))
89am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
90am__v_CCLD_0 = @echo " CCLD " $@;
91AM_V_GEN = $(am__v_GEN_$(V))
92am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
93am__v_GEN_0 = @echo " GEN " $@;
94SOURCES = $(libevas_cserve_la_SOURCES)
95DIST_SOURCES = $(libevas_cserve_la_SOURCES)
96ETAGS = etags
97CTAGS = ctags
98DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
99ACLOCAL = @ACLOCAL@
100ALLOCA = @ALLOCA@
101AMTAR = @AMTAR@
102AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
103AR = @AR@
104AS = @AS@
105AUTOCONF = @AUTOCONF@
106AUTOHEADER = @AUTOHEADER@
107AUTOMAKE = @AUTOMAKE@
108AWK = @AWK@
109CC = @CC@
110CCDEPMODE = @CCDEPMODE@
111CFLAGS = @CFLAGS@
112CHECK_CFLAGS = @CHECK_CFLAGS@
113CHECK_LIBS = @CHECK_LIBS@
114CPP = @CPP@
115CPPFLAGS = @CPPFLAGS@
116CXX = @CXX@
117CXXCPP = @CXXCPP@
118CXXDEPMODE = @CXXDEPMODE@
119CXXFLAGS = @CXXFLAGS@
120CYGPATH_W = @CYGPATH_W@
121DEFS = @DEFS@
122DEPDIR = @DEPDIR@
123DIRECTFB_CFLAGS = @DIRECTFB_CFLAGS@
124DIRECTFB_LIBS = @DIRECTFB_LIBS@
125DLLTOOL = @DLLTOOL@
126DSYMUTIL = @DSYMUTIL@
127DUMPBIN = @DUMPBIN@
128ECHO_C = @ECHO_C@
129ECHO_N = @ECHO_N@
130ECHO_T = @ECHO_T@
131ECORE_EVAS_CFLAGS = @ECORE_EVAS_CFLAGS@
132ECORE_EVAS_LIBS = @ECORE_EVAS_LIBS@
133EDB_CFLAGS = @EDB_CFLAGS@
134EDB_LIBS = @EDB_LIBS@
135EDJE_CFLAGS = @EDJE_CFLAGS@
136EDJE_LIBS = @EDJE_LIBS@
137EET_CFLAGS = @EET_CFLAGS@
138EET_LIBS = @EET_LIBS@
139EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@
140EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@
141EFL_FNMATCH_LIBS = @EFL_FNMATCH_LIBS@
142EGREP = @EGREP@
143EINA_CFLAGS = @EINA_CFLAGS@
144EINA_LIBS = @EINA_LIBS@
145EVAS_CFLAGS = @EVAS_CFLAGS@
146EVAS_LIBS = @EVAS_LIBS@
147EVAS_SSE3_CFLAGS = @EVAS_SSE3_CFLAGS@
148EVIL_CFLAGS = @EVIL_CFLAGS@
149EVIL_LIBS = @EVIL_LIBS@
150EXEEXT = @EXEEXT@
151FGREP = @FGREP@
152FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
153FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
154FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
155FREETYPE_LIBS = @FREETYPE_LIBS@
156FRIBIDI_CFLAGS = @FRIBIDI_CFLAGS@
157FRIBIDI_LIBS = @FRIBIDI_LIBS@
158GL_EET_CFLAGS = @GL_EET_CFLAGS@
159GL_EET_LIBS = @GL_EET_LIBS@
160GREP = @GREP@
161HARFBUZZ_CFLAGS = @HARFBUZZ_CFLAGS@
162HARFBUZZ_LIBS = @HARFBUZZ_LIBS@
163INSTALL = @INSTALL@
164INSTALL_DATA = @INSTALL_DATA@
165INSTALL_PROGRAM = @INSTALL_PROGRAM@
166INSTALL_SCRIPT = @INSTALL_SCRIPT@
167INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
168LD = @LD@
169LDFLAGS = @LDFLAGS@
170LIBOBJS = @LIBOBJS@
171LIBS = @LIBS@
172LIBTOOL = @LIBTOOL@
173LINEBREAK_CFLAGS = @LINEBREAK_CFLAGS@
174LINEBREAK_LIBS = @LINEBREAK_LIBS@
175LIPO = @LIPO@
176LN_S = @LN_S@
177LTLIBOBJS = @LTLIBOBJS@
178MAKEINFO = @MAKEINFO@
179MKDIR_P = @MKDIR_P@
180MODULE_ARCH = @MODULE_ARCH@
181NM = @NM@
182NMEDIT = @NMEDIT@
183OBJC = @OBJC@
184OBJCDEPMODE = @OBJCDEPMODE@
185OBJCFLAGS = @OBJCFLAGS@
186OBJDUMP = @OBJDUMP@
187OBJEXT = @OBJEXT@
188OTOOL = @OTOOL@
189OTOOL64 = @OTOOL64@
190PACKAGE = @PACKAGE@
191PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
192PACKAGE_NAME = @PACKAGE_NAME@
193PACKAGE_STRING = @PACKAGE_STRING@
194PACKAGE_TARNAME = @PACKAGE_TARNAME@
195PACKAGE_URL = @PACKAGE_URL@
196PACKAGE_VERSION = @PACKAGE_VERSION@
197PATH_SEPARATOR = @PATH_SEPARATOR@
198PIXMAN_CFLAGS = @PIXMAN_CFLAGS@
199PIXMAN_LIBS = @PIXMAN_LIBS@
200PKG_CONFIG = @PKG_CONFIG@
201PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
202PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
203PNG_CFLAGS = @PNG_CFLAGS@
204PNG_LIBS = @PNG_LIBS@
205RANLIB = @RANLIB@
206SDL_CFLAGS = @SDL_CFLAGS@
207SDL_LIBS = @SDL_LIBS@
208SED = @SED@
209SET_MAKE = @SET_MAKE@
210SHELL = @SHELL@
211SHM_OPEN_LINK = @SHM_OPEN_LINK@
212STRIP = @STRIP@
213SVG_CFLAGS = @SVG_CFLAGS@
214SVG_LIBS = @SVG_LIBS@
215VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
216VALGRIND_LIBS = @VALGRIND_LIBS@
217VERSION = @VERSION@
218VMAJ = @VMAJ@
219WIN32_CFLAGS = @WIN32_CFLAGS@
220WIN32_CPPFLAGS = @WIN32_CPPFLAGS@
221XCB_CFLAGS = @XCB_CFLAGS@
222XCB_GL_CFLAGS = @XCB_GL_CFLAGS@
223XCB_GL_LIBS = @XCB_GL_LIBS@
224XCB_LIBS = @XCB_LIBS@
225XEXT_CFLAGS = @XEXT_CFLAGS@
226XEXT_LIBS = @XEXT_LIBS@
227XMKMF = @XMKMF@
228X_CFLAGS = @X_CFLAGS@
229X_EXTRA_LIBS = @X_EXTRA_LIBS@
230X_LIBS = @X_LIBS@
231X_PRE_LIBS = @X_PRE_LIBS@
232abs_builddir = @abs_builddir@
233abs_srcdir = @abs_srcdir@
234abs_top_builddir = @abs_top_builddir@
235abs_top_srcdir = @abs_top_srcdir@
236ac_ct_CC = @ac_ct_CC@
237ac_ct_CXX = @ac_ct_CXX@
238ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
239ac_ct_OBJC = @ac_ct_OBJC@
240altivec_cflags = @altivec_cflags@
241am__include = @am__include@
242am__leading_dot = @am__leading_dot@
243am__quote = @am__quote@
244am__tar = @am__tar@
245am__untar = @am__untar@
246bindir = @bindir@
247build = @build@
248build_alias = @build_alias@
249build_cpu = @build_cpu@
250build_os = @build_os@
251build_vendor = @build_vendor@
252builddir = @builddir@
253datadir = @datadir@
254datarootdir = @datarootdir@
255dlopen_libs = @dlopen_libs@
256docdir = @docdir@
257dvidir = @dvidir@
258edje_cc = @edje_cc@
259efl_doxygen = @efl_doxygen@
260efl_have_doxygen = @efl_have_doxygen@
261evas_engine_buffer_cflags = @evas_engine_buffer_cflags@
262evas_engine_buffer_libs = @evas_engine_buffer_libs@
263evas_engine_direct3d_cflags = @evas_engine_direct3d_cflags@
264evas_engine_direct3d_libs = @evas_engine_direct3d_libs@
265evas_engine_directfb_cflags = @evas_engine_directfb_cflags@
266evas_engine_directfb_libs = @evas_engine_directfb_libs@
267evas_engine_fb_cflags = @evas_engine_fb_cflags@
268evas_engine_fb_libs = @evas_engine_fb_libs@
269evas_engine_gl_cocoa_cflags = @evas_engine_gl_cocoa_cflags@
270evas_engine_gl_cocoa_libs = @evas_engine_gl_cocoa_libs@
271evas_engine_gl_common_libs = @evas_engine_gl_common_libs@
272evas_engine_gl_sdl_cflags = @evas_engine_gl_sdl_cflags@
273evas_engine_gl_sdl_libs = @evas_engine_gl_sdl_libs@
274evas_engine_gl_xcb_cflags = @evas_engine_gl_xcb_cflags@
275evas_engine_gl_xcb_libs = @evas_engine_gl_xcb_libs@
276evas_engine_gl_xlib_cflags = @evas_engine_gl_xlib_cflags@
277evas_engine_gl_xlib_libs = @evas_engine_gl_xlib_libs@
278evas_engine_psl1ght_cflags = @evas_engine_psl1ght_cflags@
279evas_engine_psl1ght_libs = @evas_engine_psl1ght_libs@
280evas_engine_software_16_ddraw_cflags = @evas_engine_software_16_ddraw_cflags@
281evas_engine_software_16_ddraw_libs = @evas_engine_software_16_ddraw_libs@
282evas_engine_software_16_sdl_cflags = @evas_engine_software_16_sdl_cflags@
283evas_engine_software_16_sdl_libs = @evas_engine_software_16_sdl_libs@
284evas_engine_software_16_wince_cflags = @evas_engine_software_16_wince_cflags@
285evas_engine_software_16_wince_libs = @evas_engine_software_16_wince_libs@
286evas_engine_software_16_x11_cflags = @evas_engine_software_16_x11_cflags@
287evas_engine_software_16_x11_libs = @evas_engine_software_16_x11_libs@
288evas_engine_software_8_x11_cflags = @evas_engine_software_8_x11_cflags@
289evas_engine_software_8_x11_libs = @evas_engine_software_8_x11_libs@
290evas_engine_software_ddraw_cflags = @evas_engine_software_ddraw_cflags@
291evas_engine_software_ddraw_libs = @evas_engine_software_ddraw_libs@
292evas_engine_software_gdi_cflags = @evas_engine_software_gdi_cflags@
293evas_engine_software_gdi_libs = @evas_engine_software_gdi_libs@
294evas_engine_software_sdl_cflags = @evas_engine_software_sdl_cflags@
295evas_engine_software_sdl_libs = @evas_engine_software_sdl_libs@
296evas_engine_software_xcb_cflags = @evas_engine_software_xcb_cflags@
297evas_engine_software_xcb_libs = @evas_engine_software_xcb_libs@
298evas_engine_software_xlib_cflags = @evas_engine_software_xlib_cflags@
299evas_engine_software_xlib_libs = @evas_engine_software_xlib_libs@
300evas_image_loader_bmp_cflags = @evas_image_loader_bmp_cflags@
301evas_image_loader_bmp_libs = @evas_image_loader_bmp_libs@
302evas_image_loader_edb_cflags = @evas_image_loader_edb_cflags@
303evas_image_loader_edb_libs = @evas_image_loader_edb_libs@
304evas_image_loader_eet_cflags = @evas_image_loader_eet_cflags@
305evas_image_loader_eet_libs = @evas_image_loader_eet_libs@
306evas_image_loader_generic_cflags = @evas_image_loader_generic_cflags@
307evas_image_loader_generic_libs = @evas_image_loader_generic_libs@
308evas_image_loader_gif_cflags = @evas_image_loader_gif_cflags@
309evas_image_loader_gif_libs = @evas_image_loader_gif_libs@
310evas_image_loader_ico_cflags = @evas_image_loader_ico_cflags@
311evas_image_loader_ico_libs = @evas_image_loader_ico_libs@
312evas_image_loader_jpeg_cflags = @evas_image_loader_jpeg_cflags@
313evas_image_loader_jpeg_libs = @evas_image_loader_jpeg_libs@
314evas_image_loader_pmaps_cflags = @evas_image_loader_pmaps_cflags@
315evas_image_loader_pmaps_libs = @evas_image_loader_pmaps_libs@
316evas_image_loader_png_cflags = @evas_image_loader_png_cflags@
317evas_image_loader_png_libs = @evas_image_loader_png_libs@
318evas_image_loader_psd_cflags = @evas_image_loader_psd_cflags@
319evas_image_loader_psd_libs = @evas_image_loader_psd_libs@
320evas_image_loader_svg_cflags = @evas_image_loader_svg_cflags@
321evas_image_loader_svg_libs = @evas_image_loader_svg_libs@
322evas_image_loader_tga_cflags = @evas_image_loader_tga_cflags@
323evas_image_loader_tga_libs = @evas_image_loader_tga_libs@
324evas_image_loader_tiff_cflags = @evas_image_loader_tiff_cflags@
325evas_image_loader_tiff_libs = @evas_image_loader_tiff_libs@
326evas_image_loader_wbmp_cflags = @evas_image_loader_wbmp_cflags@
327evas_image_loader_wbmp_libs = @evas_image_loader_wbmp_libs@
328evas_image_loader_xpm_cflags = @evas_image_loader_xpm_cflags@
329evas_image_loader_xpm_libs = @evas_image_loader_xpm_libs@
330exec_prefix = @exec_prefix@
331have_evas_engine_gl_x11 = @have_evas_engine_gl_x11@
332have_evas_engine_gl_xcb = @have_evas_engine_gl_xcb@
333have_evas_engine_gl_xlib = @have_evas_engine_gl_xlib@
334have_evas_engine_software_x11 = @have_evas_engine_software_x11@
335have_evas_engine_software_xcb = @have_evas_engine_software_xcb@
336have_evas_engine_software_xlib = @have_evas_engine_software_xlib@
337have_lcov = @have_lcov@
338host = @host@
339host_alias = @host_alias@
340host_cpu = @host_cpu@
341host_os = @host_os@
342host_vendor = @host_vendor@
343htmldir = @htmldir@
344includedir = @includedir@
345infodir = @infodir@
346install_sh = @install_sh@
347libdir = @libdir@
348libexecdir = @libexecdir@
349localedir = @localedir@
350localstatedir = @localstatedir@
351lt_ECHO = @lt_ECHO@
352lt_enable_auto_import = @lt_enable_auto_import@
353mandir = @mandir@
354mkdir_p = @mkdir_p@
355oldincludedir = @oldincludedir@
356pdfdir = @pdfdir@
357pkgconfig_requires_private = @pkgconfig_requires_private@
358prefix = @prefix@
359program_transform_name = @program_transform_name@
360psdir = @psdir@
361pthread_cflags = @pthread_cflags@
362pthread_libs = @pthread_libs@
363release_info = @release_info@
364requirement_evas = @requirement_evas@
365sbindir = @sbindir@
366sharedstatedir = @sharedstatedir@
367srcdir = @srcdir@
368sysconfdir = @sysconfdir@
369target_alias = @target_alias@
370top_build_prefix = @top_build_prefix@
371top_builddir = @top_builddir@
372top_srcdir = @top_srcdir@
373version_info = @version_info@
374MAINTAINERCLEANFILES = Makefile.in
375AM_CPPFLAGS = \
376-I. \
377-I$(top_srcdir)/src/lib \
378-I$(top_srcdir)/src/lib/include \
379-I$(top_srcdir)/src/lib/cserve \
380-DPACKAGE_BIN_DIR=\"$(bindir)\" \
381-DPACKAGE_LIB_DIR=\"$(libdir)\" \
382-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
383@EINA_CFLAGS@ \
384@FREETYPE_CFLAGS@ \
385@FRIBIDI_CFLAGS@ \
386@EET_CFLAGS@ \
387@FONTCONFIG_CFLAGS@ \
388@pthread_cflags@ \
389@PIXMAN_CFLAGS@
390
391@EVAS_CSERVE_TRUE@noinst_LTLIBRARIES = libevas_cserve.la
392libevas_cserve_la_SOURCES = \
393evas_cs.h \
394evas_cs_main.c \
395evas_cs_server.c \
396evas_cs_client.c \
397evas_cs_mem.c
398
399libevas_cserve_la_LIBADD = @EINA_LIBS@ -lrt
400all: all-am
401
402.SUFFIXES:
403.SUFFIXES: .c .lo .o .obj
404$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
405 @for dep in $?; do \
406 case '$(am__configure_deps)' in \
407 *$$dep*) \
408 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
409 && { if test -f $@; then exit 0; else break; fi; }; \
410 exit 1;; \
411 esac; \
412 done; \
413 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/lib/cserve/Makefile'; \
414 $(am__cd) $(top_srcdir) && \
415 $(AUTOMAKE) --gnu src/lib/cserve/Makefile
416.PRECIOUS: Makefile
417Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
418 @case '$?' in \
419 *config.status*) \
420 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
421 *) \
422 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
423 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
424 esac;
425
426$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
427 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
428
429$(top_srcdir)/configure: $(am__configure_deps)
430 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
431$(ACLOCAL_M4): $(am__aclocal_m4_deps)
432 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
433$(am__aclocal_m4_deps):
434
435clean-noinstLTLIBRARIES:
436 -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
437 @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
438 dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
439 test "$$dir" != "$$p" || dir=.; \
440 echo "rm -f \"$${dir}/so_locations\""; \
441 rm -f "$${dir}/so_locations"; \
442 done
443libevas_cserve.la: $(libevas_cserve_la_OBJECTS) $(libevas_cserve_la_DEPENDENCIES)
444 $(AM_V_CCLD)$(LINK) $(am_libevas_cserve_la_rpath) $(libevas_cserve_la_OBJECTS) $(libevas_cserve_la_LIBADD) $(LIBS)
445
446mostlyclean-compile:
447 -rm -f *.$(OBJEXT)
448
449distclean-compile:
450 -rm -f *.tab.c
451
452@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evas_cs_client.Plo@am__quote@
453@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evas_cs_main.Plo@am__quote@
454@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evas_cs_mem.Plo@am__quote@
455@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evas_cs_server.Plo@am__quote@
456
457.c.o:
458@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
459@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
460@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
461@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
462@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
463@am__fastdepCC_FALSE@ $(COMPILE) -c $<
464
465.c.obj:
466@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
467@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
468@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
469@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
470@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
471@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
472
473.c.lo:
474@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
475@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
476@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
477@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
478@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
479@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
480
481mostlyclean-libtool:
482 -rm -f *.lo
483
484clean-libtool:
485 -rm -rf .libs _libs
486
487ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
488 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
489 unique=`for i in $$list; do \
490 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
491 done | \
492 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
493 END { if (nonempty) { for (i in files) print i; }; }'`; \
494 mkid -fID $$unique
495tags: TAGS
496
497TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
498 $(TAGS_FILES) $(LISP)
499 set x; \
500 here=`pwd`; \
501 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
502 unique=`for i in $$list; do \
503 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
504 done | \
505 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
506 END { if (nonempty) { for (i in files) print i; }; }'`; \
507 shift; \
508 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
509 test -n "$$unique" || unique=$$empty_fix; \
510 if test $$# -gt 0; then \
511 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
512 "$$@" $$unique; \
513 else \
514 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
515 $$unique; \
516 fi; \
517 fi
518ctags: CTAGS
519CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
520 $(TAGS_FILES) $(LISP)
521 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
522 unique=`for i in $$list; do \
523 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
524 done | \
525 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
526 END { if (nonempty) { for (i in files) print i; }; }'`; \
527 test -z "$(CTAGS_ARGS)$$unique" \
528 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
529 $$unique
530
531GTAGS:
532 here=`$(am__cd) $(top_builddir) && pwd` \
533 && $(am__cd) $(top_srcdir) \
534 && gtags -i $(GTAGS_ARGS) "$$here"
535
536distclean-tags:
537 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
538
539distdir: $(DISTFILES)
540 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
541 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
542 list='$(DISTFILES)'; \
543 dist_files=`for file in $$list; do echo $$file; done | \
544 sed -e "s|^$$srcdirstrip/||;t" \
545 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
546 case $$dist_files in \
547 */*) $(MKDIR_P) `echo "$$dist_files" | \
548 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
549 sort -u` ;; \
550 esac; \
551 for file in $$dist_files; do \
552 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
553 if test -d $$d/$$file; then \
554 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
555 if test -d "$(distdir)/$$file"; then \
556 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
557 fi; \
558 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
559 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
560 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
561 fi; \
562 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
563 else \
564 test -f "$(distdir)/$$file" \
565 || cp -p $$d/$$file "$(distdir)/$$file" \
566 || exit 1; \
567 fi; \
568 done
569check-am: all-am
570check: check-am
571all-am: Makefile $(LTLIBRARIES)
572installdirs:
573install: install-am
574install-exec: install-exec-am
575install-data: install-data-am
576uninstall: uninstall-am
577
578install-am: all-am
579 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
580
581installcheck: installcheck-am
582install-strip:
583 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
584 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
585 `test -z '$(STRIP)' || \
586 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
587mostlyclean-generic:
588
589clean-generic:
590
591distclean-generic:
592 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
593 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
594
595maintainer-clean-generic:
596 @echo "This command is intended for maintainers to use"
597 @echo "it deletes files that may require special tools to rebuild."
598 -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
599clean: clean-am
600
601clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
602 mostlyclean-am
603
604distclean: distclean-am
605 -rm -rf ./$(DEPDIR)
606 -rm -f Makefile
607distclean-am: clean-am distclean-compile distclean-generic \
608 distclean-tags
609
610dvi: dvi-am
611
612dvi-am:
613
614html: html-am
615
616html-am:
617
618info: info-am
619
620info-am:
621
622install-data-am:
623
624install-dvi: install-dvi-am
625
626install-dvi-am:
627
628install-exec-am:
629
630install-html: install-html-am
631
632install-html-am:
633
634install-info: install-info-am
635
636install-info-am:
637
638install-man:
639
640install-pdf: install-pdf-am
641
642install-pdf-am:
643
644install-ps: install-ps-am
645
646install-ps-am:
647
648installcheck-am:
649
650maintainer-clean: maintainer-clean-am
651 -rm -rf ./$(DEPDIR)
652 -rm -f Makefile
653maintainer-clean-am: distclean-am maintainer-clean-generic
654
655mostlyclean: mostlyclean-am
656
657mostlyclean-am: mostlyclean-compile mostlyclean-generic \
658 mostlyclean-libtool
659
660pdf: pdf-am
661
662pdf-am:
663
664ps: ps-am
665
666ps-am:
667
668uninstall-am:
669
670.MAKE: install-am install-strip
671
672.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
673 clean-libtool clean-noinstLTLIBRARIES ctags distclean \
674 distclean-compile distclean-generic distclean-libtool \
675 distclean-tags distdir dvi dvi-am html html-am info info-am \
676 install install-am install-data install-data-am install-dvi \
677 install-dvi-am install-exec install-exec-am install-html \
678 install-html-am install-info install-info-am install-man \
679 install-pdf install-pdf-am install-ps install-ps-am \
680 install-strip installcheck installcheck-am installdirs \
681 maintainer-clean maintainer-clean-generic mostlyclean \
682 mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
683 pdf pdf-am ps ps-am tags uninstall uninstall-am
684
685
686# Tell versions [3.59,3.63) of GNU make to not export all variables.
687# Otherwise a system limit (for SysV at least) may be exceeded.
688.NOEXPORT:
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
diff --git a/libraries/evas/src/lib/cserve/evas_cs_client.c b/libraries/evas/src/lib/cserve/evas_cs_client.c
new file mode 100644
index 0000000..b24848d
--- /dev/null
+++ b/libraries/evas/src/lib/cserve/evas_cs_client.c
@@ -0,0 +1,528 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <signal.h>
6
7#include "evas_cs.h"
8
9#ifdef EVAS_CSERVE
10
11static Server *cserve = NULL;
12static int csrve_init = 0;
13static int connect_num = 0;
14static int cserve_discon = 0;
15
16static void
17pipe_handler(int x __UNUSED__, siginfo_t *info __UNUSED__, void *data __UNUSED__)
18{
19}
20
21static void
22pipe_handle(int push)
23{
24 static struct sigaction old_action;
25 struct sigaction action;
26
27 if (push)
28 {
29 action.sa_handler = NULL;
30 action.sa_sigaction = pipe_handler;
31 action.sa_flags = SA_RESTART | SA_SIGINFO;
32 sigemptyset(&action.sa_mask);
33 sigaction(SIGPIPE, &action, &old_action);
34 }
35 else
36 {
37 sigaction(SIGPIPE, &old_action, &action);
38 }
39}
40
41static Server *
42server_connect(void)
43{
44 Server *s;
45 char buf[PATH_MAX];
46 int curstate = 0;
47 struct sockaddr_un socket_unix;
48 int socket_unix_len;
49
50 s = calloc(1, sizeof(Server));
51 if (!s) return NULL;
52 s->ch[0].fd = -1;
53 s->ch[1].fd = -1;
54 snprintf(buf, sizeof(buf), "/tmp/.evas-cserve-%x", getuid());
55 s->socket_path = strdup(buf);
56 if (!s->socket_path)
57 {
58 free(s);
59 return NULL;
60 }
61 s->ch[0].fd = socket(AF_UNIX, SOCK_STREAM, 0);
62 if (s->ch[0].fd < 0) goto error;
63 if (fcntl(s->ch[0].fd, F_SETFD, FD_CLOEXEC) < 0) goto error;
64 if (setsockopt(s->ch[0].fd, SOL_SOCKET, SO_REUSEADDR, &curstate, sizeof(curstate)) < 0)
65 goto error;
66 socket_unix.sun_family = AF_UNIX;
67 strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path));
68 socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix);
69 if (connect(s->ch[0].fd, (struct sockaddr *)&socket_unix, socket_unix_len) < 0) goto error;
70
71 s->ch[1].fd = socket(AF_UNIX, SOCK_STREAM, 0);
72 if (s->ch[1].fd < 0) goto error;
73 if (fcntl(s->ch[1].fd, F_SETFD, FD_CLOEXEC) < 0) goto error;
74 if (setsockopt(s->ch[1].fd, SOL_SOCKET, SO_REUSEADDR, &curstate, sizeof(curstate)) < 0)
75 goto error;
76 socket_unix.sun_family = AF_UNIX;
77 strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path));
78 socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix);
79 if (connect(s->ch[1].fd, (struct sockaddr *)&socket_unix, socket_unix_len) < 0) goto error;
80
81 return s;
82 error:
83 if (s->ch[0].fd >= 0) close(s->ch[0].fd);
84 if (s->ch[1].fd >= 0) close(s->ch[1].fd);
85 free(s->socket_path);
86 free(s);
87 return NULL;
88}
89
90static void
91server_disconnect(Server *s)
92{
93 close(s->ch[0].fd);
94 close(s->ch[1].fd);
95 free(s->socket_path);
96 free(s);
97}
98
99static int
100server_send(Server *s, int channel, int opcode, int size, unsigned char *data)
101{
102 int ints[3];
103 int num;
104
105 pipe_handle(1);
106 ints[0] = size;
107 ints[1] = opcode;
108 s->ch[channel].req_to++;
109 ints[2] = s->ch[channel].req_to;
110 num = write(s->ch[channel].fd, ints, (sizeof(int) * 3));
111 if (num < 0)
112 {
113 pipe_handle(0);
114 if (cserve) server_disconnect(cserve);
115 cserve = NULL;
116 return 0;
117 }
118 num = write(s->ch[channel].fd, data, size);
119 if (num < 0)
120 {
121 pipe_handle(0);
122 if (cserve) server_disconnect(cserve);
123 cserve = NULL;
124 return 0;
125 }
126 pipe_handle(0);
127 return 1;
128}
129
130static unsigned char *
131server_read(Server *s, int channel, int *opcode, int *size)
132{
133 int ints[3], num, left;
134 unsigned char *data;
135
136 num = read(s->ch[channel].fd, ints, sizeof(int) * 3);
137 if (num != (sizeof(int) * 3))
138 {
139 if (cserve) server_disconnect(cserve);
140 cserve = NULL;
141 return NULL;
142 }
143 *size = ints[0];
144 *opcode = ints[1];
145 if ((*size < 0) || (*size > (1024 * 1024))) return NULL;
146 if (ints[2] != (s->ch[channel].req_from + 1))
147 {
148 ERR("EEK! sequence number mismatch from serer with pid: %i. "
149 "---- num %i is not 1 more than %i"
150 ,
151 s->pid, ints[2], s->ch[channel].req_from);
152 return NULL;
153 }
154 s->ch[channel].req_from++;
155 data = malloc(*size);
156 if (!data) return NULL;
157 num = read(s->ch[channel].fd, data, *size);
158 if (num < 0)
159 {
160 free(data);
161 return NULL;
162 }
163 left = *size - num;
164 while (left > 0)
165 {
166 num = read(s->ch[channel].fd, data + (*size - left), left);
167 if (num < 0)
168 {
169 free(data);
170 return NULL;
171 }
172 left -= num;
173 }
174 return data;
175}
176
177static int
178server_init(Server *s)
179{
180 Op_Init msg, *rep;
181 int opcode;
182 int size;
183
184 msg.pid = getpid();
185 msg.server_id = 0;
186 msg.handle = NULL;
187 if (!server_send(s, 0, OP_INIT, sizeof(msg), (unsigned char *)(&msg)))
188 return 0;
189 rep = (Op_Init *)server_read(s, 0, &opcode, &size);
190 if ((rep) && (opcode == OP_INIT) && (size == sizeof(Op_Init)))
191 {
192 s->pid = rep->pid;
193 s->server_id = rep->server_id;
194 s->main_handle = rep->handle;
195 connect_num++;
196 msg.pid = getpid();
197 msg.server_id = 1;
198 msg.handle = rep->handle;
199 free(rep);
200 if (!server_send(s, 1, OP_INIT, sizeof(msg), (unsigned char *)(&msg)))
201 return 0;
202 rep = (Op_Init *)server_read(s, 1, &opcode, &size);
203 if ((rep) && (opcode == OP_INIT) && (size == sizeof(Op_Init)))
204 {
205 free(rep);
206 return 1;
207 }
208 if (rep) free(rep);
209 return 0;
210 }
211 if (rep) free(rep);
212 return 0;
213}
214
215EAPI Eina_Bool
216evas_cserve_init(void)
217{
218 csrve_init++;
219 if (cserve) return 1;
220 cserve = server_connect();
221 if (!cserve) return 0;
222 if (!server_init(cserve))
223 {
224 if (cserve) server_disconnect(cserve);
225 cserve = NULL;
226 return 0;
227 }
228 return 1;
229}
230
231EAPI int
232evas_cserve_use_get(void)
233{
234 return csrve_init;
235}
236
237EAPI Eina_Bool
238evas_cserve_have_get(void)
239{
240 if (cserve) return 1;
241 return 0;
242}
243
244EAPI void
245evas_cserve_shutdown(void)
246{
247 csrve_init--;
248 if (csrve_init > 0) return;
249 if (!cserve) return;
250 server_disconnect(cserve);
251 cserve = NULL;
252}
253
254EAPI void
255evas_cserve_discon(void)
256{
257 if (cserve)
258 {
259 server_disconnect(cserve);
260 cserve = NULL;
261 cserve_discon = 1;
262 }
263}
264
265static void
266server_reinit(void)
267{
268 if (cserve) return;
269 if (cserve_discon) return;
270 cserve = server_connect();
271 if (cserve)
272 {
273 if (!server_init(cserve))
274 {
275 if (cserve) server_disconnect(cserve);
276 cserve = NULL;
277 }
278 }
279}
280
281EAPI Eina_Bool
282evas_cserve_image_load(Image_Entry *ie, const char *file, const char *key, RGBA_Image_Loadopts *lopt)
283{
284 Op_Load msg;
285 Op_Load_Reply *rep;
286 unsigned char *buf;
287 char fbuf[PATH_MAX], wdb[PATH_MAX];
288 int flen, klen;
289 int opcode;
290 int size;
291
292 if (csrve_init > 0) server_reinit();
293 else return 0;
294 if (!cserve) return 0;
295 if (!key) key = "";
296 memset(&msg, 0, sizeof(msg));
297 msg.lopt.scale_down_by = lopt->scale_down_by;
298 msg.lopt.dpi = lopt->dpi;
299 msg.lopt.w = lopt->w;
300 msg.lopt.h = lopt->h;
301 msg.lopt.region.x = lopt->region.x;
302 msg.lopt.region.y = lopt->region.y;
303 msg.lopt.region.w = lopt->region.w;
304 msg.lopt.region.h = lopt->region.h;
305 msg.lopt.orientation = lopt->orientation;
306 if (file[0] != '/')
307 {
308 if (getcwd(wdb, sizeof(wdb)))
309 {
310 snprintf(fbuf, sizeof(buf), "%s/%s", wdb, file);
311 file = fbuf;
312 }
313 }
314 if (!realpath(file, wdb)) file = wdb;
315 flen = strlen(file) + 1;
316 klen = strlen(key) + 1;
317 buf = malloc(sizeof(msg) + flen + klen);
318 if (!buf) return 0;
319 memcpy(buf, &msg, sizeof(msg));
320 memcpy(buf + sizeof(msg), file, flen);
321 memcpy(buf + sizeof(msg) + flen, key, klen);
322 if (!server_send(cserve, ie->channel, OP_LOAD,
323 sizeof(msg) + flen + klen,
324 buf))
325 {
326 free(buf);
327 return 0;
328 }
329 free(buf);
330 if (!cserve) return 0;
331 rep = (Op_Load_Reply *)server_read(cserve, ie->channel, &opcode, &size);
332 if ((rep) && (opcode == OP_LOAD) && (size == sizeof(Op_Load_Reply)))
333 {
334 ie->w = rep->image.w;
335 ie->h = rep->image.h;
336 ie->flags.alpha = rep->image.alpha;
337 ie->data1 = rep->handle;
338 }
339 if (rep) free(rep);
340 if (!ie->data1) return 0;
341 ie->connect_num = connect_num;
342 if (cserve)
343 ie->server_id = cserve->server_id;
344 return 1;
345}
346
347EAPI Eina_Bool
348evas_cserve_image_data_load(Image_Entry *ie)
349{
350 Op_Loaddata msg;
351 Op_Loaddata_Reply *rep;
352 int opcode;
353 int size;
354 if (csrve_init > 0) server_reinit();
355 else return 0;
356 if (!cserve) return 0;
357 if (!ie->data1) return 0;
358 if (cserve->server_id != ie->server_id)
359 {
360 ie->data1 = NULL;
361 if (!evas_cserve_image_load(ie, ie->file, ie->key, &(ie->load_opts)))
362 return 0;
363 }
364 if (ie->connect_num != connect_num) return 0;
365 memset(&msg, 0, sizeof(msg));
366 msg.handle = ie->data1;
367 msg.server_id = cserve->server_id;
368 if (!server_send(cserve, ie->channel, OP_LOADDATA, sizeof(msg), (unsigned char *)(&msg)))
369 return 0;
370 if (!cserve) return 0;
371 rep = (Op_Loaddata_Reply *)server_read(cserve, ie->channel, &opcode, &size);
372 if ((rep) && (opcode == OP_LOADDATA) && (size == sizeof(Op_Loaddata_Reply)))
373 {
374 if (rep->mem.size <= 0)
375 {
376 free(rep);
377 return 0;
378 }
379 ie->data2 = evas_cserve_mem_open(cserve->pid, rep->mem.id, NULL, rep->mem.size, 0);
380 free(rep);
381 return 1;
382 }
383 if (rep) free(rep);
384 return 0;
385}
386
387EAPI void
388evas_cserve_image_free(Image_Entry *ie)
389{
390 Op_Unload msg;
391
392 if (csrve_init > 0) server_reinit();
393 else return;
394 if (!cserve) return;
395 if (!ie->data1) return;
396 memset(&msg, 0, sizeof(msg));
397 msg.handle = ie->data1;
398 msg.server_id = cserve->server_id;
399 if (ie->data2) evas_cserve_image_unload(ie);
400 if (cserve)
401 {
402 if (ie->connect_num == connect_num)
403 {
404 if (ie->server_id == cserve->server_id)
405 server_send(cserve, ie->channel, OP_UNLOAD, sizeof(msg), (unsigned char *)(&msg));
406 }
407 }
408 ie->data1 = NULL;
409 ie->data2 = NULL;
410}
411
412EAPI void
413evas_cserve_image_unload(Image_Entry *ie)
414{
415 Op_Unloaddata msg;
416
417 if (csrve_init > 0) server_reinit();
418 else return;
419 if (!cserve) return;
420 if (!ie->data1) return;
421 if (ie->connect_num != connect_num) return;
422 memset(&msg, 0, sizeof(msg));
423 msg.handle = ie->data1;
424 msg.server_id = cserve->server_id;
425 if (ie->data2) evas_cserve_mem_close(ie->data2);
426 ie->data2 = NULL;
427 if (ie->connect_num == connect_num)
428 {
429 if (ie->server_id == cserve->server_id)
430 server_send(cserve, ie->channel, OP_UNLOADDATA, sizeof(msg), (unsigned char *)(&msg));
431 }
432}
433
434EAPI void
435evas_cserve_image_useless(Image_Entry *ie)
436{
437 Op_Unloaddata msg;
438
439 if (csrve_init > 0) server_reinit();
440 else return;
441 if (!cserve) return;
442 if (!ie->data1) return;
443 if (ie->connect_num != connect_num) return;
444 memset(&msg, 0, sizeof(msg));
445 msg.handle = ie->data1;
446 msg.server_id = cserve->server_id;
447 if (ie->data2) evas_cserve_mem_close(ie->data2);
448 ie->data2 = NULL;
449 if (ie->connect_num == connect_num)
450 {
451 if (ie->server_id == cserve->server_id)
452 server_send(cserve, ie->channel, OP_USELESSDATA, sizeof(msg), (unsigned char *)(&msg));
453 }
454}
455
456EAPI Eina_Bool
457evas_cserve_raw_config_get(Op_Getconfig_Reply *config)
458{
459 Op_Getconfig_Reply *rep;
460 int opcode;
461 int size;
462 if (csrve_init > 0) server_reinit();
463 else return 0;
464 if (!cserve) return 0;
465 if (!server_send(cserve, 0, OP_GETCONFIG, 0, NULL)) return 0;
466 rep = (Op_Getconfig_Reply *)server_read(cserve, 0, &opcode, &size);
467 if ((rep) && (opcode == OP_GETCONFIG) && (size == sizeof(Op_Getconfig_Reply)))
468 {
469 memcpy(config, rep, sizeof(Op_Getconfig_Reply));
470 free(rep);
471 return 1;
472 }
473 if (rep) free(rep);
474 return 0;
475}
476
477EAPI Eina_Bool
478evas_cserve_raw_config_set(Op_Setconfig *config)
479{
480 if (csrve_init > 0) server_reinit();
481 else return 0;
482 if (!cserve) return 0;
483 if (!server_send(cserve, 0, OP_SETCONFIG, sizeof(Op_Setconfig), (unsigned char *)config)) return 0;
484 return 1;
485}
486
487EAPI Eina_Bool
488evas_cserve_raw_stats_get(Op_Getstats_Reply *stats)
489{
490 Op_Getstats_Reply *rep;
491 int opcode;
492 int size;
493 if (csrve_init > 0) server_reinit();
494 else return 0;
495 if (!cserve) return 0;
496 if (!server_send(cserve, 0, OP_GETSTATS, 0, NULL)) return 0;
497 rep = (Op_Getstats_Reply *)server_read(cserve, 0, &opcode, &size);
498 if ((rep) && (opcode == OP_GETSTATS) && (size == sizeof(Op_Getstats_Reply)))
499 {
500 memcpy(stats, rep, sizeof(Op_Getstats_Reply));
501 free(rep);
502 return 1;
503 }
504 if (rep) free(rep);
505 return 0;
506}
507
508EAPI Op_Getinfo_Reply *
509evas_cserve_raw_info_get(void)
510{
511 Op_Getinfo_Reply *rep;
512 int opcode;
513 int size;
514 if (csrve_init > 0) server_reinit();
515 else return NULL;
516 if (!cserve) return NULL;
517 if (!server_send(cserve, 0, OP_GETINFO, 0, NULL)) return NULL;
518 rep = (Op_Getinfo_Reply *)server_read(cserve, 0, &opcode, &size);
519 if ((rep) && (opcode == OP_GETINFO) &&
520 (size >= (int)sizeof(Op_Getinfo_Reply)))
521 {
522 return rep;
523 }
524 if (rep) free(rep);
525 return NULL;
526}
527
528#endif
diff --git a/libraries/evas/src/lib/cserve/evas_cs_main.c b/libraries/evas/src/lib/cserve/evas_cs_main.c
new file mode 100644
index 0000000..e8282aa
--- /dev/null
+++ b/libraries/evas/src/lib/cserve/evas_cs_main.c
@@ -0,0 +1,9 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include "evas_cs.h"
6
7#ifdef EVAS_CSERVE
8
9#endif
diff --git a/libraries/evas/src/lib/cserve/evas_cs_mem.c b/libraries/evas/src/lib/cserve/evas_cs_mem.c
new file mode 100644
index 0000000..15edf93
--- /dev/null
+++ b/libraries/evas/src/lib/cserve/evas_cs_mem.c
@@ -0,0 +1,168 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include "evas_cs.h"
6
7#ifdef EVAS_CSERVE
8
9EAPI Mem *
10evas_cserve_mem_new(int size, const char *name)
11{
12 Mem *m;
13 static int id = 0;
14 char buf[PATH_MAX];
15
16 m = calloc(1, sizeof(Mem));
17 if (!m) return NULL;
18 if (name)
19 snprintf(buf, sizeof(buf), "/evas-shm-%x.%s", getuid(), name);
20 else
21 {
22 id++;
23 snprintf(buf, sizeof(buf), "/evas-shm-%x.%x.%x", getuid(), getpid(), id);
24 }
25 m->id = id;
26 m->offset = 0;
27 m->name = strdup(buf);
28 if (!m->name)
29 {
30 free(m);
31 return NULL;
32 }
33 m->size = size;
34 m->fd = shm_open(m->name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
35 if (m->fd < 0)
36 {
37 free(m->name);
38 free(m);
39 return NULL;
40 }
41 if (ftruncate(m->fd, m->size) < 0)
42 {
43 shm_unlink(m->name);
44 close(m->fd);
45 free(m->name);
46 free(m);
47 return NULL;
48 }
49
50 eina_mmap_safety_enabled_set(EINA_TRUE);
51
52 m->data = mmap(NULL, m->size, PROT_READ | PROT_WRITE, MAP_SHARED, m->fd, 0);
53 if (m->data == MAP_FAILED)
54 {
55 shm_unlink(m->name);
56 close(m->fd);
57 free(m->name);
58 free(m);
59 return NULL;
60 }
61 m->ref = 1;
62 m->write = 1;
63 return m;
64}
65
66EAPI void
67evas_cserve_mem_free(Mem *m)
68{
69 shm_unlink(m->name);
70 munmap(m->data, m->size);
71 close(m->fd);
72 free(m->name);
73 free(m);
74}
75
76EAPI Mem *
77evas_cserve_mem_open(int pid, int id, const char *name, int size, int do_write)
78{
79 Mem *m;
80 char buf[PATH_MAX];
81
82 m = calloc(1, sizeof(Mem));
83 if (!m) return NULL;
84 if (name)
85 snprintf(buf, sizeof(buf), "/evas-shm-%x.%s", getuid(), name);
86 else
87 snprintf(buf, sizeof(buf), "/evas-shm-%x.%x.%x", getuid(), pid, id);
88 m->name = strdup(buf);
89 if (!m->name)
90 {
91 free(m);
92 return NULL;
93 }
94 m->size = size;
95 if (do_write)
96 m->fd = shm_open(m->name, O_RDWR, S_IRUSR | S_IWUSR);
97 else
98 m->fd = shm_open(m->name, O_RDONLY, S_IRUSR);
99 if (m->fd < 0)
100 {
101 free(m->name);
102 free(m);
103 return NULL;
104 }
105 m->write = do_write;
106
107 eina_mmap_safety_enabled_set(EINA_TRUE);
108
109 if (do_write)
110 m->data = mmap(NULL, m->size, PROT_READ | PROT_WRITE, MAP_SHARED, m->fd, 0);
111 else
112 m->data = mmap(NULL, m->size, PROT_READ, MAP_SHARED, m->fd, 0);
113 if (m->data == MAP_FAILED)
114 {
115 close(m->fd);
116 free(m->name);
117 free(m);
118 return NULL;
119 }
120 m->ref = 1;
121 return m;
122}
123
124EAPI void
125evas_cserve_mem_close(Mem *m)
126{
127 munmap(m->data, m->size);
128 close(m->fd);
129 free(m->name);
130 free(m);
131}
132
133EAPI Eina_Bool
134evas_cserve_mem_resize(Mem *m, int size)
135{
136 if (m->size == size) return 1;
137 if (m->write)
138 {
139 if (ftruncate(m->fd, size) < 0) return 0;
140 munmap(m->data, m->size);
141 eina_mmap_safety_enabled_set(EINA_TRUE);
142 m->data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, m->fd, 0);
143 }
144 else
145 {
146 munmap(m->data, m->size);
147 eina_mmap_safety_enabled_set(EINA_TRUE);
148 m->data = mmap(NULL, size, PROT_READ, MAP_SHARED, m->fd, 0);
149 }
150 if (m->data == MAP_FAILED)
151 {
152 m->data = NULL;
153 return 0;
154 }
155 m->size = size;
156 return 1;
157}
158
159EAPI void
160evas_cserve_mem_del(int pid, int id)
161{
162 char buf[PATH_MAX];
163
164 snprintf(buf, sizeof(buf), "/evas-shm-%x.%x.%x", getuid(), pid, id);
165 shm_unlink(buf);
166}
167
168#endif
diff --git a/libraries/evas/src/lib/cserve/evas_cs_server.c b/libraries/evas/src/lib/cserve/evas_cs_server.c
new file mode 100644
index 0000000..3b5d8b9
--- /dev/null
+++ b/libraries/evas/src/lib/cserve/evas_cs_server.c
@@ -0,0 +1,380 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include "evas_cs.h"
6
7#ifdef EVAS_CSERVE
8
9EAPI Server *
10evas_cserve_server_add(void)
11{
12 Server *s;
13 char buf[PATH_MAX];
14 struct sockaddr_un socket_unix;
15 struct linger lin;
16 mode_t pmode;
17 int socket_unix_len;
18
19 s = calloc(1, sizeof(Server));
20 if (!s) return NULL;
21 s->ch[0].fd = -1;
22 snprintf(buf, sizeof(buf), "/tmp/.evas-cserve-%x", getuid());
23 s->socket_path = strdup(buf);
24 if (!s->socket_path)
25 {
26 free(s);
27 return NULL;
28 }
29 pmode = umask(~(S_IRUSR | S_IWUSR));
30 start:
31 s->ch[0].fd = socket(AF_UNIX, SOCK_STREAM, 0);
32 if (s->ch[0].fd < 0) goto error;
33 if (fcntl(s->ch[0].fd, F_SETFL, O_NONBLOCK) < 0) goto error;
34 if (fcntl(s->ch[0].fd, F_SETFD, FD_CLOEXEC) < 0) goto error;
35 lin.l_onoff = 1;
36 lin.l_linger = 0;
37 if (setsockopt(s->ch[0].fd, SOL_SOCKET, SO_LINGER, &lin, sizeof(struct linger)) < 0)
38 goto error;
39 socket_unix.sun_family = AF_UNIX;
40 strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path));
41 socket_unix_len = LENGTH_OF_SOCKADDR_UN(&socket_unix);
42 if (bind(s->ch[0].fd, (struct sockaddr *)&socket_unix, socket_unix_len) < 0)
43 {
44 if ((connect(s->ch[0].fd, (struct sockaddr *)&socket_unix, socket_unix_len) < 0) &&
45 (unlink(s->socket_path) >= 0))
46 {
47 close(s->ch[0].fd);
48 goto start;
49 }
50 else
51 goto error;
52 }
53 if (listen(s->ch[0].fd, 4096) < 0) goto error;
54 umask(pmode);
55 return s;
56 error:
57 umask(pmode);
58 if (s->ch[0].fd >= 0) close(s->ch[0].fd);
59 free(s->socket_path);
60 free(s);
61 return NULL;
62}
63
64EAPI void
65evas_cserve_server_del(Server *s)
66{
67 Client *c;
68
69 EINA_LIST_FREE(s->clients, c)
70 {
71 LKL(c->lock);
72 close(c->fd);
73 if (c->buf) free(c->buf);
74 if (c->inbuf) free(c->inbuf);
75 LKD(c->lock);
76 free(c);
77 }
78 close(s->ch[0].fd);
79 unlink(s->socket_path);
80 free(s->socket_path);
81 free(s);
82}
83
84static void
85server_accept(Server *s)
86{
87 Client *c;
88 int new_fd;
89 struct sockaddr_in incoming;
90 size_t size_in;
91
92 size_in = sizeof(struct sockaddr_in);
93 new_fd = accept(s->ch[0].fd, (struct sockaddr *)&incoming, (socklen_t *)&size_in);
94 if (new_fd < 0) return;
95 fcntl(new_fd, F_SETFL, O_NONBLOCK);
96 fcntl(new_fd, F_SETFD, FD_CLOEXEC);
97 c = calloc(1, sizeof(Client));
98 if (!c)
99 {
100 close(new_fd);
101 return;
102 }
103 c->server = s;
104 c->fd = new_fd;
105 LKI(c->lock);
106 s->clients = eina_list_append(s->clients, c);
107}
108
109static void
110client_flush(Client *c)
111{
112 int num;
113
114 num = write(c->fd, c->buf, c->bufsize);
115 if (num < 0)
116 {
117 c->dead = 1;
118 return;
119 }
120 if (num < c->bufsize)
121 {
122 unsigned char *buf;
123
124 buf = malloc(c->bufsize - num);
125 if (buf)
126 {
127 memcpy(buf, c->buf + num, c->bufsize - num);
128 free(c->buf);
129 c->bufsize = c->bufsize - num;
130 c->bufalloc = c->bufsize;
131 c->buf = buf;
132 }
133 }
134 else
135 {
136 free(c->buf);
137 c->buf = NULL;
138 c->bufsize = 0;
139 c->bufalloc = 0;
140 }
141}
142
143static void
144client_buf_add(Client *c, unsigned char *data, int size)
145{
146 int newsize;
147 unsigned char *buf;
148
149 newsize = c->bufsize + size;
150 if (newsize > c->bufalloc)
151 {
152 c->bufalloc = newsize + 16384;
153 buf = realloc(c->buf, c->bufalloc);
154 if (buf) c->buf = buf;
155 else return;
156 }
157 memcpy(c->buf + c->bufsize, data, size);
158 c->bufsize += size;
159}
160
161static void
162client_write(Client *c, unsigned char *data, int size)
163{
164 int num;
165
166 if (!c->buf)
167 {
168 num = write(c->fd, data, size);
169 if (num != size)
170 client_buf_add(c, data + num, size - num);
171 }
172 else
173 {
174 client_buf_add(c, data, size);
175 }
176}
177
178EAPI void
179evas_cserve_client_send(Client *c, int opcode, int size, unsigned char *data)
180{
181 unsigned char *data2;
182 int *ints;
183
184 data2 = malloc(size + (sizeof(int) * 3));
185 if (!data2) return;
186 ints = (int *)data2;
187 ints[0] = size;
188 ints[1] = opcode;
189// LKL(c->lock);
190 c->req_to++;
191 ints[2] = c->req_to;
192 memcpy(data2 + (sizeof(int) * 3), data, size);
193 client_write(c, data2, size + (sizeof(int) * 3));
194// LKU(c->lock);
195 free(data2);
196}
197
198static void
199server_message_handle(Server *s, Client *c, int opcode, int size, unsigned char *data)
200{
201 if (s->func) s->func(s->data, s, c, opcode, size, data);
202}
203
204EAPI void
205evas_cserve_server_message_handler_set(Server *s, int (*func) (void *fdata, Server *s, Client *c, int opcode, int size, unsigned char *data), void *data)
206{
207 s->func = func;
208 s->data = data;
209}
210
211static int
212server_parse(Server *s, Client *c)
213{
214 int *ints;
215 unsigned char *data, *newbuf;
216
217 if (c->inbufsize < (int)sizeof(int)) return 0;
218 ints = (int *)((c->inbuf));
219 if ((ints[0] < 0) || (ints[0] > (1024 * 1024)))
220 return 0;
221 if (c->inbufsize < (ints[0] + ((int)sizeof(int) * 3)))
222 {
223 return 0;
224 }
225 data = c->inbuf + (sizeof(int) * 3);
226 if (ints[2] != (c->req_from + 1))
227 {
228 ERR("EEK! sequence number mismatch from client with pid: %i."
229 "---- num %i is not 1 more than %i"
230 ,
231 c->pid, ints[2], c->req_from);
232 return 0;
233 }
234 c->req_from++;
235 server_message_handle(s, c, ints[1], ints[0], data);
236 c->inbufalloc -= ints[0] + (sizeof(int) * 3);
237 if (c->inbufalloc == 0)
238 {
239 free(c->inbuf);
240 c->inbuf = NULL;
241 c->inbufsize = 0;
242 return 0;
243 }
244 newbuf = malloc(c->inbufalloc);
245 if (!newbuf)
246 {
247 c->inbufalloc += ints[0] + (sizeof(int) * 3);
248 /* fixme - bad situation */
249 return 0;
250 }
251 memcpy(newbuf, c->inbuf + ints[0] + (sizeof(int) * 3), c->inbufalloc);
252 c->inbufsize -= ints[0] + (sizeof(int) * 3);
253 free(c->inbuf);
254 c->inbuf = newbuf;
255 return 1;
256}
257
258static void
259server_data(Server *s, Client *c, unsigned char *data, int size)
260{
261 if (!c->inbuf)
262 {
263 c->inbuf = malloc(size);
264 if (c->inbuf)
265 {
266 memcpy(c->inbuf, data, size);
267 c->inbufalloc = size;
268 c->inbufsize = size;
269 }
270 else
271 {
272 /* fixme - bad situation */
273 return;
274 }
275 }
276 else
277 {
278 int size2;
279
280 size2 = c->inbufsize + size;
281 if (size2 > c->inbufalloc)
282 {
283 unsigned char *newbuf;
284
285 c->inbufalloc = size2;
286 newbuf = realloc(c->inbuf, c->inbufalloc);
287 if (newbuf) c->inbuf = newbuf;
288 else size2 = 0;
289 }
290 if (size2 > 0)
291 {
292 memcpy(c->inbuf + c->inbufsize, data, size);
293 c->inbufsize = size2;
294 }
295 else
296 {
297 /* fixme - bad situation */
298 return;
299 }
300 }
301 while (server_parse(s, c));
302}
303
304EAPI void
305evas_cserve_server_wait(Server *s, int timeout)
306{
307 fd_set rset, wset, xset;
308 int maxfd;
309 int ret;
310 struct timeval to;
311 Eina_List *l, *dead = NULL;
312 Client *c;
313
314 maxfd = 0;
315 FD_ZERO(&rset);
316 FD_ZERO(&wset);
317 FD_ZERO(&xset);
318 FD_SET(s->ch[0].fd, &rset);
319 if (s->ch[0].fd > maxfd) maxfd = s->ch[0].fd;
320 EINA_LIST_FOREACH(s->clients, l, c)
321 {
322 FD_SET(c->fd, &rset);
323 if (c->buf)
324 FD_SET(c->fd, &wset);
325 if (c->fd > maxfd) maxfd = c->fd;
326 }
327 if (timeout > 0)
328 {
329 to.tv_sec = timeout / 1000000;
330 to.tv_usec = timeout % 1000000;
331 ret = select(maxfd + 1, &rset, &wset, &xset, &to);
332 }
333 else
334 ret = select(maxfd + 1, &rset, &wset, &xset, NULL);
335 if (ret < 1) return;
336
337 EINA_LIST_FOREACH(s->clients, l, c)
338 {
339 if (c->dead) continue;
340 if (FD_ISSET(c->fd, &rset))
341 {
342 unsigned char buf[16384];
343 int num;
344
345 errno = 0;
346 num = read(c->fd, buf, sizeof(buf));
347 if (num <= 0)
348 {
349 c->dead = 1;
350 dead = eina_list_append(dead, c);
351 }
352 else if (num > 0)
353 {
354 server_data(s, c, buf, num);
355 }
356 }
357 else if (FD_ISSET(c->fd, &wset))
358 {
359 client_flush(c);
360 if (c->dead) dead = eina_list_append(dead, c);
361 }
362 }
363 if (FD_ISSET(s->ch[0].fd, &rset))
364 {
365 server_accept(s);
366 }
367 EINA_LIST_FREE(dead, c)
368 {
369 LKL(c->lock);
370 if (c->func) c->func(c->data, c);
371 s->clients = eina_list_remove(s->clients, c);
372 close(c->fd);
373 if (c->buf) free(c->buf);
374 if (c->inbuf) free(c->inbuf);
375 LKD(c->lock);
376 free(c);
377 }
378}
379
380#endif