X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=jbsockets.c;h=1a6485dfb8c865aebe9237d0f7e7421582d79e23;hp=7648c2bafab68b06a9d24e5ef7ec6b67f94a48f3;hb=e4aec8092bcef36685f4ce01ed83de1c024ba252;hpb=34bf407d7722634d6363c46dd4d0df00f53732ef diff --git a/jbsockets.c b/jbsockets.c index 7648c2ba..1a6485df 100644 --- a/jbsockets.c +++ b/jbsockets.c @@ -1,15 +1,15 @@ -const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.24 2002/03/07 03:51:36 oes Exp $"; +const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.33 2002/04/03 16:02:18 gliptak Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $ * * Purpose : Contains wrappers for system-specific sockets code, - * so that the rest of JunkBuster can be more + * so that the rest of Junkbuster can be more * OS-independent. Contains #ifdefs to make this work * on many platforms. * * Copyright : Written by and Copyright (C) 2001 the SourceForge - * IJBSWA team. http://ijbswa.sourceforge.net + * Privoxy team. http://www.privoxy.org/ * * Based on the Internet Junkbuster originally written * by and Copyright (C) 1997 Anonymous Coders and @@ -35,12 +35,63 @@ const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.24 2002/03/07 03:51:36 oes Ex * * Revisions : * $Log: jbsockets.c,v $ + * Revision 1.33 2002/04/03 16:02:18 gliptak + * Correcting compile warning with older gcc + * + * Revision 1.32 2002/03/31 17:18:59 jongfoster + * Win32 only: Enabling STRICT to fix a VC++ compile warning. + * + * Revision 1.31 2002/03/29 03:33:13 david__schmidt + * Fix Mac OSX compiler warnings + * + * Revision 1.30 2002/03/27 14:32:43 david__schmidt + * More compiler warning message maintenance + * + * Revision 1.29 2002/03/26 22:29:54 swa + * we have a new homepage! + * + * Revision 1.28 2002/03/24 13:25:43 swa + * name change related issues + * + * Revision 1.27 2002/03/13 00:27:05 jongfoster + * Killing warnings + * + * Revision 1.26 2002/03/11 22:07:02 david__schmidt + * OS/2 port maintenance: + * - Fixed EMX build - it had decayed a little + * - Fixed inexplicable crash during FD_ZERO - must be due to a bad macro. + * substituted a memset for now. + * + * Revision 1.25 2002/03/09 20:03:52 jongfoster + * - Making various functions return int rather than size_t. + * (Undoing a recent change). Since size_t is unsigned on + * Windows, functions like read_socket that return -1 on + * error cannot return a size_t. + * + * THIS WAS A MAJOR BUG - it caused frequent, unpredictable + * crashes, and also frequently caused JB to jump to 100% + * CPU and stay there. (Because it thought it had just + * read ((unsigned)-1) == 4Gb of data...) + * + * - The signature of write_socket has changed, it now simply + * returns success=0/failure=nonzero. + * + * - Trying to get rid of a few warnings --with-debug on + * Windows, I've introduced a new type "jb_socket". This is + * used for the socket file descriptors. On Windows, this + * is SOCKET (a typedef for unsigned). Everywhere else, it's + * an int. The error value can't be -1 any more, so it's + * now JB_INVALID_SOCKET (which is -1 on UNIX, and in + * Windows it maps to the #define INVALID_SOCKET.) + * + * - The signature of bind_port has changed. + * * Revision 1.24 2002/03/07 03:51:36 oes * - Improved handling of failed DNS lookups * - Fixed compiler warnings etc * * Revision 1.23 2002/03/05 00:36:01 jongfoster - * Fixing bug 514988 - unable to restart JunkBuster + * Fixing bug 514988 - unable to restart Junkbuster * * Revision 1.22 2002/03/04 02:08:02 david__schmidt * Enable web editing of actions file on OS/2 (it had been broken all this time!) @@ -134,6 +185,9 @@ const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.24 2002/03/07 03:51:36 oes Ex #ifdef _WIN32 +#ifndef STRICT +#define STRICT +#endif #include #include #include @@ -160,8 +214,10 @@ const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.24 2002/03/07 03:51:36 oes Ex #if defined(__EMX__) || defined (__OS2__) #include /* OS/2/EMX needs a little help with select */ +#ifdef __OS2__ #include #endif +#endif #endif @@ -334,7 +390,7 @@ jb_socket connect_to(const char *host, int portnum, struct client_state *csp) * nonzero on error. * *********************************************************************/ -int write_socket(jb_socket fd, const char *buf, int len) +int write_socket(jb_socket fd, const char *buf, size_t len) { if (len == 0) { @@ -348,7 +404,9 @@ int write_socket(jb_socket fd, const char *buf, int len) log_error(LOG_LEVEL_LOG, "%N", len, buf); -#if defined(_WIN32) || defined(__BEOS__) || defined(AMIGA) +#if defined(_WIN32) + return (send(fd, buf, (int)len, 0) != (int)len); +#elif defined(__BEOS__) || defined(AMIGA) return (send(fd, buf, len, 0) != len); #elif defined(__OS2__) /* @@ -410,10 +468,12 @@ int read_socket(jb_socket fd, char *buf, int len) return(0); } -#if defined(_WIN32) || defined(__BEOS__) || defined(AMIGA) || defined(__OS2__) +#if defined(_WIN32) return(recv(fd, buf, len, 0)); +#elif defined(__BEOS__) || defined(AMIGA) || defined(__OS2__) + return(recv(fd, buf, (size_t)len, 0)); #else - return(read(fd, buf, len)); + return(read(fd, buf, (size_t)len)); #endif } @@ -509,11 +569,11 @@ int bind_port(const char *hostnam, int portnum, jb_socket *pfd) #ifndef _WIN32 /* * This is not needed for Win32 - in fact, it stops - * duplicate instances of JunkBuster from being caught. + * duplicate instances of Junkbuster from being caught. * * On UNIX, we assume the user is sensible enough not - * to start JunkBuster multiple times on the same IP. - * Without this, stopping and restarting JunkBuster + * to start Junkbuster multiple times on the same IP. + * Without this, stopping and restarting Junkbuster * from a script fails. * Note: SO_REUSEADDR is meant to only take over * sockets which are *not* in listen state in Linux, @@ -574,7 +634,12 @@ int accept_connection(struct client_state * csp, jb_socket fd) struct sockaddr_in client, server; struct hostent *host = NULL; jb_socket afd; - size_t c_length, s_length; +#if defined(_WIN32) || defined(__OS2__) || defined(__APPLE_CC__) + /* Wierdness - fix a warning. */ + int c_length, s_length; +#else + socklen_t c_length, s_length; +#endif #if defined(HAVE_GETHOSTBYADDR_R_8_ARGS) || defined(HAVE_GETHOSTBYADDR_R_7_ARGS) || defined(HAVE_GETHOSTBYADDR_R_5_ARGS) struct hostent result; #if defined(HAVE_GETHOSTBYADDR_R_5_ARGS)