Split uhub.h

This commit is contained in:
Jan Vidar Krey 2009-08-28 16:18:18 +02:00
parent 11b288a669
commit 5203ecdadc
3 changed files with 150 additions and 147 deletions

View File

@ -139,53 +139,29 @@ libuhub_SOURCES := \
src/util/list.c \ src/util/list.c \
src/util/log.c \ src/util/log.c \
src/util/memory.c \ src/util/memory.c \
src/adc/message.c \
src/util/misc.c \ src/util/misc.c \
src/core/netevent.c \ src/core/netevent.c \
src/network/connection.c \ src/network/connection.c \
src/network/network.c \ src/network/network.c \
src/util/rbtree.c \ src/util/rbtree.c \
src/core/route.c \ src/core/route.c \
src/adc/sid.c \
src/util/tiger.c \ src/util/tiger.c \
src/core/user.c \ src/core/user.c \
src/core/usermanager.c src/core/usermanager.c
uhub_SOURCES := src/core/main.c libadc_common_SOURCES := \
src/adc/message.c \
src/adc/sid.c
libucadc_SOURCES := src/tools/adcclient.c libadc_client_SOURCES := \
src/tools/adcclient.c
uhub_SOURCES := src/core/main.c
adcrush_SOURCES := src/tools/adcrush.c adcrush_SOURCES := src/tools/adcrush.c
admin_SOURCES := src/tools/admin.c admin_SOURCES := src/tools/admin.c
uhub_HEADERS := \
src/adc/adcconst.h \
src/core/auth.h \
src/core/config.h \
src/core/eventid.h \
src/core/eventqueue.h \
src/core/hub.h \
src/core/hubevent.h \
src/core/hubio.h \
src/core/inf.h \
src/util/ipcalc.h \
src/util/list.h \
src/util/log.h \
src/util/memory.h \
src/adc/message.h \
src/util/misc.h \
src/core/netevent.h \
src/network/connection.h \
src/network/network.h \
src/util/rbtree.h \
src/core/route.h \
src/adc/sid.h \
src/util/tiger.h \
src/uhub.h \
src/core/user.h \
src/core/usermanager.h
autotest_SOURCES := \ autotest_SOURCES := \
autotest/test_message.tcc \ autotest/test_message.tcc \
autotest/test_list.tcc \ autotest/test_list.tcc \
@ -201,13 +177,15 @@ autotest_SOURCES := \
autotest_OBJECTS = autotest.o autotest_OBJECTS = autotest.o
# Source to objects # Source to objects
libuhub_OBJECTS := $(libuhub_SOURCES:.c=.o) libuhub_OBJECTS := $(libuhub_SOURCES:.c=.o)
libucadc_OBJECTS:= $(libucadc_SOURCES:.c=.o) libadc_client_OBJECTS := $(libadc_client_SOURCES:.c=.o)
uhub_OBJECTS := $(uhub_SOURCES:.c=.o) libadc_common_OBJECTS := $(libadc_common_SOURCES:.c=.o)
adcrush_OBJECTS := $(adcrush_SOURCES:.c=.o)
admin_OBJECTS := $(admin_SOURCES:.c=.o)
all_OBJECTS := $(libuhub_OBJECTS) $(uhub_OBJECTS) $(adcrush_OBJECTS) $(autotest_OBJECTS) $(admin_OBJECTS) uhub_OBJECTS := $(uhub_SOURCES:.c=.o)
adcrush_OBJECTS := $(adcrush_SOURCES:.c=.o)
admin_OBJECTS := $(admin_SOURCES:.c=.o)
all_OBJECTS := $(libuhub_OBJECTS) $(uhub_OBJECTS) $(adcrush_OBJECTS) $(autotest_OBJECTS) $(admin_OBJECTS) $(libadc_common_OBJECTS) $(libadc_client_OBJECTS)
LIBUHUB=libuhub.a LIBUHUB=libuhub.a
LIBUCADC=libucadc.a LIBUCADC=libucadc.a
@ -221,13 +199,13 @@ autotest_BINARY=autotest/test$(BIN_EXT)
all: $(uhub_BINARY) all: $(uhub_BINARY)
$(adcrush_BINARY): $(LIBUHUB) $(adcrush_OBJECTS) $(adcrush_BINARY): $(adcrush_OBJECTS) $(libuhub_OBJECTS) $(libadc_common_OBJECTS) $(libadc_client_OBJECTS)
$(MSG_LD) $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(MSG_LD) $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
$(admin_BINARY): $(admin_OBJECTS) $(libucadc_OBJECTS) $(libuhub_OBJECTS) $(admin_BINARY): $(admin_OBJECTS) $(libuhub_OBJECTS) $(libadc_common_OBJECTS) $(libadc_client_OBJECTS)
$(MSG_LD) $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(MSG_LD) $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
$(uhub_BINARY): $(libuhub_OBJECTS) $(uhub_OBJECTS) $(uhub_BINARY): $(uhub_OBJECTS) $(libuhub_OBJECTS) $(libadc_common_OBJECTS)
$(MSG_LD) $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(MSG_LD) $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
autotest.c: $(autotest_SOURCES) autotest.c: $(autotest_SOURCES)
@ -236,7 +214,7 @@ autotest.c: $(autotest_SOURCES)
$(autotest_OBJECTS): autotest.c $(autotest_OBJECTS): autotest.c
$(MSG_CC) $(CC) -c $(CFLAGS) -Isrc -o $@ $< $(MSG_CC) $(CC) -c $(CFLAGS) -Isrc -o $@ $<
$(autotest_BINARY): $(autotest_OBJECTS) $(libuhub_OBJECTS) $(autotest_BINARY): $(autotest_OBJECTS) $(libuhub_OBJECTS) $(libadc_common_OBJECTS) $(libadc_client_OBJECTS)
$(MSG_LD) $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(MSG_LD) $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
autotest: $(autotest_BINARY) autotest: $(autotest_BINARY)

