From d570da1aeed86f0b5d51fbc4cf38233a5e661c92 Mon Sep 17 00:00:00 2001 From: wens Date: Fri, 30 Jan 2009 11:06:47 +0000 Subject: replace unixclient with toconnect git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4432 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- innbbsd/bbsnnrp.c | 4 ++-- innbbsd/connectsock.c | 38 -------------------------------------- innbbsd/ctlinnbbsd.c | 2 +- innbbsd/externs.h | 1 - innbbsd/pmain.c | 2 +- 5 files changed, 4 insertions(+), 43 deletions(-) diff --git a/innbbsd/bbsnnrp.c b/innbbsd/bbsnnrp.c index 87e04aee..c950fbf7 100644 --- a/innbbsd/bbsnnrp.c +++ b/innbbsd/bbsnnrp.c @@ -483,7 +483,7 @@ initsockets(server, bbsnnrp, type) int nnrpfd; int innbbsfd; if (AskLocal) { - innbbsfd = unixclient(DefaultPath, "tcp"); + innbbsfd = toconnect(DefaultPath); if (innbbsfd < 0) { fprintf(stderr, "Connect to %s error. You may not run innbbsd\n", LOCALDAEMON); /* @@ -496,7 +496,7 @@ initsockets(server, bbsnnrp, type) } close(innbbsfd); /* try again */ - innbbsfd = unixclient(DefaultPath, "tcp"); + innbbsfd = toconnect(DefaultPath); if (innbbsfd < 0) { exit(3); } diff --git a/innbbsd/connectsock.c b/innbbsd/connectsock.c index 8d8cddad..2340eaea 100644 --- a/innbbsd/connectsock.c +++ b/innbbsd/connectsock.c @@ -425,41 +425,3 @@ inetclient(server, service, protocol) return s; } - -int -unixclient(path, protocol) - char *path; - char *protocol; -{ - struct protoent *pe; /* protocol information entry */ - struct sockaddr_un s_un; /* unix endpoint address */ - int s; - - bzero((char *)&s_un, sizeof(s_un)); - s_un.sun_family = AF_UNIX; - - if (path == NULL) - path = DEFAULTPATH; - if (protocol == NULL) - protocol = "tcp"; - strcpy(s_un.sun_path, path); - - /* map protocol name to protocol number */ - pe = getprotobyname(protocol); - if (pe == NULL) { - fprintf(stderr, "%s: Unknown protocol.\n", protocol); - return (-1); - } - /* Allocate a socket */ - s = socket(PF_UNIX, strcmp(protocol, "tcp") ? SOCK_DGRAM : SOCK_STREAM, 0); - if (s < 0) { - perror("socket"); - return -1; - } - /* Connect the socket to the server */ - if (connect(s, (struct sockaddr *) & s_un, sizeof(s_un)) < 0) { - /* perror("connect"); */ - return -1; - } - return s; -} diff --git a/innbbsd/ctlinnbbsd.c b/innbbsd/ctlinnbbsd.c index 0c4a9356..67181fce 100644 --- a/innbbsd/ctlinnbbsd.c +++ b/innbbsd/ctlinnbbsd.c @@ -112,7 +112,7 @@ ctlinnbbsd(argc, argv) void initsocket() { - innbbsfd = unixclient(DefaultPath, "tcp"); + innbbsfd = toconnect(DefaultPath); if (innbbsfd < 0) { fprintf(stderr, "Connect to %s error. You may not run innbbsd\n", DefaultPath); exit(2); diff --git a/innbbsd/externs.h b/innbbsd/externs.h index f8f52d01..f17cb70b 100644 --- a/innbbsd/externs.h +++ b/innbbsd/externs.h @@ -50,7 +50,6 @@ void readlines(ClientType *); /* connectsock.c */ int open_listen(char *, char *, int (*) (int)); int open_unix_listen(char *, char *, int (*) (int)); -int unixclient(char *, char *); void docompletehalt(int); int inetclient(char *, char *, char *); int tryaccept(int); diff --git a/innbbsd/pmain.c b/innbbsd/pmain.c index d0f86484..5236244e 100644 --- a/innbbsd/pmain.c +++ b/innbbsd/pmain.c @@ -55,7 +55,7 @@ p_unix_main(path) #ifdef DEBUG printf("start to allocate path %s\n", path); #endif - int fd = unixclient(path, "tcp"); + int fd = toconnect(path); if (fd < 0) unlink(path); else -- cgit v1.2.3