Now loading the UDP transport

This commit is contained in:
Pierre Pronchery 2012-10-18 01:29:08 +00:00
parent 3d8d705476
commit 440f65ec5c
3 changed files with 72 additions and 7 deletions

View File

@ -5,9 +5,9 @@ BINDIR = $(PREFIX)/bin
CC ?= cc CC ?= cc
CPPFLAGSF?= CPPFLAGSF?=
CPPFLAGS= -I ../include CPPFLAGS= -I ../include
CFLAGSF = -W CFLAGSF = -W `pkg-config --cflags libSystem`
CFLAGS = -Wall -g -O2 CFLAGS = -Wall -g -O2
LDFLAGSF= -lApp LDFLAGSF= `pkg-config --libs libSystem` -lApp
LDFLAGS = -L../src -Wl,-rpath,../src LDFLAGS = -L../src -Wl,-rpath,../src
RM ?= rm -f RM ?= rm -f
LN ?= ln -f LN ?= ln -f

View File

@ -1,8 +1,8 @@
targets=tests.log,udp targets=tests.log,udp
cppflags=-I ../include cppflags=-I ../include
cflags_force=-W cflags_force=-W `pkg-config --cflags libSystem`
cflags=-Wall -g -O2 cflags=-Wall -g -O2
ldflags_force=-lApp ldflags_force=`pkg-config --libs libSystem` -lApp
ldflags=-L../src -Wl,-rpath,../src ldflags=-L../src -Wl,-rpath,../src
dist=Makefile,tests.sh dist=Makefile,tests.sh

View File

@ -15,16 +15,68 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <System.h>
#include "App.h" #include "App.h"
/* private */ /* private */
/* prototypes */
static int _udp(char const * name);
static int _usage(void);
/* functions */ /* functions */
/* udp */ /* udp */
static int _udp(void) static int _udp(char const * name)
{ {
char * cwd;
Plugin * plugin;
AppTransportPluginDefinition * plugind;
AppTransportPlugin * server;
AppTransportPlugin * client;
/* load the transport plug-in */
if((cwd = getcwd(NULL, 0)) == NULL)
return error_set_print("udp", 2, "%s", strerror(errno));
/* XXX rather ugly but does the trick */
plugin = plugin_new(cwd, "../src", "transport", "udp");
free(cwd);
if(plugin == NULL)
return error_print("udp");
if((plugind = plugin_lookup(plugin, "transport")) == NULL)
{
plugin_delete(plugin);
return error_print("udp");
}
/* create a server and a client */
server = plugind->init(NULL, ATM_SERVER, name);
client = plugind->init(NULL, ATM_CLIENT, name);
if(server == NULL || client == NULL)
{
if(client != NULL)
plugind->destroy(client);
if(server != NULL)
plugind->destroy(server);
plugin_delete(plugin);
return error_print("udp");
}
/* FIXME really implement */ /* FIXME really implement */
return -1; plugin_delete(plugin);
return 0;
}
/* usage */
static int _usage(void)
{
fputs("Usage: udp name\n", stderr);
return 1;
} }
@ -33,5 +85,18 @@ static int _udp(void)
/* main */ /* main */
int main(int argc, char * argv[]) int main(int argc, char * argv[])
{ {
return (_udp() == 0) ? 0 : 2; char const * name = "127.0.0.1:4242";
int o;
while((o = getopt(argc, argv, "")) != -1)
switch(o)
{
default:
return _usage();
}
if(optind == argc - 1)
name = argv[optind];
else if(optind != argc)
return _usage();
return (_udp(name) == 0) ? 0 : 2;
} }