Various build fixes.
This commit is contained in:
parent
52cbec24b6
commit
11b288a669
|
@ -1,2 +1,8 @@
|
|||
*~
|
||||
*.o
|
||||
*.[oa]
|
||||
*.exe
|
||||
*.gch
|
||||
uhub-admin
|
||||
adcrush
|
||||
uhub
|
||||
|
||||
|
|
46
GNUmakefile
46
GNUmakefile
|
@ -8,7 +8,6 @@ LD := $(CC)
|
|||
MV := mv
|
||||
RANLIB := ranlib
|
||||
CFLAGS += -pipe -Wall
|
||||
USE_PCH ?= YES
|
||||
USE_SSL ?= NO
|
||||
USE_BIGENDIAN ?= AUTO
|
||||
BITS ?= AUTO
|
||||
|
@ -47,19 +46,16 @@ endif
|
|||
|
||||
ifeq ($(SILENT),YES)
|
||||
MSG_CC=@echo " CC:" $(notdir $^) &&
|
||||
MSG_PCH=@echo " PCH:" $(notdir $@) &&
|
||||
MSG_LD=@echo " LD:" $(notdir $@) &&
|
||||
MSG_AR=@echo " AR:" $(notdir $@) &&
|
||||
else
|
||||
MSG_CC=
|
||||
MSG_PCH=
|
||||
MSG_LD=
|
||||
MSG_AR=
|
||||
endif
|
||||
|
||||
ifeq ($(TERSE), YES)
|
||||
MSG_CC=@
|
||||
MSG_PCH=@
|
||||
MSG_LD=@
|
||||
MSG_AR=@
|
||||
MSG_CLEAN=-n ""
|
||||
|
@ -67,8 +63,8 @@ else
|
|||
MSG_CLEAN="Clean as a whistle"
|
||||
endif
|
||||
|
||||
CFLAGS += -I/source/libevent
|
||||
LDFLAGS += -L/source/libevent
|
||||
# CFLAGS += -I/source/libevent
|
||||
# LDFLAGS += -L/source/libevent
|
||||
|
||||
ifeq ($(RELEASE),YES)
|
||||
CFLAGS += -O3 -DNDEBUG
|
||||
|
@ -93,13 +89,6 @@ CFLAGS += -finstrument-functions
|
|||
CFLAGS += -DDEBUG_FUNCTION_TRACE
|
||||
endif
|
||||
|
||||
ifeq ($(USE_PCH),YES)
|
||||
PCHSRC=src/uhub.h
|
||||
PCH=src/uhub.h.gch
|
||||
else
|
||||
PCH=
|
||||
endif
|
||||
|
||||
ifneq ($(BITS), AUTO)
|
||||
ifeq ($(BITS), 64)
|
||||
CFLAGS += -m64
|
||||
|
@ -230,27 +219,16 @@ autotest_BINARY=autotest/test$(BIN_EXT)
|
|||
%.o: %.c
|
||||
$(MSG_CC) $(CC) -c $(CFLAGS) -o $@ $^
|
||||
|
||||
all: $(uhub_BINARY) $(PCH)
|
||||
all: $(uhub_BINARY)
|
||||
|
||||
$(adcrush_BINARY): $(PCH) $(LIBUHUB) $(adcrush_OBJECTS)
|
||||
$(MSG_LD) $(CC) -o $@ $(adcrush_OBJECTS) $(LIBUHUB) $(LDFLAGS) $(LDLIBS)
|
||||
$(adcrush_BINARY): $(LIBUHUB) $(adcrush_OBJECTS)
|
||||
$(MSG_LD) $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
|
||||
|
||||
$(admin_BINARY): $(PCH) $(LIBUCADC) $(LIBUHUB) $(admin_OBJECTS)
|
||||
$(MSG_LD) $(CC) -o $@ $(admin_OBJECTS) $(LIBUCADC) $(LIBUHUB) $(LDFLAGS) $(LDLIBS)
|
||||
$(admin_BINARY): $(admin_OBJECTS) $(libucadc_OBJECTS) $(libuhub_OBJECTS)
|
||||
$(MSG_LD) $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
|
||||
|
||||
$(uhub_BINARY): $(PCH) $(LIBUHUB) $(uhub_OBJECTS)
|
||||
$(MSG_LD) $(CC) -o $@ $(uhub_OBJECTS) $(LIBUHUB) $(LDFLAGS) $(LDLIBS)
|
||||
|
||||
$(LIBUHUB): $(libuhub_OBJECTS)
|
||||
$(MSG_AR) $(AR) rc $@ $^ && $(RANLIB) $@
|
||||
|
||||
$(LIBUCADC): $(libucadc_OBJECTS)
|
||||
$(MSG_AR) $(AR) rc $@ $^ && $(RANLIB) $@
|
||||
|
||||
ifeq ($(USE_PCH),YES)
|
||||
$(PCH): $(uhub_HEADERS)
|
||||
$(MSG_PCH) $(CC) $(CFLAGS) -o $@ $(PCHSRC)
|
||||
endif
|
||||
$(uhub_BINARY): $(libuhub_OBJECTS) $(uhub_OBJECTS)
|
||||
$(MSG_LD) $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
|
||||
|
||||
autotest.c: $(autotest_SOURCES)
|
||||
$(shell exotic --standalone $(autotest_SOURCES) > $@)
|
||||
|
@ -258,7 +236,7 @@ autotest.c: $(autotest_SOURCES)
|
|||
$(autotest_OBJECTS): autotest.c
|
||||
$(MSG_CC) $(CC) -c $(CFLAGS) -Isrc -o $@ $<
|
||||
|
||||
$(autotest_BINARY): $(autotest_OBJECTS) $(LIBUHUB)
|
||||
$(autotest_BINARY): $(autotest_OBJECTS) $(libuhub_OBJECTS)
|
||||
$(MSG_LD) $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
|
||||
|
||||
autotest: $(autotest_BINARY)
|
||||
|
@ -279,10 +257,10 @@ install: $(uhub_BINARY)
|
|||
endif
|
||||
|
||||
dist-clean:
|
||||
@rm -rf $(all_OBJECTS) $(PCH) *~ core
|
||||
@rm -rf $(all_OBJECTS) *~ core
|
||||
|
||||
clean:
|
||||
@rm -rf $(libuhub_OBJECTS) $(PCH) *~ core $(uhub_BINARY) $(LIBUHUB) $(all_OBJECTS) && \
|
||||
@rm -rf $(libuhub_OBJECTS) *~ core $(uhub_BINARY) $(admin_BINARY) $(autotest_BINARY) $(adcrush_BINARY) $(LIBUHUB) $(all_OBJECTS) && \
|
||||
echo $(MSG_CLEAN)
|
||||
|
||||
|
||||
|
|
|
@ -17,11 +17,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "adcclient.h"
|
||||
#include "tools/adcclient.h"
|
||||
|
||||
#define ADC_HANDSHAKE "HSUP ADBASE ADTIGR\n"
|
||||
#define ADC_CID_SIZE 39
|
||||
|
||||
#define BIG_BUFSIZE 32768
|
||||
#define TIGERSIZE 24
|
||||
|
||||
|
@ -83,6 +82,8 @@ static void timer_callback(struct net_timer* t, void* arg)
|
|||
static void event_callback(struct net_connection* con, int events, void *arg)
|
||||
{
|
||||
struct ADC_client* client = (struct ADC_client*) arg;
|
||||
ADC_client_debug(client, "event_callback. events=%d", events);
|
||||
|
||||
if (events == NET_EVENT_SOCKERROR || events == NET_EVENT_CLOSED)
|
||||
{
|
||||
client->callbacks.connection(client, -1, "Closed/socket error");
|
||||
|
@ -269,6 +270,7 @@ void ADC_client_send_info(struct ADC_client* client)
|
|||
|
||||
int ADC_client_create(struct ADC_client* client, const char* nickname, const char* description)
|
||||
{
|
||||
ADC_client_debug(client, "ADC_client_create: %s", nickname);
|
||||
memset(client, 0, sizeof(struct ADC_client));
|
||||
|
||||
int sd = net_socket_create(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
@ -302,7 +304,6 @@ int ADC_client_connect(struct ADC_client* client, const char* address)
|
|||
{
|
||||
if (!ADC_client_parse_address(client, address))
|
||||
return 0;
|
||||
client->hub_address = hub_strdup(address);
|
||||
}
|
||||
|
||||
int ret = net_connect(client->con->sd, (struct sockaddr*) &client->addr, sizeof(struct sockaddr_in));
|
||||
|
@ -362,22 +363,29 @@ void ADC_client_disconnect(struct ADC_client* client)
|
|||
static int ADC_client_parse_address(struct ADC_client* client, const char* arg)
|
||||
{
|
||||
char* split;
|
||||
int ssl = 0;
|
||||
struct hostent* dns;
|
||||
struct in_addr* addr;
|
||||
|
||||
if (!arg)
|
||||
return 0;
|
||||
|
||||
client->hub_address = hub_strdup(arg);
|
||||
|
||||
/* Minimum length of a valid address */
|
||||
if (strlen(arg) < 9)
|
||||
return 0;
|
||||
|
||||
/* Check for ADC or ADCS */
|
||||
if (strncmp(arg, "adc://", 6) != 0 && strncmp(arg, "adcs://", 7) != 0)
|
||||
if (!strncmp(arg, "adc://", 6))
|
||||
ssl = 0;
|
||||
else if (!strncmp(arg, "adcs://", 7))
|
||||
ssl = 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
/* Split hostname and port (if possible) */
|
||||
split = strrchr(arg+6, ':');
|
||||
split = strrchr(client->hub_address + 6 + ssl, ':');
|
||||
if (split == 0 || strlen(split) < 2 || strlen(split) > 6)
|
||||
return 0;
|
||||
|
||||
|
@ -389,7 +397,7 @@ static int ADC_client_parse_address(struct ADC_client* client, const char* arg)
|
|||
split[0] = 0;
|
||||
|
||||
/* Resolve IP address (FIXME: blocking call) */
|
||||
dns = gethostbyname(arg+6);
|
||||
dns = gethostbyname(client->hub_address + 6 + ssl);
|
||||
if (dns)
|
||||
{
|
||||
addr = (struct in_addr*) dns->h_addr_list[0];
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
#ifndef HAVE_UHUB_ADC_CLIENT_H
|
||||
#define HAVE_UHUB_ADC_CLIENT_H
|
||||
|
||||
#include "uhub.h"
|
||||
|
||||
#define ADC_BUFSIZE 16384
|
||||
#define ADC_SIDSIZE 4
|
||||
|
||||
enum ADC_client_state
|
||||
{
|
||||
|
@ -65,27 +66,11 @@ struct ADC_client
|
|||
char* desc;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create/Allocate/Initialize an ADC_client struct
|
||||
* NOTE: If this is successful, one must call ADC_client_destroy to cleanup afterwards.
|
||||
*/
|
||||
extern int ADC_client_create(struct ADC_client* client, const char* nickname, const char* description);
|
||||
|
||||
/**
|
||||
* Destroy an ADC_client struct.
|
||||
*/
|
||||
extern void ADC_client_destroy(struct ADC_client* client);
|
||||
|
||||
extern int ADC_client_connect(struct ADC_client* client, const char* address);
|
||||
|
||||
extern void ADC_client_disconnect(struct ADC_client* client);
|
||||
|
||||
/**
|
||||
* Send a message (ADC command)
|
||||
*/
|
||||
extern void ADC_client_send(struct ADC_client* client, char* msg);
|
||||
int ADC_client_create(struct ADC_client* client, const char* nickname, const char* description);
|
||||
void ADC_client_destroy(struct ADC_client* client);
|
||||
int ADC_client_connect(struct ADC_client* client, const char* address);
|
||||
void ADC_client_disconnect(struct ADC_client* client);
|
||||
void ADC_client_send(struct ADC_client* client, char* msg);
|
||||
|
||||
#endif /* HAVE_UHUB_ADC_CLIENT_H */
|
||||
|
||||
|
|
|
@ -6,12 +6,9 @@
|
|||
|
||||
#define ADC_CLIENTS_DEFAULT 100
|
||||
#define ADC_MAX_CLIENTS 25000
|
||||
|
||||
#define ADC_CID_SIZE 39
|
||||
|
||||
#define BIG_BUFSIZE 32768
|
||||
#define TIGERSIZE 24
|
||||
|
||||
#define ADCRUSH "adcrush/0.2"
|
||||
#define ADC_NICK "[BOT]adcrush"
|
||||
#define ADC_DESC "crash\\stest\\sdummy"
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
* A remote uhub admin client.
|
||||
*/
|
||||
|
||||
|
||||
#include "uhub.h"
|
||||
#include "adcclient.h"
|
||||
#include "network/connection.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
@ -15,7 +12,9 @@ int main(int argc, char** argv)
|
|||
ADC_client_create(&client, "uhub-admin", "stresstester");
|
||||
ADC_client_connect(&client, "adc://adc.extatic.org:1511");
|
||||
|
||||
printf("START\n");
|
||||
event_dispatch();
|
||||
printf("STOP\n");
|
||||
|
||||
ADC_client_destroy(&client);
|
||||
net_destroy();
|
||||
|
|
Loading…
Reference in New Issue