From 112555e592b73cf58ab08da901af01309e3d1173 Mon Sep 17 00:00:00 2001 From: Masanori Ogino Date: Thu, 7 Dec 2023 12:44:29 +0900 Subject: [PATCH] Cleanup some obsolete code Signed-off-by: Masanori Ogino --- level1.c | 131 ------------------------------------------------------- sj3lib.c | 28 ------------ string.c | 32 -------------- 3 files changed, 191 deletions(-) diff --git a/level1.c b/level1.c index ee01ec3..59a3dd6 100644 --- a/level1.c +++ b/level1.c @@ -29,8 +29,6 @@ #include "config.h" -#include "sj_sysvdef.h" - #include #include #include @@ -50,18 +48,10 @@ #include "sj3lib.h" -#ifdef SVR4 -#define signal sigset -#endif - int sj3_error_number; char *sj3_socket_name = SocketName; char *sj3_port_name = PortName; -#ifdef TLI -extern int t_errno; -#else int sj3_port_number = PortNumber; -#endif #define BUFFER_SIZE BUFSIZ static char *af_unix_str = "unix"; @@ -94,15 +84,9 @@ put_flush(void) u_char *p; 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) { shutdown(server_fd, 2); close(server_fd); -#endif cliptr -> fd = server_fd = -1; sj3_error_number = SJ3_ServerDown; return(ERROR); @@ -208,12 +192,8 @@ get_buffer(void) getlen = read(server_fd, getbuf, sizeof(getbuf)); if (getlen <=0) { -#ifdef TLI - t_close(server_fd); -#else shutdown(server_fd, 2); close(server_fd); -#endif cliptr -> fd = server_fd = -1; sj3_error_number = SJ3_ServerDown; return ERROR; @@ -300,7 +280,6 @@ skip_ndata(int n) while (n-- > 0) get_byte(); } -#ifndef TLI static int open_unix(void) { @@ -327,7 +306,6 @@ open_unix(void) return fd; } -#endif void sj3_set_timeout(int timeout) @@ -343,76 +321,12 @@ connect_timeout(void) static int 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 servent *sp; int port; struct sockaddr_in sin; -#endif 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))) { sj3_error_number = SJ3_GetHostByName; return ERROR; @@ -432,29 +346,12 @@ open_inet(char* host) sj3_error_number = SJ3_OpenSocket; return ERROR; } -#endif if (sj3_timeout > 0) { signal(SIGALRM, (void (*)())connect_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)); -#endif if (sj3_timeout > 0) { alarm(0); signal(SIGALRM, SIG_IGN); @@ -463,19 +360,6 @@ open_inet(char* host) sj3_error_number = SJ3_ConnectSocket; 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; } @@ -497,16 +381,6 @@ sj3_make_connection( client -> fd = -1; 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; strcpy(host, af_unix_str); @@ -515,7 +389,6 @@ sj3_make_connection( if ((server_fd = open_inet(serv)) == ERROR) return ERROR; gethostname(host, sizeof(host)); } -#endif client -> fd = server_fd; client_init(client); @@ -592,11 +465,7 @@ sj3_erase_connection(SJ3_CLIENT_ENV* client) if (put_flush() == ERROR) return ERROR; sj3_error_number = get_int(); -#ifdef TLI - t_close(server_fd); -#else close(server_fd); -#endif cliptr -> fd = -1; if (ReadErrorFlag) return ERROR; return sj3_error_number ? ERROR : 0; diff --git a/sj3lib.c b/sj3lib.c index 957f4e4..8485ece 100644 --- a/sj3lib.c +++ b/sj3lib.c @@ -49,18 +49,10 @@ #include "sj3lib.h" extern int sj3_error_number; -#ifdef __sony_news -extern int _sys_code; -#else #define SYS_SJIS 0 #define SYS_EUC 1 #define SYS_NOTDEF -1 static int _sys_code = SYS_NOTDEF; -#endif /* __sony_news */ - -#ifndef lint -static char rcsid_sony[] = "$Header: /export/work/contrib/sj3/sj3lib/RCS/sj.c,v 1.14 1994/06/03 07:42:13 notanaka Exp $ SONY;"; -#endif char *sj3_user_dir = "user"; static char *path_delimiter = "/"; @@ -76,7 +68,6 @@ static u_char buf2[YomiBufSize]; static u_char kbuf[KanjiBufSize]; -#ifndef __sony_news static int set_sys_code(void) { @@ -88,7 +79,6 @@ set_sys_code(void) return SYS_EUC; } -#endif static int @@ -515,10 +505,8 @@ sj3_getkan_euc(u_char* yomi, SJ3_BUNSETU* bun, u_char* knj, int knjsiz) int sj3_getkan_mb(u_char* yomi, SJ3_BUNSETU* bun, u_char* knj, int knjsiz) { -#ifndef __sony_news if (_sys_code == SYS_NOTDEF) _sys_code = set_sys_code(); -#endif if (_sys_code == SYS_EUC) return sj3_getkan_euc(yomi, bun, knj, knjsiz); else @@ -582,10 +570,8 @@ sj3_douoncnt_euc(u_char* yomi) int sj3_douoncnt_mb(u_char* yomi) { -#ifndef __sony_news if (_sys_code == SYS_NOTDEF) _sys_code = set_sys_code(); -#endif if (_sys_code == SYS_EUC) return sj3_douoncnt_euc(yomi); else @@ -657,10 +643,8 @@ sj3_getdouon_euc(u_char* yomi, SJ3_DOUON* dou) int sj3_getdouon_mb(u_char* yomi, SJ3_DOUON* dou) { -#ifndef __sony_news if (_sys_code == SYS_NOTDEF) _sys_code = set_sys_code(); -#endif if (_sys_code == SYS_EUC) return sj3_getdouon_euc(yomi, dou); else @@ -731,10 +715,8 @@ sj3_gakusyuu2_euc(u_char* yomi1, u_char* yomi2, SJ3_STUDYREC* dcid) int sj3_gakusyuu2_mb(u_char* yomi1, u_char* yomi2, SJ3_STUDYREC* dcid) { -#ifndef __sony_news if (_sys_code == SYS_NOTDEF) _sys_code = set_sys_code(); -#endif if (_sys_code == SYS_EUC) return sj3_gakusyuu2_euc(yomi1, yomi2, dcid); else @@ -817,10 +799,8 @@ sj3_touroku_euc(u_char* yomi, u_char* kanji, int code) int sj3_touroku_mb(u_char* yomi, u_char* kanji, int code) { -#ifndef __sony_news if (_sys_code == SYS_NOTDEF) _sys_code = set_sys_code(); -#endif if (_sys_code == SYS_EUC) return sj3_touroku_euc(yomi, kanji, code); else @@ -895,10 +875,8 @@ sj3_syoukyo_euc(u_char* yomi, u_char* kanji, int code) int sj3_syoukyo_mb(u_char* yomi, u_char* kanji, int code) { -#ifndef __sony_news if (_sys_code == SYS_NOTDEF) _sys_code = set_sys_code(); -#endif if (_sys_code == SYS_EUC) return sj3_syoukyo_euc(yomi, kanji, code); else @@ -963,10 +941,8 @@ sj3_getdict_euc(u_char* buf) int sj3_getdict_mb(u_char* buf) { -#ifndef __sony_news if (_sys_code == SYS_NOTDEF) _sys_code = set_sys_code(); -#endif if (_sys_code == SYS_EUC) return sj3_getdict_euc(buf); else @@ -1030,10 +1006,8 @@ sj3_nextdict_euc(u_char* buf) int sj3_nextdict_mb(u_char* buf) { -#ifndef __sony_news if (_sys_code == SYS_NOTDEF) _sys_code = set_sys_code(); -#endif if (_sys_code == SYS_EUC) return sj3_nextdict_euc(buf); else @@ -1097,10 +1071,8 @@ sj3_prevdict_euc(u_char* buf) int sj3_prevdict_mb(u_char* buf) { -#ifndef __sony_news if (_sys_code == SYS_NOTDEF) _sys_code = set_sys_code(); -#endif if (_sys_code == SYS_EUC) return sj3_prevdict_euc(buf); else diff --git a/string.c b/string.c index 853719b..18a433a 100644 --- a/string.c +++ b/string.c @@ -29,8 +29,6 @@ #include "config.h" -#include "sj_sysvdef.h" - #include #include #include @@ -43,7 +41,6 @@ #define FALSE (0) #endif -#ifndef __sony_news #define sjis2euc sj3_sjis2euc #define euc2sjis sj3_euc2sjis @@ -53,7 +50,6 @@ #define iskana(c) ((0xa1 <= (c)) && ((c) <= 0xdf)) unsigned short sjis2euc(), euc2sjis(); -#endif void sj_sjis2jis(), sj_jis2sjis(); @@ -178,7 +174,6 @@ int max; #define MASK 0x7f #define MSB 0x80 -#if !defined(__sony_news) || (defined(__sony_news) && !defined(SVR4)) static unsigned char def_char[] = {0x81, 0x40}; int @@ -351,31 +346,4 @@ unsigned short code; code = (tmp[0] << 8) + tmp[1]; return(code); -} -#else -#ifndef SVR4 -static unsigned char def_char[] = {0x81, 0x40}; - -int -sj3_sjistoeuc(e, elen, s, slen) -unsigned char *s, *e; -int slen, elen; -{ - int dummy; - - return sj3_str_sjistoeuc(e, elen, s, def_char, &dummy); } - -int -sj3_euctosjis(s, slen, e, elen) -unsigned char *s, *e; -int slen, elen; -{ - int dummy; - - return sj3_str_euctosjis(s, slen, e, def_char, &dummy); -} -#endif -#endif - -