summaryrefslogtreecommitdiff
path: root/japanese/skkinput/patches
diff options
context:
space:
mode:
authoritohy <itohy@pkgsrc.org>2000-11-09 03:54:07 +0000
committeritohy <itohy@pkgsrc.org>2000-11-09 03:54:07 +0000
commitf3d48b3df4698cf43183d3d49bd115d3d472e267 (patch)
tree999708e500dd3eaad198ff4617fa9445c0a0db0c /japanese/skkinput/patches
parent7dc26c0f0ccde5dd8f273c2f6e91f6f663aff337 (diff)
downloadpkgsrc-f3d48b3df4698cf43183d3d49bd115d3d472e267.tar.gz
Dual stack (IPv6) support.
Make "skkserv_port:" line in skk.conf accept the service name as well as the port number. tmpnam() -> mkstemp() to make temp file handling safer.
Diffstat (limited to 'japanese/skkinput/patches')
-rw-r--r--japanese/skkinput/patches/patch-ab91
-rw-r--r--japanese/skkinput/patches/patch-ac75
-rw-r--r--japanese/skkinput/patches/patch-ad184
-rw-r--r--japanese/skkinput/patches/patch-ae39
4 files changed, 359 insertions, 30 deletions
diff --git a/japanese/skkinput/patches/patch-ab b/japanese/skkinput/patches/patch-ab
index 11d4701eda8..2174768295d 100644
--- a/japanese/skkinput/patches/patch-ab
+++ b/japanese/skkinput/patches/patch-ab
@@ -1,17 +1,49 @@
-$NetBSD: patch-ab,v 1.1.1.1 1999/12/24 03:23:50 itohy Exp $
+$NetBSD: patch-ab,v 1.2 2000/11/09 03:54:07 itohy Exp $
--- skkconfig.c.orig Thu Nov 13 22:42:43 1997
-+++ skkconfig.c Fri Dec 24 00:51:24 1999
-@@ -988,12 +988,43 @@
++++ skkconfig.c Thu Nov 9 00:19:40 2000
+@@ -100,6 +100,7 @@
+ * skkinput の動作を決定する変数群。
+ */
+ extern int skkserv_portnum ;
++extern char *skkserv_portstr ;
+ extern char *skkserv_host ;
+ extern char *skkinput_local_jisyo_name ;
+ extern char *skkinput_backup_jisyo_name ;
+@@ -980,6 +981,21 @@
+ return ;
+ }
+
++#ifdef SKK_CONF
++char *
++strsave(const char *str)
++{
++ char *p;
++
++ if ((p = malloc(strlen(str) + 1)) == NULL) {
++ fprintf(stderr, "Fatal: Memory Exhausted.\n");
++ exit(1);
++ }
++ strcpy(p, str);
++ return p;
++}
++#endif
++
+ /*
+ * skkinput の動作記述をする変数を初期化する関数。
+ *------
+@@ -987,30 +1003,54 @@
+ */
void initSkkinputDousaketteiVariables( void )
{
- struct servent *servent ;
+- struct servent *servent ;
+#ifdef SKK_CONF /* use skk.conf */
+ FILE *conffp;
+ char line[128];
-+ static char hostbuf[120];
++ char hostbuf[128];
++ char servbuf[128];
+ char *confhost = NULL;
-+ int confport = 0;
++ char *confport = NULL;
+
+ if ((conffp = fopen(SKK_CONF, "r")) != NULL) {
+ char *p, *data;
@@ -24,10 +56,11 @@ $NetBSD: patch-ab,v 1.1.1.1 1999/12/24 03:23:50 itohy Exp $
+ if ((data = strtok((char *) NULL, " \t\n")) == NULL)
+ continue;
+ if (!strcmp(p, "skkserv_host")) {
-+ strcpy(hostbuf, data);
-+ confhost = hostbuf;
++ strcpy(hostbuf, data);
++ confhost = hostbuf;
+ } else if (!strcmp(p, "skkserv_port")) {
-+ confport = atoi(data);
++ strcpy(servbuf, data);
++ confport = servbuf;
+ }
+ }
+ }
@@ -38,34 +71,32 @@ $NetBSD: patch-ab,v 1.1.1.1 1999/12/24 03:23:50 itohy Exp $
skkinput_backup_jisyo_name = DEFAULT_SKKBJISYO ;
skkinput_record_name = DEFAULT_SKKRECORD ;
skk_local_jisyo_name = DEFAULT_SKKLOCALJISYO ;
+- /* "/etc/services" からポート番号を得ておく。*/
+- servent = getservbyname( SKKSERV_SERVICE_NAME, SKKSERV_SERVICE_PROTO ) ;
+- if( servent == NULL ){
+- /* /etc/services に設定はなかったので、config.h の中のを使う。*/
+- skkserv_portnum = atoi( DEFAULT_SKKPORT ) ;
+- } else {
+- /* /etc/services に設定があった…。*/
+- skkserv_portnum = htons( servent->s_port ) ;
+-#if defined(DEBUG)
+- fprintf
+- ( stderr, "getservbyname: \"%s\", %d\n",
+- servent->s_name, skkserv_portnum ) ;
+#ifdef SKK_CONF
+ if (confport)
-+ skkserv_portnum = confport;
-+ else {
-+#endif
- /* "/etc/services" からポート番号を得ておく。*/
- servent = getservbyname( SKKSERV_SERVICE_NAME, SKKSERV_SERVICE_PROTO ) ;
- if( servent == NULL ){
-@@ -1001,16 +1032,22 @@
- skkserv_portnum = atoi( DEFAULT_SKKPORT ) ;
- } else {
- /* /etc/services に設定があった…。*/
-- skkserv_portnum = htons( servent->s_port ) ;
-+ skkserv_portnum = ntohs( servent->s_port ) ;
- #if defined(DEBUG)
- fprintf
- ( stderr, "getservbyname: \"%s\", %d\n",
- servent->s_name, skkserv_portnum ) ;
++ skkserv_portstr = strsave(confport);
++ else
#endif
- }
-+#ifdef SKK_CONF
-+ }
-+#endif
+- }
++ skkserv_portstr = SKKSERV_SERVICE_NAME;
/* 環境変数 SKKSERV が設定されていれば、それを DEFAULT の skkserv *
* host とする。*/
if( ( skkserv_host = getenv( "SKKSERVER" ) ) == NULL )
+#ifdef SKK_CONF
-+ if ((skkserv_host = confhost) == NULL)
++ if (confhost)
++ skkserv_host = strsave(confhost); /* XXX this may leak */
++ else
+#endif
skkserv_host = DEFAULT_SKKSERVER ;
diff --git a/japanese/skkinput/patches/patch-ac b/japanese/skkinput/patches/patch-ac
new file mode 100644
index 00000000000..688257d4598
--- /dev/null
+++ b/japanese/skkinput/patches/patch-ac
@@ -0,0 +1,75 @@
+$NetBSD: patch-ac,v 1.1 2000/11/09 03:54:07 itohy Exp $
+
+--- skkldic.c.orig Fri Nov 14 13:04:12 1997
++++ skkldic.c Wed Nov 8 20:01:38 2000
+@@ -27,6 +27,13 @@
+ #include <sys/types.h>
+ #include <X11/Intrinsic.h>
+
++#ifdef CSRG_BASED
++#include <sys/param.h>
++#if defined(BSD) && BSD >= 199306
++#define HAVE_MKSTEMP
++#endif
++#endif
++
+ #include "commondef.h"
+ #include "buffers.h"
+ #include "config.h"
+@@ -863,7 +870,12 @@
+ {
+ FILE *fpSrc, *fpDest ;
+ unsigned long lines ;
++#ifdef HAVE_MKSTEMP
++ char tempfilename[64] ;
++ int tmpfd;
++#else
+ char *tempfilename ;
++#endif
+
+ #ifdef DEBUG_LDIC
+ fprintf( stderr, "Now saving ....\"%s\"\n", skkinput_local_jisyo_path ) ;
+@@ -890,7 +902,15 @@
+ * 存在しない場合はどうするのか? */
+
+ /* 辞書の更新を行う際に利用されるテンポラリファイル。*/
++#ifdef HAVE_MKSTEMP
++ strcpy(tempfilename, "/tmp/skkinputXXXXXXXX");
++ if ((tmpfd = mkstemp(tempfilename)) < 0) {
++ perror("skkinput: cannot create temp file");
++ return;
++ }
++#else
+ tempfilename = tmpnam( NULL ) ;
++#endif
+
+ /* 局所辞書のバックアップを削除する。失敗した場合なんかは知らない。*/
+ unlink( skkinput_jisyo_backup_path ) ;
+@@ -901,12 +921,19 @@
+ skkinput_copyFile
+ ( skkinput_local_jisyo_path, tempfilename ) ;
+ /* 局所辞書のコピーが存在しない。これは不味い状態である。*/
++#ifdef HAVE_MKSTEMP
++ if( ( fpSrc = fdopen( tmpfd, "rb" ) ) == NULL ){
++ close(tmpfd);
++ return;
++ }
++#else
+ if( ( fpSrc = fopen( tempfilename, "rb" ) ) == NULL ){
+ #ifdef DEBUG_LDIC
+ fprintf( stderr, "cannot create backup jisyo...error!\n" ) ;
+ #endif
+ return ;
+ }
++#endif
+ /* 書き込めない…これは無理だ…。*/
+ if( ( fpDest = fopen( skkinput_local_jisyo_path, "wb" ) ) == NULL ){
+ #ifdef DEBUG_LDIC
+@@ -922,6 +949,7 @@
+ /* file coding system を調べ直す。*/
+ skkinput_local_jisyo_coding_system =
+ check_skkinput_jisyo_code( skkinput_local_jisyo_path ) ;
++ unlink( tempfilename ) ;
+ return ;
+ }
+ lines = 0 ;
diff --git a/japanese/skkinput/patches/patch-ad b/japanese/skkinput/patches/patch-ad
new file mode 100644
index 00000000000..8506e0550b9
--- /dev/null
+++ b/japanese/skkinput/patches/patch-ad
@@ -0,0 +1,184 @@
+$NetBSD: patch-ad,v 1.1 2000/11/09 03:54:08 itohy Exp $
+
+--- skksoc.c.orig Thu Oct 30 13:40:59 1997
++++ skksoc.c Wed Nov 8 21:48:24 2000
+@@ -36,6 +36,11 @@
+
+ #include "commondef.h"
+ #include "buffers.h"
++#include "config.h"
++
++#ifdef PF_INET6
++# define HAVE_GETADDRINFO
++#endif
+
+ /*
+ * プロトタイプ宣言。
+@@ -51,12 +56,15 @@
+ } ;
+
+ extern char *skkserv_host ;
+-extern int skkserv_portnum ;
++extern char *skkserv_portnum ;
++extern char *skkserv_portstr ;
+
+ /* skkserv とお話する際のバッファ。*/
+ static struct MessageBuffer mesbuf ;
++#ifndef HAVE_GETADDRINFO
+ /* SKK server の情報。*/
+ struct sockaddr_in server ;
++#endif
+ /* SKK server の Host の情報。*/
+ static struct hostent *host ;
+ /* skkserv をお話するのに利用する socket */
+@@ -79,13 +87,14 @@
+ static void myCharStringToNormalString
+ ( struct MessageBuffer *buf, struct myChar *string ) ;
+
++#ifndef HAVE_GETADDRINFO
+ /*
+ * ソケットを作成する関数。
+ *------------
+ * server の名前が与えられると、そこに対しての socket を作成しよう
+ * と試みる。
+ */
+-static int makeSocket( char *server_name, int port_num )
++static int makeSocket( char *server_name )
+ {
+ struct protoent *proto;
+ /* Protocol の設定。*/
+@@ -115,22 +124,10 @@
+ #else
+ memcpy( &server.sin_addr, host->h_addr, host->h_length ) ;
+ #endif
+- server.sin_port = htons( port_num ) ;
+-
+- read_skkserv_fp = fdopen( skkserv_soc, "r" ) ;
+- write_skkserv_fp = fdopen( skkserv_soc, "w" ) ;
+
+- /* fdopen に失敗したら… */
+- if( read_skkserv_fp == NULL || write_skkserv_fp == NULL ){
+- if( read_skkserv_fp != NULL )
+- fclose( read_skkserv_fp ) ;
+- if( write_skkserv_fp != NULL )
+- fclose( write_skkserv_fp ) ;
+- read_skkserv_fp = write_skkserv_fp = NULL ;
+- return 1 ;
+- }
+ return 0 ;
+ }
++#endif /* ! HAVE_GETADDRINFO */
+
+ /*
+ * skkserv に message を送信する関数。
+@@ -294,14 +291,72 @@
+ * socket を用意し、skkerv に接続する関数。
+ *----
+ */
+-int skkinput_StartCommunication( char *server_name, int port_num )
++int skkinput_StartCommunication( char *server_name, char *port_str )
+ {
++#ifdef HAVE_GETADDRINFO
++ struct addrinfo aihint, *ai0, *ai;
++ int error;
++ char portnum[32];
++
++ /* backward compatibility */
++ if (skkserv_portnum) {
++ sprintf(portnum, "%d", skkserv_portnum);
++ port_str = portnum;
++ }
++
++#ifdef HAVE_BZERO
++ bzero((char*)&aihint, sizeof aihint);
++#else
++ memset((char*)&aihint, 0, sizeof aihint);
++#endif
++ aihint.ai_family = PF_UNSPEC;
++ aihint.ai_socktype = SOCK_STREAM;
++ aihint.ai_flags = AI_CANONNAME;
++ error = getaddrinfo(server_name, port_str, &aihint, &ai0);
++ if (error) {
++ printf("%s: %s\r\n", gai_strerror(error), server_name);
++ return -1;
++ }
++
++ skkserv_soc = -1;
++ for (ai = ai0; ai; ai = ai->ai_next) {
++ skkserv_soc = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
++ if (skkserv_soc >= 0 &&
++ connect(skkserv_soc, ai->ai_addr, ai->ai_addrlen) == 0)
++ break;
++ close(skkserv_soc);
++ skkserv_soc = -1;
++ }
++ if (skkserv_soc < 0) {
++ perror(server_name);
++ skkserv_connection_ok = False ;
++ return 1;
++ }
++#else
++ struct servent *servent ;
++ int port;
++
++ if ((port = atoi(port_str)) <= 0) {
++ /* "/etc/services" からポート番号を得ておく。*/
++ servent = getservbyname( port_str, SKKSERV_SERVICE_PROTO ) ;
++ if( servent == NULL ){
++ /* /etc/services に設定はなかったので、config.h の中のを使う。*/
++ port = atoi( DEFAULT_SKKPORT ) ;
++ } else {
++ /* /etc/services に設定があった…。*/
++ port = ntohs( servent->s_port ) ;
++#if defined(DEBUG)
++ fprintf( stderr, "getservbyname: \"%s\", %d\n", servent->s_name, port ) ;
++#endif
++ }
++ }
+ /* skkerv と通信するためのソケットを作成致します。*/
+- if( makeSocket( server_name, port_num ) ){
++ if( makeSocket( server_name ) ){
+ fprintf( stderr, "Warning : cannot make a socket." ) ;
+ skkserv_connection_ok = False ;
+ return 1 ;
+ }
++ server.sin_port = htons( port ) ;
+ /* 接続要求。*/
+ if( connect( skkserv_soc,
+ ( struct sockaddr *)&server, sizeof( server ) ) < 0 ){
+@@ -312,6 +367,19 @@
+ skkserv_connection_ok = False ;
+ return 1 ;
+ }
++#endif
++ read_skkserv_fp = fdopen( skkserv_soc, "r" ) ;
++ write_skkserv_fp = fdopen( skkserv_soc, "w" ) ;
++
++ /* fdopen に失敗したら… */
++ if( read_skkserv_fp == NULL || write_skkserv_fp == NULL ){
++ if( read_skkserv_fp != NULL )
++ fclose( read_skkserv_fp ) ;
++ if( write_skkserv_fp != NULL )
++ fclose( write_skkserv_fp ) ;
++ read_skkserv_fp = write_skkserv_fp = NULL ;
++ return 1 ;
++ }
+ skkserv_connection_ok = True ;
+ return 0 ;
+ }
+@@ -357,13 +425,13 @@
+
+ #ifndef MAIKAI_SKKSERV_TO_CONNECT_SURU
+ if( !skkserv_connection_ok ){
+- if( skkinput_StartCommunication( skkserv_host, skkserv_portnum ) )
++ if( skkinput_StartCommunication( skkserv_host, skkserv_portstr ) )
+ return top ;
+ }
+ #else
+ /* skkserv が生きていなければ、メッセージの送りようが無いので終了
+ する。*/
+- if( skkinput_StartCommunication( skkserv_host, skkserv_portnum ) )
++ if( skkinput_StartCommunication( skkserv_host, skkserv_portstr ) )
+ return top ;
+ #endif
+
diff --git a/japanese/skkinput/patches/patch-ae b/japanese/skkinput/patches/patch-ae
new file mode 100644
index 00000000000..8aef772fb4c
--- /dev/null
+++ b/japanese/skkinput/patches/patch-ae
@@ -0,0 +1,39 @@
+$NetBSD: patch-ae,v 1.1 2000/11/09 03:54:08 itohy Exp $
+
+--- main.c.orig Mon Mar 23 15:05:22 1998
++++ main.c Wed Nov 8 03:07:44 2000
+@@ -110,7 +110,7 @@
+ extern void initHenkanKakuteiHashTable( void ) ;
+ extern void clearHenkanKakuteiHash( void ) ;
+ /* skksoc.c */
+-extern int skkinput_StartCommunication( char *server_name, int port_num ) ;
++extern int skkinput_StartCommunication( char *server_name, char *port_str ) ;
+ extern int skkinput_CloseCommunication( void ) ;
+ /* skkldic.c */
+ extern int set_localjisyo
+@@ -197,6 +197,7 @@
+ /* その他、skkinput が必要とする…skkInputWidget 毎には必要としない情報。*/
+ char *skkserv_host ;
+ int skkserv_portnum ;
++char *skkserv_portstr ;
+ char *skkinput_local_jisyo_name ;
+ char *skkinput_backup_jisyo_name ;
+ char *skk_local_jisyo_name ;
+@@ -375,7 +376,7 @@
+ if( number_of_protocols > 0 ){
+ #ifndef MAIKAI_SKKSERV_TO_CONNECT_SURU
+ /* socket を作成しておく。*/
+- skkinput_StartCommunication( skkserv_host, skkserv_portnum ) ;
++ skkinput_StartCommunication( skkserv_host, skkserv_portstr ) ;
+ #endif
+ /* 局所辞書の情報を入れておく。*/
+ set_localjisyo
+@@ -698,7 +699,7 @@
+ break ;
+ /* skkserv と通信するに利用するポート番号を設定する。*/
+ case OPTION_PORT :
+- skkserv_portnum = atoi( argv[ i ] ) ;
++ skkserv_portstr = argv[ i ];
+ break ;
+ /* 局所辞書の名前を設定する。*/
+ case OPTION_USERDIC :