ret = init_unix_addr(&unix_addr, conf.afs_socket_arg);
if (ret < 0)
goto out;
- ret = -E_CONNECT;
- if (connect(fd, (struct sockaddr *)&unix_addr, sizeof(unix_addr)) < 0) /* FIXME: Use para_connect() */
+ ret = PARA_CONNECT(fd, &unix_addr);
+ if (ret < 0)
goto out;
ret = send_bin_buffer(fd, buf, sizeof(buf));
if (ret < 0)
#include "audioc.cmdline.h"
#include "para.h"
+#include "error.h"
#include "net.h"
#include "string.h"
#include "fd.h"
-#include "error.h"
INIT_AUDIOC_ERRLISTS;
ret = -E_INIT_SOCK_ADDR;
if (init_unix_addr(&unix_addr, socket_name) < 0)
goto out;
- ret = -E_AUDIOC_CONNECT;
- if (connect(fd, (struct sockaddr *)&unix_addr, UNIX_PATH_MAX) < 0) /* FIXME: Use para_connect() */
+ ret = PARA_CONNECT(fd, &unix_addr);
+ if (ret < 0)
goto out;
ret = send_cred_buffer(fd, args);
if (ret < 0)
/** \file audiod.c the paraslash's audio daemon */
#include "para.h"
-
+#include "error.h"
#include "audiod.cmdline.h"
#include "list.h"
#include "sched.h"
#include "fd.h"
#include "write.h"
#include "write_common.h"
-#include "error.h"
#include "signal.h"
/** define the array of error lists needed by para_audiod */
/** \file client_common.c common functions of para_client and para_audiod */
#include "para.h"
+#include "error.h"
#include "list.h"
#include "sched.h"
#include "client.cmdline.h"
#include "string.h"
#include "client.cmdline.h"
#include "client.h"
-#include "error.h"
/*
* rc4 encrypt data before sending
pcd->fd = ret;
/* init their_addr */
init_sockaddr(&their_addr, pcd->conf.server_port_arg, he);
- ret = para_connect(pcd->fd, &their_addr);
+ ret = PARA_CONNECT(pcd->fd, &their_addr);
if (ret < 0)
goto err_out;
pcd->status = CL_CONNECTED;
if (ret < 0)
goto err_out;
PARA_NOTICE_LOG("connecting to %s:%d\n", conf->host_arg, conf->port_arg);
- ret = connect(pdd->fd, ai->ai_addr, ai->ai_addrlen);
+ ret = PARA_CONNECT(pdd->fd, ai->ai_addr);
freeaddrinfo(ai);
if (ret < 0) {
ret = -E_DCCP_CONNECT;
*/
#include "para.h"
+#include "error.h"
#include "afh.h"
#include "server.h"
#include "net.h"
#include "vss.h"
#include "send.h"
#include "dccp.h"
-#include "error.h"
#include "string.h"
#include "fd.h"
#include "close_on_fork.h"
/** \file http_recv.c paraslash's http receiver */
#include "para.h"
-
+#include "error.h"
#include "http.h"
#include "list.h"
#include "sched.h"
#include "recv.h"
#include "http_recv.cmdline.h"
-#include "error.h"
#include "net.h"
#include "string.h"
#include "fd.h"
phd->fd = ret;
/* init their_addr */
init_sockaddr(&their_addr, conf->port_arg, he);
- /* connect */
PARA_NOTICE_LOG("connecting to %s:%d\n", conf->host_arg,
conf->port_arg);
- ret = para_connect(phd->fd, &their_addr);
+ ret = PARA_CONNECT(phd->fd, &their_addr);
if (ret < 0) {
close(phd->fd);
goto err_out;
/** \file net.c networking-related helper functions */
+#include "error.h"
#include "para.h"
#include "net.h"
#include "string.h"
-#include "error.h"
/** Information about one encrypted connection. */
return socket_fd;
}
-/**
- * a wrapper around connect(2)
- *
- * \param fd the file descriptor
- * \param their_addr the address to connect
- *
- * \return \p -E_CONNECT on errors, 1 on success
- *
- * \sa connect(2)
- */
-int para_connect(int fd, struct sockaddr_in *their_addr)
-{
- int ret;
-
- if ((ret = connect(fd, (struct sockaddr *)their_addr,
- sizeof(struct sockaddr))) == -1)
- return -E_CONNECT;
- return 1;
-}
-
/**
* paraslash's wrapper around the accept system call
*
int get_host_info(char *host, struct hostent **ret);
int get_stream_socket(int domain);
void init_sockaddr(struct sockaddr_in*, int, const struct hostent*);
-int para_connect(int fd, struct sockaddr_in *their_addr);
int send_buffer(int, const char *);
int send_bin_buffer(int, const char *, size_t);
__printf_2_3 int send_va_buffer(int fd, const char *fmt, ...);
void *private_data);
void disable_crypt(int fd);
+/**
+ * A wrapper around connect(2).
+ *
+ * \param fd The file descriptor.
+ * \param their_addr The address to connect.
+ *
+ * This should not be called directly. Always use the PARA_CONNECT macro.
+ *
+ * \return \p -E_CONNECT on errors, 1 on success.
+ *
+ * \sa connect(2), PARA_CONNECT.
+ */
+_static_inline_ int _para_connect(int fd, void *addr, socklen_t len)
+{
+ if (connect(fd, (struct sockaddr *)addr, len) == -1)
+ return -E_CONNECT;
+ return 1;
+}
+
+/** A macro for connect() which does not need a \a len parameter. */
+#define PARA_CONNECT(fd, addr) _para_connect(fd, addr, sizeof(*(addr)))