128
src/system.h Normal file
View File

@ -0,0 +1,128 @@
/*
* uhub - A tiny ADC p2p connection hub
* Copyright (C) 2007-2009, Jan Vidar Krey
*
* 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; either version 3 of the License, or
* (at your option) any later version.
*
* 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/>.
*
*/
#ifndef HAVE_UHUB_SYSTEM_H
#define HAVE_UHUB_SYSTEM_H
#if USE_REGPARM && __GNUC__ >= 3
#define REGPRM1 __attribute__((regparm(1)))
#define REGPRM2 __attribute__((regparm(2)))
#define REGPRM3 __attribute__((regparm(3)))
#else
#define REGPRM1
#define REGPRM2
#define REGPRM3
#endif
#ifndef FORCEINLINE
#if __GNUC__ < 3
#define FORCEINLINE inline
#else
#define FORCEINLINE inline __attribute__((always_inline))
#endif
#endif
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#if defined(__CYGWIN__) || defined(__MINGW32__)
#ifndef WINSOCK
#define WINSOCK
#endif
#endif
#ifdef WINSOCK
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <sys/types.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#endif
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#if !defined(WIN32)
#include <grp.h>
#include <pwd.h>
#include <sys/resource.h>
#define HAVE_STRNDUP
#define HAVE_MEMMEM
#define HAVE_GETRLIMIT
#endif
/* printf and size_t support */
#if defined(WIN32)
/* Windows uses %Iu for size_t */
#define PRINTF_SIZE_T "%Iu"
#else
#define PRINTF_SIZE_T "%zu"
#endif
#ifdef SSL_SUPPORT
#include <openssl/ssl.h>
#include <openssl/err.h>
#endif
#include "../version.h"
#define uhub_assert assert
#include <event.h>
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__sun__)
#undef HAVE_STRNDUP
#undef HAVE_MEMMEM
#endif
#ifdef MSG_NOSIGNAL
#define UHUB_SEND_SIGNAL MSG_NOSIGNAL
#else
#ifdef MSG_NOPIPE
#define UHUB_SEND_SIGNAL MSG_NOPIPE
#else
#define UHUB_SEND_SIGNAL 0
#endif
#endif
#ifndef INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN 46
#endif
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif /* HAVE_UHUB_SYSTEM_H */

View File

@ -25,103 +25,7 @@
/* #define MEMORY_DEBUG */ /* #define MEMORY_DEBUG */
/* #define DEBUG_SENDQ 1 */ /* #define DEBUG_SENDQ 1 */
#if USE_REGPARM && __GNUC__ >= 3 #include "system.h"
#define REGPRM1 __attribute__((regparm(1)))
#define REGPRM2 __attribute__((regparm(2)))
#define REGPRM3 __attribute__((regparm(3)))
#else
#define REGPRM1
#define REGPRM2
#define REGPRM3
#endif
#ifndef FORCEINLINE
#if __GNUC__ < 3
#define FORCEINLINE inline
#else
#define FORCEINLINE inline __attribute__((always_inline))
#endif
#endif
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#if defined(__CYGWIN__) || defined(__MINGW32__)
#ifndef WINSOCK
#define WINSOCK
#endif
#endif
#ifdef WINSOCK
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <sys/types.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#endif
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#if !defined(WIN32)
#include <grp.h>
#include <pwd.h>
#include <sys/resource.h>
#define HAVE_STRNDUP
#define HAVE_MEMMEM
#define HAVE_GETRLIMIT
#endif
/* printf and size_t support */
#if defined(WIN32)
/* Windows uses %Iu for size_t */
#define PRINTF_SIZE_T "%Iu"
#else
#define PRINTF_SIZE_T "%zu"
#endif
#ifdef SSL_SUPPORT
#include <openssl/ssl.h>
#include <openssl/err.h>
#endif
#include "../version.h"
#define uhub_assert assert
#include <event.h>
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__sun__)
#undef HAVE_STRNDUP
#undef HAVE_MEMMEM
#endif
#ifdef MSG_NOSIGNAL
#define UHUB_SEND_SIGNAL MSG_NOSIGNAL
#else
#ifdef MSG_NOPIPE
#define UHUB_SEND_SIGNAL MSG_NOPIPE
#else
#define UHUB_SEND_SIGNAL 0
#endif
#endif
#define SERVER_PORT 1511 #define SERVER_PORT 1511
#define SERVER_ADDR_IPV6 "::" #define SERVER_ADDR_IPV6 "::"
@ -154,19 +58,12 @@
#define MAX_RECV_BUF 65535 #define MAX_RECV_BUF 65535
#define MAX_SEND_BUF 65535 #define MAX_SEND_BUF 65535
#ifndef INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN 46
#endif
#include "adc/adcconst.h"
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "adc/adcconst.h"
#include "util/ipcalc.h" #include "util/ipcalc.h"
#include "util/list.h" #include "util/list.h"
#include "util/log.h" #include "util/log.h"