Renamed the broker tool "AppBroker"
This commit is contained in:
parent
69586d44ae
commit
c8f3a396ce
2
Makefile
2
Makefile
|
@ -58,7 +58,7 @@ dist:
|
||||||
$(PACKAGE)-$(VERSION)/src/appinterface.h \
|
$(PACKAGE)-$(VERSION)/src/appinterface.h \
|
||||||
$(PACKAGE)-$(VERSION)/src/token.h \
|
$(PACKAGE)-$(VERSION)/src/token.h \
|
||||||
$(PACKAGE)-$(VERSION)/src/project.conf \
|
$(PACKAGE)-$(VERSION)/src/project.conf \
|
||||||
$(PACKAGE)-$(VERSION)/tools/broker.c \
|
$(PACKAGE)-$(VERSION)/tools/appbroker.c \
|
||||||
$(PACKAGE)-$(VERSION)/tools/Makefile \
|
$(PACKAGE)-$(VERSION)/tools/Makefile \
|
||||||
$(PACKAGE)-$(VERSION)/tools/README \
|
$(PACKAGE)-$(VERSION)/tools/README \
|
||||||
$(PACKAGE)-$(VERSION)/tools/project.conf \
|
$(PACKAGE)-$(VERSION)/tools/project.conf \
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
TARGETS = broker
|
TARGETS = AppBroker
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
DESTDIR =
|
DESTDIR =
|
||||||
BINDIR = $(PREFIX)/bin
|
BINDIR = $(PREFIX)/bin
|
||||||
|
@ -17,18 +17,18 @@ INSTALL = install
|
||||||
|
|
||||||
all: $(TARGETS)
|
all: $(TARGETS)
|
||||||
|
|
||||||
broker_OBJS = broker.o
|
AppBroker_OBJS = appbroker.o
|
||||||
broker_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
AppBroker_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||||
broker_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
AppBroker_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||||
|
|
||||||
broker: $(broker_OBJS)
|
AppBroker: $(AppBroker_OBJS)
|
||||||
$(CC) -o broker $(broker_OBJS) $(broker_LDFLAGS)
|
$(CC) -o AppBroker $(AppBroker_OBJS) $(AppBroker_LDFLAGS)
|
||||||
|
|
||||||
broker.o: broker.c
|
appbroker.o: appbroker.c
|
||||||
$(CC) $(broker_CFLAGS) -c broker.c
|
$(CC) $(AppBroker_CFLAGS) -c appbroker.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(broker_OBJS)
|
$(RM) $(AppBroker_OBJS)
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
$(RM) $(TARGETS)
|
$(RM) $(TARGETS)
|
||||||
|
|
|
@ -21,36 +21,39 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <System.h>
|
#include <System.h>
|
||||||
|
|
||||||
#define PACKAGE "broker"
|
#define APPBROKER_PROGNAME "AppBroker"
|
||||||
|
|
||||||
|
|
||||||
/* broker */
|
/* AppBroker */
|
||||||
typedef struct _BrokerData
|
/* private */
|
||||||
|
/* types */
|
||||||
|
typedef struct _AppBrokerData
|
||||||
{
|
{
|
||||||
char const * prefix;
|
char const * prefix;
|
||||||
char const * outfile;
|
char const * outfile;
|
||||||
FILE * fp;
|
FILE * fp;
|
||||||
} BrokerData;
|
} AppBrokerData;
|
||||||
|
|
||||||
|
|
||||||
/* broker */
|
/* functions */
|
||||||
static void _broker_head(BrokerData * data);
|
static void _appbroker_head(AppBrokerData * data);
|
||||||
static int _broker_foreach(char const * key, Hash * value, BrokerData * data);
|
static int _appbroker_foreach(char const * key, Hash * value,
|
||||||
static int _broker_foreach_arg(BrokerData * data, char const * sep,
|
AppBrokerData * data);
|
||||||
|
static int _appbroker_foreach_arg(AppBrokerData * data, char const * sep,
|
||||||
char const * arg);
|
char const * arg);
|
||||||
static void _broker_tail(BrokerData * data);
|
static void _appbroker_tail(AppBrokerData * data);
|
||||||
|
|
||||||
static int _broker(char const * outfile, char const * filename)
|
static int _appbroker(char const * outfile, char const * filename)
|
||||||
{
|
{
|
||||||
Config * config;
|
Config * config;
|
||||||
BrokerData data;
|
AppBrokerData data;
|
||||||
|
|
||||||
if((config = config_new()) == NULL)
|
if((config = config_new()) == NULL)
|
||||||
return error_print(PACKAGE);
|
return error_print(APPBROKER_PROGNAME);
|
||||||
if(config_load(config, filename) != 0)
|
if(config_load(config, filename) != 0)
|
||||||
{
|
{
|
||||||
config_delete(config);
|
config_delete(config);
|
||||||
return error_print(PACKAGE);
|
return error_print(APPBROKER_PROGNAME);
|
||||||
}
|
}
|
||||||
data.prefix = config_get(config, NULL, "service");
|
data.prefix = config_get(config, NULL, "service");
|
||||||
if((data.outfile = outfile) == NULL)
|
if((data.outfile = outfile) == NULL)
|
||||||
|
@ -58,20 +61,20 @@ static int _broker(char const * outfile, char const * filename)
|
||||||
else if((data.fp = fopen(outfile, "w")) == NULL)
|
else if((data.fp = fopen(outfile, "w")) == NULL)
|
||||||
{
|
{
|
||||||
config_delete(config);
|
config_delete(config);
|
||||||
return error_set_print(PACKAGE, 1, "%s: %s", outfile,
|
return error_set_print(APPBROKER_PROGNAME, 1, "%s: %s", outfile,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
_broker_head(&data);
|
_appbroker_head(&data);
|
||||||
fputs("\n\n/* functions */\n", data.fp);
|
fputs("\n\n/* functions */\n", data.fp);
|
||||||
hash_foreach(config, (HashForeach)_broker_foreach, &data);
|
hash_foreach(config, (HashForeach)_appbroker_foreach, &data);
|
||||||
_broker_tail(&data);
|
_appbroker_tail(&data);
|
||||||
if(outfile != NULL)
|
if(outfile != NULL)
|
||||||
fclose(data.fp);
|
fclose(data.fp);
|
||||||
config_delete(config);
|
config_delete(config);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _broker_head(BrokerData * data)
|
static void _appbroker_head(AppBrokerData * data)
|
||||||
{
|
{
|
||||||
fputs("/* $""Id$ */\n\n\n\n", data->fp);
|
fputs("/* $""Id$ */\n\n\n\n", data->fp);
|
||||||
if(data->prefix != NULL)
|
if(data->prefix != NULL)
|
||||||
|
@ -100,7 +103,8 @@ static void _broker_head(BrokerData * data)
|
||||||
fputs("typedef String ** STRING_INOUT;\n", data->fp);
|
fputs("typedef String ** STRING_INOUT;\n", data->fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _broker_foreach(char const * key, Hash * value, BrokerData * data)
|
static int _appbroker_foreach(char const * key, Hash * value,
|
||||||
|
AppBrokerData * data)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char buf[8];
|
char buf[8];
|
||||||
|
@ -117,7 +121,7 @@ static int _broker_foreach(char const * key, Hash * value, BrokerData * data)
|
||||||
snprintf(buf, sizeof(buf), "arg%d", i + 1);
|
snprintf(buf, sizeof(buf), "arg%d", i + 1);
|
||||||
if((p = hash_get(value, buf)) == NULL)
|
if((p = hash_get(value, buf)) == NULL)
|
||||||
break;
|
break;
|
||||||
if(_broker_foreach_arg(data, sep, p) != 0)
|
if(_appbroker_foreach_arg(data, sep, p) != 0)
|
||||||
return 1;
|
return 1;
|
||||||
sep = ", ";
|
sep = ", ";
|
||||||
}
|
}
|
||||||
|
@ -125,7 +129,7 @@ static int _broker_foreach(char const * key, Hash * value, BrokerData * data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _broker_foreach_arg(BrokerData * data, char const * sep,
|
static int _appbroker_foreach_arg(AppBrokerData * data, char const * sep,
|
||||||
char const * arg)
|
char const * arg)
|
||||||
{
|
{
|
||||||
char * p;
|
char * p;
|
||||||
|
@ -145,7 +149,7 @@ static int _broker_foreach_arg(BrokerData * data, char const * sep,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _broker_tail(BrokerData * data)
|
static void _appbroker_tail(AppBrokerData * data)
|
||||||
{
|
{
|
||||||
if(data->prefix != NULL)
|
if(data->prefix != NULL)
|
||||||
fprintf(data->fp, "%s%s%s", "\n#endif /* !", data->prefix,
|
fprintf(data->fp, "%s%s%s", "\n#endif /* !", data->prefix,
|
||||||
|
@ -156,7 +160,7 @@ static void _broker_tail(BrokerData * data)
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
fputs("Usage: broker [-o outfile] filename\n", stderr);
|
fputs("Usage: " APPBROKER_PROGNAME " [-o outfile] filename\n", stderr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,5 +182,5 @@ int main(int argc, char * argv[])
|
||||||
}
|
}
|
||||||
if(optind + 1 != argc)
|
if(optind + 1 != argc)
|
||||||
return _usage();
|
return _usage();
|
||||||
return (_broker(outfile, argv[optind]) == 0) ? 0 : 2;
|
return (_appbroker(outfile, argv[optind]) == 0) ? 0 : 2;
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
targets=broker
|
targets=AppBroker
|
||||||
cppflags_force=-I ../include
|
cppflags_force=-I ../include
|
||||||
cflags_force=-W
|
cflags_force=-W
|
||||||
cflags=-Wall -g -O2 -pedantic
|
cflags=-Wall -g -O2 -pedantic
|
||||||
|
@ -6,6 +6,6 @@ ldflags_force=-lSystem -L$(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib
|
||||||
ldflags=-L../src
|
ldflags=-L../src
|
||||||
dist=Makefile,README
|
dist=Makefile,README
|
||||||
|
|
||||||
[broker]
|
[AppBroker]
|
||||||
type=binary
|
type=binary
|
||||||
sources=broker.c
|
sources=appbroker.c
|
||||||
|
|
Loading…
Reference in New Issue
Block a user