Compare commits
2 Commits
visual_stu
...
0.3.x-stab
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9f32c8f7f | ||
|
|
4c94753469 |
@@ -119,6 +119,7 @@ void sid_pool_destroy(struct sid_pool* pool)
|
||||
|
||||
sid_t sid_alloc(struct sid_pool* pool, struct hub_user* user)
|
||||
{
|
||||
sid_t n;
|
||||
if (pool->count >= (pool->max - pool->min))
|
||||
{
|
||||
#ifdef DEBUG_SID
|
||||
@@ -127,7 +128,7 @@ sid_t sid_alloc(struct sid_pool* pool, struct hub_user* user)
|
||||
return 0;
|
||||
}
|
||||
|
||||
sid_t n = (++pool->count);
|
||||
n = (++pool->count);
|
||||
for (; (pool->map[n % pool->max]); n++) ;
|
||||
|
||||
#ifdef DEBUG_SID
|
||||
|
||||
@@ -426,11 +426,12 @@ static int command_broadcast(struct hub_info* hub, struct hub_user* user, struct
|
||||
char from_sid[5];
|
||||
char buffer[128];
|
||||
size_t recipients = 0;
|
||||
struct hub_user* target;
|
||||
|
||||
memcpy(from_sid, sid_to_string(user->id.sid), sizeof(from_sid));
|
||||
memcpy(pm_flag + 2, from_sid, sizeof(from_sid));
|
||||
|
||||
struct hub_user* target = (struct hub_user*) list_get_first(hub->users->list);
|
||||
target = (struct hub_user*) list_get_first(hub->users->list);
|
||||
while (target)
|
||||
{
|
||||
if (target != user)
|
||||
|
||||
109
src/includes.h
Normal file
109
src/includes.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* uhub - A tiny ADC p2p connection hub
|
||||
* Copyright (C) 2007-2010, 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_INCLUDES_H
|
||||
#define HAVE_UHUB_INCLUDES_H
|
||||
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#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>
|
||||
|
||||
#ifndef __sun__
|
||||
# include <getopt.h>
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.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>
|
||||
#endif
|
||||
|
||||
#ifdef SSL_SUPPORT
|
||||
# include <openssl/ssl.h>
|
||||
# include <openssl/err.h>
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
# define USE_EPOLL
|
||||
# include <sys/epoll.h>
|
||||
#endif
|
||||
|
||||
#ifdef BSD_LIKE
|
||||
# define USE_KQUEUE
|
||||
# include <sys/event.h>
|
||||
#endif
|
||||
|
||||
#define USE_SELECT
|
||||
# ifndef WINSOCK
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#if !defined(WIN32)
|
||||
# define HAVE_STRNDUP
|
||||
# define HAVE_GETRLIMIT
|
||||
# if !defined(__HAIKU__)
|
||||
# define HAVE_MEMMEM
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(BSD_LIKE) || defined(__sun__)
|
||||
# undef HAVE_STRNDUP
|
||||
# undef HAVE_MEMMEM
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
/* Windows uses %Iu for size_t */
|
||||
#define PRINTF_SIZE_T "%Iu"
|
||||
#else
|
||||
/* NOTE: does not work for old versions of gcc (like 2.95) */
|
||||
#define PRINTF_SIZE_T "%zu"
|
||||
#endif
|
||||
|
||||
#define uhub_assert assert
|
||||
|
||||
|
||||
#endif /* HAVE_UHUB_INCLUDES_H */
|
||||
110
src/system.h
110
src/system.h
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* uhub - A tiny ADC p2p connection hub
|
||||
* Copyright (C) 2007-2009, Jan Vidar Krey
|
||||
* Copyright (C) 2007-2010, 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
|
||||
@@ -20,30 +20,6 @@
|
||||
#ifndef HAVE_UHUB_SYSTEM_H
|
||||
#define HAVE_UHUB_SYSTEM_H
|
||||
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
#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(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
# define BSD_LIKE
|
||||
#endif
|
||||
@@ -54,85 +30,6 @@
|
||||
# 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>
|
||||
|
||||
#ifndef __sun__
|
||||
#include <getopt.h>
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.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
|
||||
#ifndef __HAIKU__
|
||||
#define HAVE_MEMMEM
|
||||
#endif
|
||||
#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
|
||||
|
||||
#ifdef __linux__
|
||||
#define USE_EPOLL
|
||||
#include <sys/epoll.h>
|
||||
#endif
|
||||
|
||||
#ifdef BSD_LIKE
|
||||
#define USE_KQUEUE
|
||||
#include <sys/event.h>
|
||||
#endif
|
||||
|
||||
#define USE_SELECT
|
||||
#ifndef WINSOCK
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#if defined(BSD_LIKE) || defined(__sun__)
|
||||
#undef HAVE_STRNDUP
|
||||
#undef HAVE_MEMMEM
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Detect operating system info.
|
||||
* See: http://predef.sourceforge.net/
|
||||
@@ -218,6 +115,11 @@
|
||||
# define CPUINFO "SuperH"
|
||||
#endif
|
||||
|
||||
/* System includes */
|
||||
#include "includes.h"
|
||||
#include "../version.h"
|
||||
|
||||
|
||||
/* Misc */
|
||||
#ifdef MSG_NOSIGNAL
|
||||
# define UHUB_SEND_SIGNAL MSG_NOSIGNAL
|
||||
|
||||
Reference in New Issue
Block a user