From 23b25315f20433e6f633951f48cd9a555483f6d0 Mon Sep 17 00:00:00 2001 From: Marcel Poul Date: Tue, 13 Dec 2011 10:58:20 +0000 Subject: [PATCH] flex & bison stuff; import of hex2num routine --- emi.canl.canl-c/Makefile | 33 +++++++++++++++++++-------------- emi.canl.canl-c/src/proxy/data.c | 17 +++++++++++++++++ 2 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 emi.canl.canl-c/src/proxy/data.c diff --git a/emi.canl.canl-c/Makefile b/emi.canl.canl-c/Makefile index 1601204..f9b8713 100644 --- a/emi.canl.canl-c/Makefile +++ b/emi.canl.canl-c/Makefile @@ -7,7 +7,7 @@ libdir=lib -include Makefile.inc -include ${top_srcdir}/project/version.properties -VPATH=${top_srcdir}/src +VPATH=${top_srcdir}/src/:${top_srcdir}/src/proxy/ LIBCARES_LIBS?=-lcares LIBSSL_LIBS?=-lssl @@ -35,6 +35,9 @@ SRC_SER=canl_sample_server.c HEAD_SER=canl.h OBJ_SER=canl_sample_server.lo +YACC=bison -y +CFLAGS=-Wall -fPIC -I${top_srcdir}/src/proxy -I. + # In order to use libtool versioning correcty, we must have: # # current = major + minor + offset @@ -51,23 +54,25 @@ major:=${shell \ all: libcanl.la server client -libcanl.la: canl.lo canl_err.lo canl_dns.lo canl_ssl.lo canl_cert.lo canl_err_desc.lo +libcanl.la: canl.lo canl_err.lo canl_dns.lo canl_ssl.lo canl_cert.lo signing_policy.lo doio.lo evaluate.lo list.lo normalize.lo proxycertinfo.lo scutils.lo sslutils.lo namespaces.lo data.lo lex.signing.lo lex.namespaces.lo ${LINK} -rpath ${stagedir}${prefix}/${libdir} ${version_info} $+ ${LFLAGS_LIB} -o $@ -canl.lo: canl.c ${HEAD_CANL} - ${COMPILE} -c ${top_srcdir}/src/canl.c ${CFLAGS_LIB} -o $@ - -canl_dns.lo: canl_dns.c ${HEAD_CANL} - ${COMPILE} -c ${top_srcdir}/src/canl_dns.c ${CFLAGS_LIB} -o $@ +%.lo: %.y + ${YACC} -d ${YFLAGS} $< + mv y.tab.c $*.c + mv y.tab.h $*.h + ${COMPILE} -c ${CFLAGS_LIB} $*.c + flex -b -f -d ${top_srcdir}/src/proxy/namespaces.l + flex -b -f -d ${top_srcdir}/src/proxy/signing_policy.l -canl_err.lo: canl_err.c ${HEAD_CANL} - ${COMPILE} -c ${top_srcdir}/src/canl_err.c ${CFLAGS_LIB} -o $@ +%.lo: %.c ${HEAD_CANL} + ${COMPILE} -c $< ${CFLAGS_LIB} -o $@ -canl_ssl.lo: canl_ssl.c ${HEAD_CANL} - ${COMPILE} -c ${top_srcdir}/src/canl_ssl.c ${CFLAGS_LIB} -o $@ +lex.signing.lo: lex.signing.c + ${COMPILE} -c $< ${CFLAGS_LIB} -o $@ -canl_cert.lo: canl_cert.c ${HEAD_CANL} - ${COMPILE} -c ${top_srcdir}/src/canl_cert.c ${CFLAGS_LIB} -o $@ +lex.namespaces.lo: lex.namespaces.c + ${COMPILE} -c $< ${CFLAGS_LIB} -o $@ client: ${OBJ_CLI} ${LINK} $< ${LFLAGS_CLI} -o $@ @@ -103,4 +108,4 @@ stage: all $(MAKE) install PREFIX=${stagedir} clean: - rm -rfv *.o *.lo libcanl.la .libs client server canl_err.h canl_err_desc.c + rm -rfv *.o *.lo libcanl.la .libs client server signing_policy.c ${top_srcdir}/*.c ${top_srcdir}/*.h diff --git a/emi.canl.canl-c/src/proxy/data.c b/emi.canl.canl-c/src/proxy/data.c new file mode 100644 index 0000000..f0c0113 --- /dev/null +++ b/emi.canl.canl-c/src/proxy/data.c @@ -0,0 +1,17 @@ +/* XXX from common/data.cc */ + +#include + +int hex2num(char c) +{ + if (isdigit(c)) + return c - '0'; + else { + char d = tolower(c); + + if (d >= 'a' && d <= 'f') + return d - 'a' + 10; + + return 0; + } +} -- 1.8.2.3