sj3lib: Remove TLI support
Signed-off-by: Masanori Ogino <mogino@acm.org>
This commit is contained in:
parent
a330e51700
commit
d09baa32bc
3 changed files with 1 additions and 144 deletions
|
|
@ -60,17 +60,11 @@
|
||||||
#define MaxClientNum 512
|
#define MaxClientNum 512
|
||||||
#define LogOutFile NULL
|
#define LogOutFile NULL
|
||||||
#define PortName "sj3"
|
#define PortName "sj3"
|
||||||
#ifdef TLI
|
|
||||||
#define LocalHost "localhost"
|
|
||||||
#define ProtoName "tcp"
|
|
||||||
#define PortNumber "3000"
|
|
||||||
#else
|
|
||||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
|
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
|
||||||
#define PortNumber 3086
|
#define PortNumber 3086
|
||||||
#else /* ! __FreeBSD__ __NetBSD__ __OpenBSD__ */
|
#else /* ! __FreeBSD__ __NetBSD__ __OpenBSD__ */
|
||||||
#define PortNumber 3000
|
#define PortNumber 3000
|
||||||
#endif /* ! __FreeBSD__ __NetBSD__ __OpenBSD__ */
|
#endif /* ! __FreeBSD__ __NetBSD__ __OpenBSD__ */
|
||||||
#endif
|
|
||||||
#define DirectryMode 0755
|
#define DirectryMode 0755
|
||||||
#define DictFileMode 0644
|
#define DictFileMode 0644
|
||||||
#define MODE_MASK 0777
|
#define MODE_MASK 0777
|
||||||
|
|
|
||||||
|
|
@ -172,9 +172,6 @@ typedef struct client {
|
||||||
StdyFile *stdy;
|
StdyFile *stdy;
|
||||||
short version;
|
short version;
|
||||||
u_char def_char[2];
|
u_char def_char[2];
|
||||||
#if (defined(TLI) && defined(SOCK_UNIX))
|
|
||||||
int unix_flag;
|
|
||||||
#endif
|
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
struct client *next;
|
struct client *next;
|
||||||
} Client;
|
} Client;
|
||||||
|
|
|
||||||
136
sj3lib/level1.c
136
sj3lib/level1.c
|
|
@ -31,6 +31,7 @@
|
||||||
#include "sj_sysvdef.h"
|
#include "sj_sysvdef.h"
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|
@ -42,16 +43,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#ifdef TLI
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <netconfig.h>
|
|
||||||
#include <netdir.h>
|
|
||||||
#include <stropts.h>
|
|
||||||
#include <tiuser.h>
|
|
||||||
#else
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Const.h"
|
#include "Const.h"
|
||||||
#include "sj3cmd.h"
|
#include "sj3cmd.h"
|
||||||
#include "sj3err.h"
|
#include "sj3err.h"
|
||||||
|
|
@ -69,11 +60,7 @@ static char rcsid_patch[] = "$Id: level1.c,v 1.2 2004/07/20 15:55:43 hiroo Exp $
|
||||||
int sj3_error_number;
|
int sj3_error_number;
|
||||||
char *sj3_socket_name = SocketName;
|
char *sj3_socket_name = SocketName;
|
||||||
char *sj3_port_name = PortName;
|
char *sj3_port_name = PortName;
|
||||||
#ifdef TLI
|
|
||||||
extern int t_errno;
|
|
||||||
#else
|
|
||||||
int sj3_port_number = PortNumber;
|
int sj3_port_number = PortNumber;
|
||||||
#endif
|
|
||||||
|
|
||||||
#define BUFFER_SIZE BUFSIZ
|
#define BUFFER_SIZE BUFSIZ
|
||||||
static char *af_unix_str = "unix";
|
static char *af_unix_str = "unix";
|
||||||
|
|
@ -106,15 +93,9 @@ put_flush(void)
|
||||||
u_char *p;
|
u_char *p;
|
||||||
|
|
||||||
for (i = putpos, p = putbuf ; i > 0 ; i -= j, p += j) {
|
for (i = putpos, p = putbuf ; i > 0 ; i -= j, p += j) {
|
||||||
#ifdef TLI
|
|
||||||
if ((j = write(server_fd, p, i)) <= 0) {
|
|
||||||
t_sndrel(server_fd);
|
|
||||||
close(server_fd);
|
|
||||||
#else
|
|
||||||
if ((j = write(server_fd, p, i)) <= 0) {
|
if ((j = write(server_fd, p, i)) <= 0) {
|
||||||
shutdown(server_fd, 2);
|
shutdown(server_fd, 2);
|
||||||
close(server_fd);
|
close(server_fd);
|
||||||
#endif
|
|
||||||
cliptr -> fd = server_fd = -1;
|
cliptr -> fd = server_fd = -1;
|
||||||
sj3_error_number = SJ3_ServerDown;
|
sj3_error_number = SJ3_ServerDown;
|
||||||
return(ERROR);
|
return(ERROR);
|
||||||
|
|
@ -211,12 +192,8 @@ get_buffer(void)
|
||||||
|
|
||||||
getlen = read(server_fd, getbuf, sizeof(getbuf));
|
getlen = read(server_fd, getbuf, sizeof(getbuf));
|
||||||
if (getlen <=0) {
|
if (getlen <=0) {
|
||||||
#ifdef TLI
|
|
||||||
t_close(server_fd);
|
|
||||||
#else
|
|
||||||
shutdown(server_fd, 2);
|
shutdown(server_fd, 2);
|
||||||
close(server_fd);
|
close(server_fd);
|
||||||
#endif
|
|
||||||
cliptr -> fd = server_fd = -1;
|
cliptr -> fd = server_fd = -1;
|
||||||
sj3_error_number = SJ3_ServerDown;
|
sj3_error_number = SJ3_ServerDown;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
|
|
@ -301,7 +278,6 @@ skip_ndata(int n)
|
||||||
while (n-- > 0) get_byte();
|
while (n-- > 0) get_byte();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TLI
|
|
||||||
static int
|
static int
|
||||||
open_unix(void)
|
open_unix(void)
|
||||||
{
|
{
|
||||||
|
|
@ -328,7 +304,6 @@ open_unix(void)
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
sj3_set_timeout(int timeout)
|
sj3_set_timeout(int timeout)
|
||||||
|
|
@ -344,76 +319,12 @@ connect_timeout(void)
|
||||||
static int
|
static int
|
||||||
open_inet(char* host)
|
open_inet(char* host)
|
||||||
{
|
{
|
||||||
#ifdef TLI
|
|
||||||
int val;
|
|
||||||
char *t_alloc();
|
|
||||||
struct t_call *callptr;
|
|
||||||
struct netconfig *nconf;
|
|
||||||
struct nd_hostserv hserv;
|
|
||||||
struct nd_addrlist *addrs;
|
|
||||||
void *handlep;
|
|
||||||
char host_name[BUFSIZ], proto_name[BUFSIZ], *port_name, *tmp_addr;
|
|
||||||
extern void *setnetpath();
|
|
||||||
extern struct netconfig *getnetpath();
|
|
||||||
#else
|
|
||||||
struct hostent *hp;
|
struct hostent *hp;
|
||||||
struct servent *sp;
|
struct servent *sp;
|
||||||
int port;
|
int port;
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
#endif
|
|
||||||
int fd, ret;
|
int fd, ret;
|
||||||
|
|
||||||
#ifdef TLI
|
|
||||||
if ((tmp_addr = strchr(host, '/')) != NULL) {
|
|
||||||
strncpy(proto_name, host, (unsigned int) (tmp_addr - host));
|
|
||||||
proto_name[(unsigned int) (tmp_addr - host)] = '\0';
|
|
||||||
tmp_addr++;
|
|
||||||
} else {
|
|
||||||
strncpy(proto_name, ProtoName, strlen(ProtoName));
|
|
||||||
proto_name[strlen(ProtoName)] = '\0';
|
|
||||||
tmp_addr = host;
|
|
||||||
}
|
|
||||||
if ((port_name = strchr(tmp_addr, ':')) != NULL) {
|
|
||||||
strncpy(host_name, tmp_addr, (unsigned int)(port_name - tmp_addr));
|
|
||||||
host_name[(unsigned int)(port_name - tmp_addr)] = '\0';
|
|
||||||
port_name++;
|
|
||||||
} else {
|
|
||||||
strcpy(host_name, tmp_addr);
|
|
||||||
port_name = PortName;
|
|
||||||
}
|
|
||||||
hserv.h_host = host_name;
|
|
||||||
hserv.h_serv = port_name;
|
|
||||||
|
|
||||||
if ((handlep = setnetpath()) == NULL) {
|
|
||||||
sj3_error_number = SJ3_GetHostByName;
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
while ((nconf = getnetpath(handlep)) != NULL) {
|
|
||||||
if (((nconf->nc_semantics == NC_TPI_COTS_ORD) ||
|
|
||||||
(nconf->nc_semantics == NC_TPI_COTS)) &&
|
|
||||||
(strncmp(nconf->nc_proto, proto_name, strlen(proto_name)) == 0))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (nconf == NULL) {
|
|
||||||
sj3_error_number = SJ3_GetHostByName;
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
if (netdir_getbyname(nconf, &hserv, &addrs) != 0) {
|
|
||||||
hserv.h_serv = PortNumber;
|
|
||||||
if (netdir_getbyname(nconf, &hserv, &addrs) != 0) {
|
|
||||||
sj3_error_number = SJ3_GetHostByName;
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (( fd = t_open(nconf->nc_device, O_RDWR, (struct t_info *)0)) < 0) {
|
|
||||||
sj3_error_number = SJ3_OpenSocket;
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
if (t_bind(fd, (struct t_bind *)0, (struct t_bind *) 0) < 0) {
|
|
||||||
sj3_error_number = SJ3_OpenSocket;
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (!(hp = gethostbyname(host))) {
|
if (!(hp = gethostbyname(host))) {
|
||||||
sj3_error_number = SJ3_GetHostByName;
|
sj3_error_number = SJ3_GetHostByName;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
|
|
@ -433,29 +344,12 @@ open_inet(char* host)
|
||||||
sj3_error_number = SJ3_OpenSocket;
|
sj3_error_number = SJ3_OpenSocket;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (sj3_timeout > 0) {
|
if (sj3_timeout > 0) {
|
||||||
signal(SIGALRM, (void (*)())connect_timeout);
|
signal(SIGALRM, (void (*)())connect_timeout);
|
||||||
alarm(sj3_timeout);
|
alarm(sj3_timeout);
|
||||||
}
|
}
|
||||||
#ifdef TLI
|
|
||||||
if((callptr = (struct t_call *) t_alloc(fd, T_CALL, T_ALL)) == NULL) {
|
|
||||||
sj3_error_number = SJ3_NotEnoughMemory;
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
callptr->addr = *(addrs->n_addrs);
|
|
||||||
callptr->opt.len = 0;
|
|
||||||
callptr->opt.maxlen = 0;
|
|
||||||
callptr->opt.buf = (char *)NULL;
|
|
||||||
callptr->udata.len = 0;
|
|
||||||
callptr->udata.maxlen = 0;
|
|
||||||
callptr->udata.buf = (char *)NULL;
|
|
||||||
|
|
||||||
ret = t_connect(fd, callptr, (struct t_call *) 0);
|
|
||||||
#else
|
|
||||||
ret = connect(fd, (struct sockaddr *)&sin, sizeof(sin));
|
ret = connect(fd, (struct sockaddr *)&sin, sizeof(sin));
|
||||||
#endif
|
|
||||||
if (sj3_timeout > 0) {
|
if (sj3_timeout > 0) {
|
||||||
alarm(0);
|
alarm(0);
|
||||||
signal(SIGALRM, SIG_IGN);
|
signal(SIGALRM, SIG_IGN);
|
||||||
|
|
@ -464,19 +358,6 @@ open_inet(char* host)
|
||||||
sj3_error_number = SJ3_ConnectSocket;
|
sj3_error_number = SJ3_ConnectSocket;
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
#ifdef TLI
|
|
||||||
if (ioctl(fd, I_POP, (char *) 0) < 0) {
|
|
||||||
sj3_error_number = SJ3_NotOpened;
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
if (ioctl(fd, I_PUSH, "tirdwr") < 0) {
|
|
||||||
sj3_error_number = SJ3_NotOpened;
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
val = 0;
|
|
||||||
(void) ioctl(fd, I_SETCLTIME, &val);
|
|
||||||
endnetpath(handlep);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
@ -498,16 +379,6 @@ sj3_make_connection(
|
||||||
client -> fd = -1;
|
client -> fd = -1;
|
||||||
|
|
||||||
if (!serv || *serv == '\0' || !strcmp(serv, af_unix_str))
|
if (!serv || *serv == '\0' || !strcmp(serv, af_unix_str))
|
||||||
#ifdef TLI
|
|
||||||
{
|
|
||||||
serv = LocalHost;
|
|
||||||
strcpy(host, af_unix_str);
|
|
||||||
} else {
|
|
||||||
gethostname(host, sizeof(host));
|
|
||||||
}
|
|
||||||
if ((server_fd = open_inet(serv)) == ERROR) return ERROR;
|
|
||||||
|
|
||||||
#else
|
|
||||||
{
|
{
|
||||||
if ((server_fd = open_unix()) == ERROR) return ERROR;
|
if ((server_fd = open_unix()) == ERROR) return ERROR;
|
||||||
strcpy(host, af_unix_str);
|
strcpy(host, af_unix_str);
|
||||||
|
|
@ -516,7 +387,6 @@ sj3_make_connection(
|
||||||
if ((server_fd = open_inet(serv)) == ERROR) return ERROR;
|
if ((server_fd = open_inet(serv)) == ERROR) return ERROR;
|
||||||
gethostname(host, sizeof(host));
|
gethostname(host, sizeof(host));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
client -> fd = server_fd;
|
client -> fd = server_fd;
|
||||||
client_init(client);
|
client_init(client);
|
||||||
|
|
||||||
|
|
@ -593,11 +463,7 @@ sj3_erase_connection(SJ3_CLIENT_ENV* client)
|
||||||
if (put_flush() == ERROR) return ERROR;
|
if (put_flush() == ERROR) return ERROR;
|
||||||
|
|
||||||
sj3_error_number = get_int();
|
sj3_error_number = get_int();
|
||||||
#ifdef TLI
|
|
||||||
t_close(server_fd);
|
|
||||||
#else
|
|
||||||
close(server_fd);
|
close(server_fd);
|
||||||
#endif
|
|
||||||
cliptr -> fd = -1;
|
cliptr -> fd = -1;
|
||||||
if (ReadErrorFlag) return ERROR;
|
if (ReadErrorFlag) return ERROR;
|
||||||
return sj3_error_number ? ERROR : 0;
|
return sj3_error_number ? ERROR : 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue