forked from enlightenment/efl
emile: Added example program for base64 encoding and decoding.
Summary: Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com> Reviewers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D3554
This commit is contained in:
parent
63a410667a
commit
46fd6307b2
|
@ -5064,6 +5064,7 @@ src/examples/eldbus/Makefile
|
||||||
src/examples/ephysics/Makefile
|
src/examples/ephysics/Makefile
|
||||||
src/examples/edje/Makefile
|
src/examples/edje/Makefile
|
||||||
src/examples/emotion/Makefile
|
src/examples/emotion/Makefile
|
||||||
|
src/examples/emile/Makefile
|
||||||
src/examples/ethumb_client/Makefile
|
src/examples/ethumb_client/Makefile
|
||||||
src/examples/elua/Makefile
|
src/examples/elua/Makefile
|
||||||
src/examples/eolian_cxx/Makefile
|
src/examples/eolian_cxx/Makefile
|
||||||
|
|
|
@ -118,6 +118,7 @@ examples/eldbus \
|
||||||
examples/ephysics \
|
examples/ephysics \
|
||||||
examples/edje \
|
examples/edje \
|
||||||
examples/emotion \
|
examples/emotion \
|
||||||
|
examples/emile \
|
||||||
examples/elocation \
|
examples/elocation \
|
||||||
examples/ethumb_client
|
examples/ethumb_client
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
|
|
||||||
|
AM_CPPFLAGS = \
|
||||||
|
-I. \
|
||||||
|
-I$(top_srcdir)/src/lib/efl \
|
||||||
|
-I$(top_builddir)/src/lib/efl \
|
||||||
|
-I$(top_builddir)/src/lib/efl/interfaces \
|
||||||
|
-I$(top_srcdir)/src/lib/eina \
|
||||||
|
-I$(top_builddir)/src/lib/eina \
|
||||||
|
-I$(top_srcdir)/src/lib/emile \
|
||||||
|
-I$(top_builddir)/src/lib/emile
|
||||||
|
|
||||||
|
LDADD = $(top_builddir)/src/lib/eina/libeina.la @EMILE_LDFLAGS@
|
||||||
|
|
||||||
|
SRCS = \
|
||||||
|
emile_base64.c
|
||||||
|
|
||||||
|
EXTRA_PROGRAMS = \
|
||||||
|
emile_base64
|
||||||
|
|
||||||
|
emile_base64_CPPFLAGS = \
|
||||||
|
-I$(top_srcdir)/src/lib/efl \
|
||||||
|
-I$(top_srcdir)/src/lib/eina \
|
||||||
|
-I$(top_builddir)/src/lib/efl \
|
||||||
|
-I$(top_builddir)/src/lib/efl/interfaces \
|
||||||
|
-I$(top_builddir)/src/lib/eina \
|
||||||
|
-I$(top_srcdir)/src/lib/emile \
|
||||||
|
@EMILE_CFLAGS@
|
||||||
|
|
||||||
|
emile_base64_LDADD = \
|
||||||
|
$(top_builddir)/src/lib/eina/libeina.la \
|
||||||
|
$(top_builddir)/src/lib/emile/libemile.la \
|
||||||
|
@EMILE_LDFLAGS@
|
||||||
|
|
||||||
|
examples: $(EXTRA_PROGRAMS)
|
||||||
|
|
||||||
|
clean-local:
|
||||||
|
rm -f $(EXTRA_PROGRAMS)
|
||||||
|
|
||||||
|
install-examples:
|
||||||
|
$(MKDIR_P) $(datadir)/emile/examples
|
||||||
|
cd $(srcdir) && $(install_sh_DATA) -c $(SRCS) $(DATA_FILES) $(datadir)/emile/examples
|
||||||
|
|
||||||
|
uninstall-local:
|
||||||
|
for f in $(SRCS) $(DATA_FILES); do \
|
||||||
|
rm -f $(datadir)/emile/examples/$$f ; \
|
||||||
|
done
|
||||||
|
|
||||||
|
if ALWAYS_BUILD_EXAMPLES
|
||||||
|
noinst_PROGRAMS = $(EXTRA_PROGRAMS)
|
||||||
|
endif
|
|
@ -0,0 +1,14 @@
|
||||||
|
CC=gcc
|
||||||
|
COMMON_FLAGS=`pkg-config --libs --cflags eina, emile`
|
||||||
|
|
||||||
|
EXAMPLES= emile_base64
|
||||||
|
|
||||||
|
all: examples
|
||||||
|
examples: $(EXAMPLES)
|
||||||
|
|
||||||
|
$(EXAMPLES):
|
||||||
|
$(CC) -o $@ $@.c $(COMMON_FLAGS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@echo "Cleaning up built objects..."
|
||||||
|
@rm -Rf $(EXAMPLES)
|
|
@ -0,0 +1,29 @@
|
||||||
|
//Compile with:
|
||||||
|
//gcc -Wall -o emile_base64 emile_base64.c `pkg-config --cflags --libs eina emile`
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <Eina.h>
|
||||||
|
#include <Emile.h>
|
||||||
|
|
||||||
|
int main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Eina_Strbuf *b64;
|
||||||
|
Eina_Binbuf *decoded;
|
||||||
|
Eina_Binbuf *str;
|
||||||
|
|
||||||
|
eina_init();
|
||||||
|
|
||||||
|
str = eina_binbuf_new();
|
||||||
|
eina_binbuf_append_length(str, (unsigned char *)"Enlightenment", 13);
|
||||||
|
b64 = emile_base64_encode(str);
|
||||||
|
printf("%s\n", eina_strbuf_string_get(b64));
|
||||||
|
decoded = emile_base64_decode(b64);
|
||||||
|
printf("decoded string: %s\n", eina_binbuf_string_get(decoded));
|
||||||
|
eina_strbuf_free(b64);
|
||||||
|
eina_binbuf_free(decoded);
|
||||||
|
|
||||||
|
eina_binbuf_free(str);
|
||||||
|
eina_shutdown();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue