Author: Mark
Date: Tue Mar 22 07:26:24 2005
New Revision: 2386
Added:
trunk/src/ossocket.c
Modified:
trunk/src/Makefile.am
trunk/src/dcc.c
trunk/src/neostats.vcproj
trunk/src/oscalls.c
trunk/src/sock.c
Log:
more sock updates and fix win32 dcc support, there was a reason it has it's own version of sock_connect
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Tue Mar 22 07:26:24 2005
@@ -6,8 +6,9 @@
dotconf.c conf.c dl.c dns.c exclude.c hash.c ircd.c ircstring.c \
lang.c list.c log.c main.c match.c misc.c modules.c \
ns_help.c servers.c services.c signals.c sock.c support.c \
- timer.c transfer.c users.c modes.c ctcp.c dcc.c oscalls.c nsmemory.c \
- base64.c numerics.c settings.c botinfo.c
+ timer.c transfer.c users.c modes.c ctcp.c dcc.c nsmemory.c \
+ base64.c numerics.c settings.c botinfo.c \
+ oscalls.c ossocket.c
AM_CFLAGS = -I$(top_srcdir)/lib/adns \
@PCRE_CFLAGS@ @CURL_CFLAGS@ -DNEOSTATSCORE \
-I$(top_srcdir)/lib/event
Modified: trunk/src/dcc.c
==============================================================================
--- trunk/src/dcc.c (original)
+++ trunk/src/dcc.c Tue Mar 22 07:26:24 2005
@@ -46,7 +46,9 @@
static int dcc_error(int what, void *arg);
static void DelDCCClient(Client *dcc);
static int dcc_write(Client *dcc, char *buf);
-static dcc_cmd dcc_cmds[]= {
+
+static dcc_cmd dcc_cmds[]=
+{
{"SEND", dcc_req_send},
{"CHAT", dcc_req_chat},
{NULL},
@@ -74,7 +76,6 @@
static int DCCChatStart(Client *dcc, int port)
{
-
dcc->port = port;
if (dcc->ip.s_addr > 0) {
/* we have a valid IP address for this user, so just go and kick off the connection straight away */
@@ -86,10 +87,8 @@
return NS_SUCCESS;
}
-
-
-
-static int DCCChatConnect(Client *dcc, int port) {
+static int DCCChatConnect(Client *dcc, int port)
+{
OS_SOCKET socketfd;
char tmpname[BUFSIZE];
Modified: trunk/src/neostats.vcproj
==============================================================================
--- trunk/src/neostats.vcproj (original)
+++ trunk/src/neostats.vcproj Tue Mar 22 07:26:24 2005
@@ -210,6 +210,9 @@
RelativePath=".\oscalls.c">
</File>
<File
+ RelativePath=".\ossocket.c">
+ </File>
+ <File
RelativePath=".\servers.c">
</File>
<File
Modified: trunk/src/oscalls.c
==============================================================================
--- trunk/src/oscalls.c (original)
+++ trunk/src/oscalls.c Tue Mar 22 07:26:24 2005
@@ -379,63 +379,6 @@
}
/*
- * Wrapper function for sock_close
- */
-
-int os_sock_close( OS_SOCKET sock )
-{
-#ifdef WIN32
- return closesocket( sock );
-#else
- return close( sock );
-#endif
-}
-
-/*
- * Wrapper function for sock_write
- */
-
-int os_sock_write( OS_SOCKET s, const char* buf, int len )
-{
-#ifdef WIN32
- return send( s, buf, len, 0 );
-#else
- return write( s, buf, len );
-#endif
-}
-
-/*
- * Wrapper function for sock_read
- */
-
-int os_sock_read( OS_SOCKET s, char* buf, int len )
-{
-#ifdef WIN32
- return recv( s, buf, len, 0 );
-#else
- return read( s, buf, len );
-#endif
-}
-
-/*
- * Wrapper function for sock_set_nonblocking
- */
-
-int os_sock_set_nonblocking( OS_SOCKET s )
-{
- int flags;
-
-#ifdef WIN32
- flags = 1;
- return ioctlsocket( s, FIONBIO, &flags );
-#else
- flags = fcntl( s, F_GETFL, 0 );
- flags |= O_NONBLOCK;
- return fcntl( s, F_SETFL, flags );
-#endif
-}
-
-/*
* Wrapper function for strftime
*/
Added: trunk/src/ossocket.c
==============================================================================
--- (empty file)
+++ trunk/src/ossocket.c Tue Mar 22 07:26:24 2005
@@ -0,0 +1,84 @@
+/* NeoStats - IRC Statistical Services
+** Copyright (c) 1999-2005 Adam Rutter, Justin Hammond, Mark Hetherington
+** http://www.neostats.net/
+**
+** 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 2 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, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+** USA
+**
+** NeoStats CVS Identification
+** $Id: oscalls.c 2366 2005-03-18 12:29:37Z Fish $
+*/
+
+/* @file Portability wrapper functions
+ */
+
+/*
+ * Wrapper function for sock_close
+ */
+
+#include "neostats.h"
+
+int os_sock_close( OS_SOCKET sock )
+{
+#ifdef WIN32
+ return closesocket( sock );
+#else
+ return close( sock );
+#endif
+}
+
+/*
+ * Wrapper function for sock_write
+ */
+
+int os_sock_write( OS_SOCKET s, const char* buf, int len )
+{
+#ifdef WIN32
+ return send( s, buf, len, 0 );
+#else
+ return write( s, buf, len );
+#endif
+}
+
+/*
+ * Wrapper function for sock_read
+ */
+
+int os_sock_read( OS_SOCKET s, char* buf, int len )
+{
+#ifdef WIN32
+ return recv( s, buf, len, 0 );
+#else
+ return read( s, buf, len );
+#endif
+}
+
+/*
+ * Wrapper function for sock_set_nonblocking
+ */
+
+int os_sock_set_nonblocking( OS_SOCKET s )
+{
+ int flags;
+
+#ifdef WIN32
+ flags = 1;
+ return ioctlsocket( s, FIONBIO, &flags );
+#else
+ flags = fcntl( s, F_GETFL, 0 );
+ flags |= O_NONBLOCK;
+ return fcntl( s, F_SETFL, flags );
+#endif
+}
Modified: trunk/src/sock.c
==============================================================================
--- trunk/src/sock.c (original)
+++ trunk/src/sock.c Tue Mar 22 07:26:24 2005
@@ -48,31 +48,47 @@
char recbuf[BUFSIZE];
-/** @breif Event Subsystem Callback
+/** @brief Event Subsystem Callback
*/
-void libevent_log(int severity, const char *msg) {
- switch (severity) {
- case _EVENT_LOG_DEBUG:
- dlog(DEBUG1, "LibEvent: %s", msg);
- break;
- case _EVENT_LOG_MSG:
- nlog(LOG_INFO, "LibEvent: %s", msg);
- break;
- case _EVENT_LOG_WARN:
- nlog(LOG_WARNING, "LibEvent: %s", msg);
- break;
- case _EVENT_LOG_ERR:
- nlog(LOG_ERROR, "LibEvent: %s", msg);
- break;
- default:
- nlog(LOG_WARNING, "LibEvent(%d): %s", severity, msg);
- break;
- }
+void libevent_log(int severity, const char *msg)
+{
+ switch (severity) {
+ case _EVENT_LOG_DEBUG:
+ dlog(DEBUG1, "LibEvent: %s", msg);
+ break;
+ case _EVENT_LOG_MSG:
+ nlog(LOG_INFO, "LibEvent: %s", msg);
+ break;
+ case _EVENT_LOG_WARN:
+ nlog(LOG_WARNING, "LibEvent: %s", msg);
+ break;
+ case _EVENT_LOG_ERR:
+ nlog(LOG_ERROR, "LibEvent: %s", msg);
+ break;
+ default:
+ nlog(LOG_WARNING, "LibEvent(%d): %s", severity, msg);
+ break;
+ }
}
+/** @brief Called when we receive a error from the ircd socket
+ *
+ * @param what the type of error
+ * @data not used.
+ *
+ * @return Never Returns. Just exits
+ */
-
-static int error_from_ircd_socket(int what, void *data);
+static int
+error_from_ircd_socket(int what, void *data) {
+ nlog (LOG_CRITICAL, "Error from IRCd Socket: %s", strerror(errno));
+ /* Try to close socket then reset the servsock value to avoid cyclic calls */
+ del_sock(me.servsock);
+ me.servsock = NULL;
+ /* XXX really exit? */
+ do_exit (NS_EXIT_ERROR, NULL);
+ return 0;
+}
/** @brief Connect to a IRC server. Only used internally.
*
@@ -290,10 +306,12 @@
/* set non blocking */
+#ifndef WIN32
if ((i = os_sock_set_nonblocking (s)) < 0) {
nlog (LOG_CRITICAL, "can't set socket %d(%s) non-blocking: %s", s, GET_CUR_MODNAME(), strerror (i));
return NS_FAILURE;
}
+#endif
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&flags, sizeof(flags));
if ((i = connect (s, (struct sockaddr *) &sa, sizeof (sa))) < 0) {
@@ -372,24 +390,6 @@
}
-/** @breif Called when we receive a error from the ircd socket
- *
- * @param what the type of error
- * @data not used.
- *
- * @return Never Returns. Just exits
- */
-
-static int
-error_from_ircd_socket(int what, void *data) {
- nlog (LOG_CRITICAL, "Error from IRCd Socket: %s", strerror(errno));
- /* Try to close socket then reset the servsock value to avoid cyclic calls */
- del_sock(me.servsock);
- me.servsock = NULL;
- /* XXX really exit? */
- do_exit (NS_EXIT_ERROR, NULL);
- return 0;
-}
#undef SOCKDEBUG
/** @brief This function actually handles reading data from our sockets
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.