From ca4e92eb8e4e512725180c4dfc19d4eb75917589 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Fri, 28 Sep 2012 00:25:57 +0000 Subject: [PATCH] Working on the modularization of libApp --- Makefile | 9 +++- include/App.h | 3 ++ include/App/app.h | 26 +++++++++++ include/App/appclient.h | 6 +-- include/App/appmessage.h | 45 +++++++++++++++++++ include/App/appserver.h | 6 +-- include/App/apptransport.h | 77 ++++++++++++++++++++++++++++++++ project.conf | 2 +- src/Makefile | 14 ++++-- src/appmessage.c | 91 ++++++++++++++++++++++++++++++++++++++ src/apptransport.c | 83 ++++++++++++++++++++++++++++++++++ src/apptransport.h | 31 +++++++++++++ src/project.conf | 18 +++++--- src/transport/Makefile | 61 +++++++++++++++++++++++++ src/transport/openssl.c | 78 ++++++++++++++++++++++++++++++++ src/transport/project.conf | 16 +++++++ src/transport/tcp.c | 78 ++++++++++++++++++++++++++++++++ src/transport/udp.c | 78 ++++++++++++++++++++++++++++++++ 18 files changed, 703 insertions(+), 19 deletions(-) create mode 100644 include/App/app.h create mode 100644 include/App/appmessage.h create mode 100644 include/App/apptransport.h create mode 100644 src/appmessage.c create mode 100644 src/apptransport.c create mode 100644 src/apptransport.h create mode 100644 src/transport/Makefile create mode 100644 src/transport/openssl.c create mode 100644 src/transport/project.conf create mode 100644 src/transport/tcp.c create mode 100644 src/transport/udp.c diff --git a/Makefile b/Makefile index adb4af9..706dbd8 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PACKAGE = libApp VERSION = 0.1.5 -SUBDIRS = data doc include src tools +SUBDIRS = data doc include src src/transport tools RM ?= rm -f LN ?= ln -f TAR ?= tar -czvf @@ -40,12 +40,19 @@ dist: $(PACKAGE)-$(VERSION)/include/App/project.conf \ $(PACKAGE)-$(VERSION)/src/appclient.c \ $(PACKAGE)-$(VERSION)/src/appinterface.c \ + $(PACKAGE)-$(VERSION)/src/appmessage.c \ $(PACKAGE)-$(VERSION)/src/appserver.c \ + $(PACKAGE)-$(VERSION)/src/apptransport.c \ $(PACKAGE)-$(VERSION)/src/common.c \ $(PACKAGE)-$(VERSION)/src/Makefile \ $(PACKAGE)-$(VERSION)/src/appinterface.h \ + $(PACKAGE)-$(VERSION)/src/apptransport.h \ $(PACKAGE)-$(VERSION)/src/common.h \ $(PACKAGE)-$(VERSION)/src/project.conf \ + $(PACKAGE)-$(VERSION)/src/transport/openssl.c \ + $(PACKAGE)-$(VERSION)/src/transport/tcp.c \ + $(PACKAGE)-$(VERSION)/src/transport/udp.c \ + $(PACKAGE)-$(VERSION)/src/transport/project.conf \ $(PACKAGE)-$(VERSION)/tools/appbroker.c \ $(PACKAGE)-$(VERSION)/tools/appclient.c \ $(PACKAGE)-$(VERSION)/tools/Makefile \ diff --git a/include/App.h b/include/App.h index 1d45767..12043dd 100644 --- a/include/App.h +++ b/include/App.h @@ -19,7 +19,10 @@ # define LIBAPP_APP_H +# include "App/app.h" # include "App/appclient.h" # include "App/appserver.h" +# include "App/appmessage.h" +# include "App/apptransport.h" #endif /* !LIBAPP_APP_H */ diff --git a/include/App/app.h b/include/App/app.h new file mode 100644 index 0000000..16334d8 --- /dev/null +++ b/include/App/app.h @@ -0,0 +1,26 @@ +/* $Id$ */ +/* Copyright (c) 2012 Pierre Pronchery */ +/* This file is part of DeforaOS System libApp */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + + +#ifndef LIBAPP_APP_APP_H +# define LIBAPP_APP_APP_H + + +/* App */ +/* types */ +typedef struct _AppMessage AppMessage; + +#endif /* !LIBAPP_APP_APP_H */ diff --git a/include/App/appclient.h b/include/App/appclient.h index f9fb5cd..c79a93a 100644 --- a/include/App/appclient.h +++ b/include/App/appclient.h @@ -15,8 +15,8 @@ -#ifndef LIBAPP_APPCLIENT_H -# define LIBAPP_APPCLIENT_H +#ifndef LIBAPP_APP_APPCLIENT_H +# define LIBAPP_APP_APPCLIENT_H # include # include @@ -36,4 +36,4 @@ void appclient_delete(AppClient * appclient); int appclient_call(AppClient * appclient, int32_t * ret, char const * function, ...); -#endif /* !LIBAPP_APPCLIENT_H */ +#endif /* !LIBAPP_APP_APPCLIENT_H */ diff --git a/include/App/appmessage.h b/include/App/appmessage.h new file mode 100644 index 0000000..1f49348 --- /dev/null +++ b/include/App/appmessage.h @@ -0,0 +1,45 @@ +/* $Id$ */ +/* Copyright (c) 2012 Pierre Pronchery */ +/* This file is part of DeforaOS System libApp */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + + +#ifndef LIBAPP_APP_APPMESSAGE_H +# define LIBAPP_APP_APPMESSAGE_H + +# include +# include "app.h" + + +/* AppMessage */ +/* type */ +typedef enum _AppMessageType +{ + AMT_CALL = 0 +} AppMessageType; + + +/* functions */ +AppMessage * appmessage_new_call(char const * method, ...); +AppMessage * appmessage_new_deserialize(Buffer * buffer); +void appmessage_delete(AppMessage * appmessage); + +/* accessors */ +String const * appmessage_get_method(AppMessage * message); +AppMessageType appmessage_get_type(AppMessage * message); + +/* useful */ +int appmessage_serialize(AppMessage * message, Buffer * buffer); + +#endif /* !LIBAPP_APP_APPMESSAGE_H */ diff --git a/include/App/appserver.h b/include/App/appserver.h index af79259..2ffd33b 100644 --- a/include/App/appserver.h +++ b/include/App/appserver.h @@ -15,8 +15,8 @@ -#ifndef LIBAPP_APPSERVER_H -# define LIBAPP_APPSERVER_H +#ifndef LIBAPP_APP_APPSERVER_H +# define LIBAPP_APP_APPSERVER_H # include @@ -46,4 +46,4 @@ void * appserver_get_client_id(AppServer * appserver); /* useful */ int appserver_loop(AppServer * appserver); -#endif /* !LIBAPP_APPSERVER_H */ +#endif /* !LIBAPP_APP_APPSERVER_H */ diff --git a/include/App/apptransport.h b/include/App/apptransport.h new file mode 100644 index 0000000..d86875c --- /dev/null +++ b/include/App/apptransport.h @@ -0,0 +1,77 @@ +/* $Id$ */ +/* Copyright (c) 2012 Pierre Pronchery */ +/* This file is part of DeforaOS System libApp */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + + +#ifndef LIBAPP_APP_APPTRANSPORT_H +# define LIBAPP_APP_APPTRANSPORT_H + +# include +# include "app.h" + + +/* AppTransport */ +/* types */ +typedef struct _AppTransport AppTransport; + +typedef struct _AppTransportClient * AppTransportClient; + +typedef enum _AppTransportMode +{ + ATM_SERVER = 0, + ATM_CLIENT +} AppTransportMode; + +typedef enum _AppTransportStatus +{ + ATS_INIT = 0, + ATS_CONNECTED, + ATS_INFO, + ATS_WARNING, + ATS_ERROR, + ATS_ERROR_FATAL +} AppTransportStatus; + +typedef struct _AppTransportPlugin AppTransportPlugin; + +typedef struct _AppTransportPluginDefinition AppTransportPluginDefinition; + +typedef struct _AppTransportPluginHelper +{ + AppTransport * apptransport; + Event * event; + /* callbacks */ + int (*status)(AppTransport * transport, AppTransportStatus status, + unsigned int code, char const * message); + /* clients */ + AppTransportClient * (*client_new)(AppTransport * transport); + void (*client_delete)(AppTransport * transport, + AppTransportClient * client); + int (*client_receive)(AppTransport * transport, + AppTransportClient * client, AppMessage * message); +} AppTransportPluginHelper; + +struct _AppTransportPluginDefinition +{ + char const * name; + char const * description; + AppTransportPlugin * (*init)(AppTransportPluginHelper * helper, + AppTransportMode mode, char const * name); + void (*destroy)(AppTransportPlugin * transport); + int (*send)(AppTransportPlugin * transport, AppMessage * message, + int acknowledge); +}; + +#endif /* !LIBAPP_APP_APPTRANSPORT_H */ diff --git a/project.conf b/project.conf index 5435d97..6bfd8f3 100644 --- a/project.conf +++ b/project.conf @@ -3,4 +3,4 @@ version=0.1.5 config=h,sh dist=Makefile,COPYING,config.h,config.sh -subdirs=data,doc,include,src,tools +subdirs=data,doc,include,src,src/transport,tools diff --git a/src/Makefile b/src/Makefile index 7412ba9..5204aa0 100644 --- a/src/Makefile +++ b/src/Makefile @@ -4,11 +4,11 @@ DESTDIR = LIBDIR = $(PREFIX)/lib CC ?= cc CPPFLAGSF= -I ../include -CPPFLAGS= -I $(PREFIX)/include -D WITH_SSL +CPPFLAGS= -I $(PREFIX)/include CFLAGSF = -W -fPIC `pkg-config --cflags libSystem` CFLAGS = -Wall -g -O2 -pedantic LDFLAGSF= `pkg-config --libs libSystem` -LDFLAGS = -lssl +LDFLAGS = AR ?= ar RANLIB ?= ranlib CCSHARED?= $(CC) -shared @@ -20,9 +20,9 @@ INSTALL ?= install all: $(TARGETS) -libApp_OBJS = appclient.o appinterface.o appserver.o common.o +libApp_OBJS = appclient.o appinterface.o appmessage.o appserver.o apptransport.o common.o libApp_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) -libApp_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) `pkg-config --libs openssl` -lssl +libApp_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) libApp.a: $(libApp_OBJS) $(AR) -rc libApp.a $(libApp_OBJS) @@ -39,9 +39,15 @@ appclient.o: appclient.c appinterface.h ../include/App/appclient.h common.h appinterface.o: appinterface.c ../include/App/appserver.h ../config.h $(CC) $(libApp_CFLAGS) -c appinterface.c +appmessage.o: appmessage.c + $(CC) $(libApp_CFLAGS) -c appmessage.c + appserver.o: appserver.c appinterface.h ../include/App/appserver.h ../config.h $(CC) $(libApp_CFLAGS) -c appserver.c +apptransport.o: apptransport.c apptransport.h ../include/App/apptransport.h ../config.h + $(CC) $(libApp_CFLAGS) -c apptransport.c + common.o: common.c $(CC) $(libApp_CFLAGS) -c common.c diff --git a/src/appmessage.c b/src/appmessage.c new file mode 100644 index 0000000..ddbc3d7 --- /dev/null +++ b/src/appmessage.c @@ -0,0 +1,91 @@ +/* $Id$ */ +/* Copyright (c) 2012 Pierre Pronchery */ +/* This file is part of DeforaOS System libApp */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + + +#include +#include +#include "App/appmessage.h" + + +/* AppMessage */ +/* private */ +/* types */ +struct _AppMessage +{ + AppMessageType type; + + union + { + struct + { + char * method; + Variable * var; + size_t var_cnt; + } call; + } t; +}; + + +/* private */ +/* prototypes */ + + +/* public */ +/* functions */ +/* appmessage_new_call */ +AppMessage * appmessage_new_call(char const * method, ...) +{ + AppMessage * message; + va_list ap; + Variable * v; + + if((message = object_new(sizeof(*message))) == NULL) + return NULL; + message->type = AMT_CALL; + message->t.call.method = string_new(method); + /* copy the arguments */ + va_start(ap, method); + while((v = va_arg(ap, Variable *)) != NULL) + ; + va_end(ap); + /* check for errors */ + if(message->t.call.method == NULL) + { + appmessage_delete(message); + return NULL; + } + return message; +} + + +/* appmessage_delete */ +static void _delete_call(AppMessage * message); + +void appmessage_delete(AppMessage * message) +{ + switch(message->type) + { + case AMT_CALL: + _delete_call(message); + break; + } + object_delete(message); +} + +static void _delete_call(AppMessage * message) +{ + string_delete(message->t.call.method); +} diff --git a/src/apptransport.c b/src/apptransport.c new file mode 100644 index 0000000..b5c1855 --- /dev/null +++ b/src/apptransport.c @@ -0,0 +1,83 @@ +/* $Id$ */ +/* Copyright (c) 2012 Pierre Pronchery */ +/* This file is part of DeforaOS System libApp */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + + +#include +#include +#include "apptransport.h" +#include "../config.h" + +#ifndef PREFIX +# define PREFIX "/usr/local" +#endif +#ifndef LIBDIR +# define LIBDIR PREFIX "/lib" +#endif + + +/* AppTransport */ +/* private */ +/* types */ +struct _AppTransport +{ + AppTransportPluginHelper helper; + Plugin * plugin; + AppTransportPlugin * tplugin; + AppTransportPluginDefinition * definition; +}; + + +/* protected */ +/* functions */ +/* apptransport_new */ +AppTransport * apptransport_new(AppTransportMode mode, char const * plugin, + char const * name) +{ + AppTransport * transport; + + /* allocate the transport */ + if((transport = object_new(sizeof(*transport))) == NULL) + return NULL; + memset(transport, 0, sizeof(*transport)); + /* initialize the helper */ + /* FIXME implement */ + /* load the transport plug-in */ + if((transport->plugin = plugin_new(LIBDIR, "App", "transport", plugin)) + == NULL + || (transport->definition = plugin_lookup( + transport->plugin, "transport")) == NULL + || transport->definition->init == NULL + || transport->definition->destroy == NULL + || (transport->tplugin = transport->definition->init( + &transport->helper, mode, name)) + == NULL) + { + apptransport_delete(transport); + return NULL; + } + return transport; +} + + +/* apptransport_delete */ +void apptransport_delete(AppTransport * transport) +{ + if(transport->tplugin != NULL) + transport->definition->destroy(transport->tplugin); + if(transport->plugin != NULL) + plugin_delete(transport->plugin); + object_delete(transport); +} diff --git a/src/apptransport.h b/src/apptransport.h new file mode 100644 index 0000000..8cbcce2 --- /dev/null +++ b/src/apptransport.h @@ -0,0 +1,31 @@ +/* $Id$ */ +/* Copyright (c) 2012 Pierre Pronchery */ +/* This file is part of DeforaOS System libApp */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + + +#ifndef LIBAPP_APPTRANSPORT_H +# define LIBAPP_APPTRANSPORT_H + +#include "App/apptransport.h" + + +/* AppTransport */ +/* protected */ +/* functions */ +AppTransport * apptransport_new(AppTransportMode mode, char const * plugin, + char const * name); +void apptransport_delete(AppTransport * transport); + +#endif /* !LIBAPP_APPTRANSPORT_H */ diff --git a/src/project.conf b/src/project.conf index 6c2bc32..0e757d1 100644 --- a/src/project.conf +++ b/src/project.conf @@ -1,18 +1,16 @@ targets=libApp cppflags_force=-I ../include -cppflags=-I $(PREFIX)/include -D WITH_SSL -#cppflags=-I $(PREFIX)/include +cppflags=-I $(PREFIX)/include cflags_force=-W -fPIC `pkg-config --cflags libSystem` cflags=-Wall -g -O2 -pedantic ldflags_force=`pkg-config --libs libSystem` -ldflags=-lssl -dist=Makefile,appinterface.h,common.h +ldflags= +dist=Makefile,appinterface.h,apptransport.h,common.h [libApp] type=library -sources=appclient.c,appinterface.c,appserver.c,common.c -ldflags=`pkg-config --libs openssl` -lssl -lsocket -lws2_32 -#ldflags=-lsocket -lws2_32 +sources=appclient.c,appinterface.c,appmessage.c,appserver.c,apptransport.c,common.c +ldflags=-lsocket -lws2_32 install=$(LIBDIR) [appclient.c] @@ -21,5 +19,11 @@ depends=appinterface.h,../include/App/appclient.h,common.h [appinterface.c] depends=../include/App/appserver.h,../config.h +[apptransport.c] +depends=../include/App/appmessage.h,../config.h + [appserver.c] depends=appinterface.h,../include/App/appserver.h,../config.h + +[apptransport.c] +depends=apptransport.h,../include/App/apptransport.h,../config.h diff --git a/src/transport/Makefile b/src/transport/Makefile new file mode 100644 index 0000000..c3405e7 --- /dev/null +++ b/src/transport/Makefile @@ -0,0 +1,61 @@ +TARGETS = openssl.so tcp.so udp.so +PREFIX = /usr/local +DESTDIR = +LIBDIR = $(PREFIX)/lib +CC ?= cc +CPPFLAGSF?= +CPPFLAGS= -I ../../include +CFLAGSF = -W +CFLAGS = -Wall -g -O2 -pedantic -fPIC +AR ?= ar +RANLIB ?= ranlib +CCSHARED?= $(CC) -shared +RM ?= rm -f +LN ?= ln -f +MKDIR ?= mkdir -p +INSTALL ?= install + + +all: $(TARGETS) + +openssl_OBJS = openssl.o +openssl_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) +openssl_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) + +openssl.so: $(openssl_OBJS) + $(CCSHARED) -o openssl.so $(openssl_OBJS) $(openssl_LDFLAGS) + +tcp_OBJS = tcp.o +tcp_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) +tcp_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) + +tcp.so: $(tcp_OBJS) + $(CCSHARED) -o tcp.so $(tcp_OBJS) $(tcp_LDFLAGS) + +udp_OBJS = udp.o +udp_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) +udp_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) + +udp.so: $(udp_OBJS) + $(CCSHARED) -o udp.so $(udp_OBJS) $(udp_LDFLAGS) + +openssl.o: openssl.c + $(CC) $(openssl_CFLAGS) -c openssl.c + +tcp.o: tcp.c + $(CC) $(tcp_CFLAGS) -c tcp.c + +udp.o: udp.c + $(CC) $(udp_CFLAGS) -c udp.c + +clean: + $(RM) -- $(openssl_OBJS) $(tcp_OBJS) $(udp_OBJS) + +distclean: clean + $(RM) -- $(TARGETS) + +install: $(TARGETS) + +uninstall: + +.PHONY: all clean distclean install uninstall diff --git a/src/transport/openssl.c b/src/transport/openssl.c new file mode 100644 index 0000000..f350b40 --- /dev/null +++ b/src/transport/openssl.c @@ -0,0 +1,78 @@ +/* $Id$ */ +/* Copyright (c) 2012 Pierre Pronchery */ +/* This file is part of DeforaOS System libApp */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + + +#include +#include "App/apptransport.h" + + +/* OpenSSL */ +/* private */ +/* types */ +typedef struct _AppTransportPlugin OpenSSL; + +struct _AppTransportPlugin +{ + AppTransportPluginHelper * helper; + int fd; +}; + + +/* protected */ +/* prototypes */ +/* plug-in */ +static OpenSSL * _openssl_init(AppTransportPluginHelper * helper, + AppTransportMode mode, char const * name); +static void _openssl_destroy(OpenSSL * openssl); + + +/* public */ +/* constants */ +/* plug-in */ +AppTransportPluginDefinition definition = +{ + "OpenSSL", + NULL, + _openssl_init, + _openssl_destroy, + NULL +}; + + +/* protected */ +/* functions */ +/* plug-in */ +/* openssl_init */ +static OpenSSL * _openssl_init(AppTransportPluginHelper * helper, + AppTransportMode mode, char const * name) +{ + OpenSSL * openssl; + + if((openssl = object_new(sizeof(*openssl))) == NULL) + return NULL; + openssl->helper = helper; + openssl->fd = -1; + /* FIXME really implement */ + return openssl; +} + + +/* openssl_destroy */ +static void _openssl_destroy(OpenSSL * openssl) +{ + /* FIXME really implement */ + object_delete(openssl); +} diff --git a/src/transport/project.conf b/src/transport/project.conf new file mode 100644 index 0000000..942a1d4 --- /dev/null +++ b/src/transport/project.conf @@ -0,0 +1,16 @@ +targets=openssl,tcp,udp +cppflags=-I ../../include +cflags_force=-W +cflags=-Wall -g -O2 -pedantic -fPIC + +[openssl] +type=plugin +sources=openssl.c + +[tcp] +type=plugin +sources=tcp.c + +[udp] +type=plugin +sources=udp.c diff --git a/src/transport/tcp.c b/src/transport/tcp.c new file mode 100644 index 0000000..d40ef43 --- /dev/null +++ b/src/transport/tcp.c @@ -0,0 +1,78 @@ +/* $Id$ */ +/* Copyright (c) 2012 Pierre Pronchery */ +/* This file is part of DeforaOS System libApp */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + + +#include +#include "App/apptransport.h" + + +/* TCP */ +/* private */ +/* types */ +typedef struct _AppTransportPlugin TCP; + +struct _AppTransportPlugin +{ + AppTransportPluginHelper * helper; + int fd; +}; + + +/* protected */ +/* prototypes */ +/* plug-in */ +static TCP * _tcp_init(AppTransportPluginHelper * helper, + AppTransportMode mode, char const * name); +static void _tcp_destroy(TCP * tcp); + + +/* public */ +/* constants */ +/* plug-in */ +AppTransportPluginDefinition definition = +{ + "TCP", + NULL, + _tcp_init, + _tcp_destroy, + NULL +}; + + +/* protected */ +/* functions */ +/* plug-in */ +/* tcp_init */ +static TCP * _tcp_init(AppTransportPluginHelper * helper, + AppTransportMode mode, char const * name) +{ + TCP * tcp; + + if((tcp = object_new(sizeof(*tcp))) == NULL) + return NULL; + tcp->helper = helper; + tcp->fd = -1; + /* FIXME really implement */ + return tcp; +} + + +/* tcp_destroy */ +static void _tcp_destroy(TCP * tcp) +{ + /* FIXME really implement */ + object_delete(tcp); +} diff --git a/src/transport/udp.c b/src/transport/udp.c new file mode 100644 index 0000000..d7924da --- /dev/null +++ b/src/transport/udp.c @@ -0,0 +1,78 @@ +/* $Id$ */ +/* Copyright (c) 2012 Pierre Pronchery */ +/* This file is part of DeforaOS System libApp */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + + +#include +#include "App/apptransport.h" + + +/* UDP */ +/* private */ +/* types */ +typedef struct _AppTransportPlugin UDP; + +struct _AppTransportPlugin +{ + AppTransportPluginHelper * helper; + int fd; +}; + + +/* protected */ +/* prototypes */ +/* plug-in */ +static UDP * _udp_init(AppTransportPluginHelper * helper, + AppTransportMode mode, char const * name); +static void _udp_destroy(UDP * udp); + + +/* public */ +/* constants */ +/* plug-in */ +AppTransportPluginDefinition definition = +{ + "UDP", + NULL, + _udp_init, + _udp_destroy, + NULL +}; + + +/* protected */ +/* functions */ +/* plug-in */ +/* udp_init */ +static UDP * _udp_init(AppTransportPluginHelper * helper, + AppTransportMode mode, char const * name) +{ + UDP * udp; + + if((udp = object_new(sizeof(*udp))) == NULL) + return NULL; + udp->helper = helper; + udp->fd = -1; + /* FIXME really implement */ + return udp; +} + + +/* udp_destroy */ +static void _udp_destroy(UDP * udp) +{ + /* FIXME really implement */ + object_delete(udp); +}