bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

socket-client.c doesn't need to compile on UNIX.


From: Derek Price
Subject: socket-client.c doesn't need to compile on UNIX.
Date: Sat, 24 Sep 2005 20:26:21 -0400
User-agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)

I've committed the attached patch.  I'm going to follow it shortly with
the a harmless reformatting patch.  I would like to remove the lines
below from socket-client.h, as I think whatever #defines SOCK_STRERROR
to some other function than strerror should know what headers it needs
and should already have included them where needed, but I am afraid of
breaking the Windows build, so if you could verify that it is okay, when
you get the chance, Conrad, I would appreciate it.

# if defined SOCK_ERRNO || defined SOCK_STRERROR
#   ifdef HAVE_WINSOCK_H
#     include <winsock.h>
#   else /* No winsock.h */
#     include <sys/socket.h>
#     include <netinet/in.h>
#     include <arpa/inet.h>
#     include <netdb.h>
#   endif /* No winsock.h */
# endif


Thanks,

Derek

-- 
Derek R. Price
CVS Solutions Architect
Ximbiot <http://ximbiot.com>
v: +1 717.579.6168
f: +1 717.234.3125
<mailto:derek@ximbiot.com>

Index: src/Makefile.am
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/Makefile.am,v
retrieving revision 1.46
diff -u -p -r1.46 Makefile.am
--- src/Makefile.am     1 Feb 2005 22:20:06 -0000       1.46
+++ src/Makefile.am     25 Sep 2005 00:21:45 -0000
@@ -76,7 +76,6 @@ cvs_SOURCES = \
        run.c \
        scramble.c \
        server.c \
-       socket-client.c socket-client.h \
        stack.c stack.h \
        status.c \
        subr.c subr.h \
@@ -103,7 +102,8 @@ cvs_SOURCES = \
        watch.h
 
 EXTRA_cvs_SOURCES = gssapi-client.c gssapi-client.h \
-                    kerberos4-client.c kerberos4-client.h
+                    kerberos4-client.c kerberos4-client.h \
+                   socket-client.c socket-client.h
 
 cvs_DEPENDENCIES = $(cvs_client_objects) \
        ../diff/libdiff.a \
Index: src/client.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/client.c,v
retrieving revision 1.430
diff -u -p -r1.430 client.c
--- src/client.c        23 Sep 2005 03:19:22 -0000      1.430
+++ src/client.c        25 Sep 2005 00:21:47 -0000
@@ -5174,4 +5174,31 @@ send_init_command (void)
     send_to_server ("\012", 0);
 }
 
+
+
+#if defined AUTH_CLIENT_SUPPORT || defined HAVE_KERBEROS || defined HAVE_GSSAPI
+
+struct hostent *
+init_sockaddr (struct sockaddr_in *name, char *hostname, unsigned int port)
+{
+    struct hostent *hostinfo;
+    unsigned short shortport = port;
+
+    memset (name, 0, sizeof (*name));
+    name->sin_family = AF_INET;
+    name->sin_port = htons (shortport);
+    hostinfo = gethostbyname (hostname);
+    if (!hostinfo)
+    {
+       fprintf (stderr, "Unknown host %s.\n", hostname);
+       exit (EXIT_FAILURE);
+    }
+    name->sin_addr = *(struct in_addr *) hostinfo->h_addr;
+    return hostinfo;
+}
+
+#endif /* defined AUTH_CLIENT_SUPPORT || defined HAVE_KERBEROS
+       * || defined HAVE_GSSAPI
+       */
+
 #endif /* CLIENT_SUPPORT */
Index: src/client.h
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/client.h,v
retrieving revision 1.58
diff -u -p -r1.58 client.h
--- src/client.h        13 Jul 2005 17:06:35 -0000      1.58
+++ src/client.h        25 Sep 2005 00:21:47 -0000
@@ -209,4 +209,17 @@ int client_process_import_file
 void client_import_done (void);
 void client_notify (const char *, const char *, const char *, int,
                     const char *);
+
+#if defined AUTH_CLIENT_SUPPORT || defined HAVE_KERBEROS || defined HAVE_GSSAPI
+# ifdef HAVE_WINSOCK_H
+#  include <winsock.h>
+# else /* No winsock.h */
+#  include <sys/socket.h>
+#  include <netinet/in.h>
+#  include <arpa/inet.h>
+#  include <netdb.h>
+# endif /* No winsock.h */
+struct hostent *init_sockaddr (struct sockaddr_in *, char *, unsigned int);
+#endif
+
 #endif /* CLIENT_SUPPORT */
