[NeoStats-Devel] [Commits] r2459 - trunk/lib/adns

[email protected]
Newsgroups gmane.comp.neostats.devel
Message-ID <[email protected]>
Author: Mark
Date: Wed Apr  6 06:46:26 2005
New Revision: 2459

Modified:
   trunk/lib/adns/adns.h
   trunk/lib/adns/adns_win32.h
   trunk/lib/adns/event.c
   trunk/lib/adns/internal.h
   trunk/lib/adns/setup.c
Log:
adns include tidy up and begin using neostats os socket layer

Modified: trunk/lib/adns/adns.h
==============================================================================
--- trunk/lib/adns/adns.h	(original)
+++ trunk/lib/adns/adns.h	Wed Apr  6 06:46:26 2005
@@ -36,12 +36,7 @@
 #ifdef WIN32
 #include "adns_win32.h"
 #else
-#include <stdio.h>
-
-#include <sys/types.h>
 # define ADNS_API
-# define ADNS_SOCKET int
-# define adns_socket_close(sck) close(sck)
 # define adns_socket_read(sck, data, len) read(sck, data, len)
 # define adns_socket_write(sck, data, len) write(sck, data, len)
 # define ADNS_CAPTURE_ERRNO {}
@@ -581,9 +576,9 @@
  * value is returned.
  */
 
-ADNS_API int adns_processreadable(adns_state ads, ADNS_SOCKET fd, const struct timeval *now);
-ADNS_API int adns_processwriteable(adns_state ads, ADNS_SOCKET fd, const struct timeval *now);
-ADNS_API int adns_processexceptional(adns_state ads, ADNS_SOCKET fd, const struct timeval *now);
+ADNS_API int adns_processreadable(adns_state ads, OS_SOCKET fd, const struct timeval *now);
+ADNS_API int adns_processwriteable(adns_state ads, OS_SOCKET fd, const struct timeval *now);
+ADNS_API int adns_processexceptional(adns_state ads, OS_SOCKET fd, const struct timeval *now);
 /* Gives adns flow-of-control so that it can process incoming data
  * from, or send outgoing data via, fd.  Very like _processany.  If it
  * returns zero then fd will no longer be readable or writeable

Modified: trunk/lib/adns/adns_win32.h
==============================================================================
--- trunk/lib/adns/adns_win32.h	(original)
+++ trunk/lib/adns/adns_win32.h	Wed Apr  6 06:46:26 2005
@@ -74,24 +74,12 @@
 
 /* ---------------- START OF C HEADER -------------- */
 
-#include <stdlib.h>
-#include <stdio.h>
 #include <Winsock2.h>
 #include <windows.h>
-#include <sys/types.h>
-#include <time.h>
-#include <errno.h>
-#include <assert.h>
 #include <limits.h>
 #include <malloc.h>
 #include <signal.h>
 
-#ifndef inline
-#define inline __inline
-#endif
-
-#define ADNS_SOCKET SOCKET
-#define adns_socket_close(sck) closesocket(sck)
 #define adns_socket_read(sck, data, len) recv(sck, (char *)data, len, 0)
 #define adns_socket_write(sck, data, len) send(sck, (char *)data, len, 0)
 

Modified: trunk/lib/adns/event.c
==============================================================================
--- trunk/lib/adns/event.c	(original)
+++ trunk/lib/adns/event.c	Wed Apr  6 06:46:26 2005
@@ -57,7 +57,7 @@
     if (ads->fdfunc) 
       ads->fdfunc(ads->tcpsocket, -1);
       
-	adns_socket_close(ads->tcpsocket);
+	os_sock_close(ads->tcpsocket);
 	ads->tcpsocket = -1;
 	ads->tcprecv.used = ads->tcprecv_skip = ads->tcpsend.used = 0;
 }
@@ -104,7 +104,7 @@
 
 void adns__tcp_tryconnect(adns_state ads, struct timeval now) {
   int r, tries;
-  ADNS_SOCKET fd;
+  OS_SOCKET fd;
 	struct sockaddr_in addr;
 	struct protoent *proto;
 
@@ -140,7 +140,7 @@
 			adns__diag(ads, -1, 0,
 				   "cannot make TCP socket nonblocking: %s",
 				   strerror(r));
-			adns_socket_close(fd);
+			os_sock_close(fd);
 			return;
 		}
 		memset(&addr, 0, sizeof(addr));
@@ -403,7 +403,7 @@
 	return 2;
 }
 
