summaryrefslogtreecommitdiff
path: root/netlib.c
diff options
context:
space:
mode:
authorRemco Treffkorn <remco@rvt.com>1998-08-18 22:03:13 +0000
committerRemco Treffkorn <remco@rvt.com>1998-08-18 22:03:13 +0000
commit361ade8eb495c29f652a74748f7a29e167500199 (patch)
treee79271e5693fc269016b8d4c855371f9ef9eb29c /netlib.c
parentdaa932c27d860386b3383e4ab10ea1a80ba053a5 (diff)
downloadgpsd-361ade8eb495c29f652a74748f7a29e167500199.tar.gz
*** empty log message ***
Diffstat (limited to 'netlib.c')
-rw-r--r--netlib.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/netlib.c b/netlib.c
index d585060d..a75e417c 100644
--- a/netlib.c
+++ b/netlib.c
@@ -1,4 +1,4 @@
-
+#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -7,11 +7,14 @@
#include <varargs.h>
#include <netdb.h>
#include <stdio.h>
+#include <arpa/inet.h>
#if defined (HAVE_SYS_PARAM_H)
#include <sys/param.h>
#endif
+#include "gpsd.h"
+
static char mbuf[128];
int passivesock(char *service, char *protocol, int qlen)
@@ -25,7 +28,7 @@ int passivesock(char *service, char *protocol, int qlen)
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
- if (pse = getservbyname(service, protocol))
+ if ( (pse = getservbyname(service, protocol)) )
sin.sin_port = htons(ntohs((u_short) pse->s_port));
else if ((sin.sin_port = htons((u_short) atoi(service))) == 0) {
sprintf(mbuf, "Can't get \"%s\" service entry.\n", service);
@@ -55,11 +58,6 @@ int passivesock(char *service, char *protocol, int qlen)
return s;
}
-int passiveUDP(char *service, int qlen)
-{
- return passivesock(service, "udp", qlen);
-}
-
int passiveTCP(char *service, int qlen)
{
return passivesock(service, "tcp", qlen);
@@ -77,13 +75,13 @@ int connectsock(char *host, char *service, char *protocol)
bzero((char *) &sin, sizeof(sin));
sin.sin_family = AF_INET;
- if (pse = getservbyname(service, protocol))
+ if ( (pse = getservbyname(service, protocol)) )
sin.sin_port = htons(ntohs((u_short) pse->s_port));
else if ((sin.sin_port = htons((u_short) atoi(service))) == 0) {
sprintf(mbuf, "Can't get \"%s\" service entry.\n", service);
errexit(mbuf);
}
- if (phe = gethostbyname(host))
+ if ( (phe = gethostbyname(host)) )
bcopy(phe->h_addr, (char *) &sin.sin_addr, phe->h_length);
else if ((sin.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE) {
sprintf(mbuf, "Can't get host entry: \"%s\".\n", host);
@@ -109,11 +107,6 @@ int connectsock(char *host, char *service, char *protocol)
return s;
}
-int connectUDP(char *host, char *service)
-{
- return connectsock(host, service, "udp");
-}
-
int connectTCP(char *host, char *service)
{
return connectsock(host, service, "tcp");