Index: src/socket-client.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/socket-client.c,v
retrieving revision 1.17
diff -u -p -r1.17 socket-client.c
--- src/socket-client.c 25 Sep 2005 00:05:12 -0000      1.17
+++ src/socket-client.c 25 Sep 2005 00:21:47 -0000
@@ -10,40 +10,21 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.  */
 
-#include <config.h>
+/***
+ *** THIS FILE SHOULD NEVER BE COMPILED UNLESS NO_SOCKET_TO_FD IS DEFINED.
+ ***/
 
-#include "cvs.h"
-#include "buffer.h"
+#ifdef HAVE_CONFIG
+# include <config.h>
+#endif
 
 #ifdef CLIENT_SUPPORT
 
-#include "socket-client.h"
-
-
-#if defined (AUTH_CLIENT_SUPPORT) || defined (HAVE_KERBEROS) || defined 
(HAVE_GSSAPI)
-
-struct hostent *
-init_sockaddr (struct sockaddr_in *name, char *hostname, unsigned int port)
-{
-    struct hostent *hostinfo;
-    unsigned short shortport = port;
-
-    memset (name, 0, sizeof (*name));
-    name->sin_family = AF_INET;
-    name->sin_port = htons (shortport);
-    hostinfo = gethostbyname (hostname);
-    if (!hostinfo)
-    {
-       fprintf (stderr, "Unknown host %s.\n", hostname);
-       exit (EXIT_FAILURE);
-    }
-    name->sin_addr = *(struct in_addr *) hostinfo->h_addr;
-    return hostinfo;
-}
+#include "cvs.h"
+#include "buffer.h"
 
-#endif
+#include "socket-client.h"
 
-#ifdef NO_SOCKET_TO_FD
 
 /* Under certain circumstances, we must communicate with the server
    via a socket using send() and recv().  This is because under some
@@ -256,7 +237,5 @@ socket_buffer_initialize (int socket, in
                           memory,
                           sbuf);
 }
-
-#endif /* NO_SOCKET_TO_FD */
 
 #endif /* CLIENT_SUPPORT */
Index: src/socket-client.h
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/socket-client.h,v
retrieving revision 1.6
diff -u -p -r1.6 socket-client.h
--- src/socket-client.h 23 Jul 2003 20:42:26 -0000      1.6
+++ src/socket-client.h 25 Sep 2005 00:21:47 -0000
@@ -13,12 +13,7 @@
 #ifndef SOCKET_CLIENT_H__
 #define SOCKET_CLIENT_H__ 1
 
-#include <config.h>
-
-struct buffer *socket_buffer_initialize
-  (int, int, void (*) (struct buffer *));
-
-# if defined(AUTH_CLIENT_SUPPORT) || defined(HAVE_KERBEROS) || 
defined(HAVE_GSSAPI) || defined(SOCK_ERRNO) || defined(SOCK_STRERROR)
+# if defined SOCK_ERRNO || defined SOCK_STRERROR
 #   ifdef HAVE_WINSOCK_H
 #     include <winsock.h>
 #   else /* No winsock.h */
@@ -29,6 +24,9 @@ struct buffer *socket_buffer_initialize
 #   endif /* No winsock.h */
 # endif
 
+struct buffer *socket_buffer_initialize
+  (int, int, void (*) (struct buffer *));
+
 /* If SOCK_ERRNO is defined, then send()/recv() and other socket calls
    do not set errno, but that this macro should be used to obtain an
    error code.  This probably doesn't make sense unless
@@ -43,15 +41,10 @@ struct buffer *socket_buffer_initialize
 # ifndef SOCK_STRERROR
 #   define SOCK_STRERROR strerror
 
-#   if STDC_HEADERS
-#     include <string.h>
-#   endif
-
+#   include <string.h>
 #   ifndef strerror
 extern char *strerror (int);
 #   endif
 # endif /* ! SOCK_STRERROR */
-
-struct hostent *init_sockaddr (struct sockaddr_in *, char *, unsigned int);
 
 #endif /* SOCKET_CLIENT_H__ */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]