-int adns_processreadable(adns_state ads, ADNS_SOCKET fd, const struct timeval *now) {
+int adns_processreadable(adns_state ads, OS_SOCKET fd, const struct timeval *now) {
 	int want, dgramlen, r, udpaddrlen, serv, old_skip;
 	byte udpbuf[DNS_MAXUDP];
 	struct sockaddr_in udpaddr;
@@ -550,7 +550,7 @@
 	return r;
 }
 
-int adns_processwriteable(adns_state ads, ADNS_SOCKET fd,
+int adns_processwriteable(adns_state ads, OS_SOCKET fd,
 			  const struct timeval *now)
 {
 	int r;
@@ -636,7 +636,7 @@
 	return r;
 }
 
-int adns_processexceptional(adns_state ads, ADNS_SOCKET fd,
+int adns_processexceptional(adns_state ads, OS_SOCKET fd,
 			    const struct timeval *now)
 {
 	adns__consistency(ads, 0, cc_entex);
@@ -658,10 +658,10 @@
 	return 0;
 }
 
-static void fd_event(adns_state ads, ADNS_SOCKET fd,
+static void fd_event(adns_state ads, OS_SOCKET fd,
 		     int revent, int pollflag,
 		     int maxfd, const fd_set * fds,
-		     int (*func)(adns_state, ADNS_SOCKET fd, const struct timeval *now),
+		     int (*func)(adns_state, OS_SOCKET fd, const struct timeval *now),
 		     struct timeval now, int *r_r) {
 	int r;
 
@@ -688,7 +688,7 @@
 		    const fd_set * writefds, const fd_set * exceptfds,
 		    struct timeval now, int *r_r) {
   int i, revents;
-  ADNS_SOCKET fd;
+  OS_SOCKET fd;
 
 	for (i = 0; i < npollfds; i++) {
 		fd = pollfds[i].fd;
@@ -714,7 +714,7 @@
 	struct timeval tv_nowbuf;
 	struct pollfd pollfds[MAX_POLLFDS];
   int i, maxfd, npollfds;
-  ADNS_SOCKET fd;
+  OS_SOCKET fd;
 
 	adns__consistency(ads, 0, cc_entex);
 

Modified: trunk/lib/adns/internal.h
==============================================================================
--- trunk/lib/adns/internal.h	(original)
+++ trunk/lib/adns/internal.h	Wed Apr  6 06:46:26 2005
@@ -317,7 +317,7 @@
 	struct query_queue udpw, tcpw, childw, output;
 	adns_query forallnext;
   int nextid;
-  ADNS_SOCKET udpsocket, tcpsocket;
+  OS_SOCKET udpsocket, tcpsocket;
 	vbuf tcpsend, tcprecv;
   int nservers, nsortlist, nsearchlist, searchndots, tcpserver, tcprecv_skip;
 	enum adns__tcpstate {
@@ -346,7 +346,7 @@
 
 /* From setup.c: */
 
-int adns__setnonblock(adns_state ads, ADNS_SOCKET fd); /* => errno value */
+int adns__setnonblock(adns_state ads, OS_SOCKET fd); /* => errno value */
 
 /* From general.c: */
 

Modified: trunk/lib/adns/setup.c
==============================================================================
--- trunk/lib/adns/setup.c	(original)
+++ trunk/lib/adns/setup.c	Wed Apr  6 06:46:26 2005
@@ -558,7 +558,7 @@
 }
 
 
-int adns__setnonblock(adns_state ads, ADNS_SOCKET fd) {
+int adns__setnonblock(adns_state ads, OS_SOCKET fd) {
 #ifdef WIN32
    unsigned long Val = 1;
    return (ioctlsocket (fd, FIONBIO, &Val) == 0) ? 0 : -1;
@@ -668,7 +668,7 @@
 	return 0;
 
       x_closeudp:
-  adns_socket_close(ads->udpsocket);
+  os_sock_close(ads->udpsocket);
       x_free:
   ns_free(ads);
 #ifdef WIN32
@@ -825,12 +825,12 @@
     if (ads->fdfunc) 
       ads->fdfunc(ads->udpsocket, -1);
 
-  adns_socket_close(ads->udpsocket);
+  os_sock_close(ads->udpsocket);
 	if (ads->tcpsocket >= 0) {
       
 	    if (ads->fdfunc) 
 	        ads->fdfunc(ads->tcpsocket, -1);
-		adns_socket_close(ads->tcpsocket);
+		os_sock_close(ads->tcpsocket);
     }
 	adns__vbuf_free(&ads->tcpsend);
 	adns__vbuf_free(&ads->tcprecv);
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.