[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Cvs-cvs] Changes to ccvs/src/socket-client.c
From: |
Derek Robert Price |
Subject: |
[Cvs-cvs] Changes to ccvs/src/socket-client.c |
Date: |
Sat, 24 Sep 2005 19:57:03 -0400 |
Index: ccvs/src/socket-client.c
diff -u ccvs/src/socket-client.c:1.15 ccvs/src/socket-client.c:1.16
--- ccvs/src/socket-client.c:1.15 Thu May 26 08:24:17 2005
+++ ccvs/src/socket-client.c Sat Sep 24 23:57:02 2005
@@ -23,7 +23,7 @@
#if defined (AUTH_CLIENT_SUPPORT) || defined (HAVE_KERBEROS) || defined
(HAVE_GSSAPI)
struct hostent *
-init_sockaddr( struct sockaddr_in *name, char *hostname, unsigned int port )
+init_sockaddr (struct sockaddr_in *name, char *hostname, unsigned int port)
{
struct hostent *hostinfo;
unsigned short shortport = port;
@@ -32,7 +32,7 @@
name->sin_family = AF_INET;
name->sin_port = htons (shortport);
hostinfo = gethostbyname (hostname);
- if (hostinfo == NULL)
+ if (!hostinfo)
{
fprintf (stderr, "Unknown host %s.\n", hostname);
exit (EXIT_FAILURE);
@@ -73,38 +73,15 @@
int socket;
};
-static int socket_buffer_input (void *, char *, size_t, size_t, size_t *);
-static int socket_buffer_output (void *, const char *, size_t, size_t *);
-static int socket_buffer_flush (void *);
-static int socket_buffer_shutdown (struct buffer *);
-
-
-
-/* Create a buffer based on a socket. */
-
-struct buffer *
-socket_buffer_initialize( int socket, int input,
- void (*memory) ( struct buffer * ) )
-{
- struct socket_buffer *sbuf = xmalloc (sizeof *sbuf);
- sbuf->socket = socket;
- return buf_initialize (input ? socket_buffer_input : NULL,
- input ? NULL : socket_buffer_output,
- input ? NULL : socket_buffer_flush,
- NULL, NULL,
- socket_buffer_shutdown,
- memory,
- sbuf);
-}
-
/* The buffer input function for a buffer built on a socket. */
static int
-socket_buffer_input( void *closure, char *data, size_t need, size_t size,
size_t *got )
+socket_buffer_input (void *closure, char *data, size_t need, size_t size,
+ size_t *got)
{
- struct socket_buffer *sb = (struct socket_buffer *) closure;
+ struct socket_buffer *sb = closure;
int nbytes;
/* I believe that the recv function gives us exactly the semantics
@@ -131,7 +108,8 @@
nbytes = recv (sb->socket, data, size, 0);
if (nbytes < 0)
- error (1, 0, "reading from server: %s", SOCK_STRERROR (SOCK_ERRNO));
+ error (1, 0, "reading from server: %s",
+ SOCK_STRERROR (SOCK_ERRNO));
if (nbytes == 0)
{
/* End of file (for example, the server has closed
@@ -158,9 +136,10 @@
/* The buffer output function for a buffer built on a socket. */
static int
-socket_buffer_output( void *closure, const char *data, size_t have, size_t
*wrote )
+socket_buffer_output (void *closure, const char *data, size_t have,
+ size_t *wrote)
{
- struct socket_buffer *sb = (struct socket_buffer *) closure;
+ struct socket_buffer *sb = closure;
*wrote = have;
@@ -172,7 +151,8 @@
is needed for systems where its return value is something other than
the number of bytes written. */
if (send (sb->socket, data, have, 0) < 0)
- error (1, 0, "writing to server socket: %s", SOCK_STRERROR
(SOCK_ERRNO));
+ error (1, 0, "writing to server socket: %s",
+ SOCK_STRERROR (SOCK_ERRNO));
#else
while (have > 0)
{
@@ -180,7 +160,8 @@
nbytes = send (sb->socket, data, have, 0);
if (nbytes < 0)
- error (1, 0, "writing to server socket: %s", SOCK_STRERROR
(SOCK_ERRNO));
+ error (1, 0, "writing to server socket: %s",
+ SOCK_STRERROR (SOCK_ERRNO));
have -= nbytes;
data += nbytes;
@@ -196,7 +177,7 @@
/*ARGSUSED*/
static int
-socket_buffer_flush( void *closure )
+socket_buffer_flush (void *closure)
{
/* Nothing to do. Sockets are always flushed. */
return 0;
@@ -205,9 +186,9 @@
static int
-socket_buffer_shutdown( struct buffer *buf )
+socket_buffer_shutdown (struct buffer *buf)
{
- struct socket_buffer *n = (struct socket_buffer *) buf->closure;
+ struct socket_buffer *n = buf->closure;
char tmp;
/* no need to flush children of an endpoint buffer here */
@@ -217,9 +198,11 @@
int err = 0;
if (! buf_empty_p (buf)
|| (err = recv (n->socket, &tmp, 1, 0)) > 0)
- error (0, 0, "dying gasps from %s unexpected",
current_parsed_root->hostname);
+ error (0, 0, "dying gasps from %s unexpected",
+ current_parsed_root->hostname);
else if (err == -1)
- error (0, 0, "reading from %s: %s", current_parsed_root->hostname,
SOCK_STRERROR (SOCK_ERRNO));
+ error (0, 0, "reading from %s: %s", current_parsed_root->hostname,
+ SOCK_STRERROR (SOCK_ERRNO));
/* shutdown() socket */
# ifdef SHUTDOWN_SERVER
@@ -227,7 +210,8 @@
# endif
if (shutdown (n->socket, 0) < 0)
{
- error (1, 0, "shutting down server socket: %s", SOCK_STRERROR
(SOCK_ERRNO));
+ error (1, 0, "shutting down server socket: %s",
+ SOCK_STRERROR (SOCK_ERRNO));
}
buf->input = NULL;
@@ -245,13 +229,33 @@
# endif
if (shutdown (n->socket, 1) < 0)
{
- error (1, 0, "shutting down server socket: %s", SOCK_STRERROR
(SOCK_ERRNO));
+ error (1, 0, "shutting down server socket: %s",
+ SOCK_STRERROR (SOCK_ERRNO));
}
buf->output = NULL;
}
return 0;
+}
+
+
+
+/* Create a buffer based on a socket. */
+
+struct buffer *
+socket_buffer_initialize (int socket, int input,
+ void (*memory) (struct buffer *))
+{
+ struct socket_buffer *sbuf = xmalloc (sizeof *sbuf);
+ sbuf->socket = socket;
+ return buf_initialize (input ? socket_buffer_input : NULL,
+ input ? NULL : socket_buffer_output,
+ input ? NULL : socket_buffer_flush,
+ NULL, NULL,
+ socket_buffer_shutdown,
+ memory,
+ sbuf);
}
#endif /* NO_SOCKET_TO_FD */
- [Cvs-cvs] Changes to ccvs/src/socket-client.c,
Derek Robert Price <=