#include "bacula.h"
#include "jcr.h"
+#include <netdb.h>
extern time_t watchdog_time;
#define ENODATA EPIPE
#endif
-
+#ifdef HAVE_WIN32
+#define socketRead(fd, buf, len) recv(fd, buf, len, 0)
+#define socketWrite(fd, buf, len) send(fd, buf, len, 0)
+#else
+#define socketRead(fd, buf, len) read(fd, buf, len)
+#define socketWrite(fd, buf, len) write(fd, buf, len)
+#endif
/*
while (nleft > 0) {
do {
errno = 0;
- nread = read(bsock->fd, ptr, nleft);
+ nread = socketRead(bsock->fd, ptr, nleft);
if (bsock->timed_out || bsock->terminated) {
return nread;
}
while (nleft > 0) {
do {
errno = 0;
- nwritten = write(bsock->fd, ptr, nleft);
+ nwritten = socketWrite(bsock->fd, ptr, nleft);
if (bsock->timed_out || bsock->terminated) {
return nwritten;
}
#define NO_DATA 4 /* Valid name, no data record of requested type. */
#endif
-extern int h_errno; /* On error has one of the above */
-
/*
* Get human readable error for gethostbyname()
*/
-static char *gethost_strerror()
+static const char *gethost_strerror()
{
switch (h_errno) {
case NETDB_INTERNAL:
* ***FIXME*** implement service from /etc/services
*/
static BSOCK *
-bnet_open(JCR *jcr, char *name, char *host, char *service, int port, int *fatal)
+bnet_open(JCR *jcr, const char *name, char *host, char *service, int port, int *fatal)
{
int sockfd;
struct sockaddr_in tcp_serv_addr; /* socket information */
* Try to connect to host for max_retry_time at retry_time intervals.
*/
BSOCK *
-bnet_connect(JCR *jcr, int retry_interval, int max_retry_time, char *name,
+bnet_connect(JCR *jcr, int retry_interval, int max_retry_time, const char *name,
char *host, char *service, int port, int verbose)
{
int i;
* 1 on success
*/
int
-bnet_fsend(BSOCK *bs, char *fmt, ...)
+bnet_fsend(BSOCK *bs, const char *fmt, ...)
{
va_list arg_ptr;
int maxlen;
* This probably should be done in net_open
*/
BSOCK *
-init_bsock(JCR *jcr, int sockfd, char *who, char *host, int port,
+init_bsock(JCR *jcr, int sockfd, const char *who, char *host, int port,
struct sockaddr_in *client_addr)
{
BSOCK *bsock = (BSOCK *)malloc(sizeof(BSOCK));