Added a template transport
This commit is contained in:
parent
15ebf43c9e
commit
20f1156396
1
Makefile
1
Makefile
|
@ -53,6 +53,7 @@ dist:
|
||||||
$(PACKAGE)-$(VERSION)/src/common.h \
|
$(PACKAGE)-$(VERSION)/src/common.h \
|
||||||
$(PACKAGE)-$(VERSION)/src/project.conf \
|
$(PACKAGE)-$(VERSION)/src/project.conf \
|
||||||
$(PACKAGE)-$(VERSION)/src/transport/tcp.c \
|
$(PACKAGE)-$(VERSION)/src/transport/tcp.c \
|
||||||
|
$(PACKAGE)-$(VERSION)/src/transport/template.c \
|
||||||
$(PACKAGE)-$(VERSION)/src/transport/udp.c \
|
$(PACKAGE)-$(VERSION)/src/transport/udp.c \
|
||||||
$(PACKAGE)-$(VERSION)/src/transport/Makefile \
|
$(PACKAGE)-$(VERSION)/src/transport/Makefile \
|
||||||
$(PACKAGE)-$(VERSION)/src/transport/project.conf \
|
$(PACKAGE)-$(VERSION)/src/transport/project.conf \
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
TARGETS = tcp.so udp.so
|
TARGETS = tcp.so template.so udp.so
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
DESTDIR =
|
DESTDIR =
|
||||||
LIBDIR = $(PREFIX)/lib
|
LIBDIR = $(PREFIX)/lib
|
||||||
|
@ -25,6 +25,13 @@ tcp_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||||
tcp.so: $(tcp_OBJS)
|
tcp.so: $(tcp_OBJS)
|
||||||
$(CCSHARED) -o tcp.so $(tcp_OBJS) $(tcp_LDFLAGS)
|
$(CCSHARED) -o tcp.so $(tcp_OBJS) $(tcp_LDFLAGS)
|
||||||
|
|
||||||
|
template_OBJS = template.o
|
||||||
|
template_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||||
|
template_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||||
|
|
||||||
|
template.so: $(template_OBJS)
|
||||||
|
$(CCSHARED) -o template.so $(template_OBJS) $(template_LDFLAGS)
|
||||||
|
|
||||||
udp_OBJS = udp.o
|
udp_OBJS = udp.o
|
||||||
udp_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
udp_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||||
udp_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
udp_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||||
|
@ -35,11 +42,14 @@ udp.so: $(udp_OBJS)
|
||||||
tcp.o: tcp.c
|
tcp.o: tcp.c
|
||||||
$(CC) $(tcp_CFLAGS) -c tcp.c
|
$(CC) $(tcp_CFLAGS) -c tcp.c
|
||||||
|
|
||||||
|
template.o: template.c
|
||||||
|
$(CC) $(template_CFLAGS) -c template.c
|
||||||
|
|
||||||
udp.o: udp.c
|
udp.o: udp.c
|
||||||
$(CC) $(udp_CFLAGS) -c udp.c
|
$(CC) $(udp_CFLAGS) -c udp.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) -- $(tcp_OBJS) $(udp_OBJS)
|
$(RM) -- $(tcp_OBJS) $(template_OBJS) $(udp_OBJS)
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
$(RM) -- $(TARGETS)
|
$(RM) -- $(TARGETS)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
targets=tcp,udp
|
targets=tcp,template,udp
|
||||||
cppflags_force=-I ../../include
|
cppflags_force=-I ../../include
|
||||||
cppflags=
|
cppflags=
|
||||||
cflags_force=-W -fPIC
|
cflags_force=-W -fPIC
|
||||||
|
@ -10,6 +10,10 @@ type=plugin
|
||||||
sources=tcp.c
|
sources=tcp.c
|
||||||
install=$(LIBDIR)/App/transport
|
install=$(LIBDIR)/App/transport
|
||||||
|
|
||||||
|
[template]
|
||||||
|
type=plugin
|
||||||
|
sources=template.c
|
||||||
|
|
||||||
[udp]
|
[udp]
|
||||||
type=plugin
|
type=plugin
|
||||||
sources=udp.c
|
sources=udp.c
|
||||||
|
|
106
src/transport/template.c
Normal file
106
src/transport/template.c
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
/* $Id$ */
|
||||||
|
/* Copyright (c) 2012 Pierre Pronchery <khorben@defora.org> */
|
||||||
|
/* 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 <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <System.h>
|
||||||
|
#include "App/apptransport.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Template */
|
||||||
|
/* private */
|
||||||
|
/* types */
|
||||||
|
typedef struct _AppTransportPlugin Template;
|
||||||
|
|
||||||
|
struct _AppTransportPlugin
|
||||||
|
{
|
||||||
|
AppTransportPluginHelper * helper;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* protected */
|
||||||
|
/* prototypes */
|
||||||
|
/* plug-in */
|
||||||
|
static Template * _template_init(AppTransportPluginHelper * helper,
|
||||||
|
AppTransportMode mode, char const * name);
|
||||||
|
static void _template_destroy(Template * template);
|
||||||
|
|
||||||
|
|
||||||
|
/* public */
|
||||||
|
/* constants */
|
||||||
|
/* plug-in */
|
||||||
|
AppTransportPluginDefinition transport =
|
||||||
|
{
|
||||||
|
"Template",
|
||||||
|
NULL,
|
||||||
|
_template_init,
|
||||||
|
_template_destroy,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* protected */
|
||||||
|
/* functions */
|
||||||
|
/* plug-in */
|
||||||
|
/* template_init */
|
||||||
|
static int _init_client(Template * template, char const * name);
|
||||||
|
static int _init_server(Template * template, char const * name);
|
||||||
|
|
||||||
|
static Template * _template_init(AppTransportPluginHelper * helper,
|
||||||
|
AppTransportMode mode, char const * name)
|
||||||
|
{
|
||||||
|
Template * template;
|
||||||
|
int res = -1;
|
||||||
|
|
||||||
|
if((template = object_new(sizeof(*template))) == NULL)
|
||||||
|
return NULL;
|
||||||
|
template->helper = helper;
|
||||||
|
switch(mode)
|
||||||
|
{
|
||||||
|
case ATM_CLIENT:
|
||||||
|
res = _init_client(template, name);
|
||||||
|
break;
|
||||||
|
case ATM_SERVER:
|
||||||
|
res = _init_server(template, name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* check for errors */
|
||||||
|
if(res != 0)
|
||||||
|
{
|
||||||
|
_template_destroy(template);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _init_client(Template * template, char const * name)
|
||||||
|
{
|
||||||
|
/* FIXME really implement */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _init_server(Template * template, char const * name)
|
||||||
|
{
|
||||||
|
/* FIXME really implement */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* template_destroy */
|
||||||
|
static void _template_destroy(Template * template)
|
||||||
|
{
|
||||||
|
/* FIXME really implement */
|
||||||
|
object_delete(template);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user