diff -rBbuN larbin-2.6.3-orig/Makefile larbin-2.6.3/Makefile --- larbin-2.6.3-orig/Makefile Sun Apr 14 20:40:11 2002 +++ larbin-2.6.3/Makefile Fri Aug 22 11:08:17 2003 @@ -7,7 +7,7 @@ (cd src; $(MAKE) dep) all debug prof: - (cd adns; $(MAKE)) + (cd adns; $(MAKE); ranlib libadns.a ) (cd src; $(MAKE) $@) cp src/larbin . diff -rBbuN larbin-2.6.3-orig/adns/check.c larbin-2.6.3/adns/check.c --- larbin-2.6.3-orig/adns/check.c Sun Apr 14 20:40:12 2002 +++ larbin-2.6.3/adns/check.c Fri Aug 22 11:08:17 2003 @@ -53,6 +53,15 @@ } \ } while(0) +#define DLIST_ASSERTON_NOPART(node, nodevar, list) \ + do { \ + for ((nodevar)= (list).head; \ + (nodevar) != (node); \ + (nodevar)= (nodevar)-> next) { \ + assert((nodevar)); \ + } \ + } while(0) + static void checkc_query_alloc(adns_state ads, adns_query qu) { allocnode *an; @@ -183,16 +192,16 @@ if (qu) { switch (qu->state) { case query_tosend: - DLIST_ASSERTON(qu, search, ads->udpw, ); + DLIST_ASSERTON_NOPART(qu, search, ads->udpw); break; case query_tcpw: - DLIST_ASSERTON(qu, search, ads->tcpw, ); + DLIST_ASSERTON_NOPART(qu, search, ads->tcpw); break; case query_childw: - DLIST_ASSERTON(qu, search, ads->childw, ); + DLIST_ASSERTON_NOPART(qu, search, ads->childw); break; case query_done: - DLIST_ASSERTON(qu, search, ads->output, ); + DLIST_ASSERTON_NOPART(qu, search, ads->output); break; default: assert(!"specific query state"); diff -rBbuN larbin-2.6.3-orig/adns/dlist.h larbin-2.6.3/adns/dlist.h --- larbin-2.6.3-orig/adns/dlist.h Wed Jan 2 11:44:51 2002 +++ larbin-2.6.3/adns/dlist.h Fri Aug 22 11:08:17 2003 @@ -47,7 +47,21 @@ (list).tail= (node); \ } while(0) -#define LIST_UNLINK(list,node) LIST_UNLINK_PART(list,node,) -#define LIST_LINK_TAIL(list,node) LIST_LINK_TAIL_PART(list,node,) +#define LIST_UNLINK(list,node) \ + do { \ + if ((node)-> back) (node)-> back-> next= (node)-> next; \ + else (list).head= (node)-> next; \ + if ((node)-> next) (node)-> next-> back= (node)-> back; \ + else (list).tail= (node)-> back; \ + } while(0) + + +#define LIST_LINK_TAIL(list,node) \ + do { \ + (node)-> next= 0; \ + (node)-> back= (list).tail; \ + if ((list).tail) (list).tail-> next= (node); else (list).head= (node); \ + (list).tail= (node); \ + } while(0) #endif diff -rBbuN larbin-2.6.3-orig/src/fakepoll.h larbin-2.6.3/src/fakepoll.h --- larbin-2.6.3-orig/src/fakepoll.h Thu Jan 1 01:00:00 1970 +++ larbin-2.6.3/src/fakepoll.h Fri Aug 22 11:08:23 2003 @@ -0,0 +1,165 @@ +// fakepoll.h +// poll using select +// Warning: a call to this poll() takes about 4K of stack space. + +// Greg Parker gparker-web@sealiesoftware.com December 2000 +// This code is in the public domain and may be copied or modified without +// permission. + +// Updated May 2002: +// * fix crash when an fd is less than 0 +// * set errno=EINVAL if an fd is greater or equal to FD_SETSIZE +// * don't set POLLIN or POLLOUT in revents if it wasn't requested +// in events (only happens when an fd is in the poll set twice) + +#ifndef _FAKE_POLL_H +#define _FAKE_POLL_H + +#include +#ifndef FD_SETSIZE +#define FD_SETSIZE OPEN_MAX +#endif +#include +#include +#include +#include +#include +#include + +typedef struct pollfd { + int fd; /* file desc to poll */ + short events; /* events of interest on fd */ + short revents; /* events that occurred on fd */ +} pollfd_t; + + +// poll flags +#define POLLIN 0x0001 +#define POLLOUT 0x0004 +#define POLLERR 0x0008 + +// synonyms +#define POLLNORM POLLIN +#define POLLPRI POLLIN +#define POLLRDNORM POLLIN +#define POLLRDBAND POLLIN +#define POLLWRNORM POLLOUT +#define POLLWRBAND POLLOUT + +// ignored +#define POLLHUP 0x0010 +#define POLLNVAL 0x0020 + +inline int poll(struct pollfd *pollSet, int pollCount, int pollTimeout) +{ + struct timeval tv; + struct timeval *tvp; + fd_set readFDs, writeFDs, exceptFDs; + fd_set *readp, *writep, *exceptp; + struct pollfd *pollEnd, *p; + int selected; + int result; + int maxFD; + + if (!pollSet) { + pollEnd = NULL; + readp = NULL; + writep = NULL; + exceptp = NULL; + maxFD = 0; + } + else { + pollEnd = pollSet + pollCount; + readp = &readFDs; + writep = &writeFDs; + exceptp = &exceptFDs; + + FD_ZERO(readp); + FD_ZERO(writep); + FD_ZERO(exceptp); + + // Find the biggest fd in the poll set + maxFD = 0; + for (p = pollSet; p < pollEnd; p++) { + if (p->fd > maxFD) maxFD = p->fd; + } + + if (maxFD >= FD_SETSIZE) { + // At least one fd is too big + errno = EINVAL; + return -1; + } + + // Transcribe flags from the poll set to the fd sets + for (p = pollSet; p < pollEnd; p++) { + if (p->fd < 0) { + // Negative fd checks nothing and always reports zero + } else { + if (p->events & POLLIN) FD_SET(p->fd, readp); + if (p->events & POLLOUT) FD_SET(p->fd, writep); + if (p->events != 0) FD_SET(p->fd, exceptp); + // POLLERR is never set coming in; poll() always reports errors + // But don't report if we're not listening to anything at all. + } + } + } + + // poll timeout is in milliseconds. Convert to struct timeval. + // poll timeout == -1 : wait forever : select timeout of NULL + // poll timeout == 0 : return immediately : select timeout of zero + if (pollTimeout >= 0) { + tv.tv_sec = pollTimeout / 1000; + tv.tv_usec = (pollTimeout % 1000) * 1000; + tvp = &tv; + } else { + tvp = NULL; + } + + + selected = select(maxFD+1, readp, writep, exceptp, tvp); + + + if (selected < 0) { + // Error during select + result = -1; + } + else if (selected > 0) { + // Select found something + // Transcribe result from fd sets to poll set. + // Also count the number of selected fds. poll returns the + // number of ready fds; select returns the number of bits set. + int polled = 0; + for (p = pollSet; p < pollEnd; p++) { + p->revents = 0; + if (p->fd < 0) { + // Negative fd always reports zero + } else { + if ((p->events & POLLIN) && FD_ISSET(p->fd, readp)) { + p->revents |= POLLIN; + } + if ((p->events & POLLOUT) && FD_ISSET(p->fd, writep)) { + p->revents |= POLLOUT; + } + if ((p->events != 0) && FD_ISSET(p->fd, exceptp)) { + p->revents |= POLLERR; + } + + if (p->revents) polled++; + } + } + result = polled; + } + else { + // selected == 0, select timed out before anything happened + // Clear all result bits and return zero. + for (p = pollSet; p < pollEnd; p++) { + p->revents = 0; + } + result = 0; + } + + return result; +} + + +#endif diff -rBbuN larbin-2.6.3-orig/src/fetch/fetchOpen.cc larbin-2.6.3/src/fetch/fetchOpen.cc --- larbin-2.6.3-orig/src/fetch/fetchOpen.cc Wed Jan 2 11:44:53 2002 +++ larbin-2.6.3/src/fetch/fetchOpen.cc Fri Aug 22 11:08:17 2003 @@ -4,7 +4,7 @@ #include #include -#include +#include #include diff -rBbuN larbin-2.6.3-orig/src/fetch/fetchPipe.cc larbin-2.6.3/src/fetch/fetchPipe.cc --- larbin-2.6.3-orig/src/fetch/fetchPipe.cc Wed Apr 3 20:20:04 2002 +++ larbin-2.6.3/src/fetch/fetchPipe.cc Fri Aug 22 11:08:17 2003 @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -24,6 +24,13 @@ #include "interf/output.h" #include "utils/debug.h" + +/* hackery for MacOS X */ +#ifdef __APPLE__ +#ifdef __MACH__ +typedef unsigned int socklen_t; +#endif +#endif static void pipeRead (Connexion *conn); static void pipeWrite (Connexion *conn); diff -rBbuN larbin-2.6.3-orig/src/global.h larbin-2.6.3/src/global.h --- larbin-2.6.3-orig/src/global.h Tue Jul 8 22:25:24 2003 +++ larbin-2.6.3/src/global.h Fri Aug 22 11:08:17 2003 @@ -10,7 +10,16 @@ #include #include #include + +#ifdef __APPLE__ +#ifdef __MACH__ +#include "fakepoll.h" +#endif +#endif + +#ifndef POLLIN #include +#endif #include diff -rBbuN larbin-2.6.3-orig/src/interf/input.cc larbin-2.6.3/src/interf/input.cc --- larbin-2.6.3-orig/src/interf/input.cc Sun Mar 17 10:28:27 2002 +++ larbin-2.6.3/src/interf/input.cc Fri Aug 22 11:08:17 2003 @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include "options.h" @@ -15,6 +15,13 @@ #include "utils/text.h" #include "utils/debug.h" #include "interf/input.h" + +/* hackery for MacOS X */ +#ifdef __APPLE__ +#ifdef __MACH__ +typedef unsigned int socklen_t; +#endif +#endif #define INIT -1 #define END -2 diff -rBbuN larbin-2.6.3-orig/src/utils/url.cc larbin-2.6.3/src/utils/url.cc --- larbin-2.6.3-orig/src/utils/url.cc Tue Mar 26 20:15:16 2002 +++ larbin-2.6.3/src/utils/url.cc Fri Aug 22 11:08:17 2003 @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include "options.h" diff -rBbuN larbin-2.6.3-orig/src/utils/url.h larbin-2.6.3/src/utils/url.h --- larbin-2.6.3-orig/src/utils/url.h Sat Mar 23 10:06:06 2002 +++ larbin-2.6.3/src/utils/url.h Fri Aug 22 11:08:17 2003 @@ -8,7 +8,7 @@ #define URL_H #include -#include +#include #include #include