diff options
author | Russ Allbery <rra@stanford.edu> | 2013-02-22 12:57:45 -0800 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2013-02-22 16:49:54 -0800 |
commit | 51c3c86d3ff2d4c0be736b67613da9dad4a284be (patch) | |
tree | 97cd93ba8f3e07fd042aec46b5669496fef71cb4 /client | |
parent | 085f0b66214099779e795577da0bcad3f2ef4740 (diff) |
Coding style and improvements to new remctl_open_*
Fix various warnings. Pre-declare the addrinfo and sockaddr structs
in remctl.h so that the header is still standalone. Install symlinks
for the manual page for the new documented APIs. Add the new functions
to the symbol export maps. Make network_connect more const-correct.
Change-Id: I1fbc5e62444161957dca24b9f85b3bb0ed22719a
Reviewed-on: https://gerrit.stanford.edu/810
Tested-by: Russ Allbery <rra@stanford.edu>
Reviewed-by: Russ Allbery <rra@stanford.edu>
Diffstat (limited to 'client')
-rw-r--r-- | client/api.c | 23 | ||||
-rw-r--r-- | client/libremctl.map | 3 | ||||
-rw-r--r-- | client/libremctl.sym | 3 | ||||
-rw-r--r-- | client/remctl.h | 26 |
4 files changed, 30 insertions, 25 deletions
diff --git a/client/api.c b/client/api.c index ed9312f..5f4cbb7 100644 --- a/client/api.c +++ b/client/api.c @@ -11,7 +11,7 @@ * * Written by Russ Allbery <rra@stanford.edu> * Based on work by Anton Ushakov - * Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 + * Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012, 2013 * The Board of Trustees of the Leland Stanford Junior University * * See LICENSE for licensing terms. @@ -29,6 +29,7 @@ #include <client/internal.h> #include <client/remctl.h> #include <util/macros.h> +#include <util/network.h> /* @@ -369,7 +370,7 @@ remctl_open(struct remctl *r, const char *host, unsigned short port, */ int remctl_open_addrinfo(struct remctl *r, const char *host, - const struct addrinfo *ai, const char *principal) + const struct addrinfo *ai, const char *principal) { socket_type fd = INVALID_SOCKET; @@ -398,8 +399,8 @@ remctl_open_addrinfo(struct remctl *r, const char *host, */ int remctl_open_sockaddr(struct remctl *r, const char *host, - const struct sockaddr *addr, int addrlen, - const char *principal) + const struct sockaddr *addr, int addrlen, + const char *principal) { struct addrinfo ai; @@ -408,8 +409,7 @@ remctl_open_sockaddr(struct remctl *r, const char *host, ai.ai_socktype = SOCK_STREAM; ai.ai_protocol = IPPROTO_TCP; ai.ai_addrlen = addrlen; - ai.ai_addr = addr; - + ai.ai_addr = (struct sockaddr *) addr; return remctl_open_addrinfo(r, host, &ai, principal); } @@ -419,21 +419,14 @@ remctl_open_sockaddr(struct remctl *r, const char *host, * and principal. At least one of host or principal is required. * Returns true on success and false on failure. */ -#ifdef _WIN32 -int -remctl_open_fd(struct remctl *r, const char *host, SOCKET fd, - const char *principal) -#else int -remctl_open_fd(struct remctl *r, const char *host, int fd, - const char *principal) -#endif +remctl_open_fd(struct remctl *r, const char *host, socket_type fd, + const char *principal) { internal_reset(r); r->host = NULL; r->port = 0; r->principal = principal; - r->fd = fd; return internal_open(r, host, principal); } diff --git a/client/libremctl.map b/client/libremctl.map index 8cfa11c..d6e2aaa 100644 --- a/client/libremctl.map +++ b/client/libremctl.map @@ -8,6 +8,9 @@ REMCTL_1.0 { remctl_new; remctl_noop; remctl_open; + remctl_open_addrinfo; + remctl_open_fd; + remctl_open_sockaddr; remctl_output; remctl_result_free; remctl_set_ccache; diff --git a/client/libremctl.sym b/client/libremctl.sym index d49dbae..7f9efcd 100644 --- a/client/libremctl.sym +++ b/client/libremctl.sym @@ -6,6 +6,9 @@ remctl_error remctl_new remctl_noop remctl_open +remctl_open_addrinfo +remctl_open_fd +remctl_open_sockaddr remctl_output remctl_result_free remctl_set_ccache diff --git a/client/remctl.h b/client/remctl.h index 7667837..c418ad1 100644 --- a/client/remctl.h +++ b/client/remctl.h @@ -3,7 +3,7 @@ * * Written by Russ Allbery <rra@stanford.edu> * Based on prior work by Anton Ushakov - * Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 + * Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012, 2013 * The Board of Trustees of the Leland Stanford Junior University * * Permission is hereby granted, free of charge, to any person obtaining a @@ -46,6 +46,10 @@ struct iovec { struct iovec; #endif +/* Forward declarations of socket structs for alternate remctl_open APIs. */ +struct addrinfo; +struct sockaddr; + /* * BEGIN_DECLS is used at the beginning of declarations so that C++ * compilers don't mangle their names. END_DECLS is used at the end. @@ -125,23 +129,25 @@ void remctl_close(struct remctl *); /* * Some alternate interfaces for opening connections. In each of these, - * principal may be NULL, in which case host/<host> is used, as for the - * basic remctl_open. If principal is not NULL, then host is not used - * and may be NULL. Connections established using these interfaces do - * not support automatic connection reopening, which means they cannot - * be used to send more than one command to a v1 server. + * principal may be NULL, in which case host/<host> is used, as for the basic + * remctl_open. If principal is not NULL, then host is not used and may be + * NULL. Connections established using these interfaces do not support + * automatic connection reopening, which means they cannot be used to send + * more than one command to a v1 server. */ int remctl_open_addrinfo(struct remctl *r, const char *host, const struct addrinfo *ai, const char *principal); int remctl_open_sockaddr(struct remctl *r, const char *host, const struct sockaddr *addr, int addrlen, const char *principal); + +/* Windows uses a SOCKET type for sockets instead of an integer. */ #ifdef _WIN32 -int remctl_open_fd(struct remctl *r, const char *host, - SOCKET fd, const char *principal); +int remctl_open_fd(struct remctl *r, const char *host, SOCKET fd, + const char *principal); #else -int remctl_open_fd(struct remctl *r, const char *host, - int fd, const char *principal); +int remctl_open_fd(struct remctl *r, const char *host, int fd, + const char *principal); #endif |