Remove sj3 client for now

Signed-off-by: Masanori Ogino <mogino@acm.org>
This commit is contained in:
Masanori Ogino 2023-11-29 13:04:04 +09:00
commit fb90d2adb0
31 changed files with 0 additions and 11834 deletions

View file

@ -1,98 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "../sj3.tmpl"
INCLUDES = -I../sj3h -I../sj3lib -I../include
#if SystemV4 || SystemV
#if defined(SonySysvArchitecture)
CODE_LIBS = -lw16 -ljcode
CCOPTIONS = -Xa -Wf,-XNp9000,-XNd6000
#else
CCOPTIONS = -Xa
#endif
#if HasSockets
EXTRA_LIBRARIES = -lnsl
#endif
#else
SRC0 = nmttyslot.c
OBJ0 = nmttyslot.o
#endif
DEFINES = $(ARCDEFS) $(SYSDEFS) -DKANJI -DOKB
SYS_LIBRARIES = -ltermcap $(CODE_LIBS)
SJ3_LIBDIR = ../sj3lib
RKDIR = ../sj3rkcv
SJLIB = $(SJ3_LIBDIR)/libsj3lib.a
INSTFLAGS = -o $(SJ3OWNER) -g $(SJ3GROUP) -m 4755
DEPLIBS = $(SJLIB)
LOCAL_LIBRARIES = $(SJLIB)
SRC1 = conv.c display.c funckey.c\
eucmessage.c sj3.c\
sj3ver.c sjgetchar.c term.c $(SRC0)
SRC2 = version.c stat_conv.c henkan.c\
romaji.c code.c\
etc.c toroku.c edit.c douon.c\
sjrc.c kigou.c common.c screen.c\
libif.c
SRC3 = $(RKDIR)/rk_conv.c \
$(RKDIR)/sj3_rkcv.c \
$(RKDIR)/wc16_str.c
SRC = $(SRC1) $(SRC2) $(SRC3)
OBJS = sj3ver.o version.o sj3.o\
funckey.o term.o\
sjgetchar.o conv.o stat_conv.o henkan.o\
romaji.o display.o code.o\
etc.o toroku.o edit.o eucmessage.o douon.o\
sjrc.o kigou.o common.o screen.o\
libif.o rk_conv.o sj3_rkcv.o wc16_str.o $(OBJ0)
AllTarget(sj3)
NormalProgramTarget(sj3,$(OBJS),$(DEPLIBS),$(LOCAL_LIBRARIES),)
DependTarget()
LinkSourceFile(rk_conv.c,$(RKDIR))
LinkSourceFile(sj3_rkcv.c,$(RKDIR))
LinkSourceFile(wc16_str.c,$(RKDIR))
InstallProgramWithFlags(sj3,$(SJ3BINDIR),$(INSTFLAGS))
InstallNamedNonExec(Sjrc,sjrc,$(SJ3CONFDIR))
InstallNamedNonExec(Sjrk,sjrk,$(SJ3CONFDIR))
InstallNamedNonExec(Xterm.cvt,cvtkey.xterm,$(SJ3CONFDIR))
InstallNamedNonExec(News.cvt,cvtkey.news,$(SJ3CONFDIR))
InstallNamedNonExec(Nwp511.cvt,cvtkey.nwp511,$(SJ3CONFDIR))
InstallNamedNonExec(Nwp517.cvt,cvtkey.nwp517,$(SJ3CONFDIR))

View file

@ -1,49 +0,0 @@
## SPDX-License-Identifier: MIT-open-group
##
## Copyright (c) 1994 Sony Corporation
##
## Permission is hereby granted, free of charge, to any person obtaining
## a copy of this software and associated documentation files (the
## "Software"), to deal in the Software without restriction, including
## without limitation the rights to use, copy, modify, merge, publish,
## distribute, sublicense, and/or sell copies of the Software, and to
## permit persons to whom the Software is furnished to do so, subject to
## the following conditions:
##
## The above copyright notice and this permission notice shall be
## included in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
## IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
## DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
## OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
## THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##
## Except as contained in this notice, the name of Sony Corporation
## shall not be used in advertising or otherwise to promote the sale, use
## or other dealings in this Software without prior written authorization
## from Sony Corporation.
# sj3 command key alias file
# for console
#
F1 ^[OP
F2 ^[OQ
F3 ^[OR
F4 ^[OS
F5 ^[OT
F6 ^[OU
F7 ^[OV
F8 ^[OW
F9 ^[OX
F10 ^[OY
Select ^[OP
Kanji ^[OH
Cancel ^[OQ
Execute ^[OS
Up ^[[A
Down ^[[B
Right ^[[C
Left ^[[D

View file

@ -1,40 +0,0 @@
## SPDX-License-Identifier: MIT-open-group
##
## Copyright (c) 1994 Sony Corporation
##
## Permission is hereby granted, free of charge, to any person obtaining
## a copy of this software and associated documentation files (the
## "Software"), to deal in the Software without restriction, including
## without limitation the rights to use, copy, modify, merge, publish,
## distribute, sublicense, and/or sell copies of the Software, and to
## permit persons to whom the Software is furnished to do so, subject to
## the following conditions:
##
## The above copyright notice and this permission notice shall be
## included in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
## IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
## DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
## OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
## THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##
## Except as contained in this notice, the name of Sony Corporation
## shall not be used in advertising or otherwise to promote the sale, use
## or other dealings in this Software without prior written authorization
## from Sony Corporation.
# sj3 command key alias file
# for nwp511
#
F6 ^[OV
F7 ^[OW
F8 ^[OX
F9 ^[OY
F10 ^[OZ
Up ^[[A
Down ^[[B
Right ^[[C
Left ^[[D

View file

@ -1,45 +0,0 @@
## SPDX-License-Identifier: MIT-open-group
##
## Copyright (c) 1994 Sony Corporation
##
## Permission is hereby granted, free of charge, to any person obtaining
## a copy of this software and associated documentation files (the
## "Software"), to deal in the Software without restriction, including
## without limitation the rights to use, copy, modify, merge, publish,
## distribute, sublicense, and/or sell copies of the Software, and to
## permit persons to whom the Software is furnished to do so, subject to
## the following conditions:
##
## The above copyright notice and this permission notice shall be
## included in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
## IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
## DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
## OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
## THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##
## Except as contained in this notice, the name of Sony Corporation
## shall not be used in advertising or otherwise to promote the sale, use
## or other dealings in this Software without prior written authorization
## from Sony Corporation.
# sj3 command key alias file
# for nwp517
#
F1 ^[[17~
F2 ^[[18~
F3 ^[[19~
F4 ^[[20~
F5 ^[[21~
F6 ^[[23~
F7 ^[[24~
F8 ^[[25~
F9 ^[[26~
F10 ^[[28~
Up ^[[A
Down ^[[B
Right ^[[C
Left ^[[D

146
sj3/Sjrc
View file

@ -1,146 +0,0 @@
## SPDX-License-Identifier: MIT-open-group
##
## Copyright (c) 1994 Sony Corporation
##
## Permission is hereby granted, free of charge, to any person obtaining
## a copy of this software and associated documentation files (the
## "Software"), to deal in the Software without restriction, including
## without limitation the rights to use, copy, modify, merge, publish,
## distribute, sublicense, and/or sell copies of the Software, and to
## permit persons to whom the Software is furnished to do so, subject to
## the following conditions:
##
## The above copyright notice and this permission notice shall be
## included in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
## IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
## DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
## OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
## THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##
## Except as contained in this notice, the name of Sony Corporation
## shall not be used in advertising or otherwise to promote the sale, use
## or other dealings in this Software without prior written authorization
## from Sony Corporation.
# SJ3用セット・アップ・ファイル
# .sjrc file sample
# sj3 1.00, 1990 Sony Corp.
# シェルの指定
#.ForkShell /bin/csh
# 文節長学習機能のoff
#.bstudy off
# SJ3コマンド・キーのコントロール・コードへのバインド
# control function key examples
.key.right ^F
.key.left ^B
.key.kakuchou ^O
.key.syukusyou ^I
.key.wrap ^N
.key.wrapback ^P
.key.saihenkan ^Y
.key.cancel ^K
.key.top ^A
.key.end ^E
#.key.henkan ^T
#.key.edit ^W
#.key.buffer ^V
#.key.flush ^M
#.key.toggle ^G
#.key.reconnect ^R
#.delkey ^D
# 文字種切り替えキーを押すと決定する
#.FlushAfterConversion on
# other control function key
#.key.start
#.key.muhenkan
#.key.kettei
#.key.hiragana
#.key.halpha
#.key.zalpha
#.key.hkatakana
#.key.zkatakana
#.key.code
#.key.etc
# その他キーが押されたときのコマンド・キーの指定
#.etckey.toroku hira
#.etckey.syoukyo zkatakana
#.etckey.help hkatakana
#.etckey.sjrc zalpha
# SJ3コマンド・キーのエスケープ・シーケンスへのバインド
# escape sequence function key (for nwp511)
nwp511.key.etc ^[OT
nwp511.key.code ^[OU
nwp511.key.halpha F6
nwp511.key.zalpha F7
nwp511.key.hkatakana F8
nwp511.key.zkatakana F9
nwp511.key.hiragana F10
nwp511.guide.function 半ア 全ア 半カ 全カ かな code \ \ 変換 無変 etc\. 決定
nwp511.guide.etc その他       
nwp511.guide.funcetc                編集 \ \ 登録 消去 help sjrc
# SJ3コマンド・キーのエスケープ・シーケンスへのバインド
# escape sequence function key (for nwp517)
nwp517.key.henkan F1
nwp517.key.muhenkan F2
nwp517.key.etc F3
nwp517.key.kettei F4
nwp517.key.code F5
nwp517.key.halpha F6
nwp517.key.zalpha F7
nwp517.key.hkatakana F8
nwp517.key.zkatakana F9
nwp517.key.hiragana F10
# viでESCキーを押した場合の動作
# for vi
.SetNormal ^[
# emacsでコントロール-Xを押したときの動作
# for emacs
#.ThroughNext ^X
# 初期動作モード
.InitialMode unbuff.halpha.direct
# ガイドラインのヘルプレベル
#.HelpMode off
# code キーを押したときの最初のデフォルトコード
#.DefaultCode jis
# 入力モード切り替えで、無変換キーを押したときのモード
.MuhenkanMode halpha
# 入力モード切り替えで、無変換キーを押したときのトグル動作
.MuhenkanToggle on
# ガイドラインのメッセージの変更例
#.guide.buffer +  
#.guide.unbuffer -
#.guide.function 変換 無変 ETC\. 決定 CODE \ 半ア 全ア 半カ 全カ かな
#.guide.hira 全かな
#.guide.zkata 全カタ
#.guide.hkata 半カナ
#.guide.zalpha 全アル
#.guide.halpha 半アル
# サーバの指定
#.server yourhost1 yourhost2 yourhost3
# ローマ字かな変換出来ないときベルを鳴らす
#.rkerrbell on

327
sj3/Sjrk
View file

@ -1,327 +0,0 @@
## SPDX-License-Identifier: MIT-open-group
##
## Copyright (c) 1994 Sony Corporation
##
## Permission is hereby granted, free of charge, to any person obtaining
## a copy of this software and associated documentation files (the
## "Software"), to deal in the Software without restriction, including
## without limitation the rights to use, copy, modify, merge, publish,
## distribute, sublicense, and/or sell copies of the Software, and to
## permit persons to whom the Software is furnished to do so, subject to
## the following conditions:
##
## The above copyright notice and this permission notice shall be
## included in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
## IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
## DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
## OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
## THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##
## Except as contained in this notice, the name of Sony Corporation
## shall not be used in advertising or otherwise to promote the sale, use
## or other dealings in this Software without prior written authorization
## from Sony Corporation.
#
# ローマ字かな変換規則定義ファイル
# デフォルトファイル
#
#フォーマット(区切りはスペースもしくはタブ)
#[in_romaji] [out_kana] [out_romaji]
A あ
I い
U う
E え
O お
KA か
KI き
KU く
KE け
KO こ
CA か
CI き
CU く
CE け
CO こ
KYA きゃ
KYI き
KYU きゅ
KYE きぇ
KYO きょ
QYA きゃ
QYI き
QYU きゅ
QYE きぇ
QYO きょ
SA さ
SI し
SU す
SE せ
SO そ
SYA しゃ
SYI し
SYU しゅ
SYE しぇ
SYO しょ
SHA しゃ
SHI し
SHU しゅ
SHE しぇ
SHO しょ
TA た
TI ち
TU つ
TE て
TO と
TSA た
TSI ち
TSU つ
TSE て
TSO と
THA たぁ
THI てぃ
THU とぅ
TYA ちゃ
TYI ち
TYU ちゅ
TYE ちぇ
TYO ちょ
TSYA ちゃ
TSYI ち
TSYU ちゅ
TSYE ちぇ
TSYO ちょ
CHA ちゃ
CHI ち
CHU ちゅ
CHE ちぇ
CHO ちょ
CYA ちゃ
CYI ち
CYU ちゅ
CYE ちぇ
CYO ちょ
NA な
NI に
NU ぬ
NE ね
NO の
NYA にゃ
NYI に
NYU にゅ
NYE にぇ
NYO にょ
HA は
HI ひ
HU ふ
HE へ
HO ほ
HYA ひゃ
HYI ひ
HYU ひゅ
HYE ひぇ
HYO ひょ
FA ふぁ
FI ふぃ
FU ふ
FE ふぇ
FO ふぉ
FYA ふゃ
FYI ふぃ
FYU ふゅ
FYE ふぇ
FYO ふょ
MA ま
MI み
MU む
ME め
MO も
MYA みゃ
MYI み
MYU みゅ
MYE みぇ
MYO みょ
YA や
YI い
YU ゆ
YE いぇ
YO よ
RA ら
RI り
RU る
RE れ
RO ろ
LA ら
LI り
LU る
LE れ
LO ろ
RYA りゃ
RYI り
RYU りゅ
RYE りぇ
RYO りょ
LYA りゃ
LYI り
LYU りゅ
LYE りぇ
LYO りょ
WA わ
WI うぃ
WU う
WE うぇ
WO を
GA が
GI ぎ
GU ぐ
GE げ
GO ご
GYA ぎゃ
GYI ぎ
GYU ぎゅ
GYE ぎぇ
GYO ぎょ
ZA ざ
ZI じ
ZU ず
ZE ぜ
ZO ぞ
ZYA じゃ
ZYI じ
ZYU じゅ
ZYE じぇ
ZYO じょ
JA じゃ
JI じ
JU じゅ
JE じぇ
JO じょ
JYA じゃ
JYI じ
JYU じゅ
JYE じぇ
JYO じょ
DA だ
DI ぢ
DU づ
DE で
DO ど
DYA ぢゃ
DYI ぢ
DYU ぢゅ
DYE ぢぇ
DYO ぢょ
DHA だぁ
DHI でぃ
DHU どぅ
DHYU でゅ
BA ば
BI び
BU ぶ
BE べ
BO ぼ
BYA びゃ
BYI び
BYU びゅ
BYE びぇ
BYO びょ
VA ヴぁ
VI ヴぃ
VU ヴ
VE ヴぇ
VO ヴぉ
VYA びゃ
VYI び
VYU びゅ
VYE びぇ
VYO びょ
PA ぱ
PI ぴ
PU ぷ
PE ぺ
PO ぽ
PYA ぴゃ
PYI ぴ
PYU ぴゅ
PYE ぴぇ
PYO ぴょ
QA くぁ
QI くぃ
QU くぅ
QE くぇ
QO くぉ
N ん
NN ん
#MB ん B
#MM ん M
#MP ん P
KK っ K
SS っ S
TT っ T
HH っ H
MM っ M
YY っ Y
RR っ R
LL っ L
WW っ W
GG っ G
ZZ っ Z
DD っ D
BB っ B
PP っ P
CC っ C
FF っ F
JJ っ J
VV っ V
QQ っ Q
XX っ X
#TCH っ CH
XA ぁ
XI ぃ
XU ぅ
XE ぇ
XO ぉ
XYA ゃ
XYI ぃ
XYU ゅ
XYE ぇ
XYO ょ
XTU っ
XTSU っ
XWA ゎ
XKA ヵ
XKE ヶ
X, ゛
X. ゜
~
#- ー
#, 、
#. 。
#@ ・
#[ 「
#] 」
#Z. …
#SONY ソニー

View file

@ -1,59 +0,0 @@
## SPDX-License-Identifier: MIT-open-group
##
## Copyright (c) 1994 Sony Corporation
##
## Permission is hereby granted, free of charge, to any person obtaining
## a copy of this software and associated documentation files (the
## "Software"), to deal in the Software without restriction, including
## without limitation the rights to use, copy, modify, merge, publish,
## distribute, sublicense, and/or sell copies of the Software, and to
## permit persons to whom the Software is furnished to do so, subject to
## the following conditions:
##
## The above copyright notice and this permission notice shall be
## included in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
## IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
## DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
## OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
## THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##
## Except as contained in this notice, the name of Sony Corporation
## shall not be used in advertising or otherwise to promote the sale, use
## or other dealings in this Software without prior written authorization
## from Sony Corporation.
# sj3 command key alias file
# for xterm
#
F1 ^[[11~
F2 ^[[12~
F3 ^[[13~
F4 ^[[14~
F5 ^[[15~
F6 ^[[17~
F7 ^[[18~
F8 ^[[19~
F9 ^[[20~
F10 ^[[21~
#F11 ^[[23~
#F12 ^[[24~
#F13 ^[[25~
#F14 ^[[26~
#F15 ^[[28~
#F16 ^[[29~
#F17 ^[[31~
#F18 ^[[32~
#F19 ^[[33~
#F20 ^[[34~
Select ^[[4~
Kanji ^[[7~
Cancel ^[[8~
Execute ^[[9~
Up ^[[A
Down ^[[B
Right ^[[C
Left ^[[D

View file

@ -1,209 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "sj_sysvdef.h"
#include "wchar16.h"
#include "kctype.h"
#if defined(__sony_news) && defined(SVR4)
#include "jctype.h"
#endif
#include "sj2.h"
#include "key.h"
#include "rk.h"
static u_char cbuf[5];
static int cur_code = CODE_EUC;
extern int current_locale;
static int ccnt = 0;
codeconv(c, rkstr)
wchar16_t c;
u_int *rkstr;
{
register u_short ccode, i;
u_short CheckCcode();
extern int erase_char;
if (c == erase_char) {
if (ccnt) {
ccnt--;
*rkstr++ = erase_char + ERRCODE;
} else {
*rkstr++ = erase_char;
}
} else if (iswcntrl(c) || (WcIsKANJI(c) && ccnt == 0)) {
*rkstr++ = c;
if (iswcntrl(c))
ccnt = 0;
} else if ((ccode = CheckCcode(c)) > 0) {
if (ccnt == 4) {
if ((cur_code != CODE_EUC) || (cur_code != CODE_EUC2)) {
if ((cur_code == CODE_KUTEN) || (cur_code == CODE_KUTEN2))
ccode += 0x2020;
ccode = jis2euc(ccode & 0x7f7f);
}
if ((cur_code == CODE_KUTEN2) ||
(cur_code == CODE_JIS2) || (cur_code == CODE_EUC2))
ccode &= WcX0212MASK;
ccnt--;
for (; ccnt > 0; ccnt--)
*rkstr++ = erase_char + ERRCODE;
*rkstr++ = SetMojilen(4) + ccode;
} else
*rkstr++ = c + ERRCODE;
} else
*rkstr++ = ERRBEL;
*rkstr = RKEND;
}
u_short
CheckCcode (c)
wchar16_t c;
{
register u_char c1;
register u_short code;
if (!WcIsASCII(c) || !isxdigit(WcLowByte(c)) ||
(cur_code == CODE_KUTEN && !isdigit(WcLowByte(c))))
return(0);
cbuf[ccnt] = WcLowByte(c);
cbuf[ccnt + 1] = '\0';
if ((cur_code == CODE_KUTEN) || (cur_code == CODE_KUTEN2)) {
if (ccnt % 2) {
code = (cbuf[ccnt-1] - '0') * 10 + cbuf[ccnt] - '0';
if (code < 1 || code > 94)
return(0);
if (ccnt >= 3)
code += ((cbuf[0]-'0') * 10 + cbuf[1]-'0') << 8;
} else
code = 1;
} else {
code = (u_short)strtol((char *)cbuf, (char **)NULL, 16);
if (ccnt % 2)
c1 = code & 0xff;
else
c1 = code & 0xf;
switch(cur_code) {
case CODE_SJIS:
if (ccnt == 0 && (c1 == 8 || c1 == 9 || c1 >= 0xe))
break;
if (ccnt == 1 && issjis1(c1))
break;
if (ccnt == 2 && c1 >= 4)
break;
if (ccnt == 3 && issjis2(c1))
break;
return(0);
case CODE_EUC:
case CODE_EUC2:
if (ccnt % 2 && iseuc(c1))
break;
if (!(ccnt % 2) && (c1 >= 0xa && c1 <= 0xf))
break;
return(0);
case CODE_JIS:
case CODE_JIS2:
if (ccnt % 2 && isjjis(c1))
break;
if (!(ccnt % 2) && (c1 >= 2 && c1 <= 7))
break;
return(0);
}
}
ccnt++;
return(code);
}
u_short
strtocode()
{
register int c;
u_short code;
while (ccnt < 4) {
c = inkey();
if (AnotherConversion ()) {
unget_key(c);
ccnt = 0;
return(-1);
}
if ((code = CheckCcode(c)) == 0) {
ccnt = 0;
beep();
return(0);
}
}
ccnt = 0;
switch (cur_code) {
case CODE_SJIS :
return(sjis2jis(code));
case CODE_KUTEN :
case CODE_KUTEN2:
return(code + 0x2020);
default :
return(code & 0x7f7f);
}
}
ChangeCode ()
{
if (cur_code == CODE_KUTEN2)
cur_code = CODE_SJIS;
else {
if (current_locale == LC_CTYPE_SHIFTJIS) {
if( cur_code == CODE_KUTEN) {
cur_code = CODE_SJIS;
return;
}
if(cur_code == CODE_SJIS) {
cur_code++;
} else {
cur_code += 2;
}
} else
cur_code++;
}
}
SetCode(code)
int code;
{
cur_code = code;
}
GetCcode()
{
return(cur_code);
}

View file

@ -1,136 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "conversion.h"
int allways_buff = 0;
int no_flush = 0;
int HHlevel = 2;
int Hlevel = 2;
int oasys = 0;
int flush_conversion;
Conversion *current_conversion;
Conversion *default_conversion;
Conversion *
AllocConversion ()
{
register Conversion *c;
if ((c = (Conversion *)malloc (sizeof(Conversion))) == NULL) {
fprintf (stderr, "conversion: can't alloc memory\n\r");
return (0);
}
c->Imode = MODE_ZHIRA;
c->BuffMode = BUFF;
c->ha_point = 0;
c->out_point = 0;
c->span_point = 0;
c->word_regist = 0;
c->Cflag = 1;
c->SavedRow = 0;
c->SavedCol = 0;
c->CurrentVcol = 0;
c->MaxVcol = 0;
c->wrap = 1;
return (c);
}
static Conversion *push_conversion;
FreeConversion (c)
Conversion *c;
{
if (c == push_conversion)
push_conversion = 0;
free (c);
}
SetConversion (c)
Conversion *c;
{
PushConversion (current_conversion);
current_conversion = c;
}
PushConversion (c)
Conversion *c;
{
push_conversion = c;
}
PopConversion ()
{
if (push_conversion)
current_conversion = push_conversion;
}
Conversion *
GetConversion ()
{
return (current_conversion);
}
InitConversion ()
{
default_conversion = AllocConversion ();
DefaultConversion ();
}
DefaultConversion ()
{
current_conversion = default_conversion;
}
EndConversion ()
{
free (default_conversion);
}
int
wcbyte(str)
register wchar16_t *str;
{
register count=0;
while (*str) {
if (WcHighMASK & *str++)
count += 2;
else
count++;
}
return (count);
}

View file

@ -1,368 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include <errno.h>
#include "wchar16.h"
#include "select.h"
#include "key.h"
#include "inkey.h"
#include "common.h"
#define MSEC 300
int keyvalue;
char *funckey[] = {
"\033OH", "\033OP", "\033OQ",
"\033OR", "\033OS", "\033OT",
"\033OU", "\033OV", "\033OW",
"\033OX", "\033OY", "\033OZ",
"\033[C", "\033OC", "\033[D",
"\033OD", "\033[A", "\033OA",
"\033[B", "\033OB", "\033[H",
"\033[4~", "\033[11~", "\033[8~",
"\033[12~", "\033[13~", "\033[9~",
"\033[14~", "\033[15~", "\033[17~",
"\033[18~", "\033[19~", "\033[20~",
"\033[21~", "\033[7~",
};
int funcvalue[] = {
KEY_CONV, KEY_HENKAN, KEY_MUHENKAN,
KEY_ETC, KEY_KETTEI, KEY_CODE,
KEY_HALPHA, KEY_ZALPHA, KEY_HKATA,
KEY_ZKATA, KEY_ZHIRA, KEY_OTHER,
KEY_RIGHT, KEY_RIGHT, KEY_LEFT,
KEY_LEFT, KEY_UP, KEY_UP,
KEY_DOWN, KEY_DOWN, KEY_CONV,
KEY_HENKAN, KEY_HENKAN, KEY_MUHENKAN,
KEY_MUHENKAN, KEY_ETC, KEY_KETTEI,
KEY_KETTEI, KEY_CODE, KEY_HALPHA,
KEY_ZALPHA, KEY_HKATA, KEY_ZKATA,
KEY_ZHIRA, KEY_CONV,
};
int keynumber = sizeof(funckey)/sizeof(char*);
extern int Direct;
extern int master;
extern wchar16_t Ukey[UKEYNUM][SEQLEN+1];
extern int Uvalue[];
extern int Unumber;
convert_stat ()
{
stat_init ();
stat_conv ();
}
inputprocess ()
{
register int c;
wchar16_t obuf[2];
if (Direct) {
set_guide_line (KEY_CONV);
convert_stat ();
}
set_guide_line (KEY_NORMAL);
print_guide_line ();
for (;;) {
if ((c = inkey ()) == EOF)
continue;
switch (keyvalue) {
case KEY_NORMAL:
obuf[0] = c;
obuf[1] = 0;
SJ_write (obuf, 1);
break;
case KEY_CONV:
set_guide_line (KEY_CONV);
convert_stat ();
set_guide_line (KEY_NORMAL);
print_guide_line ();
break;
default:
write_pseq (0);
break;
}
}
}
wchar16_t ibuf[KEYBUFSIZ];
wchar16_t pars_seq[KEYBUFSIZ];
int buf_count = 0;
int pars_n;
static int escape = 0;
inkey ()
{
register Conversion *cv;
register int i, j;
register wchar16_t c;
cv = current_conversion;
keyvalue = KEY_NORMAL;
pars_n = 0;
if (buf_count) {
if (escape && cv->Cflag)
master_flush ();
c = *ibuf;
}
else {
if ((c = SJ_getchar ()) == (wchar16_t) EOF)
return ((short) c);
*ibuf = c;
buf_count = 1;
}
if (*ibuf == ESC) {
keyvalue = sequence (ibuf, &buf_count);
escape = 1;
}
else {
escape = 0;
}
if (keyvalue == KEY_NORMAL)
keyvalue = parse_command (ibuf, &buf_count);
if (keyvalue == KEY_NORMAL) {
c = *ibuf;
for (i=1 ; i < buf_count ; i++)
ibuf[i - 1] = ibuf[i];
buf_count--;
}
if (buf_count > KEYBUFLIM) {
for (i = buf_count - 1; i >= 0 ; i --) {
if (ibuf[i] == ESC) {
for (j = i ; j < buf_count ; j ++)
ibuf[j-i] = ibuf[j];
buf_count -= i;
return(c);
}
}
buf_count = 0;
}
return (c);
}
sequence (buf, count)
wchar16_t *buf;
register int *count;
{
register int n;
SELECT_FD ifds;
struct timeval t;
register wchar16_t *s;
int value;
if (*count > 1 && (value = parse_escape (buf, count, 1)) != KEY_MORE)
return (value);
s = buf + *count;
for (;;) {
t.tv_sec = 0;
t.tv_usec = UsecWeight (0);
FD_ZERO (&ifds);
FD_SET (STDIN, &ifds);
if (select (STDIN + 1, &ifds, 0, 0, &t) <= 0) {
if (errno == EINTR) {
errno = 0;
continue;
} else {
return (parse_escape (buf, count, 0));
}
}
if ((n = SJ_read (s, KEYBUFLIM)) <= 0) {
return (parse_escape (buf, *count, 0));
}
s += n;
*count += n;
if ((value = parse_escape (buf, count, 1)) == KEY_MORE)
continue;
else {
return (value);
}
}
}
parse_escape (s, count, more)
register wchar16_t *s;
register int *count;
int more;
{
register int i, j;
wchar16_t temp[KEYBUFSIZ];
int possible;
possible = 0;
for (i = 0 ; i < Unumber ; i ++) {
for (j=0 ; j < *count ; j++) {
if (s[j] != Ukey[i][j])
break;
}
if (j == wslen (&Ukey[i][0])) {
Strncpy (pars_seq, s, j);
pars_seq[j] = (wchar16_t) '\0';
pars_n = j;
*count -= j;
if (*count > 0) {
Strncpy (temp, &s[j], *count);
temp[*count] = (wchar16_t) '\0';
wscpy(s, temp);
}
return (Uvalue[i]);
}
else if (j == *count)
possible = 1;
}
for (i = 0 ; i < keynumber ; i ++) {
for (j = 0 ; j < *count ; j ++) {
if (s[j] != (u_char)funckey[i][j])
break;
}
if (j == strlen (funckey[i])) {
Strncpy (pars_seq, s, j);
pars_seq[j] = (wchar16_t) '\0';
pars_n = j;
*count -= j;
if (*count > 0) {
Strncpy (temp, &s[j], *count);
temp[*count] = (wchar16_t) '\0';
wscpy (s, temp);
}
return (funcvalue[i]);
}
else if (j == *count)
possible = 1;
}
if (*count == 1)
return (KEY_NORMAL);
else if (more && possible)
return (KEY_MORE);
else {
Strncpy (pars_seq, s, *count);
pars_seq[*count] = (wchar16_t) '\0';
pars_n = *count;
*count = 0;
*s = '\0';
return (KEY_OTHER);
}
}
write_pseq (mod)
int mod;
{
if (mod == 3) {
if (pars_n > 0) {
pars_n = 0;
return (*pars_seq);
}
}
if (mod == 2) {
if (pars_n == 1) {
pars_n = 0;
return (*pars_seq);
}
pars_n = 0;
return (0);
}
if (mod == 1) {
if (pars_n == 1) {
pars_n = 0;
return (*pars_seq);
}
else if (IsGoto (*pars_seq)) {
Strncpy (&ibuf[buf_count], &pars_seq[1], pars_n - 1);
buf_count += pars_n - 1;
pars_n = 0;
return (*pars_seq);
}
}
if (pars_n > 0)
SJ_through (pars_seq, pars_n);
pars_n = 0;
return (0);
}

View file

@ -1,491 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "sj_sysvdef.h"
#include <errno.h>
#include "common.h"
#include "inkey.h"
#include "select.h"
char bp[TCBUFSIZE];
char bpwork[AREASIZE];
char cmove[SHORTLENGTH];
extern int master;
extern int vflag;
extern char term_name[];
int status_line;
char *CM,*US,*UE,*SO,*SE,*CE,*CS,*BEL,*RP,*AP,*TS,*FS,*DS,*I2;
char *SC,*RC,*SR,*DO;
static int keyboard = OTHER_KB;
checkterm ()
{
char *kb, *area, *tgetstr (), *tmp;
int val;
register Conversion *cv;
cv = current_conversion;
val = tgetent (bp, term_name);
if (val == -1) {
aprintf ("Can't open termcap file\n\r");
done3 ();
} else if (val == 0) {
aprintf ("No termcap entry for %s\n\r",term_name);
done3 ();
}
if ((val = tgetnum("co")) < 0) {
cv-> column = 0;
} else {
cv-> column = val;
}
if ((val = tgetnum("li")) < 0) {
cv->line = 0;
} else {
cv->line = val;
}
if (tmp = getenv("ROWS")) {
(void) sscanf(tmp, "%d", &val);
cv->line = val;
}
if (tmp = getenv("COLUMNS")) {
(void) sscanf(tmp, "%d", &val);
cv->column = val;
}
area = bpwork;
if ((CM = tgetstr ("cm", &area)) == (char *)NULL) {
aprintf ("No termcap 'cm'\n\r");
done3 ();
}
US = tgetstr ("us", &area);
UE = tgetstr ("ue", &area);
SO = tgetstr ("so", &area);
SE = tgetstr ("se", &area);
CE = tgetstr ("ce", &area);
if ((SC = tgetstr ("sc", &area)) == NULL)
SC = "\0337";
if ((RC = tgetstr ("rc", &area)) == NULL)
RC = "\0338";
if ((SR = tgetstr ("sr", &area)) == NULL)
SR = "\033M";
if ((DO = tgetstr ("do", &area)) == NULL)
DO = "\033E";
if ((CS = tgetstr ("cs", &area)) == NULL)
CS = "\033[%i%d;%dr";
if ((BEL = tgetstr ("bl", &area)) == NULL) {
BEL = "\007";
}
if ((RP = tgetstr ("RP", &area)) == NULL) {
RP = "\033[6n";
}
if ((AP = tgetstr ("AP", &area)) == NULL) {
AP = "\033[%d;%dR";
}
if ((status_line = tgetflag("hs")) && tgetflag("es")) {
TS = tgetstr ("ts", &area);
FS = tgetstr ("fs", &area);
DS = tgetstr ("ds", &area);
#ifdef SVR4
I2 = tgetstr ("i1", &area);
#else
I2 = tgetstr ("i2", &area);
#endif
} else {
status_line = 0;
}
#ifdef SVR4
if (strstr(term_name, "news") != NULL) {
keyboard = NEWS_KB;
set_news();
} else
keyboard = OTHER_KB;
#else
kb = tgetstr ("KB", &area);
if (kb == (char *)NULL || *kb == '\0')
keyboard = OTHER_KB;
else if (strcmp (kb, "news") == 0) {
keyboard = NEWS_KB;
set_news();
} else
keyboard = OTHER_KB;
#endif
strcpy (cmove, CM);
}
void outc(c)
char c;
{
putchar (c);
}
void erroutc(c)
{
fputc (c, stderr);
}
start_guideline ()
{
if (status_line && I2)
tputs(I2, 1, erroutc);
}
end_guideline ()
{
if (status_line) {
tputs(DS, 1, outc);
fflush(stdout);
}
}
put_space (n)
int n;
{
register int i;
for (i = 0 ; i < n ; i ++)
putchar (' ');
}
Backspace ()
{
putchar (BS);
}
master_flush ()
{
SELECT_FD ifds;
int nc;
struct timeval t;
do {
cont:
t.tv_sec = 0;
t.tv_usec = UsecWeight (1);
FD_ZERO (&ifds);
FD_SET (STDIN, &ifds);
FD_SET (master, &ifds);
if (select (master + 1, &ifds, 0, 0, &t) > 0) {
if (FD_ISSET (STDIN, &ifds))
if (ThroughIntr ())
return;
if (FD_ISSET (master, &ifds))
output_master ();
} else if (errno == EINTR) {
errno = 0;
goto cont;
}
if (ioctl (master, TIOCOUTQ, &nc) < 0)
return (1);
} while (nc > 0);
return (0);
}
ThroughIntr ()
{
wchar16_t s[2];
SJ_read (s, 1);
s[1] = '\0';
if (isintr (*s)) {
master_out (s, 1);
return (1);
}
else {
unget_inkey2 (s, 1);
return (0);
}
}
under_in ()
{
tputs(US, 1, outc);
}
under_out ()
{
tputs(UE, 1, outc);
}
reverse_in ()
{
tputs(SO, 1, outc);
}
reverse_out ()
{
tputs(SE, 1, outc);
}
beep ()
{
tputs(BEL, 1, outc);
Flush ();
}
CursorSet (row, col)
u_short row, col;
{
tputs(tgoto(CM, col - 1, row - 1), 1, outc);
Flush ();
}
RegionSet (row1, row2)
int row1, row2;
{
tputs (SC, 1, outc);
tputs (tgoto (CS, row2, row1 - 1), 1, outc);
tputs (RC, 1, outc);
tputs (DO, 1, outc);
tputs (SR, 1, outc);
tputs (SC, 1, outc);
tputs (tgoto (CS, row2 - 1, row1 - 1), 1, outc);
tputs (RC, 1, outc);
Flush ();
}
#define SUCC 0
#define FAIL 1
#define CRLIMIT 4
int master_flush_flag = 1;
CursorRead (row, col)
u_short *row, *col;
{
register int count;
int row1, col1, row2, col2;
row2 = col2 = 0;
count = 0;
for (;;) {
if (++count > CRLIMIT) {
break;
}
tputs(RP, 1, outc);
fflush (stdout);
if (CRP (&row1, &col1) == FAIL)
continue;
if (master_flush_flag)
master_flush ();
tputs(RP, 1, outc);
fflush (stdout);
if (CRP (&row2, &col2) == FAIL)
continue;
if (row1 == row2 && col1 == col2)
break;
}
*row = row2;
*col = col2;
}
#define CRPLIM 4
#define BACKLIM 16
#define MARKER '%'
#define SEPARA ';'
CRP (row, col)
int *row, *col;
{
register char *sa, *sd;
register int c;
char Rchar[4], Cchar[4];
wchar16_t Back[BACKLIM];
register int Back_count, count;
count = 0;
Back_count = 0;
c = '\0';
top:
sa = AP;
sd = Rchar;
if (++count > CRPLIM)
return (FAIL);
if (Back_count) {
unget_inkey2 (Back, Back_count);
Back_count = 0;
}
while ((c != ESC) && ((c = CRI ()) != ESC) && Back_count < BACKLIM)
Back[Back_count++] = c;
if (Back_count) {
unget_inkey2 (Back, Back_count);
Back_count = 0;
}
Back[Back_count++] = c;
sa ++;
while (*sa != '\0') {
if (*sa == MARKER) {
sa += 2;
while (c = CRI ()) {
if (c == ESC)
goto top;
Back[Back_count++] = c;
if (isdigit (c)) {
*(sd ++) = c;
*sd = '\0';
}
else if (c == *sa)
break;
else
goto top;
}
if (c == SEPARA)
sd = Cchar;
}
else {
c = CRI ();
if (c == ESC)
goto top;
Back[Back_count++] = c;
if (c != *sa)
goto top;
}
sa ++;
}
*row = atoi (Rchar);
*col = atoi (Cchar);
return (SUCC);
}
unget_inkey2 (s, n)
register wchar16_t *s;
register int n;
{
extern wchar16_t ibuf[];
extern int buf_count;
register int i;
if (buf_count < KEYBUFSIZ - n) {
for (i = 0 ; i < n ; i ++)
ibuf[buf_count ++] = *(s ++);
}
}
unget_key (c)
int c;
{
wchar16_t tmp[2];
tmp[0] = c;
unget_inkey2 (tmp, 1);
}
CRI ()
{
wchar16_t c;
SJ_read (&c, 1);
return (c);
}
Clear_EOL ()
{
reverse_out();
tputs(CE, 1, outc);
}
StartGuide (row, col)
u_short *row, *col;
{
register Conversion *cv;
cv = current_conversion;
master_flush_flag = 0;
if (status_line) {
tputs (tgoto (TS, 0, 0), 1, outc);
}
else {
CursorRead (row, col);
CursorSet (cv->line + 1, 0);
}
Flush ();
}
EndGuide (row, col)
u_short row, col;
{
if (status_line) {
tputs (FS, 1, outc);
}
else {
CursorSet (row, col);
}
Flush ();
master_flush_flag = 1;
}
Flush ()
{
fflush (stdout);
}
Cscroll ()
{
return (1);
}

View file

@ -1,523 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "common.h"
#include "key.h"
#include "wchar16.h"
#define DNUM 5
static int Dcount;
static int Dpoint;
static struct douon_sj3 HenkanDouon[DOUON_N];
static wchar16_t Dkanji[BUFFLENGTH * 2];
SJ_getdouon (s, d, n, choice, reconv)
wchar16_t *s;
struct douon_sj3 *d;
int n;
int choice;
int reconv;
{
register int len;
Dcount = SJ2_getdouon (s, d, n, choice, reconv);
if (Dcount < 0 && !dconnect(1))
Dcount = SJ2_getdouon (s, d, n, choice, reconv);
if (Dcount <= 0) {
Dcount = 1;
len = wslen (s);
Strncpy ((char *)d[0].ddata, s, len);
d[0].dlen = wcbyte(s);
d[0].wlen = len;
return(0);
} else
return(1);
}
exec_douon ()
{
register Conversion *cv;
int val;
cv = GetConversion ();
if (cv->CurBun == -1) {
cv->CurBun = 0;
Rdisp ();
}
cv->PreBun = cv->CurBun;
if (cv->Bkettei[cv->CurBun] & Bmuhenkan)
val = Sdouon (2);
else
val = Sdouon (1);
if (!val)
Rdisp ();
}
wrap_douon (back)
int back;
{
register Conversion *cv;
int val;
cv = current_conversion;
if (cv->CurBun == -1) {
cv->CurBun = 0;
Rdisp ();
}
cv->PreBun = cv->CurBun;
if (cv->Dflag == cv->CurBun)
val = Rdouon (back);
else {
val = Sdouon (2);
cv->Dflag = cv->CurBun;
}
if (!val)
Rdisp ();
}
Cdouon (yomi, gnum)
wchar16_t *yomi;
int gnum;
{
register int i, j;
register int len;
register wchar16_t *s;
register int dispnum;
int num;
int displen;
int base;
char tmp[BUFFLENGTH], tmp2[BUFFLENGTH * 2];
wchar16_t wtmp[BUFFLENGTH], wtmp2[BUFFLENGTH * 2];
int gakusyuu;
u_short row, col;
register Conversion *cv;
cv = current_conversion;
gakusyuu = SJ_getdouon (yomi, HenkanDouon, gnum, 0, 0);
dispnum = DNUM;
if (dispnum > Dcount)
j = Dcount;
else
j = dispnum;
len = 0;
for (i = 0 ; i < j ; i ++)
len += HenkanDouon[i].dlen;
len /= j;
if (len < 1)
len = 1;
len += 6;
sprintf (tmp, "%d/%d ", Dcount, Dcount);
displen = cv->column - strlen (tmp) - 1;
if (displen < 1)
displen = 1;
num = displen / len;
if (num < 1)
num = 1;
if (num < dispnum && num > 0)
dispnum = num;
for (i = 0 ; ; ) {
if (i >= Dcount)
i = 0;
StartGuide (&row, &col);
Clear_EOL ();
base = i;
sprintf (tmp, "%d/%d", i + 1, Dcount);
(void) mbstowcs(wtmp, tmp, BUFFLENGTH);
printR (wtmp);
put_space (1);
for (j = 0 ; j < dispnum ; j ++, i ++) {
if (i >= Dcount)
break;
len = HenkanDouon[i].dlen;
if (len > displen)
len = displen;
s = (wchar16_t *)HenkanDouon[i].ddata;
Strncpy (wtmp, s, HenkanDouon[i].wlen);
wtmp[HenkanDouon[i].wlen] = '\0';
(void) wcstombs(tmp, wtmp, BUFFLENGTH);
sprintf (tmp2, "[%d] %s ", j+1, tmp);
(void) mbstowcs(wtmp2, tmp2, BUFFLENGTH);
SJ_print (wtmp2);
}
EndGuide (row, col);
Flush ();
num = Dselect (j);
if (num == 0)
continue;
else if (num == -1) {
if ((i >= Dcount) && ((Dcount % dispnum) != 0))
i = Dcount - (Dcount % dispnum);
else
i -= dispnum;
i -= dispnum;
if (i < 0) {
if (Dcount > dispnum) {
if ((Dcount % dispnum) == 0)
i = Dcount - dispnum;
else
i = Dcount - (Dcount % dispnum);
}
else
i = 0;
}
continue;
}
else if (num > j) {
disp_mode ();
return (FALSE);
}
else
break;
}
disp_mode ();
Dpoint = base + num - 1;
len = HenkanDouon[Dpoint].dlen;
s = (wchar16_t *)HenkanDouon[Dpoint].ddata;
Strncpy (Dkanji, s, HenkanDouon[Dpoint].wlen);
Dkanji[HenkanDouon[Dpoint].wlen] = '\0';
if (HenkanDouon[Dpoint].valid)
PushGD (gnum, &HenkanDouon[Dpoint].dcid);
if (gakusyuu)
if (HenkanDouon[Dpoint].valid)
SJ2_study (&HenkanDouon[Dpoint].dcid);
else
SJ2_toroku(yomi, HenkanDouon[Dpoint].ddata, SJ3_H_NRMNOUN);
return (TRUE);
}
Dselect (lim)
register int lim;
{
extern int keyvalue;
register int c, num;
char s[2];
SaveConversion ();
while ((c = inkey ()) != EOF) {
if (AnotherConversion ()) {
unget_key (c);
break;
}
if (keyvalue == KEY_KETTEI)
break;
else if (keyvalue == KEY_HENKAN || keyvalue == KEY_RIGHT)
return (0);
else if (c == ' ')
return (0);
else if (keyvalue == KEY_MUHENKAN || keyvalue == KEY_LEFT
|| is_bsdel (c))
return (-1);
else if (WcIsASCII(c) && isdigit (WcLowByte(c))) {
*s = c;
s[1] = '\0';
num = atoi (s);
if (num > 0 && num <= lim)
return (num);
}
else if (keyvalue != KEY_NORMAL)
break;
else if (keyvalue == KEY_NORMAL && IsESC (c))
break;
}
return (lim + 1);
}
Gdouon (yomi, num, choice, reconv)
wchar16_t *yomi;
int num;
int choice;
int reconv;
{
register int len;
register wchar16_t *s;
SJ_getdouon (yomi, HenkanDouon, num, choice, reconv);
Dpoint = 0;
len = HenkanDouon[Dpoint].wlen;
s = (wchar16_t *)HenkanDouon[Dpoint].ddata;
Strncpy (Dkanji, s, len);
Dkanji[len] = '\0';
if (HenkanDouon[Dpoint].valid)
PushGD (num, &HenkanDouon[Dpoint].dcid);
}
Sdouon (Choice)
int Choice;
{
register Conversion *cv;
register int i, j;
int len;
wchar16_t yomi[BUFFLENGTH * 2];
int count;
cv = current_conversion;
count = 0;
if (Choice == 0)
i = cv->PreBun;
else
i = cv->CurBun;
top:
if ((len = load_bun(i, yomi, MODE_ZHIRA)) <= 0) {
cv->Bkettei[i] |= Bmuhenkan;
cv->Bkettei[i] &= ~Bhenkan;
cv->Pkettei[i] = MODE_ZHIRA;
*Dkanji = '\0';
goto null;
}
else if (len > DLEN) {
cv->Bkettei[i] |= Bmuhenkan;
cv->Bkettei[i] &= ~Bhenkan;
*Dkanji = '\0';
goto null;
}
else if (Choice == 0 && (cv->Bkettei[i] & Bmuhenkan)) {
goto tail;
}
else {
cv->Bkettei[i] |= Bhenkan;
cv->Bkettei[i] &= ~Bmuhenkan;
}
if (Choice == 1) {
if (Cdouon (yomi, i) == FALSE)
return (1);
cv->Pkettei[i] = MODE_ZHIRA;
}
else if (Choice == 2) {
Gdouon (yomi, i, 0, 0);
}
else if (Choice == 3)
Gdouon (yomi, i, count, 1);
else
Gdouon (yomi, i, count, 0);
null:
len = wslen (Dkanji);
if (!(cv->Bkettei[i] & Bedit)) {
if (cv->Enum >= MAXENUM)
return (1);
j = cv->Enum ++;
cv->Edit[i] = j;
cv->Epoint[j] = &(cv->Ebuff[cv->e_point]);
cv->e_point += DLEN;
}
else
j = cv->Edit[i];
if (0 < len && len <= DLEN) {
cv->Bkettei[i] |= Bedit;
cv->Pkettei[i] = MODE_ZHIRA;
}
cv->Elen[j] = len;
wscpy (cv->Epoint[j], Dkanji);
tail:
if (Choice == 0 && i != cv->CurBun) {
i = cv->CurBun;
goto top;
}
if (cv->PreBun == cv->Bnum)
cv->Bkettei[cv->Bnum] = Bend;
return (0);
}
Rdouon (back)
int back;
{
register Conversion *cv;
register int i, j;
register int len;
register wchar16_t *s;
cv = current_conversion;
if (Dcount > 0) {
if (back) {
Dpoint --;
if (Dpoint < 0)
Dpoint = Dcount - 1;
}
else {
Dpoint ++;
if (Dpoint >= Dcount)
Dpoint = 0;
}
len = HenkanDouon[Dpoint].wlen;
s = (wchar16_t *)HenkanDouon[Dpoint].ddata;
Strncpy (Dkanji, s, len);
Dkanji[len] = '\0';
i = cv->CurBun;
j = cv->Edit[i];
cv->Elen[j] = len;
wscpy (cv->Epoint[j], Dkanji);
return (0);
}
return (1);
}
Bkanji (kanji)
wchar16_t *kanji;
{
register Conversion *cv;
register int i;
int plen, len;
wchar16_t *s;
cv = current_conversion;
s = kanji;
*s = '\0';
plen = 0;
for (i = 0 ; i < cv->Bnum ; i ++) {
if ((len = Bstr (i, s)) <= 0)
continue;
s += len;
plen += len;
}
return(plen);
}
struct studyrec Gdata[BUFFLENGTH];
PushGD (num, wordid)
int num;
struct studyrec *wordid;
{
Gdata[num] = *wordid;
}
cl_gakusyuu ()
{
register Conversion *cv;
register int i, j;
register int o_point, n_point;
cv = current_conversion;
for (i = 0 ; i < cv->Bnum ; i ++) {
if (cv->OrgPlen[i] != cv->Plen[i]) {
o_point = n_point = 0;
j = i;
while (j < cv->Bnum) {
o_point += cv->OrgPlen[j];
n_point += cv->Plen[j];
j ++;
if (o_point == n_point)
break;
}
j--;
check_and_gakusyuu (i, j);
i = j;
}
}
}
check_and_gakusyuu (m, n)
int m, n;
{
register Conversion *cv;
register int i, j;
cv = current_conversion;
i = m;
j = i + 1;
while (j <= n && j < cv->Bnum) {
if (cv->Bkettei[i] & Bedit && !(cv->Bkettei[i] & Bmuhenkan))
go_gakusyuu (i);
i ++;
j ++;
}
}
go_gakusyuu (n)
int n;
{
register Conversion *cv;
register int i, j;
wchar16_t yomi1[BUFFLENGTH], yomi2[BUFFLENGTH];
struct studyrec *gdatap;
int len;
cv = current_conversion;
i = n;
j = i + 1;
if (cv->Pedited[i] == 1 || cv->Pedited[j] == 1)
return;
if ((len = load_bun(i, yomi1, MODE_ZHIRA)) <= 0 && len > DLEN)
return;
if ((len = load_bun(j, yomi2, MODE_ZHIRA)) > DLEN)
return;
if (len <= 0)
gdatap = NULL;
else
gdatap = &Gdata[j];
SJ2_clstudy (yomi1, yomi2, gdatap);
}

View file

@ -1,856 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "common.h"
#include "key.h"
static wchar16_t *jpoint;
static int iedit, jedit;
static int ilen, jlen;
push_obj (i, j)
register int i, j;
{
register Conversion *cv;
cv = GetConversion ();
jpoint = cv->Ppoint[j];
ilen = cv->Plen[i];
jlen = cv->Plen[j];
iedit = cv->Bkettei[i];
jedit = cv->Bkettei[j];
}
pop_obj (i, j)
register int i, j;
{
register Conversion *cv;
cv = GetConversion ();
cv->Ppoint[j] = jpoint;
cv->Plen[i] = ilen;
cv->Plen[j] = jlen;
cv->Bkettei[i] = iedit;
cv->Bkettei[j] = jedit;
}
Bbig ()
{
register Conversion *cv;
register int i, j, k;
int moji, last, val;
cv = GetConversion ();
if (cv->CurBun < 0)
cv->CurBun = 0;
i = cv->CurBun;
j = i + 1;
while (j < cv->Bnum) {
if (cv->Plen[j] > 0) {
push_obj (i, j);
k = cv->Ppoint[j] - cv->Ppoint[0];
last = k + cv->Plen[j];
moji = 0;
for (; k < last; k++) {
if (k < last-1 &&(cv->out_mode[k+1]&OMODE_ZEN)){
moji += 2;
k++;
}else
moji++;
if (cv->out_mode[k+1] & OMODE_MASK)
break;
}
cv->Plen[i] += moji;
cv->Plen[j] -= moji;
cv->Ppoint[j] = cv->Ppoint[i] + cv->Plen[i];
cv->PreBun = j;
if (cv->Bkettei[i] & Bhenkan) {
val = Sdouon (0);
}
else {
cv->Bkettei[i] |= Bmuhenkan;
cv->Bkettei[i] &= ~Bhenkan;
cv->Bkettei[j] |= Bmuhenkan;
cv->Bkettei[j] &= ~Bhenkan;
val = 0;
}
if (!val) {
cv->Dflag = -1;
Rdisp ();
return (1);
}
break;
}
else
j ++;
}
beep ();
if (j < cv->Bnum)
pop_obj (i, j);
return (0);
}
Bsmall (small)
int small;
{
register Conversion *cv;
register int i, j, k, moji;
int val;
cv = GetConversion ();
if (cv->CurBun < 0)
cv->CurBun = 0;
i = cv->CurBun;
j = i + 1;
if (j <= cv->Bnum && cv->Plen[i] > 1) {
if (j == cv->Bnum) {
cv->Bnum ++;
cv->Bkettei[cv->Bnum] = Bend;
cv->Plen[j] = 0;
cv->Pkettei[j] = cv->Pkettei[i];
cv->Bkettei[j] |= Bmuhenkan;
cv->Bkettei[j] &= ~Bhenkan;
}
else if (small) {
while (j < cv->Bnum - 1 && cv->Plen[j] == 0)
j ++;
if (j == cv->Bnum)
j --;
}
else if (cv->Plen[j] != 0 && cv->Enum < MAXENUM) {
for (k = cv->Bnum ; k > j ; k --) {
cv->Plen[k] = cv->Plen[k - 1];
cv->Ppoint[k] = cv->Ppoint[k - 1];
cv->Pkettei[k] = cv->Pkettei[k - 1];
cv->Bpoint[k] = cv->Bpoint[k - 1];
cv->Bkettei[k] = cv->Bkettei[k - 1];
cv->Displen[k] = cv->Displen[k - 1];
cv->Dispmod[k] = cv->Dispmod[k - 1];
cv->Edit[k] = cv->Edit[k - 1];
}
cv->Bnum ++;
cv->Plen[j] = 0;
cv->Bkettei[j] = Bmuhenkan;
cv->Displen[j] = 0;
}
else if (cv->Plen[j] != 0) {
while (j < cv->Bnum - 1 && cv->Plen[j] == 0)
j ++;
if (j == cv->Bnum)
j --;
}
else {
while (j < cv->Bnum - 1 && cv->Plen[j] == 0 &&
cv->Plen[j+1] == 0)
j ++;
}
push_obj (i, j);
k = cv->Ppoint[i] - cv->Ppoint[0] + cv->Plen[i] - 1;
if (cv->out_mode[k] & OMODE_ZEN)
moji = 2;
else
moji = 1;
cv->Plen[i] -= moji;
cv->Plen[j] += moji;
cv->Ppoint[j] = cv->Ppoint[i] + cv->Plen[i];
if (cv->Plen[i] < 1) {
beep ();
pop_obj (i, j);
return(0);
}
cv->PreBun = j;
if (cv->Bkettei[i] & Bhenkan) {
val = Sdouon (0);
}
else {
cv->Bkettei[i] |= Bmuhenkan;
cv->Bkettei[i] &= ~Bhenkan;
cv->Bkettei[j] |= Bmuhenkan;
cv->Bkettei[j] &= ~Bhenkan;
val = 0;
}
if (!val) {
cv->Dflag = -1;
Rdisp ();
return (1);
}
beep ();
pop_obj (i, j);
}
else {
beep ();
}
return (0);
}
Bdelete ()
{
register Conversion *cv;
register int i, j, deletelen, val;
cv = GetConversion ();
if (cv->CurBun < 0) {
cv->CurBun = 0;
return;
}
i = cv->CurBun;
j = i + 1;
if (j <= cv->Bnum && cv->Plen[i] > 0) {
while (j < cv->Bnum && cv->Plen[j] == 0)
j ++;
if (j == cv->Bnum) {
j = i - 1;
while (j >= 0 && cv->Plen[j] == 0)
j --;
if (j == -1)
j = i;
}
push_obj (i, j);
deletelen = cv->Plen[i];
cv->Plen[i] = 0;
cv->PreBun = i;
cv->CurBun = j;
val = Sdouon (0);
if (!val) {
cv->Dflag = -1;
Chain (i, deletelen);
Rdisp ();
if (i == j)
all_set_up ();
} else {
beep ();
pop_obj (i, j);
}
}
else {
beep ();
all_set_up ();
}
}
Chain (n, len)
register int n;
register int len;
{
register Conversion *cv;
register int i;
register wchar16_t *p;
register u_short *pp;
int mlen, plen, ipos, rlen, imlen;
cv = GetConversion ();
if (cv->Ppoint[n+1] == 0)
return;
mlen = strlen ((char *)cv->Ppoint[n+1]);
plen = cv->Ppoint[n] - cv->Ppoint[0];
p = cv->Ppoint[n];
pp = &cv->out_mode[plen];
ipos = getipos(plen);
if (cv->Ppoint[n+1] > cv->Ppoint[0])
rlen = getipos(cv->Ppoint[n+1] - cv->Ppoint[0]) - ipos;
else
rlen = 0;
imlen = 0;
for (i = 0 ; i < mlen ; i ++) {
p[i] = p[i+len];
pp[i] = pp[i+len];
imlen += pp[i] & OMODE_MASK;
}
p[mlen] = '\0';
cv->out_point -= len;
p = &cv->Halpha[ipos];
for (i = 0; i < imlen; i++)
p[i] = p[i+rlen];
p[imlen] = '\0';
cv->ha_point -= rlen;
for (i = n + 1 ; i < cv->Bnum ; i ++)
cv->Ppoint[i] -= len;
}
static int Elimit;
static int Ehlimit;
exec_edit ()
{
register Conversion *cv;
register int edit, inc, i;
register wchar16_t *s;
wchar16_t Htmp[BUFFLENGTH], Ztmp[BUFFLENGTH * 2];
u_short Omode[BUFFLENGTH * 2];
int bun;
int edited, editlen;
int len, rlen, hlen, diff;
int Zcol, cur, icur, res, ncur;
extern int keyvalue;
wchar16_t number[3];
wchar16_t tmp[3];
int num, numpoint;
extern char *Gedit;
cv = GetConversion ();
bun = cv->CurBun;
len = load_bun2(bun, Htmp, Ztmp, Omode);
rlen = wslen(Htmp);
if (len > DLEN) {
guide_print_pause(WCGedit, WCTooLong);
return(0);
}
TopGuide ();
spaceR (WCGedit);
SJ_print (Ztmp);
Clear_EOL ();
backspace (wcbyte (Ztmp));
Zcol = 0;
Flush ();
cur = cv->Ppoint[bun] - cv->Ppoint[0];
ncur = cur + cv->Plen[bun];
s = cv->Ppoint[bun];
s += cv->Plen[bun];
res = wslen(s);
i = BUFFLENGTH * 2 - res - cur - 1;
if (i < DLEN)
Elimit = i;
else
Elimit = DLEN;
i = BUFFLENGTH - wslen(cv->Halpha) + rlen - 1;
if (i < DLEN)
Ehlimit = i;
else
Ehlimit = DLEN;
edited = 0;
edit = 1;
numpoint = 0;
SaveConversion ();
while (edit) {
inc = inkey ();
cv = GetConversion ();
if (AnotherConversion ()) {
unget_key (inc);
edited = 0;
break;
}
if (keyvalue == KEY_CONV)
return (0);
if (keyvalue == KEY_HENKAN || keyvalue == KEY_KETTEI)
break;
else if (keyvalue == KEY_UP)
inc = 'a';
else if (keyvalue == KEY_DOWN)
inc = 'i';
else if (keyvalue == KEY_RIGHT)
inc = 'l';
else if (keyvalue == KEY_LEFT)
inc = 'h';
switch (inc) {
case EOF:
case ESC:
edit = 0;
break;
case 'l':
case ' ':
num = getnum (number, &numpoint);
if (Zcol >= len - 1) {
beep ();
break;
}
for (i = 0 ; i < num && Zcol < len - 1 ; i++) {
tmp[0] = Ztmp[Zcol];
tmp[1] = 0;
SJ_print(tmp);
Zcol ++;
}
Flush ();
break;
case 'h':
case BS:
num = getnum (number, &numpoint);
if (Zcol <= 0) {
beep ();
break;
}
for (i = 0 ; i < num && Zcol >= 1 ; i ++)
backspace(2);
Zcol -= 1;
Flush ();
break;
case '\014':
case '$':
num = getnum (number, &numpoint);
if (len <= 0)
break;
Zcol = len - 1;
TopGuide ();
spaceR (WCGedit);
SJ_print (Ztmp);
Clear_EOL ();
backspace (2);
Flush ();
break;
case 'a':
if (len >= 1) {
tmp[0] = Ztmp[Zcol];
tmp[1] = 0;
SJ_print (tmp);
Zcol ++;
Flush ();
}
case 'i':
num = getnum (number, &numpoint);
if (editlen = Insert(Htmp, Ztmp, Omode, Zcol)) {
len += editlen;
Zcol += editlen;
edited = 1;
}
if (Zcol >= 1) {
backspace(2);
Zcol -= 1;
}
Print_EOL (&Ztmp[Zcol]);
Flush ();
break;
case DEL:
case 'x':
num = getnum (number, &numpoint);
if (len <= 0) {
beep ();
break;
}
len -= EditDel (Htmp, Ztmp, Omode, Zcol, num);
if (Zcol >= len && Zcol >= 1) {
backspace(2);
Zcol -= 1;
}
Print_EOL (&Ztmp[Zcol]);
Flush ();
edited = 1;
break;
case 'r':
num = getnum (number, &numpoint);
if (len <= 0) {
beep ();
break;
}
i = Replace(Htmp, Ztmp, Omode, Zcol, num);
if (i > 0) {
i -= 1;
Zcol += i;
backspace(2);
edited = 1;
}
Print_EOL (&Ztmp[Zcol]);
Flush ();
break;
case 's':
num = getnum (number, &numpoint);
if (len <= 0) {
beep ();
break;
}
if (editlen = Substitute(Htmp,Ztmp,Omode,&Zcol,num)) {
len += editlen;
}
if (Zcol >= 1) {
backspace(2);
Zcol -= 1;
}
Print_EOL (&Ztmp[Zcol]);
Flush ();
edited = 1;
break;
case '0':
if (numpoint == 0) {
num = getnum (number, &numpoint);
TopGuide ();
spaceR (WCGedit);
Flush ();
Zcol = 0;
break;
}
default:
if (iswdigit (inc)) {
if (numpoint > 1) {
number[0] = number[1];
number[1] = inc;
}
else
number[numpoint ++] = inc;
}
else {
num = getnum (number, &numpoint);
beep ();
}
break;
}
}
if (edited) {
for (i = 0; i < res; i++) {
Ztmp[i + len] = *s++;
Omode[i + len] = cv->out_mode[i + ncur];
}
res += len;
s = cv->Ppoint[bun];
for (i = 0; i < res; i++) {
*s++ = Ztmp[i];
cv->out_mode[i + cur] = Omode[i];
}
*s = '\0';
hlen = wslen(Htmp);
icur = getipos(cur);
s = &cv->Halpha[icur];
s += rlen;
if (*s)
wscat (Htmp, s);
wscpy (&cv->Halpha[icur], Htmp);
if ((diff = len - cv->Plen[bun]) != 0) {
cv->Plen[bun] = len;
cv->out_point += diff;
cv->out_epoint += diff;
for (i = bun + 1 ; i < cv->Bnum ; i ++)
cv->Ppoint[i] += diff;
}
if ((diff = hlen - rlen) != 0) {
cv->ha_point += diff;
cv->ha_epoint += diff;
}
if ((i = cv->Bpoint[bun]) < (unsigned int)cv->Bpoint[0])
i = cv->span_point;
cv->kettei[i - 1] = MODE_ZHIRA;
cv->Pedited[bun] = 1;
cv->Dflag = -1;
return (1);
}
return (0);
}
getnum (number, numpoint)
wchar16_t number[];
int *numpoint;
{
char temp[3];
int i=0;
if (*numpoint == 0)
return (1);
number[*numpoint] = '\0';
*numpoint = 0;
do {
temp[i] = WcLowByte(number[i]);
} while (number[i++] != 0) ;
return (atoi (temp));
}
Replace(Hs, Zs, omode, cur, num)
wchar16_t *Hs, *Zs;
u_short *omode;
int cur, num;
{
register int i, len, inc;
int beep_on, icur1, icur2;
wchar16_t roma[SHORTBUFFSIZE+1], kana[SHORTBUFFSIZE+1];
wchar16_t work[DLEN+1];
u_short otmp[SHORTBUFFSIZE+1];
*roma = '\0';
*kana = '\0';
SaveConversion(GetConversion());
while (1) {
inc = inkey();
if (AnotherConversion(GetConversion())) {
unget_key(inc);
*kana = '\0';
break;
}
len = wslen(roma);
if (inc == ESC) {
if (len > 0)
(void)exec_romaji2(0, roma, kana, otmp,
wslen(kana), len);
break;
}
if (iswcntrl(inc) && !(len > 0 && is_bs(inc))) {
beep();
*kana = '\0';
break;
}
if (exec_romaji2(inc, roma, kana, otmp, wslen(kana), len))
break;
}
sj3_rkclear();
if ((len = wslen(kana)) <= 0)
return(0);
if (kana[2] != '\0') {
beep_on = 1;
*otmp = sj_zentohan(roma, kana, 2);
kana[2] = '\0';
} else
beep_on = 0;
backspace(wcbyte(kana));
len = wslen(&Zs[cur]);
if (num <= 0)
num = 2;
if (!(omode[cur] & OMODE_MASK))
chhstr(Hs, Zs, omode, cur);
icur1 = getipos2(omode, cur);
if (len <= num) {
num = len;
*work = '\0';
} else {
if (!(omode[cur + num] & OMODE_MASK))
chhstr(Hs, Zs, omode, cur + num);
icur2 = getipos2(omode, cur + num);
wscpy(work, &Hs[icur2]);
}
Hs[icur1] = '\0';
for (i = 0; i < num; i += 2) {
SJ_print(kana);
Zs[cur] = kana[0];
omode[cur++] = otmp[0];
Zs[cur] = kana[1];
omode[cur++] = otmp[1];
wscat(Hs, roma);
}
Flush();
wscat(Hs, work);
if (beep_on)
beep();
return(num);
}
Substitute(Hs, Zs, omode, cur, num)
wchar16_t *Hs, *Zs;
u_short *omode;
int *cur, num;
{
wchar16_t work[DLEN + 1];
wchar16_t work2[DLEN + 1];
register int len;
len = wslen(&Zs[*cur]);
if (len < num)
num = len;
Strncpy (work, &Zs[*cur], num - 1);
work[num - 1] = '\0';
wscpy(work2, work);
wscat(work2, WCDollar);
SJ_print (work2);
backspace (wcbyte(&Zs[*cur]));
Flush ();
(void)EditDel(Hs, Zs, omode, *cur, num);
if (len = Insert(Hs, Zs, omode, *cur))
*cur += len;
len -= num;
return (len);
}
Insert(Hs, Zs, omode, cur)
wchar16_t *Hs, *Zs;
u_short *omode;
int cur;
{
register int inc, len, i;
int limit, hlimit, ylen, res, icur, rlen;
wchar16_t ztmp[DLEN + 1], htmp[DLEN + 1];
u_short otmp[DLEN + 1];
ylen = wslen(Zs);
limit = Elimit - ylen;
hlimit = Ehlimit - strlen((char *)Hs);
*ztmp = '\0';
*htmp = '\0';
SaveConversion (GetConversion ());
while (1) {
inc = inkey ();
if (AnotherConversion (GetConversion ())) {
unget_key (inc);
sj3_rkclear();
return(0);
}
if (inc == ESC)
break;
if (iswcntrl(inc) && !is_bs(inc))
beep ();
else if (((len = wslen(ztmp)) >= limit ||
(rlen = wslen(htmp)) >= hlimit) && !is_bs(inc))
beep();
else
(void)exec_romaji2(inc, htmp, ztmp, otmp, len, rlen);
}
(void)exec_romaji2(0, htmp, ztmp, otmp, strlen((char *)ztmp), strlen((char *)htmp));
sj3_rkclear();
len = wslen (ztmp);
backspace(wcbyte(ztmp));
SJ_print(ztmp);
Flush();
if (len) {
if (!(omode[cur] & OMODE_MASK))
chhstr(Hs, Zs, omode, cur);
icur = getipos2(omode, cur);
res = ylen - cur;
for (i = 0; i < res; i++) {
ztmp[i + len] = Zs[i + cur];
otmp[i + len] = omode[i + cur];
}
res += len;
for (i = 0; i < res; i++) {
Zs[i + cur] = ztmp[i];
omode[i + cur] = otmp[i];
}
Zs[i + cur] = '\0';
wscat(htmp, &Hs[icur]);
wscpy(&Hs[icur], htmp);
}
return (len);
}
EditDel (Hs, Zs, omode, cur, num)
wchar16_t *Hs, *Zs;
u_short *omode;
int cur, num;
{
register int i, j;
int icur, len, rlen;
if (!(omode[cur] & OMODE_MASK))
chhstr(Hs, Zs, omode, cur);
len = wslen(&Zs[cur]);
icur = getipos2(omode, cur);
if (len < num) {
Zs[cur] = '\0';
Hs[icur] = '\0';
} else {
if (!(omode[cur + num] & OMODE_MASK))
chhstr(Hs, Zs, omode, cur + num);
rlen = getipos2(omode, cur + num) - icur;
j = len - num + cur;
for (i = cur; i < j; i++) {
Zs[i] = Zs[i + num];
omode[i] = omode[i + num];
}
Zs[i] = '\0';
j = wslen(Hs) - rlen;
for (i = icur; i < j; i++)
Hs[i] = Hs[i + rlen];
Hs[i] = '\0';
len = num;
}
return (len);
}
chhstr(Hs, Zs, omode, cur)
wchar16_t *Hs, *Zs;
u_short *omode;
int cur;
{
register int i, j, len;
int prep, nextp;
int hprep, hnextp;
wchar16_t hkana[BUFFLENGTH], *hkp;
len = wslen(Zs);
prep = cur;
hprep = getipos2(omode, prep);
nextp = cur + 1;
hnextp = getipos2(omode, nextp);
hkp = hkana;
for(i = prep; i < nextp; i++) {
if (i < nextp - 1 && (WcIsZENKAKU(Zs[i]))) {
j = sj_zentohan(hkp, &Zs[i], 1);
hkp += j;
omode[i] = j;
} else {
*hkp++ = Zs[i];
omode[i] = 1;
}
}
wscpy(hkp, &Hs[hnextp]);
wscpy(&Hs[hprep], hkana);
}
Print_EOL (s)
register wchar16_t *s;
{
if (*s != '\0')
SJ_print (s);
Clear_EOL ();
if (*s != '\0')
backspace (wcbyte (s));
}
backspace (n)
int n;
{
register int i;
for (i = 0 ; i < n ; i ++)
Backspace ();
}

475
sj3/etc.c
View file

@ -1,475 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "common.h"
#include "key.h"
extern int keyvalue;
static char rehname[SHORTLENGTH * 2];
extern char *cur_serv;
static int dcflag = 0;
exec_etc (key)
int key;
{
u_short row, col;
register int inc;
int chbun;
int edited;
int etckey;
register Conversion *cv;
cv = GetConversion ();
edited = 0;
chbun = 0;
StartGuide (&row, &col);
if (key == KEY_ETC) {
printR (WCGEtc);
if (cv->column >= MINCOL)
spaceR (WCGetc);
Clear_EOL ();
EndGuide (row, col);
SaveConversion ();
inc = inkey ();
if (AnotherConversion ())
return(KEY_NORMAL);
cv = GetConversion ();
etckey = etc_map (keyvalue);
}
else {
EndGuide (row, col);
etckey = key;
}
switch (etckey) {
case KEY_NORMAL:
normal:
switch (inc) {
case 'h':
helplevel ();
break;
case 't':
if (!IsCflag ())
chbun = exec_toroku ();
break;
case 's':
if (!IsCflag ())
chbun = exec_syoukyo ();
break;
case 'v':
case 'd':
disp_version (inc);
break;
case 'w':
change_weight ();
break;
default:
break;
}
break;
case KEY_HELP:
helplevel ();
break;
case KEY_TOROKU:
if (!IsCflag ())
chbun = exec_toroku ();
break;
case KEY_SYOUKYO:
if (!IsCflag ())
chbun = exec_syoukyo ();
break;
case KEY_SJRC:
if (IsCflag ())
exec_sjrc ();
break;
case KEY_EDIT:
if (IsHenkan ()) {
if (cv->CurBun < 0) {
cv->CurBun = 0;
Bdisp (1);
}
edited = exec_edit ();
}
break;
case KEY_RECONNECT:
if (reconnect() && IsHenkan()) {
EndGuide (row, col);
Clear_EOL();
Ccheck();
Cclear(1);
ResetHenkan();
vprintU(cv->out_buf, 1);
cv->Kanji = 0;
return(KEY_NORMAL);
}
break;
case KEY_ETC:
break;
default:
if ((inc = write_pseq (2)) != 0)
goto normal;
return(etckey);
break;
}
EndGuide (row, col);
if (edited) {
if (!Sdouon (3))
Rdisp ();
}
if (chbun)
Ssbun(1);
return(KEY_NORMAL);
}
Ssbun(flag)
int flag;
{
register Conversion *cv;
static short ScurBun, SpreBun;
cv = GetConversion();
if (flag) {
if (cv->CurBun != ScurBun || cv->PreBun != SpreBun) {
cv->CurBun = ScurBun;
cv->PreBun = SpreBun;
Bdisp();
}
} else {
ScurBun = cv->CurBun;
SpreBun = cv->PreBun;
}
}
etc_map (key)
int key;
{
extern int u_etckeys;
extern int Uetckey[], Uetcval[];
register int i;
int val;
for (i = 0 ; i < u_etckeys ; i ++) {
if (key == Uetckey[i])
return (Uetcval[i]);
}
switch (key) {
case KEY_HENKAN:
val = KEY_TOROKU;
break;
case KEY_MUHENKAN:
val = KEY_SYOUKYO;
break;
case KEY_ETC:
val = KEY_HELP;
break;
case KEY_KETTEI:
val = KEY_SJRC;
break;
case KEY_CODE:
val = KEY_EDIT;
break;
case KEY_HALPHA:
val = KEY_RECONNECT;
break;
default:
val = KEY_NORMAL;
break;
}
return (val);
}
helplevel ()
{
wchar16_t wtmp[BUFFLENGTH];
u_char mtmp[BUFFLENGTH];
u_char tmp[BUFFLENGTH];
register Conversion *cv;
cv = GetConversion ();
if (Hlevel == 1 && cv->column >= MINCOL) {
HHlevel = 2;
Hlevel = 2;
(void) wcstombs((char *)mtmp, WCMHelp, BUFFLENGTH);
sprintf ((char *)tmp, (char *)mtmp, "on");
(void) mbstowcs(wtmp, (char *)tmp, BUFFLENGTH);
}
else {
HHlevel = 1;
Hlevel = 1;
(void) wcstombs((char *)mtmp, WCMHelp, BUFFLENGTH);
sprintf ((char *)tmp, (char *)mtmp, "off");
(void) mbstowcs(wtmp, (char *)tmp, BUFFLENGTH);
}
guide_print_pause (WCGHelp, wtmp);
}
disp_version (c)
int c;
{
extern char *Version, *Copyright, *Date;
char tmp[BUFFLENGTH];
wchar16_t wtmp[BUFFLENGTH];
if (c == 'v')
sprintf (tmp, "%s, %s ", Version, Copyright);
else if (c == 'd')
sprintf (tmp, "%s ", Date);
else
return;
(void) mbstowcs(wtmp, tmp, BUFFLENGTH);
guide_print_pause (0, wtmp);
}
exec_sjrc ()
{
extern char RCfile[];
char tmp[BUFFLENGTH];
u_char SUCCorFAIL[BUFFLENGTH];
wchar16_t wtmp[BUFFLENGTH];
if (*RCfile == (char)NULL) {
getsjrc();
if (*RCfile == (char)NULL)
{
(void) wcstombs((char *)SUCCorFAIL, WCNOTHsjrc, BUFFLENGTH);
sprintf((char *)tmp, (char *)SUCCorFAIL);
(void) mbstowcs(wtmp, tmp, BUFFLENGTH);
}
else
{
(void) wcstombs((char *)SUCCorFAIL, WCSUCCsjrc, BUFFLENGTH);
sprintf (tmp, "%s %s ", RCfile, SUCCorFAIL);
(void) mbstowcs(wtmp, tmp, BUFFLENGTH);
}
} else {
if (setrc () == TRUE)
{
(void) wcstombs((char *)SUCCorFAIL, WCSUCCsjrc, BUFFLENGTH);
} else {
(void) wcstombs((char *)SUCCorFAIL, WCFAILsjrc, BUFFLENGTH);
}
sprintf (tmp, "%s %s ", RCfile, SUCCorFAIL);
(void) mbstowcs(wtmp, tmp, BUFFLENGTH);
}
guide_print_pause (0, wtmp);
}
static int weight = 3;
static int seed = 100000;
change_weight ()
{
register int c;
char s[2];
char tmp[BUFFLENGTH];
u_char mtmp[BUFFLENGTH];
wchar16_t wtmp[BUFFLENGTH];
(void) wcstombs((char *)mtmp, WCWeight_mes, BUFFLENGTH);
sprintf(tmp, (char *)mtmp, weight);
(void) mbstowcs(wtmp, tmp, BUFFLENGTH);
c = guide_print_pause (0, wtmp);
if (isdigit (c) && (c != '0')) {
s[0] = c;
s[1] = '\0';
weight = atoi (s);
}
}
UsecWeight (sw)
int sw;
{
if (sw)
return (seed);
else
return (seed * weight);
}
dconnect(aflag)
int aflag;
{
register int err;
char tmp[BUFFLENGTH];
wchar16_t wtmp[BUFFLENGTH];
u_char dtmp[BUFFLENGTH];
if (!dcflag) {
(void) wcstombs((char *)dtmp, WCDiscon, BUFFLENGTH);
sprintf(tmp, (char *)dtmp, cur_serv);
beep();
(void) mbstowcs(wtmp, tmp, BUFFLENGTH);
guide_print_pause (0, wtmp);
if (aflag && keyvalue == KEY_HENKAN) {
if ((err = sj3_autocon()) == 0) {
(void) wcstombs((char *)dtmp, WCRserv_OK, BUFFLENGTH);
sprintf(tmp, (char *)dtmp, cur_serv);
(void) mbstowcs(wtmp, (char *)tmp, BUFFLENGTH);
guide_print_pause(0, wtmp);
} else {
guide_print_pause(WCSpace, WCNconnect);
dcflag = 1;
}
} else
dcflag = 1;
disp_mode();
}
return(dcflag);
}
set_dcflag(flag)
int flag;
{
dcflag = flag;
}
IsDcflag()
{
return(dcflag);
}
reconnect ()
{
register int inc, err;
char tmp[BUFFLENGTH], *hp;
char newserv[SHORTLENGTH * 2], *nsp;
wchar16_t wtmp[BUFFLENGTH];
u_char rtmp[BUFFLENGTH];
strncpy(newserv, cur_serv, SHORTLENGTH * 2 - 1);
newserv[SHORTLENGTH * 2 - 1] = '\0';
while(1) {
SaveConversion();
TopGuide();
printR(WCGrcon);
(void) wcstombs((char *)rtmp, WCRserv, BUFFLENGTH);
sprintf(tmp, (char *)rtmp, newserv);
(void) mbstowcs(wtmp, tmp, BUFFLENGTH);
SJ_print (wtmp);
Clear_EOL();
Flush();
nsp = newserv;
while ((inc = inkey()) != EOF) {
if (AnotherConversion()) {
unget_key(inc);
return(0);
}
if (keyvalue != KEY_NORMAL && keyvalue != KEY_FLUSH)
return(0);
if (inc == '\n' || inc == '\r' || IsESC(inc))
break;
if (is_bs (inc) && nsp > newserv) {
nsp--;
*nsp = '\0';
backspace(1);
Flush();
} else if (isgraph(inc) &&
nsp < &newserv[SHORTLENGTH * 2 - 1]) {
*nsp++ = inc;
printf("%c", inc);
Flush();
} else
beep();
}
if (nsp > newserv) {
*nsp = '\0';
strcpy(rehname, newserv);
cur_serv = rehname;
} else if (newserv[0] == '\0') {
strncpy(newserv, cur_serv, SHORTLENGTH * 2 - 1);
newserv[SHORTLENGTH * 2 - 1] = '\0';
}
if ((err = SJ2_reconnect()) == 0) {
TopGuide();
printR(WCGrcon);
(void) wcstombs((char *)rtmp, WCRserv_OK, BUFFLENGTH);
sprintf(tmp, (char *)rtmp, newserv);
(void) mbstowcs(wtmp, tmp, BUFFLENGTH);
SJ_print(wtmp);
Clear_EOL();
Flush();
set_dcflag(0);
inc = inkey();
if (AnotherConversion ())
unget_key(inc);
break;
} else {
TopGuide();
printR(WCGrcon);
SJ_print(WCSpace);
sj_check_error(err);
SJ_print(WCContinue);
Clear_EOL();
Backspace();
Flush();
inc = inkey();
if (AnotherConversion()) {
unget_key(inc);
set_dcflag(1);
break;
}
if (inc == 'n' || inc == 'N' || inc == EOF) {
set_dcflag(1);
break;
}
}
}
return(1);
}
guide_print_pause (s1, s2)
wchar16_t *s1, *s2;
{
int c;
guide_print (s1, s2);
SaveConversion ();
c = inkey ();
if (AnotherConversion ()) {
unget_key (c);
return (EOF);
}
return (c);
}

View file

@ -1,486 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "wchar16.h"
#include <locale.h>
#include "kctype.h"
#include "sj3libsj3.h"
#include "sj2.h"
unsigned char *EucMessages[] = {
(u_char *)"\243\323\243\312\243\263\241\241\241\241\241\241\241\241\241\241\241\241\241\241",
(u_char *)"Buffer\241\241\241\241",
(u_char *)"Unbuffer\241\241",
(u_char *)"\301\264\244\322\244\351\244\254\244\312",
(u_char *)"\301\264\245\253\245\277\245\253\245\312",
(u_char *)"\310\276\245\253\245\277\245\253\245\312",
(u_char *)"\301\264\245\242\245\353\245\325\245\241",
(u_char *)"\310\276\245\242\245\353\245\325\245\241",
(u_char *)" \312\321\264\271 \314\265\312\321 etc. \267\350\304\352 code \310\276\245\242 \301\264\245\242 \310\276\245\253 \301\264\245\253 \244\253\244\312",
(u_char *)"\244\275\244\316\302\276\241\241\241\241\241\241\241\241\241\241\241\241\241\241",
(u_char *)" \305\320\317\277 \276\303\265\356 Help sjrc \312\324\275\270 \272\306\300\334 \241\241\241\241 \241\241\241\241 \241\241\241\241 \241\241\241\241",
(u_char *)"Help\241\241Mode",
(u_char *)" \245\254\245\244\245\311\241\246\245\351\245\244\245\363 %s \244\313\244\312\244\352\244\336\244\267\244\277 ",
(u_char *)"ShiftJIS\241\241",
(u_char *)"\241\241\243\305\243\325\243\303\241\241",
(u_char *)"\243\305\243\325\243\303\312\344\275\365",
(u_char *)"\241\241\243\312\243\311\243\323\241\241",
(u_char *)"\243\312\243\311\243\323\312\344\275\365",
(u_char *)"\241\241\241\241\266\350\305\300\241\241",
(u_char *)"\266\350\305\300\241\241\312\344\275\365",
(u_char *)"\305\320\317\277",
(u_char *)" \310\317\260\317\244\362\273\330\304\352\244\267\244\306\244\257\244\300\244\265\244\244 ",
(u_char *)" \264\301\273\372 [%s] : \306\311\244\337\306\376\316\317 ",
(u_char *)" \264\301\273\372 [%s] : \306\311\244\337 [%s] : \311\312\273\354 [%s] (y/n)? ",
(u_char *)" \264\301\273\372 [%s] : \306\311\244\337 [%s] (y/n)? ",
(u_char *)" \312\270\313\241\276\360\312\363 : 1.\314\276\273\354 2.\314\276\273\372 3.\314\276\301\260 4.\303\317\314\276 5.\245\265\312\321\306\260\273\354",
(u_char *)" \305\320\317\277\244\267\244\336\244\267\244\277 ",
(u_char *)" \306\311\244\337\306\376\316\317 ",
(u_char *)" 1",
(u_char *)"y",
(u_char *)" \306\261\260\354\244\316\303\261\270\354\244\254\244\271\244\307\244\313\302\270\272\337\244\267\244\306\244\244\244\336\244\271",
(u_char *)" \244\263\244\316\306\311\244\337\312\270\273\372\316\363\244\307\244\317\305\320\317\277\244\307\244\255\244\336\244\273\244\363",
(u_char *)" \244\263\244\316\264\301\273\372\312\270\273\372\316\363\244\307\244\317\305\320\317\277\244\307\244\255\244\336\244\273\244\363",
(u_char *)" \244\263\244\354\260\312\276\345\306\261\244\270\306\311\244\337\244\307\244\317\305\320\317\277\244\307\244\255\244\336\244\273\244\363",
(u_char *)" \244\263\244\354\260\312\276\345\245\346\241\274\245\266\274\255\275\361\244\313\244\317\305\320\317\277\244\307\244\255\244\336\244\273\244\363",
(u_char *)" \245\346\241\274\245\266\274\255\275\361\244\254\245\355\245\303\245\257\244\265\244\354\244\306\244\244\244\336\244\271",
(u_char *)" \245\267\245\271\245\306\245\340\245\250\245\351\241\274\244\307\305\320\317\277\244\307\244\255\244\336\244\273\244\363",
(u_char *)",",
(u_char *)"\276\303\265\356",
(u_char *)" \264\301\273\372 [%s] : \306\311\244\337 [%s] : \311\312\273\354 [%s]\244\362\276\303\265\356\244\267\244\336\244\267\244\277 ",
(u_char *)" \273\330\304\352\244\265\244\354\244\277\306\311\244\337\241\246\264\301\273\372\244\317\305\320\317\277\244\265\244\354\244\306\244\244\244\336\244\273\244\363",
(u_char *)" \245\346\241\274\245\266\274\255\275\361\244\254\245\355\245\303\245\257\244\265\244\354\244\306\244\244\244\336\244\271",
(u_char *)" \244\263\244\316\306\311\244\337\312\270\273\372\316\363\244\317\276\303\265\356\244\307\244\255\244\336\244\273\244\363",
(u_char *)" \244\263\244\316\264\301\273\372\312\270\273\372\316\363\244\317\276\303\265\356\244\307\244\255\244\336\244\273\244\363",
(u_char *)" \245\267\245\271\245\306\245\340\245\250\245\351\241\274\244\307\276\303\265\356\244\307\244\255\244\336\244\273\244\363",
(u_char *)"\244\362\306\311\244\337\271\376\244\337\244\336\244\267\244\277",
(u_char *)"\244\362\306\311\244\337\271\376\244\341\244\336\244\273\244\363\244\307\244\267\244\277",
(u_char *)"\245\273\245\303\245\310\245\242\245\303\245\327\245\325\245\241\245\244\245\353\244\254\244\242\244\352\244\336\244\273\244\363 ",
(u_char *)"Change weight (1-9) current weight %d ",
(u_char *)"\272\306\300\334\302\263 ",
(u_char *)" \245\265\241\274\245\320\314\276 [%s] \244\362\273\330\304\352\244\267\244\306\244\257\244\300\244\265\244\244 ",
(u_char *)" \245\265\241\274\245\320 [%s] \244\313\300\334\302\263\244\267\244\336\244\267\244\277 ",
(u_char *)"\245\265\241\274\245\320 [%s] \244\310\244\316\300\334\302\263\244\254\300\332\244\354\244\336\244\267\244\277",
(u_char *)" ",
(u_char *)" ",
(u_char *)" \302\263\244\261\244\336\244\271\244\253? y",
(u_char *)"\245\265\241\274\245\320\241\274\244\254\273\340\244\313\244\336\244\267\244\277\241\243",
(u_char *)"\245\265\241\274\245\320\241\274\244\313\300\334\302\263\272\321\244\307\244\271\241\243",
(u_char *)"\245\265\241\274\245\320\241\274\244\330\244\316\300\334\302\263\244\313\274\272\307\324\244\267\244\336\244\267\244\277\241\243",
(u_char *)"\245\341\245\244\245\363\274\255\275\361\245\325\245\241\245\244\245\353\244\362\245\252\241\274\245\327\245\363\244\307\244\255\244\336\244\273\244\363\241\243",
(u_char *)"\245\346\241\274\245\266\241\246\245\307\245\243\245\354\245\257\245\310\245\352\244\316\272\356\300\256\244\313\274\272\307\324\244\267\244\336\244\267\244\277\241\243",
(u_char *)"\245\346\241\274\245\266\274\255\275\361\245\325\245\241\245\244\245\353\244\316\300\270\300\256\244\313\274\272\307\324\244\267\244\336\244\267\244\277\241\243",
(u_char *)"\245\346\241\274\245\266\274\255\275\361\245\325\245\241\245\244\245\353\244\362\245\252\241\274\245\327\245\363\244\307\244\255\244\336\244\273\244\363\241\243",
(u_char *)"\263\330\275\254\245\325\245\241\245\244\245\353\244\316\300\270\300\256\244\313\274\272\307\324\244\267\244\336\244\267\244\277\241\243",
(u_char *)"\263\330\275\254\245\325\245\241\245\244\245\353\244\362\245\252\241\274\245\327\245\363\244\307\244\255\244\336\244\273\244\363\241\243",
(u_char *)"\312\324\275\270 ",
(u_char *)"\243\323\243\312\243\263\241\241\241\241\241\241\241\241\241\241\241\241\241\241",
(u_char *)" \312\324\275\270\312\270\273\372\316\363\244\254\304\271\244\271\244\256\244\336\244\271",
(u_char *)"$$",
(u_char *)"on",
(u_char *)"off",
(u_char *)"\314\276\273\354",
(u_char *)"\314\276\273\372",
(u_char *)"\314\276\301\260",
(u_char *)"\303\317\314\276",
(u_char *)"\245\265\312\321\306\260\273\354",
(u_char *)"",
(u_char *)"F1",
(u_char *)"F2",
(u_char *)"F3",
(u_char *)"F4",
(u_char *)"F5",
(u_char *)"F6",
(u_char *)"F7",
(u_char *)"F8",
(u_char *)"F9",
(u_char *)"F10",
(u_char *)"F11",
(u_char *)"F12",
(u_char *)"F13",
(u_char *)"F14",
(u_char *)"F15",
(u_char *)"F16",
(u_char *)"F17",
(u_char *)"F18",
(u_char *)"F19",
(u_char *)"F20",
(u_char *)"Select",
(u_char *)"Kanji",
(u_char *)"Cancel",
(u_char *)"Execute",
(u_char *)"Up",
(u_char *)"Down",
(u_char *)"Right",
(u_char *)"Left",
(u_char *)"start",
(u_char *)"henkan",
(u_char *)"muhen",
(u_char *)"kettei",
(u_char *)"hira",
(u_char *)"halpha",
(u_char *)"zalpha",
(u_char *)"hkata",
(u_char *)"zkata",
(u_char *)"code",
(u_char *)"etc",
(u_char *)"right",
(u_char *)"left",
(u_char *)"kaku",
(u_char *)"syuku",
(u_char *)"edit",
(u_char *)"toggle",
(u_char *)"wrapback",
(u_char *)"wrap",
(u_char *)"sjrc",
(u_char *)"buffer",
(u_char *)"toroku",
(u_char *)"syoukyo",
(u_char *)"help",
(u_char *)"ha-kettei",
(u_char *)"flush",
(u_char *)"debug",
(u_char *)"cancel",
(u_char *)"saihenkan",
(u_char *)"ignore",
(u_char *)"top",
(u_char *)"end",
(u_char *)"reconnect",
(u_char *)"kill",
(u_char *)"key",
(u_char *)"escape",
(u_char *)"sjxkey",
(u_char *)"etckey",
(u_char *)"intr",
(u_char *)"bskey",
(u_char *)"delkey",
(u_char *)"setnormal",
(u_char *)"throughnext",
(u_char *)"initialmode",
(u_char *)"helpmode",
(u_char *)"defaultcode",
(u_char *)"muhenkanmode",
(u_char *)"muhenkaninedit",
(u_char *)"muhenkantoggle",
(u_char *)"guide",
(u_char *)"forkshell",
(u_char *)"execshell",
(u_char *)"dictionary",
(u_char *)"userdic",
(u_char *)"maindic",
(u_char *)"romaji",
(u_char *)"bstudy",
(u_char *)"silent",
(u_char *)"flushafterconversion",
(u_char *)"rkerrbell",
(u_char *)"server",
(u_char *)"shiftjis",
(u_char *)"sjis",
(u_char *)"euc",
(u_char *)"euc2",
(u_char *)"jis",
(u_char *)"jis2",
(u_char *)"kuten",
(u_char *)"kuten2",
(u_char *)"buff",
(u_char *)"unbuff",
(u_char *)"direct",
(u_char *)"sj2",
(u_char *)"shift",
(u_char *)"function",
(u_char *)"unbuffer",
(u_char *)"funcetc"
};
#define CURMESSAGES 182
wchar16_t *WcMessages[CURMESSAGES];
#define CURWCVTKEY 29
struct wcvtkey wcvtkeytbl[CURWCVTKEY];
int
init_wcvtkey()
{
register int i = 0;
for (i = 0; i < CURWCVTKEY; i++) {
wcvtkeytbl[i].key_seq[0] = 0;
}
wcvtkeytbl[0].key_word = WCF1;
wcvtkeytbl[1].key_word = WCF2;
wcvtkeytbl[2].key_word = WCF3;
wcvtkeytbl[3].key_word = WCF4;
wcvtkeytbl[4].key_word = WCF5;
wcvtkeytbl[5].key_word = WCF6;
wcvtkeytbl[6].key_word = WCF7;
wcvtkeytbl[7].key_word = WCF8;
wcvtkeytbl[8].key_word = WCF9;
wcvtkeytbl[9].key_word = WCF10;
wcvtkeytbl[10].key_word = WCF11;
wcvtkeytbl[11].key_word = WCF12;
wcvtkeytbl[12].key_word = WCF13;
wcvtkeytbl[13].key_word = WCF14;
wcvtkeytbl[14].key_word = WCF15;
wcvtkeytbl[15].key_word = WCF16;
wcvtkeytbl[16].key_word = WCF17;
wcvtkeytbl[17].key_word = WCF18;
wcvtkeytbl[18].key_word = WCF19;
wcvtkeytbl[19].key_word = WCF20;
wcvtkeytbl[20].key_word = WCSelect;
wcvtkeytbl[21].key_word = WCKanji;
wcvtkeytbl[22].key_word = WCCancel;
wcvtkeytbl[23].key_word = WCExecute;
wcvtkeytbl[24].key_word = WCUp;
wcvtkeytbl[25].key_word = WCDown;
wcvtkeytbl[26].key_word = WCRight;
wcvtkeytbl[27].key_word = WCLeft;
wcvtkeytbl[28].key_word = NULL;
}
wchar16_t *comstr[KEY_OTHER];
int
init_comstr()
{
comstr[0] = WCStart; comstr[1] = WCHenkan; comstr[2] = WCMuhen;
comstr[3] = WCKettei; comstr[4] = WCHira; comstr[5] = WCHalpha;
comstr[6] = WCZalpha; comstr[7] = WCHkata; comstr[8] = WCZkata;
comstr[9] = WCCode; comstr[10] = WCEtc; comstr[11] = WCRightl;
comstr[12] = WCLeftl; comstr[13] = WCKaku; comstr[14] = WCSyuku;
comstr[15] = WCEdit; comstr[16] = WCToggle; comstr[17] = WCWrapback;
comstr[18] = WCWrap; comstr[19] = WCSjrc; comstr[20] = WCBuffer;
comstr[21] = WCToroku; comstr[22] = WCSyoukyo; comstr[23] = WCHelp;
comstr[24] = WCHaKettei; comstr[25] = WCFlush; comstr[26] = WCDebug;
comstr[27] = WCCancell; comstr[28] = WCSaihenkan; comstr[29] = WCIgnore;
comstr[30] = WCTop; comstr[31] = WCEnd; comstr[32] = WCReconnect;
comstr[33] = WCKill; comstr[34] = WCKara;
}
struct valtbl hin_val[5];
int
init_hin_val()
{
hin_val[0].keyword = WCMeishi; hin_val[0].ivalue = SJ3_H_NRMNOUN;
hin_val[1].keyword = WCMyouji; hin_val[1].ivalue = SJ3_H_LNAME;
hin_val[2].keyword = WCNamae; hin_val[2].ivalue = SJ3_H_FNAME;
hin_val[3].keyword = WCTimei; hin_val[3].ivalue = SJ3_H_LOCNAME;
hin_val[4].keyword = WCSahen; hin_val[4].ivalue = SJ3_H_SILVERB;
}
extern int set_func(), set_etckeys(), set_intr(),
set_delkey(), set_goto(), set_trap(), set_init_mode(),
set_helpmenu(), set_defcode(), set_muhenkan(), set_muedit(),
set_m_toggle(), set_guide(), set_forkshell(), set_bstudy(),
set_silent(), set_flush_conversion(), set_rkebell(), set_server(),
set_dict();
#define CURFUNCS 29
struct functbl funcs[CURFUNCS];
int
init_funcs()
{
funcs[0].keyword = WCKey; funcs[0].func = set_func;
funcs[1].keyword = WCEscape; funcs[1].func = set_func;
funcs[2].keyword = WCEtckey; funcs[2].func = set_etckeys;
funcs[3].keyword = WCIntr; funcs[3].func = set_intr;
funcs[4].keyword = WCDelkey; funcs[4].func = set_delkey;
funcs[5].keyword = WCSetnormal; funcs[5].func = set_goto;
funcs[6].keyword = WCThroughnext; funcs[6].func = set_trap;
funcs[7].keyword = WCInitialmode; funcs[7].func = set_init_mode;
funcs[8].keyword = WCHelpmode; funcs[8].func = set_helpmenu;
funcs[9].keyword = WCDefaultcode; funcs[9].func = set_defcode;
funcs[10].keyword = WCMuhenkanmode; funcs[10].func = set_muhenkan;
funcs[11].keyword = WCMuhenkaninedit; funcs[11].func = set_muedit;
funcs[12].keyword = WCMuhenkantoggle; funcs[12].func = set_m_toggle;
funcs[13].keyword = WCGuide; funcs[13].func = set_guide;
funcs[14].keyword = WCForkshell; funcs[14].func = set_forkshell;
funcs[15].keyword = WCExecshell; funcs[15].func = set_forkshell;
funcs[16].keyword = WCBstudy; funcs[16].func = set_bstudy;
funcs[17].keyword = WCSilent; funcs[17].func = set_silent;
funcs[18].keyword = WCFlushafterconversion; funcs[18].func = set_flush_conversion;
funcs[19].keyword = WCRkerrbell; funcs[19].func = set_rkebell;
funcs[20].keyword = WCServer; funcs[20].func = set_server;
funcs[21].keyword = WCDictionary; funcs[21].func = set_dict;
funcs[22].keyword = NULL; funcs[22].func = NULL;
}
struct valtbl mode_val[5];
int
init_mode_val()
{
mode_val[0].keyword = WCHalpha; mode_val[0].ivalue = MODE_HALPHA;
mode_val[1].keyword = WCZalpha; mode_val[1].ivalue = MODE_ZALPHA;
mode_val[2].keyword = WCHkata; mode_val[2].ivalue = MODE_HKATA;
mode_val[3].keyword = WCZkata; mode_val[3].ivalue = MODE_ZKATA;
mode_val[4].keyword = WCHira; mode_val[4].ivalue = MODE_ZHIRA;
}
struct valtbl code_val[8];
int
init_code_val()
{
code_val[0].keyword = WCShiftjis; code_val[0].ivalue = CODE_SJIS;
code_val[1].keyword = WCSjis; code_val[1].ivalue = CODE_SJIS;
code_val[2].keyword = WCEuc; code_val[2].ivalue = CODE_EUC;
code_val[3].keyword = WCEuc2; code_val[3].ivalue = CODE_EUC2;
code_val[4].keyword = WCJis; code_val[4].ivalue = CODE_JIS;
code_val[5].keyword = WCJis2; code_val[5].ivalue = CODE_JIS2;
code_val[6].keyword = WCKuten; code_val[6].ivalue = CODE_KUTEN;
code_val[7].keyword = WCKuten2; code_val[7].ivalue = CODE_KUTEN2;
}
int
init_messages()
{
#define LOCALELEN 20
char cur_loc[LOCALELEN];
char *loc;
short message_len[CURMESSAGES];
int ret;
register int i;
int all_len = 0;
int saved_locale = 0;
extern int current_locale;
if (current_locale != LC_CTYPE_EUC) {
saved_locale = current_locale;
current_locale = LC_CTYPE_EUC;
#ifdef __sony_news
strncpy((char *)cur_loc, setlocale(LC_CTYPE, NULL), LOCALELEN);
loc = setlocale(LC_CTYPE, "ja_JP.EUC");
#endif
}
for (i = 0; i < CURMESSAGES; i++) {
message_len[i] = jstrlen((char *)EucMessages[i]) + 1;
all_len += message_len[i];
}
WcMessages[0] = (wchar16_t *) malloc(all_len * sizeof(wchar16_t));
if (WcMessages[0] == NULL)
goto Fail;
ret = (int) mbstowcs(WcMessages[0], (char *)EucMessages[0], message_len[0]);
if (ret < -1)
goto Fail;
for (i = 1; i < CURMESSAGES; i++) {
WcMessages[i] = WcMessages[i-1] + message_len[i-1];
ret = mbstowcs(WcMessages[i], (char *)EucMessages[i], message_len[i]);
if (ret < -1)
goto Fail;
}
init_wcvtkey();
init_comstr();
init_hin_val();
init_funcs();
init_mode_val();
init_code_val();
if (saved_locale) {
current_locale = saved_locale;
#ifdef __sony_news
setlocale(LC_CTYPE, cur_loc);
#endif
}
return TRUE;
Fail:
if (saved_locale) {
current_locale = saved_locale;
#ifdef __sony_news
setlocale(LC_CTYPE, cur_loc);
#endif
}
return FALSE;
}

View file

@ -1,345 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include <string.h>
#include "wchar16.h"
#include "sj2.h"
#include "key.h"
#include "Paths.h"
#include "sj3.h"
struct cvtkey {
char *key_word;
char key_seq[SEQLEN];
} cvtkeytbl[] = {
{ "F1", "" },
{ "F2", "" },
{ "F3", "" },
{ "F4", "" },
{ "F5", "" },
{ "F6", "" },
{ "F7", "" },
{ "F8", "" },
{ "F9", "" },
{ "F10", "" },
{ "F11", "" },
{ "F12", "" },
{ "F13", "" },
{ "F14", "" },
{ "F15", "" },
{ "F16", "" },
{ "F17", "" },
{ "F18", "" },
{ "F19", "" },
{ "F20", "" },
{ "Select", "" },
{ "Kanji", "" },
{ "Cancel", "" },
{ "Execute", "" },
{ "Up", "" },
{ "Down", "" },
{ "Right", "" },
{ "Left", "" },
{ NULL, "" }
};
extern struct wcvtkey wcvtkeytbl[];
int Uvalue[UKEYNUM];
wchar16_t Ukey[UKEYNUM][SEQLEN + 1];
int Unumber = 0;
int comvalue[COMNUM];
wchar16_t comkey[COMNUM];
int comnumber = 0;
#define ETCKEYS 10
int u_etckeys = 0;
int Uetckey[ETCKEYS];
int Uetcval[ETCKEYS];
extern wchar16_t *comstr[];
int comstrvalue[KEY_OTHER] = {
KEY_CONV, KEY_HENKAN, KEY_MUHENKAN,
KEY_KETTEI, KEY_ZHIRA, KEY_HALPHA,
KEY_ZALPHA, KEY_HKATA, KEY_ZKATA,
KEY_CODE, KEY_ETC, KEY_RIGHT,
KEY_LEFT, KEY_UP, KEY_DOWN,
KEY_EDIT, KEY_TOGGLE, KEY_WRAPBACK,
KEY_WRAP, KEY_SJRC, KEY_BUFFER,
KEY_TOROKU, KEY_SYOUKYO, KEY_HELP,
KEY_HA_KET, KEY_FLUSH, KEY_DEBUG,
KEY_CANCEL, KEY_RECONV, KEY_IGNORE,
KEY_TOP, KEY_END, KEY_RECONNECT,
KEY_KILL,
KEY_OTHER
};
void
mk_cvtkey(char* term)
{
char *p;
char line[MAXLINE], rstr[16];
FILE *fd;
char cvtkey_file[LONGLENGTH];
struct cvtkey *ckeyp;
struct wcvtkey *wckeyp;
strcpy(cvtkey_file, DEFKEYFILE);
strcpy(line, term);
if((p = strchr(line, '-')) != NULL)
*p = '\0';
strcat(cvtkey_file, line);
if ((fd = fopen(cvtkey_file, "r")) != NULL) {
while ((p = fgets(line, MAXLINE, fd)) != NULL) {
if (*p == '#' ||*p == '\n' ||*p == '\0')
continue;
if ((p = getkey2(p, rstr)) == NULL)
continue;
ckeyp = cvtkeytbl;
wckeyp = wcvtkeytbl;
while(ckeyp->key_word != NULL) {
if (strcmp(ckeyp->key_word, rstr) == 0) {
p = getkey2(p, ckeyp->key_seq);
(void) mbstowcs(wckeyp->key_seq,
ckeyp->key_seq, SEQLEN);
break;
}
ckeyp++;
wckeyp++;
}
}
fclose(fd);
}
}
char *
getkey2(char* istr, char* ostr)
{
char *p;
int i;
while (*istr == ' ' || *istr == '\t')
istr++;
p = istr;
i = 0;
while (*p != ' ' && *p != '\t' && *p != '\n' && *p != '\0') {
*ostr++ = *p;
if (++i > SEQLEN) {
i = 0;
break;
}
p++;
}
*ostr = '\0';
if (i > 0)
return(p);
return(NULL);
}
void
clear_ukeys (void)
{
Unumber = 0;
}
void
set_func (struct wordent word[])
{
int i, num;
wchar16_t *p, *s;
struct wcvtkey *ckeyp;
if (Unumber >= UKEYNUM)
return;
for (i = 0 ; i < KEY_OTHER && *comstr[i] != '\0' ; i ++) {
if (match (word[1].word_str, comstr[i])) {
p = word[2].word_str;
if (iswupper(*p)) {
ckeyp = wcvtkeytbl;
while(ckeyp->key_word != NULL) {
if (wscmp(p, ckeyp->key_word) == 0) {
p = ckeyp->key_seq;
if (*p == '\0')
return;
break;
}
ckeyp++;
}
}
s = Ukey[Unumber];
if ((num = eval_keys (p, s)) > 1) {
if (Unumber < UKEYNUM)
Uvalue[Unumber++] = comstrvalue[i];
} else if (num >= 0) {
if (comnumber < COMNUM) {
comkey[comnumber] = *s;
comvalue[comnumber++] = comstrvalue[i];
}
}
return;
}
}
}
wchar16_t
eval_keys (wchar16_t* s, wchar16_t* p)
{
wchar16_t c, i;
if (wslen (s) > SEQLEN)
return (-1);
i = 0;
while ((c = *(s ++)) != '\0') {
if (c == '^') {
c = *(s ++);
if ('@' <= c && c <= '_')
c = c - '@';
else if (c == '?')
c = DEL;
else
c = *(--s);
}
i++;
*(p ++) = c;
}
*p = '\0';
return (i);
}
void
clear_key (void)
{
clear_commkeys ();
clear_etckeys ();
clear_ukeys ();
}
void
clear_commkeys (void)
{
comnumber = 0;
}
int
eval_key (wchar16_t* s)
{
wchar16_t c;
c = *s;
if (c == '^') {
c = s[1];
if ('@' <= c && c <= '_')
return (c - '@');
else if (c == '?')
return (DEL);
}
else if (c <= '~')
return (c);
return (-1);
}
void
clear_etckeys (void)
{
u_etckeys = 0;
}
int
set_etckeys (struct wordent word[])
{
int i;
if (u_etckeys >= ETCKEYS)
return (1);
for (i = 0 ; i < KEY_OTHER && *comstr[i] != '\0' ; i ++) {
if (match (word[1].word_str, comstr[i])) {
Uetcval[u_etckeys] = comstrvalue[i];
break;
}
}
if (i >= KEY_OTHER)
return (1);
for (i = 0 ; i < KEY_OTHER && *comstr[i] != '\0' ; i ++) {
if (match (word[2].word_str, comstr[i])) {
Uetckey[u_etckeys] = comstrvalue[i];
break;
}
}
if (i >= KEY_OTHER)
return (1);
u_etckeys ++;
return (0);
}
wchar16_t
parse_command (wchar16_t* s, int* count)
{
extern wchar16_t pars_seq[];
extern int pars_n;
int i, j;
wchar16_t c;
c = *s;
for (i = 0; i < comnumber ; i ++) {
if (c == comkey[i]) {
for (j = 1 ; j < *count ; j ++)
s[j - 1] = s[j];
(*count)--;
*pars_seq = c;
pars_seq[1] = 0;
pars_n = 1;
return (comvalue[i]);
}
}
return (KEY_NORMAL);
}

View file

@ -1,879 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "common.h"
#include "key.h"
#include "wchar16.h"
#include "kctype.h"
int i_point;
exec_henkan ()
{
register Conversion *cv;
register int i, j;
register wchar16_t *s, *p;
short sp;
int len, rlen, ilen;
int opos, ipos, bnum;
u_char index[BUFFLENGTH * 2], mode;
cv = GetConversion ();
sp = 0;
mode = cv->in_mode[sp];
cv->kettei[sp] = mode;
for (i = 1; i < cv->out_point; i++) {
if (mode != cv->in_mode[i]) {
p = &cv->out_buf[i];
cv->span_l[sp] = p - cv->span_p[sp];
sp++;
cv->span_p[sp] = p;
mode = cv->in_mode[i];
cv->kettei[sp] = mode;
}
}
cv->span_l[sp] = &cv->out_buf[i] - cv->span_p[sp];
sp++;
cv->span_point = sp;
p = cv->yomiout;
i_point = 0;
ipos = -1;
for (i = 0; i < cv->span_point; i++) {
len = cv->span_l[i];
s = cv->span_p[i];
if (cv->kettei[i] == MODE_ZHIRA) {
if (ipos >= 0) {
ilen = getipos(s - cv->out_buf) - ipos;
Strncpy(p, &cv->Halpha[ipos], ilen);
p += ilen;
ipos = -1;
for (j = 0; j < ilen; j++)
index[i_point++] = ObjMuhenkan;
}
Strncpy(p, s, len);
p += len;
for (j = 0; j < len; j++)
index[i_point++] = ObjHenkan;
} else if (ipos == -1)
ipos = getipos(s - cv->out_buf);
}
if (ipos >= 0) {
ilen = cv->ha_point - ipos;
Strncpy(p, &cv->Halpha[ipos], ilen);
p += ilen;
for (j = 0; j < ilen; j++)
index[i_point++] = ObjMuhenkan;
}
index[i_point] = ObjEnd;
*p = '\0';
bnum = SJ2_henkan(cv->yomiout, cv->Bun, cv->kanjiout, BUFFLENGTH*4);
if (bnum < 0 && !dconnect(1))
bnum = SJ2_henkan(cv->yomiout, cv->Bun, cv->kanjiout, BUFFLENGTH*4);
if (bnum <= 0) {
cv->Bun[0].srclen = i_point;
cv->Bun[0].srcstr = cv->yomiout;
cv->Bun[0].destlen = 0;
cv->Bun[0].deststr = NULL;
bnum = 1;
}
i_point = 0;
cv->Bnum = 0;
i = 0;
while (i < bnum && i < cv->span_point) {
s = cv->span_p[i];
len = cv->span_l[i];
if (index[i_point] == ObjMuhenkan) {
cv->Bkettei[cv->Bnum] = Bmuhenkan;
opos = s - cv->out_buf;
len = getipos(opos + len) - getipos(opos);
if (len < cv->Bun[i].srclen) {
i_point += len;
rlen = cv->Bun[i].srclen - len;
opos = cv->span_p[i+1] - cv->out_buf;
if (index[i_point+rlen] == ObjMuhenkan ||
rlen != 1 || cv->out_mode[opos+rlen] == 0) {
addBun(i, bnum);
cv->Bun[i].srclen = len;
cv->Bun[i+1].srclen -= len;
cv->Bun[i+1].srcstr += len;
if (cv->Bun[i].deststr != NULL) {
cv->Bun[i].destlen = len;
cv->Bun[i+1].destlen -= len;
cv->Bun[i+1].deststr += len;
}
bnum++;
} else {
cv->span_l[i] += rlen;
if ((unsigned int)cv->span_l[i + 1] >= rlen) {
cv->span_l[i + 1] -= rlen;
cv->span_p[i + 1] += rlen;
} else {
delspan(i + 1);
cv->span_point--;
}
i_point += rlen;
}
} else if (len > cv->Bun[i].srclen) {
delBun(i, bnum);
bnum--;
continue;
} else {
i_point += len;
}
} else if (index[i_point] == ObjHenkan) {
cv->Bkettei[cv->Bnum] = Bhenkan;
if (len < cv->Bun[i].srclen) {
i_point += len;
addBun(i, bnum);
cv->Bun[i].srclen = len;
cv->Bun[i+1].srclen -= len;
cv->Bun[i+1].srcstr += len;
if (cv->Bun[i].deststr != NULL) {
rlen = cv->Bun[i+1].srclen;
cv->Bun[i].destlen -= rlen;
cv->Bun[i+1].destlen = rlen;
cv->Bun[i+1].deststr +=
cv->Bun[i].destlen;
}
bnum++;
} else if (len > cv->Bun[i].srclen) {
for (j = cv->span_point; j > i; j--) {
cv->span_p[j] = cv->span_p[j-1];
cv->span_l[j] = cv->span_l[j-1];
cv->kettei[j] = cv->kettei[j-1];
}
cv->span_point++;
rlen = cv->Bun[i].srclen;
i_point += rlen;
cv->span_l[i] = rlen;
cv->span_l[i + 1] -= rlen;
cv->span_p[i + 1] += rlen;
} else {
i_point += len;
}
} else {
cv->Bnum++;
break;
}
cv->Bnum++;
i++;
}
cv->Bkettei[cv->Bnum] = Bend;
for (i = 0 ; i < cv->Bnum ; i ++) {
cv->Pkettei[i] = cv->kettei[i];
cv->Ppoint[i] = cv->span_p[i];
cv->OrgPlen[i] = cv->Plen[i] = cv->span_l[i];
cv->Pedited[i] = 0;
cv->Bpoint[i] = i + 1;
}
if (flush_conversion)
cv->PreBun = cv->CurBun = -1;
else
cv->PreBun = cv->CurBun = 0;
Bdisp (1);
cv->Dflag = -1;
cv->Enum = 0;
cv->e_point = 0;
cv->Kanji = 1;
}
addBun(cur, end)
int cur, end;
{
register int i;
register Conversion *cv;
cv = GetConversion();
for (i = end; i > cur; i--) {
cv->Bun[i].srclen = cv->Bun[i - 1].srclen;
cv->Bun[i].srcstr = cv->Bun[i - 1].srcstr;
cv->Bun[i].destlen = cv->Bun[i - 1].destlen;
cv->Bun[i].deststr = cv->Bun[i - 1].deststr;
}
}
delspan(cur)
int cur;
{
register int i;
register Conversion *cv;
cv = GetConversion();
for (i = cur; i < cv->span_point - 1; i++) {
cv->span_l[i] = cv->span_l[i + 1];
cv->span_p[i] = cv->span_p[i + 1];
cv->kettei[i] = cv->kettei[i + 1];
}
}
delBun(cur, end)
int cur, end;
{
register int i;
register Conversion *cv;
cv = GetConversion();
cv->Bun[cur].srclen += cv->Bun[cur + 1].srclen;
cv->Bun[cur].destlen += cv->Bun[cur + 1].destlen;
for (i = cur + 1; i < end; i++) {
cv->Bun[i].srclen = cv->Bun[i + 1].srclen;
cv->Bun[i].srcstr = cv->Bun[i + 1].srcstr;
cv->Bun[i].destlen = cv->Bun[i + 1].destlen;
cv->Bun[i].deststr = cv->Bun[i + 1].deststr;
}
}
IsHex (c)
register wchar16_t c;
{
return(iswxdigit(c));
}
Getcode (in, out)
wchar16_t *in, *out;
{
register int c, i, j;
u_char s[5];
int base, c_code;
u_short code;
wchar16_t sw[5];
wchar16_t tmp[3];
*out = (wchar16_t) '\0';
i = 0;
if (((c_code = GetCcode()) == CODE_KUTEN) || (c_code == CODE_KUTEN2))
base = 10;
else
base = 16;
while ((c = *in) != '\0') {
if (WcIsKANJI(c)) {
in ++;
*(out ++) = c;
i = 0;
continue;
} else if (IsHex(c))
s[i++] = WcLowByte(c);
else
break;
in ++;
if (i == 4) {
s[i] = '\0';
code = (u_short)strtol((char *)s, (char **)NULL, base);
switch (c_code) {
case CODE_KUTEN :
case CODE_KUTEN2 :
c = ((code / 100) << 8) + code % 100;
code = c + 0x2020;
case CODE_JIS :
case CODE_JIS2 :
code = jis2euc(code);
break;
case CODE_SJIS :
code = sjis2euc(code);
break;
}
if ((c_code == CODE_KUTEN2) ||
(c_code == CODE_JIS2) || (c_code == CODE_EUC2))
code &= WcX0212MASK;
if (!WcIsZENKAKU(code))
break;
*out++ = code;
i = 0;
}
}
*out = (wchar16_t) '\0';
if (i) {
for (j = 0; j < i; j++)
sw[j] = (wchar16_t) s[j];
sw[i] = (wchar16_t) '\0';
i = sj_hantozen(out, sw, i);
out += i;
}
if (*in != '\0')
(void)sj_hantozen(out, in, strlen((char *)in));
}
static u_char load_mode;
load_bun (num, s, type)
int num;
wchar16_t *s;
u_char type;
{
register Conversion *cv;
register int len, ilen;
u_char itype;
wchar16_t Htmp[BUFFLENGTH], Ztmp[BUFFLENGTH * 2];
cv = GetConversion ();
if (num < 0 || (len = cv->Plen[num]) == 0) {
*s = '\0';
return(0);
}
if (type == 0)
type = MODE_ZHIRA;
if (cv->Bpoint[num] < cv->Bpoint[0])
itype = MODE_ALPHA;
else
itype = cv->kettei[cv->Bpoint[num] - 1];
if (type & MODE_ZEN)
load_mode = 1;
else
load_mode = 0;
if (type == itype) {
Strncpy(s, cv->Ppoint[num], len);
s += len;
*s = '\0';
} else {
if (type == MODE_CODE && itype != MODE_CODE) {
ilen = getistr(Htmp, cv->Ppoint[num], len);
Getcode(Htmp, s);
len = wslen(s);
} else if ((type & MODE_CONV) && (itype == MODE_ALPHA ||
itype == MODE_ZALPHA)) {
ilen = sj_zentohan(Htmp, cv->Ppoint[num], len);
ilen = sj_rkconv(Ztmp, Htmp, ilen);
if (type & MODE_ZEN) {
len = sj_hantozen(s, Ztmp, ilen);
if (type == MODE_ZKATA) {
wscpy(Ztmp, s);
sj_htok(s, Ztmp);
}
} else
len = sj_zentohan(s, Ztmp, ilen);
} else if (!(type & MODE_CONV) && (itype == MODE_CODE ||
itype & MODE_CONV)) {
if (type & MODE_ZEN) {
ilen = getistr(Htmp, cv->Ppoint[num], len);
len = sj_hantozen(s, Htmp, ilen);
} else {
len = getistr(s, cv->Ppoint[num], len);
}
} else {
if (type & MODE_ZEN) {
len = sj_hantozen(Ztmp, cv->Ppoint[num], len);
if (type == MODE_ZKATA)
sj_htok(s, Ztmp);
else
sj_ktoh(s, Ztmp);
} else
len = sj_zentohan(s, cv->Ppoint[num], len);
}
}
return(len);
}
load_bun2(num, htmp, ztmp, omode)
int num;
wchar16_t *htmp, *ztmp;
u_short *omode;
{
register Conversion *cv;
register int i;
register int len, ilen;
u_short *op;
u_char type;
wchar16_t Ztmp[DLEN + 1];
cv = GetConversion ();
if (num < 0 || (len = cv->Plen[num]) == 0) {
*ztmp = '\0';
return(0);
}
if (cv->Bpoint[num] < cv->Bpoint[0])
i = cv->span_point;
else
i = cv->Bpoint[num];
type = cv->kettei[i - 1];
if (type == MODE_ZHIRA || type == MODE_ZKATA) {
if (len > DLEN)
return(len);
if (type == MODE_ZHIRA) {
Strncpy(ztmp, cv->Ppoint[num], len);
ztmp += len;
*ztmp = '\0';
} else {
Strncpy(Ztmp, cv->Ppoint[num], len);
Ztmp[len] = '\0';
sj_ktoh(ztmp, Ztmp);
}
(void)load_bun(num, htmp, MODE_ALPHA);
op = &cv->out_mode[cv->Ppoint[num] - cv->Ppoint[0]];
for (i = 0; i < len; i++)
*omode++ = *op++;
} else {
ilen = load_bun(num, htmp, MODE_ALPHA);
len = sj_rkconv2(ztmp, htmp, omode, ilen);
}
return(len);
}
getistr(s, ostr, len)
wchar16_t *s, *ostr;
int len;
{
register int ipos, opos;
register Conversion *cv;
int rlen;
cv = GetConversion();
opos = ostr - cv->out_buf;
if (!(cv->out_mode[opos] & OMODE_MASK))
chhstr(cv->Halpha, cv->out_buf, cv->out_mode, opos);
ipos = getipos(opos);
if (*(ostr + len) != '\0' && !(cv->out_mode[opos + len] & OMODE_MASK))
chhstr(cv->Halpha, cv->out_buf, cv->out_mode, opos + len);
rlen = getipos(opos + len) - ipos;
Strncpy(s, &cv->Halpha[ipos], rlen);
s += rlen;
*s = (wchar16_t) '\0';
return(rlen);
}
exec_muhenkan (first)
int first;
{
register Conversion *cv;
cv = GetConversion ();
cv->Bnum = 1;
cv->Ppoint[0] = &(cv->out_buf[0]);
cv->Plen[0] = cv->out_point;
cv->OrgPlen[0] = cv->Plen[0];
cv->Pedited[0] = 0;
if (first) {
cv->Bkettei[0] = Bmuhenkan;
cv->Pkettei[0] = cv->Imode;
}
else if (cv->Bkettei[0] != Bmuhenkan) {
cv->Bkettei[0] = Bmuhenkan;
cv->Pkettei[0] = MODE_ZHIRA;
}
else if (cv->Pkettei[0] != MODE_ZHIRA) {
cv->Pkettei[0] = MODE_ZHIRA;
}
else {
cv->Pkettei[0] = MODE_ZKATA;
}
if (flush_conversion)
cv->PreBun = cv->CurBun = -1;
else
cv->PreBun = cv->CurBun = 0;
cv->Dflag = -1;
cv->Enum = 0;
cv->e_point = 0;
cv->Kanji = 1;
Bdisp (1);
}
static u_char Bstr_mode;
Bstr (bnum, s)
int bnum;
wchar16_t *s;
{
register Conversion *cv;
register int i, len;
cv = GetConversion ();
if (cv->Bkettei[bnum] & Bmuhenkan) {
len = load_bun (bnum, s, cv->Pkettei[bnum]);
Bstr_mode = load_mode;
}
else if (cv->Bkettei[bnum] & Bedit) {
i = cv->Edit[bnum];
len = cv->Elen[i];
if (len <= DLEN) {
if (cv->Epoint[i] != NULL) {
Strncpy(s, cv->Epoint[i], len);
s += len;
*s = '\0';
} else
len = -1;
}
else
len = load_bun (bnum, s, 0);
Bstr_mode = 1;
}
else if (cv->Bkettei[bnum] & Bhenkan) {
if (!(i = cv->Bpoint[bnum])) {
len = -1;
return len;
}
if (cv->Bun[i - 1].deststr != NULL) {
len = cv->Bun[i - 1].destlen;
Strncpy(s, cv->Bun[i - 1].deststr, len);
s += len;
*s = '\0';
} else if (cv->Bun[i - 1].srcstr != NULL) {
len = cv->Bun[i - 1].srclen;
Strncpy(s, cv->Bun[i - 1].srcstr, len);
s += len;
*s = '\0';
} else
len = -1;
Bstr_mode = 1;
}
else
len = -1;
return (len);
}
mode_muhenkan (mod, bkettei)
register int mod, bkettei;
{
register int def;
if (!(bkettei & Bmuhenkan))
return (KEY_ZHIRA);
def = value_muhenkan ();
if (mod == MODE_ZHIRA)
return (KEY_ZKATA);
else if (mod == MODE_ZKATA) {
if (def != KEY_ZHIRA && def != KEY_ZKATA)
return (def);
}
return (KEY_ZHIRA);
}
Bchange (mod)
register int mod;
{
register Conversion *cv;
register int i;
int PushKettei;
cv = GetConversion ();
if (cv->CurBun == -1)
cv->CurBun = 0;
i = cv->PreBun = cv->CurBun;
if (mod == KEY_MUHENKAN)
mod = mode_muhenkan (cv->Pkettei[i], cv->Bkettei[i]);
else if (mod == KEY_TOGGLE)
mod = toggle_mode (cv->Pkettei[i]);
PushKettei = cv->Bkettei[i];
if (!(cv->Bkettei[i] & Bmuhenkan)) {
cv->Bkettei[i] |= Bmuhenkan;
cv->Bkettei[i] &= ~Bhenkan;
}
switch (mod) {
case KEY_CODE:
cv->Pkettei[i] = MODE_CODE;
Rdisp ();
break;
case KEY_ZHIRA:
cv->Pkettei[i] = MODE_ZHIRA;
Rdisp ();
break;
case KEY_HALPHA:
cv->Pkettei[i] = MODE_HALPHA;
Rdisp ();
break;
case KEY_ZALPHA:
cv->Pkettei[i] = MODE_ZALPHA;
Rdisp ();
break;
case KEY_HKATA:
cv->Pkettei[i] = MODE_HKATA;
Rdisp ();
break;
case KEY_ZKATA:
cv->Pkettei[i] = MODE_ZKATA;
Rdisp ();
break;
default:
cv->Bkettei[i] = PushKettei;
beep ();
break;
}
}
Bdisp (redraw)
{
register Conversion *cv;
register int i;
int len;
wchar16_t BDtmp[BUFFLENGTH * 2];
int displen;
int amount = 0;
int tmpcol=0;
u_short row, col;
CursorRead(&row, &col);
cv = GetConversion ();
Cclear (redraw);
SetVcol (0);
for (i = 0 ; i < cv->Bnum ; i ++) {
if ((len = Bstr (i, BDtmp)) < 0)
continue;
amount += len;
if (amount > BUFFLENGTH * 2) {
cv->Bnum = i + 1;
break;
}
displen = wcbyte(BDtmp);
tmpcol += displen;
if ((tmpcol > (unsigned int)cv->column) && (row == cv->line)
&& (row == cv->SavedRow) && (row > 0)) {
cv->SavedRow--;
tmpcol -= cv->column;
}
cv->Displen[i] = displen;
cv->Dispmod[i] = Bstr_mode;
if (len <= 0)
continue;
if (i == cv->CurBun)
vprintR (BDtmp, Bstr_mode);
else
vprintU (BDtmp, Bstr_mode);
}
Flush ();
}
Rdisp ()
{
register Conversion *cv;
register int i;
register int Total;
int len;
wchar16_t BDtmp[BUFFLENGTH * 2];
int displen;
int amount=0;
int tmpcol=0;
u_short row, col;
CursorRead(&row, &col);
cv = GetConversion ();
Total = 0;
for (i = 0 ; i < cv->Bnum ; i ++) {
if ((len = Bstr (i, BDtmp)) < 0)
continue;
amount += len;
if (amount > BUFFLENGTH * 2) {
cv->Bnum = i + 1;
break;
}
displen = wcbyte(BDtmp);
tmpcol += displen;
if ((tmpcol > (unsigned int)cv->column) && (row == cv->line)
&& (row == cv->SavedRow) && (row > 0)) {
cv->SavedRow--;
tmpcol -= cv->column;
}
if (cv->Displen[i] != displen || cv->Dispmod[i] != Bstr_mode) {
AfterAllPrint (i, Total);
return;
}
if (len <= 0)
continue;
if (i == cv->CurBun || i == cv->PreBun) {
if (i == cv->CurBun)
IprintR (BDtmp, Total);
else
IprintU (BDtmp, Total);
}
Total += displen;
}
Cgoto (Total);
Flush ();
}
AfterAllPrint (from, Total)
int from;
register int Total;
{
register Conversion *cv;
register int i;
int len;
wchar16_t BDtmp[BUFFLENGTH * 2];
int displen;
int amount=0;
int tmpcol=0;
u_short row, col;
CursorRead(&row, &col);
cv = GetConversion ();
Cgoto (Total);
for (i = from ; i < cv->Bnum ; i ++) {
if ((len = Bstr (i, BDtmp)) < 0)
continue;
amount += len;
if (amount > BUFFLENGTH * 2) {
cv->Bnum = i + 1;
break;
}
displen = wcbyte(BDtmp);
tmpcol += displen;
if ((tmpcol > (unsigned int)cv->column) && (row == cv->line)
&& (row == cv->SavedRow) && (row > 0)) {
cv->SavedRow--;
tmpcol -= cv->column;
}
cv->Displen[i] = displen;
cv->Dispmod[i] = Bstr_mode;
if (len <= 0)
continue;
if (i == cv->CurBun)
vprintR (BDtmp, Bstr_mode);
else
vprintU (BDtmp, Bstr_mode);
Total += displen;
}
ClearToMax ();
Cgoto (Total);
Flush ();
}
Bright ()
{
register Conversion *cv;
int flag;
cv = GetConversion ();
flag = 0;
cv->PreBun = cv->CurBun;
do {
cv->CurBun ++;
if (cv->CurBun >= cv->Bnum) {
if (flag)
return;
else
flag = 1;
cv->CurBun = 0;
}
} while (cv->Plen[cv->CurBun] <= 0);
Rdisp ();
}
Bleft ()
{
register Conversion *cv;
int flag;
cv = GetConversion ();
flag = 0;
cv->PreBun = cv->CurBun;
do {
cv->CurBun --;
if (cv->CurBun < 0) {
if (flag)
return;
else
flag = 1;
cv->CurBun = cv->Bnum - 1;
}
} while (cv->Plen[cv->CurBun] <= 0);
Rdisp ();
}
Blast ()
{
register Conversion *cv;
cv = GetConversion ();
cv->PreBun = cv->CurBun;
cv->CurBun = cv->Bnum - 1;
while (cv->Plen[cv->CurBun] <= 0) {
cv->CurBun--;
if (cv->CurBun < 0)
return;
}
Rdisp();
}
Btop ()
{
register Conversion *cv;
cv = GetConversion ();
cv->PreBun = cv->CurBun;
cv->CurBun = 0;
while (cv->Plen[cv->CurBun] <= 0) {
cv->CurBun++;
if (cv->CurBun >= cv->Bnum)
return;
}
Rdisp();
}

View file

@ -1,303 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "common.h"
#include "kctype.h"
#include "key.h"
#define BEGIN_CODE 0x2121
#define END_CODE 0x7f7e
#define INCRESE 16
static int lastcode = BEGIN_CODE;
static u_short row, col;
kigou ()
{
extern int keyvalue;
register int increse, code, basecode;
int inc, ki, low;
u_short num, CheckCcode(), strtocode();
int rval;
increse = INCRESE;
disp_mode ();
basecode = lastcode & 0xfff0;
code = lastcode;
StartGuide (&row, &col);
Clear_EOL ();
guide_kigou (basecode, code, increse);
rval = 0;
ki = 1;
SaveConversion ();
while (ki) {
inc = inkey ();
if (AnotherConversion ()) {
unget_key (inc);
break;
}
top:
switch (keyvalue) {
case KEY_CONV:
rval = 1;
ki = 0;
break;
case KEY_RIGHT:
if (code >= END_CODE) {
code = BEGIN_CODE;
basecode = code & 0xfff0;
} else {
low = ++code & 0xff;
if (low > 0x7e) {
code &= 0xff00;
code += 0x121;
low = 0x21;
}
if (code >= basecode + increse) {
if (low <= 0x21)
basecode = code & 0xfff0;
else
basecode += increse;
}
}
guide_kigou (basecode, code, increse);
break;
case KEY_LEFT:
if (code <= BEGIN_CODE) {
code = END_CODE;
basecode = code & 0xfff0;
} else {
low = --code & 0xff;
if (low < 0x21) {
code &= 0xff00;
code -= 0x82;
low = 0x7e;
}
if (code < basecode) {
if (low >= 0x7e)
basecode = code & 0xfff0;
else
basecode -= increse;
}
}
guide_kigou (basecode, code, increse);
break;
case KEY_UP:
if (basecode <= BEGIN_CODE) {
code = basecode = END_CODE & 0xfff0;
} else {
basecode -= increse;
low = basecode & 0xff;
if (low == 0x20) {
code = (basecode & 0xff00) + 0x21;
} else {
if (low < 0x20) {
basecode &= 0xff00;
basecode -= 0x90;
}
code = basecode;
}
}
guide_kigou (basecode, code, increse);
break;
case KEY_DOWN:
if (basecode >= (END_CODE & 0xfff0)) {
code = BEGIN_CODE;
basecode = code & 0xfff0;
} else {
basecode += increse;
low = basecode & 0xff;
if (low > 0x70) {
basecode &= 0xff00;
basecode += 0x120;
code = basecode + 1;
} else
code = basecode;
}
guide_kigou (basecode, code, increse);
break;
case KEY_HENKAN:
input_kigou (basecode, code, increse);
break;
case KEY_KETTEI:
input_kigou (basecode, code, increse);
ki = 0;
break;
default:
if ((keyvalue = IsCKey (inc)) != KEY_NORMAL)
goto top;
if (CheckCcode(inc)) {
if ((num = strtocode()) > 0) {
code = num;
basecode = code & 0xfff0;
guide_kigou(basecode, code, increse);
}
}
else if (inc == ESC)
ki = 0;
else if (inc == '\n' || inc == '\r' || inc == ' ')
input_kigou (basecode, code, increse);
else if (IsRedraw (inc))
guide_kigou (basecode, code, increse);
else
beep ();
break;
}
}
EndGuide (row, col);
disp_mode ();
return (rval);
}
IsRedraw (c)
int c;
{
if (c == 0x0c)
return (1);
else
return (0);
}
IsCKey (inc)
register int inc;
{
switch (inc) {
case 'l':
return (KEY_RIGHT);
case 'k':
return (KEY_UP);
case 'j':
return (KEY_DOWN);
case 'h':
return (KEY_LEFT);
default:
return (KEY_NORMAL);
}
}
guide_kigou (bcode, code, increse)
register int bcode, code, increse;
{
register int i;
extern wchar16_t Mguide[];
wchar16_t wtmp[20];
char tmp[20];
u_short prcode;
TopGuide ();
printR (Mguide);
put_space (1);
put_space (1);
for (i = 0 ; i < increse ; i ++)
pkigou (bcode + i);
prcode = code;
if (((i = GetCcode()) == CODE_KUTEN) || (i == CODE_KUTEN2)) {
prcode -= 0x2020;
sprintf (tmp, " [%02d%02d]", prcode >> 8, prcode & 0xff);
} else {
if (i == CODE_SJIS)
prcode = jis2sjis(prcode);
else if ((i == CODE_EUC) || (i == CODE_EUC2))
prcode |= 0x8080;
sprintf (tmp, " [%04x]", prcode);
}
(void) mbstowcs(wtmp, tmp, 20);
SJ_print (wtmp);
backspace (8 + (bcode + increse - code) * 2);
Flush ();
}
pkigou (code)
register int code;
{
wchar16_t tmp[3];
u_short ccode;
if (jis2euc(code) == 0) {
ccode = BEGIN_CODE;
} else {
ccode = code;
}
if ((GetCcode() == CODE_EUC2) || (GetCcode() == CODE_JIS2) ||
(GetCcode() == CODE_KUTEN2)) {
ccode = WcJIS2X0212(ccode);
} else {
ccode = WcJIS2X0208(ccode);
}
tmp[0] = ccode;
tmp[1] = '\0';
SJ_print (tmp);
}
input_kigou (basecode, code, increse)
register int basecode, code, increse;
{
wchar16_t s[2];
u_short ccode, svlen;
register Conversion *cv;
if (jis2euc(code) == 0) {
beep();
return;
}
if ((GetCcode() == CODE_EUC2) || (GetCcode() == CODE_JIS2) ||
(GetCcode() == CODE_KUTEN2)) {
ccode = WcJIS2X0212(code);
} else {
ccode = WcJIS2X0208(code);
}
EndGuide (row, col);
s[0] = ccode;
s[1] = '\0';
if (BuffYes ()) {
cv = GetConversion();
save_obuf();
(void)exec_romaji(s[0]);
if (os_point > 0) {
svlen = cv->Vlen;
vprintU(osave_buf, 1);
Cgoto(svlen);
}
restore_obuf();
} else {
master_out (s, 2);
master_flush();
}
StartGuide (&row, &col);
guide_kigou (basecode, code, increse);
lastcode = code;
}

View file

@ -1,361 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "sj_sysvdef.h"
#ifdef SVR4
#include <sys/euc.h>
#endif
#include "wchar16.h"
#include <locale.h>
#include "kctype.h"
#include "common.h"
extern char user_name[];
extern char *cur_serv, **serv_list;
extern char **dict_list;
extern int dict_num;
char *chmyhname();
extern int current_locale;
int sjislen(), euclen();
int (*len_func[3])() = {0, sjislen, euclen};
#define YOMILEN 32
#define KLEN 64
SJ2_henkan (yomiout, bun, kanjiout, kanjilen)
struct bunsetu_sj3 *bun;
wchar16_t *yomiout, *kanjiout;
int kanjilen;
{
int retv;
SJ3_BUNSETU sbun[BUFFLENGTH];
int i, sentou, saigo;
u_char yomi[BUFFLENGTH * 3];
u_char kanji[BUFFLENGTH * 6];
(void) wcstombs((char *) yomi, yomiout, BUFFLENGTH*3);
if (current_locale == LC_CTYPE_SHIFTJIS) {
retv = sj3_getkan(yomi, sbun, kanji, BUFFLENGTH * 6);
} else {
retv = sj3_getkan_euc(yomi, sbun, kanji, BUFFLENGTH * 6);
}
if (retv <= 0) return(retv);
(void) mbstowcs(kanjiout, (char *)kanji, kanjilen);
for(i = 0; i < retv; i++) {
sentou = (*len_func[current_locale])(yomi, sbun[i].srcstr - yomi);
saigo = (*len_func[current_locale])(sbun[i].srcstr, sbun[i].srclen);
bun[i].srclen = saigo;
bun[i].srcstr = yomiout + sentou;
sentou = (*len_func[current_locale])(kanji, sbun[i].deststr - kanji);
saigo = (*len_func[current_locale])(sbun[i].deststr, sbun[i].destlen);
bun[i].destlen = saigo;
bun[i].deststr = kanjiout + sentou;
(void) memcpy(&(bun[i].dcid), &(sbun[i].dcid), sizeof(sbun[i].dcid));
}
return(retv);
}
int
sjislen(str, max)
unsigned char *str;
int max;
{
register int len = 0, bytes = 1;
if (!max) return 0;
while ((bytes <= max) && *str) {
if (issjis1(*str)) {
str++;
bytes++;
if (!*str) break;
len++;
} else {
len++;
}
str++;
bytes++;
}
return len;
}
euclen(str, max)
unsigned char *str;
int max;
{
register int len = 0, bytes = 1;
if (!max) return 0;
while ((bytes <= max) && *str) {
if (*str == SS3) {
str++;
bytes++;
if (!*str) break;
str++;
bytes++;
if (!*str) break;
len++;
} else if ((*str == SS2) || (*str & 0x80)) {
str++;
bytes++;
if (!*str) break;
len++;
} else {
len++;
}
str++;
bytes++;
}
return len;
}
SJ2_getdouon (s, d, n, choice, reconv)
wchar16_t *s;
struct douon_sj3 *d;
int n;
int choice;
int reconv;
{
int i, ret;
SJ3_DOUON d_sjis[DOUON_N];
u_char yomi[BUFFLENGTH * 3];
(void) wcstombs((char *) yomi, s, BUFFLENGTH*3);
if (current_locale == LC_CTYPE_SHIFTJIS) {
ret = sj3_getdouon(yomi, d_sjis);
} else {
ret = sj3_getdouon_euc(yomi, d_sjis);
}
for (i = 0; i < ret; i++) {
(void) memcpy(&(d[i].dcid),
&(d_sjis[i].dcid), SJ3_WORD_ID_SIZE);
d[i].wlen = (int) mbstowcs(d[i].ddata, (char *)d_sjis[i].ddata,
SJ3_BUNSETU_KANJI*2);
d[i].dlen = wcbyte(d[i].ddata);
d[i].valid = (char)1;
}
if (ret < DOUON_N) {
(void) memset(&(d[ret].dcid), 0, SJ3_WORD_ID_SIZE);
d[ret].wlen = wslen(s);
for (i = 0; i < d[ret].wlen; i++) {
d[ret].ddata[i] = sj_tokata(s[i]);
}
d[ret].ddata[i] = (wchar_t) 0;
d[ret].dlen = wcbyte(s);
d[ret].valid = (char)0;
}
return(ret + 1);
}
SJ2_study (dcid)
struct studyrec *dcid;
{
sj3_gakusyuu(dcid);
}
SJ2_clstudy (yomi1, yomi2, dcid)
wchar16_t *yomi1, *yomi2;
struct studyrec *dcid;
{
u_char y1[BUFFLENGTH*2];
u_char y2[BUFFLENGTH*2];
(void) wcstombs((char *) y1, yomi1, BUFFLENGTH*2);
(void) wcstombs((char *) y2, yomi2, BUFFLENGTH*2);
if (current_locale == LC_CTYPE_SHIFTJIS) {
sj3_gakusyuu2(y1, y2, dcid);
} else {
sj3_gakusyuu2_euc(y1, y2, dcid);
}
}
SJ2_toroku (yomi, kanji, hinshi)
wchar16_t *yomi, *kanji;
int hinshi;
{
u_char y[(YOMILEN+1)*3];
u_char k[(KLEN+1)*3];
int ret;
(void)wcstombs((char *) y, yomi, (YOMILEN+1)*3);
(void)wcstombs((char *) k, kanji, (KLEN+1)*3);
if (current_locale == LC_CTYPE_SHIFTJIS) {
ret = sj3_touroku (y, k, hinshi);
} else {
ret = sj3_touroku_euc (y, k, hinshi);
}
return(ret);
}
SJ2_syoukyo (yomi, kanji, hinshi)
wchar16_t *yomi, *kanji;
int hinshi;
{
u_char y[(YOMILEN+1)*3];
u_char k[(KLEN+1)*3];
int ret;
(void)wcstombs((char *) y, yomi, (YOMILEN+1)*3);
(void)wcstombs((char *) k, kanji, (KLEN+1)*3);
if (current_locale == LC_CTYPE_SHIFTJIS) {
ret = sj3_syoukyo (y, k, hinshi);
} else {
ret = sj3_syoukyo_euc (y, k, hinshi);
}
return(ret);
}
sj_check_error (err)
int err;
{
if (err & SJ3_SERVER_DEAD)
SJ_warnning(WCServer_Dead);
if (err & SJ3_ALREADY_CONNECTED)
SJ_warnning(WCConnected);
if (err & SJ3_CONNECT_ERROR)
SJ_warnning(WCNconnect);
if (err & SJ3_CANNOT_OPEN_MDICT)
SJ_warnning(WCNopen_Mdic);
if (err & SJ3_CANNOT_MAKE_UDIR)
SJ_warnning(WCNmake_Udir);
if (err & SJ3_CANNOT_MAKE_UDICT)
SJ_warnning(WCNmake_Udic);
if (err & SJ3_CANNOT_OPEN_UDICT)
SJ_warnning(WCNopen_Udic);
if (err & SJ3_CANNOT_MAKE_STUDY)
SJ_warnning(WCNmake_Study);
if (err & SJ3_CANNOT_OPEN_STUDY)
SJ_warnning(WCNopen_Study);
}
SJ2_reconnect ()
{
int err;
sj3_close();
if (dict_num && dict_list)
err = sj3_open_with_list(chmyhname(cur_serv), user_name, dict_num, dict_list, NULL, NULL);
else
err = sj3_open(chmyhname(cur_serv), user_name);
return(err);
}
SJ2_henkan_end ()
{
sj3_close ();
}
SJ2_henkan_init ()
{
register int i, err;
int *err_dict = NULL;
int err_num = 0;
sj3_set_timeout(5);
if (dict_num && dict_list)
err = sj3_open_with_list(chmyhname(cur_serv), user_name, dict_num,
dict_list, &err_num, &err_dict);
else
err = sj3_open(chmyhname(cur_serv), user_name);
i = 0;
while (err && i < MAXSERVER - 1 && serv_list[i + 1] != NULL) {
if (dict_num && dict_list)
err = sj3_open_with_list(chmyhname(serv_list[++i]), user_name,
dict_num, dict_list, &err_num, &err_dict);
else
err = sj3_open(chmyhname(cur_serv), user_name);
}
if (err) {
printf("Warning ");
sj_check_error(err);
printf("\n\r");
set_dcflag(1);
return(1);
} else if (err_num && err_dict) {
printf("Warning ");
for( i = 0; i < err_num; i++) {
printf("%s ", dict_list[err_dict[i]]);
}
printf(" files can't open\n");
cur_serv = serv_list[i];
return (0);
} else {
cur_serv = serv_list[i];
return (0);
}
}
sj3_autocon()
{
register int i, err;
if (dict_num && dict_list) {
if (!(err = sj3_open_with_list(chmyhname(cur_serv), user_name, dict_num,
dict_list, NULL, NULL)))
return(0);
} else {
if (!(err = sj3_open(chmyhname(cur_serv), user_name)))
return(0);
}
i = 0;
while (serv_list[i] != NULL && i < MAXSERVER) {
if (strcmp(cur_serv, serv_list[i]) != 0) {
if (dict_num && dict_list) {
err = sj3_open_with_list(chmyhname(serv_list[i]), user_name,
dict_num, dict_list, NULL, NULL);
} else {
err = sj3_open(chmyhname(cur_serv), user_name);
}
if (!err) {
cur_serv = serv_list[i];
break;
}
}
i++;
}
return(err);
}

View file

@ -1,109 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "sj2.h"
#define LINESIZE 128
#include <string.h>
#include <unistd.h>
static char *getttys();
static char *ttys = "/etc/ttys";
#define NULL 0
nmttyslot (name)
char *name;
{
register char *tp, *p;
register int s, tf;
tp = name;
if ((p = strrchr (tp, '/')) == NULL)
p = tp;
else
p++;
if ((tf = open (ttys, 0)) < 0)
return(0);
s = 0;
while (tp = getttys (tf)) {
s++;
if (strcmp (p, tp) == 0) {
close (tf);
return (s);
}
}
close (tf);
return (0);
}
static char *
getttys (f)
int f;
{
static char line[LINESIZE];
register char *lp;
top:
for (lp = line ; lp < &line[LINESIZE] ; lp ++) {
if (read (f, lp, 1) != 1)
return (NULL);
if (*lp == '\n') {
*lp = '\0';
break;
}
else if (*lp == ' ' || *lp == '\t') {
while (1) {
if (read (f, lp, 1) != 1)
break;
if (*lp == '\n')
break;
}
*lp = '\0';
break;
}
}
lp = line;
if (*lp == '0' || *lp == '1')
lp += 2;
else if (*lp == '#')
goto top;
return (lp);
}

View file

@ -1,542 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "common.h"
#include "rk.h"
#include "key.h"
extern int rkerrbell;
exec_romaji(c)
wchar16_t c;
{
register Conversion *cv;
register wchar16_t *p;
register u_short c1, cc;
register u_int c2;
u_short op;
u_char mode;
int len, i;
u_int rkstr[MAXLLEN], *rkp;
extern char erase_str[];
cv = GetConversion ();
op = cv->out_point;
if (!is_bs(c) && BuffYes()) {
if ((unsigned int) cv->ha_point + hs_point >= BUFFLENGTH - 2 &&
!iswcntrl(c)) {
beep();
return(1);
}
cv->Halpha[cv->ha_point++] = c;
}
if ((mode = cv->Imode) & MODE_CONV) {
sj3_rkconvc(c, rkstr);
} else if (mode == MODE_CODE) {
codeconv(c, rkstr);
} else {
rkstr[0] = SetMojilen(1) + c;
rkstr[1] = RKEND;
}
rkp = rkstr;
i = 1;
while(*rkp != RKEND) {
c1 = ((c2 = *rkp++) & RKMASK);
if (c2 == ERRBEL) {
beep();
cv->ha_point--;
break;
}
if (is_bs(c1)) {
if (op <= 0) {
if (os_point <= 0) {
master_write(erase_str, 1);
}
} else {
if (WcIsZENKAKU(cv->out_buf[op - 1])) {
vbackchar(2);
op -=1;
} else {
vbackchar(1);
op--;
}
cv->out_point = op;
if (BuffYes() && is_bs(c)) {
if (!(cv->out_mode[op] & OMODE_MASK))
chhstr(cv->Halpha, cv->out_buf,
cv->out_mode, op);
cv->ha_point = getipos(op);
}
}
continue;
}
if (WcIsZENKAKU(c1)) {
if (op >= 1 && (cc = addten(op - 1, c1)) != 0) {
c1 = cc;
vbackchar(2);
op -= 1;
cv->out_point = op;
len = cv->out_mode[op] + GetMojilen(c2);
c2 = SetMojilen(len);
} else {
if (!GetMojilen(c2) && (mode == MODE_CODE))
c2 = SetMojilen(1);
}
if (mode == MODE_ZKATA) {
c1 = sj_tokata(c1);
} else if (mode == MODE_HKATA) {
c1 = sj_zen2han(c1);
}
} else {
if ((c2 & ERRCODE) && is_bs(c))
cv->Halpha[cv->ha_point++] = c1;
if (WcIsKANJI(c1)) {
c2 = SetMojilen(1);
} else if (iswcntrl(c1) && !(c2 & ERRCODE)) {
if (BuffYes())
cv->ha_point--;
sj3_rkreset();
i = 0;
break;
} else if (mode & MODE_ZEN) {
c1 = sj_han2zen(c1);
if (mode == MODE_ZKATA)
c1 = sj_tokata(c1);
if (op >=1 && (cc = addten(op-1, c1)) != 0){
c1 = cc;
vbackchar(2);
op --;
cv->out_point = op;
len = cv->out_mode[op]
+ GetMojilen(c2);
c2 = SetMojilen(len);
}
}
}
if ((unsigned int)cv->out_point + os_point >= BUFFLENGTH * 2 - 2) {
beep();
op = cv->out_point;
break;
}
if (WcIsZENKAKU(c1)) {
cv->out_buf[op] = c1;
cv->in_mode[op] = mode;
cv->out_mode[op++] = GetMojilen(c2);
if (mode == MODE_HKATA || WcIsKANA(cv->out_buf[op - 1])) {
cv->out_buf[op - 1] = c1 >> 8;
cv->out_buf[op] = c1 &MASK;
cv->in_mode[op] = mode;
cv->out_mode[op++] = 0;
sj3_rkreset();
}
} else {
cv->out_buf[op] = c1;
cv->in_mode[op] = mode;
cv->out_mode[op++] = GetMojilen(c2);
}
if (!BuffYes() && !(c2 & ERRCODE)) {
cv->out_buf[op] = '\0';
master_out(cv->out_buf, op);
sj3_rkreset();
op = 0;
}
}
cv->out_buf[op] = '\0';
cv->Halpha[cv->ha_point] = '\0';
if (is_bs(c) && op <= 0 && os_point <= 0) {
ResetHenkan();
if (BuffYes()) {
SetCflag();
buffers_clear();
}
}
else if ((len = op - cv->out_point) > 0) {
p = &cv->out_buf[cv->out_point];
if (BuffYes() && IsCflag ()) {
Csave ();
ClearCflag ();
}
if (mode & MODE_ZEN) {
if (!BuffYes() && len == 2)
Csave();
vprintU(p, 1);
} else {
if (!BuffYes() && len == 1)
Csave();
vprintU(p, 0);
}
}
cv->out_point = op;
return(i);
}
move_cur(kval)
int kval;
{
register Conversion *cv;
register int i;
cv = GetConversion();
switch(kval) {
case KEY_TOP:
cv->out_point = 0;
break;
case KEY_END:
cv->out_point = cv->out_epoint;
cv->ha_point = cv->ha_epoint;
break;
case KEY_LEFT:
if ((i = cv->out_point) > 0) {
i--;
if (i > 0 && (WcIsZENKAKU(cv->out_buf[i])))
i--;
cv->out_point = i;
}
break;
case KEY_RIGHT:
if ((i = cv->out_point) < cv->out_epoint) {
i++;
if (i < cv->out_epoint && (WcIsZENKAKU(cv->out_buf[i])))
i++;
cv->out_point = i;
if (cv->out_point >= cv->out_epoint)
cv->ha_point = cv->ha_epoint;
}
break;
}
if (cv->out_point != cv->Vlen) {
Cgoto(cv->out_point);
if (cv->out_point == cv->out_epoint) {
os_point = 0;
hs_point = 0;
}
}
}
addten(pos, c)
u_short pos, c;
{
register u_short prefix;
register Conversion *cv;
cv = GetConversion();
prefix = cv->out_buf[pos];
return(sj_addten(prefix, c));
}
getipos(pos)
u_short pos;
{
register Conversion *cv;
cv = GetConversion();
return(getipos2(cv->out_mode, pos));
}
getipos2(omode, pos)
u_short *omode;
u_short pos;
{
register u_short ipos;
register int i;
ipos = 0;
for (i = 0; i < (unsigned int)pos; i++) {
ipos += omode[i] & OMODE_MASK;
}
return(ipos);
}
sj_rkconv(s1, s2, len)
wchar16_t *s1, *s2;
int len;
{
register int i, rlen;
register u_int *kp;
int res, klen;
wchar16_t roma[SHORTBUFFSIZE + 1];
u_int kstr[MAXLLEN];
sj3_rkebell(0);
klen = 0;
res = 0;
while (len > 0) {
if (len + res > SHORTBUFFSIZE) {
i = SHORTBUFFSIZE - res;
len -= i;
} else {
i = len;
len = 0;
}
Strncpy(&roma[res], s2, i);
s2 += i;
roma[res + i] = '\0';
rlen = sj3_rkconv2(roma, kstr, i + res - 1);
res = wslen(roma);
if (rlen > 0) {
kp = kstr;
while (*kp != 0) {
*s1++ = (wchar16_t) *kp++;
klen++;
}
}
}
if (res > 0) {
roma[res] = 0x0a;
roma[res + 1] = '\0';
rlen = sj3_rkconv2(roma, kstr, res);
if (rlen > 0) {
kp = kstr;
while ((*kp & RKMASK) != 0x0a && *kp != 0) {
*s1++ = (wchar16_t) *kp++;
klen++;
}
} else {
klen += res;
roma[res] = '\0';
wscpy(s1, roma);
s1 += res;
}
}
*s1 = '\0';
sj3_rkebell(rkerrbell);
return(klen);
}
sj_rkconv2(s1, s2, omode, len)
wchar16_t *s1, *s2;
u_short *omode;
int len;
{
register int i, rlen;
register u_int *kp;
int res, klen, mlen;
u_short cc, c, prefix;
wchar16_t roma[SHORTBUFFSIZE + 1];
u_int kstr[BUFFLENGTH];
sj3_rkebell(0);
klen = 0;
res = 0;
prefix = 0;
while (len > 0) {
if (len + res > SHORTBUFFSIZE) {
i = SHORTBUFFSIZE - res;
len -= i;
} else {
i = len;
len = 0;
}
Strncpy(&roma[res], s2, i);
s2 += i;
roma[res + i] = '\0';
rlen = sj3_rkconv2(roma, kstr, i + res - 1);
res = strlen((char *)roma);
if (rlen <= 0)
continue;
kp = kstr;
while ((c = *kp & RKMASK) != 0) {
if (c & RKZEN) {
if ((cc = sj_addten(prefix, c)) != 0) {
omode -= 1;
s1 -= 1;
*omode += GetMojilen(*kp);
c = cc;
prefix = 0;
} else {
*omode = GetMojilen(*kp);
klen += 1;
prefix = c;
}
*s1++ = (wchar16_t) c;
omode++;
kp++;
} else {
mlen = GetMojilen(*kp);
*kp = sj_han2zen(c) + SetMojilen(mlen);
}
}
}
if (res > 0) {
roma[res] = 0x0a;
roma[res + 1] = '\0';
rlen = sj3_rkconv2(roma, kstr, res);
if (rlen > 0) {
kp = kstr;
while ((c = *kp & RKMASK) != 0x0a && c != 0) {
if (*kp & RKZEN) {
if ((cc = sj_addten(prefix, c)) != 0) {
omode -= 1;
s1 -= 1;
*omode += GetMojilen(*kp);
c = cc;
prefix = 0;
} else {
*omode = GetMojilen(*kp);
klen += 1;
prefix = c;
}
*s1++ = (wchar16_t) c;
omode++;
kp++;
} else {
mlen = GetMojilen(*kp);
*kp = sj_han2zen(c) + SetMojilen(mlen);
}
}
} else {
for (i = 0; i < res; i++) {
if (WcIsKANJI(roma[i])) {
c = roma[i];
mlen = 1;
} else {
c = sj_han2zen(roma[i]);
mlen = 1;
}
if ((cc = sj_addten(prefix, c)) != 0) {
s1 -= 1;
omode -= 1;
*omode += mlen;
c = cc;
prefix = 0;
} else {
prefix = c;
klen += 2;
*omode = mlen;
}
*s1++ = c;
omode++;
}
}
}
*s1 = '\0';
sj3_rkebell(rkerrbell);
return(klen);
}
exec_romaji2(c, hbuf, kbuf, omode, cur, hcur)
wchar16_t c, *hbuf, *kbuf;
u_short *omode;
int cur, hcur;
{
register u_short c1, cc;
register u_int c2;
register int i;
int ocur, len, retv;
u_int rkstr[MAXLLEN], *rkp;
retv = 1;
ocur = cur;
if (hcur >= 0 && !is_bs(c))
hbuf[hcur++] = c;
sj3_rkconvc(c, rkstr);
rkp = rkstr;
while(*rkp != RKEND) {
c1 = ((c2 = *rkp++) & RKMASK);
if (c2 == ERRBEL) {
if (c != 0)
beep();
hcur--;
break;
}
if (is_bs(c1)) {
if (cur <= 0) {
beep();
} else {
vbackchar(2);
cur -= 1;
ocur = cur;
}
if (hcur >= 0 && is_bs(c)) {
for (i = cur; i > 0 ; i--){
if (omode[i] & OMODE_MASK)
break;
}
hcur -= omode[i];
while (i < cur) {
len = sj_zentohan(&hbuf[hcur],&kbuf[i],1);
omode[i] = len;
hcur += len;
i ++;
}
}
continue;
}
if (!WcIsZENKAKU(c1)) {
if (hcur >= 0 && (c2 & ERRCODE) && is_bs(c))
hbuf[hcur++] = c1;
if (c1 == 0) {
hcur--;
break;
} else {
if (c2 & ERRCODE)
retv = 0;
c1 = sj_han2zen(c1);
}
}
if (cur >= 1) {
cc = kbuf[cur - 1];
if ((cc = sj_addten(cc, c1)) != 0){
c1 = cc;
vbackchar(2);
cur --;
ocur = cur;
if (hcur >= 0) {
len = omode[cur] + GetMojilen(c2);
c2 = SetMojilen(len);
}
}
}
kbuf[cur] = c1;
if (hcur >= 0) {
omode[cur] = GetMojilen(c2);
}
cur ++;
}
kbuf[cur] = '\0';
if (hcur >= 0)
hbuf[hcur] = '\0';
if (cur > ocur)
vprintU(&kbuf[ocur], 1);
return(retv);
}

View file

@ -1,502 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "common.h"
#include "key.h"
#define LINE_LENGTH 80
static wchar16_t *Guide;
static wchar16_t Nguide[LINE_LENGTH + 1];
static wchar16_t Cguide[LINE_LENGTH + 1];
wchar16_t Mguide[LINE_LENGTH + 1];
vbackchar (n)
register int n;
{
register int i;
for (i=0 ; i < n ; i++)
VBackspace ();
for (i=0 ; i < n ; i++)
Vput_space ();
for (i=0 ; i < n ; i++)
VBackspace ();
Flush ();
}
wrap_off ()
{
register Conversion *cv;
cv = GetConversion ();
cv->wrap = 0;
cv->PushCurrentVcol = cv->CurrentVcol;
}
wrap_on ()
{
register Conversion *cv;
cv = GetConversion ();
cv->wrap = 1;
cv->CurrentVcol = cv->PushCurrentVcol;
}
Vput_space ()
{
register Conversion *cv;
cv = GetConversion ();
put_space (1);
cv->Vindex[cv->Vlen ++] = cv->CurrentVcol ++;
if (cv->wrap && ((cv->CurrentVcol % cv->column) == 1)) {
put_space (1);
Backspace ();
}
}
VBackspace ()
{
register Conversion *cv;
register int i;
cv = GetConversion ();
if (cv->wrap && ((cv->CurrentVcol % cv->column) == 1)) {
Ccheck ();
i = cv->Vindex[cv->Vlen - 1] % cv->column;
if (cv->Vlen > 0 && i > 1) {
CursorSet (
cv->SavedRow + (cv->CurrentVcol / cv->column) - 1,
cv->Vindex[cv->Vlen - 1] % cv->column
);
}
else
CursorSet (
cv->SavedRow + (cv->CurrentVcol / cv->column) - 1,
cv->column
);
}
else
Backspace ();
if (cv->Vlen > 0)
cv->CurrentVcol = cv->Vindex[--(cv->Vlen)];
else {
cv->Vlen = 0;
cv->CurrentVcol = cv->Vindex[cv->Vlen];
}
}
master_out (s, n)
wchar16_t *s;
int n;
{
master_write (s, n);
master_flush ();
}
master_write (s, n)
wchar16_t *s;
int n;
{
SJ_write (s, n);
}
vprintU (s, mod)
wchar16_t *s;
char mod;
{
register Conversion *cv;
register int i, col, oldcol, len;
register u_short *p;
cv = GetConversion ();
printU (s);
oldcol = cv->CurrentVcol % cv->column;
if (cv->wrap && (mod == 1) && (oldcol == 0))
cv->CurrentVcol ++;
len = wcbyte (s);
p = &(cv->Vindex[cv->Vlen]);
cv->Vlen += len;
for (i = 0 ; i < len ; i ++)
*(p ++) = cv->CurrentVcol ++;
if (cv->wrap) {
col = cv->CurrentVcol % cv->column;
if (col == 1) {
put_space (1);
Backspace ();
}
if ((mod == 1) && (oldcol + len > (unsigned int)cv->column)
&& ((col & 1) == 0)) {
cv->CurrentVcol ++;
}
}
*p = cv->CurrentVcol;
if (cv->CurrentVcol > cv->MaxVcol)
cv->MaxVcol = cv->CurrentVcol;
Flush ();
}
vprintR (s, mod)
wchar16_t *s;
char mod;
{
register Conversion *cv;
register int i, col, oldcol, len;
register u_short *p;
cv = GetConversion ();
printR (s);
oldcol = cv->CurrentVcol % cv->column;
if (cv->wrap && (mod == 1) && (oldcol == 0))
cv->CurrentVcol ++;
len = wcbyte (s);
p = &(cv->Vindex[cv->Vlen]);
cv->Vlen += len;
for (i = 0 ; i < len ; i ++)
*(p ++) = cv->CurrentVcol ++;
if (cv->wrap) {
col = cv->CurrentVcol % cv->column;
if (col == 1) {
put_space (1);
Backspace ();
}
if ((mod == 1) && (oldcol + len > (unsigned int)cv->column)
&& ((col & 1) == 0)) {
cv->CurrentVcol ++;
}
}
*p = cv->CurrentVcol;
if (cv->CurrentVcol > cv->MaxVcol)
cv->MaxVcol = cv->CurrentVcol;
Flush ();
}
IprintU (s, index)
wchar16_t *s;
int index;
{
Cgoto (index);
printU (s);
Flush ();
}
IprintR (s, index)
wchar16_t *s;
int index;
{
Cgoto (index);
printR (s);
Flush ();
}
printU (s)
wchar16_t *s;
{
under_in ();
SJ_print (s);
under_out ();
}
printR (s)
wchar16_t *s;
{
reverse_in ();
SJ_print (s);
reverse_out ();
}
Csave ()
{
register Conversion *cv;
cv = GetConversion ();
CursorRead (&(cv->SavedRow), &(cv->SavedCol));
cv->CurrentVcol = cv->SavedCol;
cv->Vlen = 0;
cv->Vindex[cv->Vlen] = cv->MaxVcol = cv->CurrentVcol;
}
SetVcol (index)
int index;
{
register Conversion *cv;
cv = GetConversion ();
cv->Vlen = index;
cv->CurrentVcol = cv->Vindex[cv->Vlen];
}
Cload ()
{
register Conversion *cv;
cv = GetConversion ();
CursorSet (cv->SavedRow, cv->SavedCol);
}
Cclear (redraw)
int redraw;
{
register Conversion *cv;
register int spaces;
u_short row, col;
if (redraw) {
cv = GetConversion ();
CursorRead (&row, &col);
spaces = (row - cv->SavedRow) * cv->column
+ (col - cv->SavedCol) + 1;
Cload ();
put_space (spaces);
}
Cload ();
Flush ();
}
Cgoto (index)
register int index;
{
register Conversion *cv;
register int row, col;
cv = GetConversion ();
SetVcol (index);
row = cv->SavedRow + (int)(cv->CurrentVcol / cv->column);
col = cv->CurrentVcol % cv->column;
CursorSet (row, col);
}
ClearToMax ()
{
register Conversion *cv;
register int space;
cv = GetConversion ();
space = cv->MaxVcol - cv->CurrentVcol;
put_space (space);
}
Ccheck ()
{
register Conversion *cv;
register int row, tmp, diff;
if (Cscroll ()) {
cv = GetConversion ();
tmp = (int)(cv->CurrentVcol / cv->column);
diff = cv->CurrentVcol - (tmp * cv->column);
if (diff == 0)
tmp --;
row = cv->SavedRow + tmp;
if (row >= (unsigned int)cv->line)
cv->SavedRow -= (row - cv->line);
}
}
spaceR (s)
register wchar16_t *s;
{
register wchar16_t *t;
wchar16_t tmp[40];
t = tmp;
while (*s != '\0') {
if (*s == ' ') {
*t = '\0';
printR (tmp);
t = tmp;
put_space (1);
}
else
*(t ++) = *s;
s ++;
}
*t = '\0';
printR (tmp);
Flush ();
}
clear_guide_line ()
{
u_short row, col;
StartGuide (&row, &col);
Clear_EOL ();
EndGuide (row, col);
Flush ();
}
print_guide_line ()
{
u_short row, col;
StartGuide (&row, &col);
spaceR (Guide);
Clear_EOL ();
EndGuide (row, col);
Flush ();
}
set_guide_line (mode)
int mode;
{
switch (mode) {
case KEY_NORMAL:
wscpy (Nguide, WCSJrun);
Guide = Nguide;
break;
case KEY_CONV:
Guide = Cguide;
break;
default:
break;
}
}
disp_mode ()
{
register Conversion *cv;
int c_code;
register wchar16_t *Pmode, *Bmode;
cv = GetConversion ();
switch (cv->Imode) {
case MODE_CODE:
c_code = GetCcode();
switch (c_code) {
case CODE_SJIS:
Pmode = WCGCshift;
break;
case CODE_EUC:
Pmode = WCGCeuc;
break;
case CODE_JIS:
Pmode = WCGCjis;
break;
case CODE_KUTEN:
Pmode = WCGCkuten;
break;
case CODE_EUC2:
Pmode = WCGCeuc2;
break;
case CODE_JIS2:
Pmode = WCGCjis2;
break;
case CODE_KUTEN2:
Pmode = WCGCkuten2;
break;
}
break;
case MODE_ZHIRA:
Pmode = WCMode_Zhira;
break;
case MODE_ZKATA:
Pmode = WCMode_Zkata;
break;
case MODE_HKATA:
Pmode = WCMode_Hkata;
break;
case MODE_ZALPHA:
Pmode = WCMode_Zalpha;
break;
case MODE_HALPHA:
Pmode = WCMode_Halpha;
break;
default:
break;
}
switch (cv->BuffMode) {
case BUFF:
Bmode = WCMode_buff;
break;
case UNBUFF:
Bmode = WCMode_unbuff;
break;
default:
break;
}
wscpy (Cguide, Bmode);
wscat (Cguide, Pmode);
wscpy (Mguide, Cguide);
if (Hlevel > 1)
wscat (Cguide, WCGmode);
print_guide_line ();
}
TopGuide ()
{
u_short row, col;
StartGuide (&row, &col);
}
guide_print (s1, s2)
wchar16_t *s1, *s2;
{
u_short row, col;
StartGuide (&row, &col);
if (s1)
printR (s1);
SJ_print (s2);
Clear_EOL ();
EndGuide (row, col);
Flush ();
}

1314
sj3/sj3.c

File diff suppressed because it is too large Load diff

View file

@ -1,48 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "sj2.h"
print_version ()
{
extern int vflag;
extern char *version;
extern char *Date;
extern char *Copyright;
extern char *Allrights;
if (vflag == 1) {
aprintf ("%s\n\r%s\n\r%s\n\r%s\n\r", version, Date, Copyright, Allrights);
fflush (stdout);
}
}

View file

@ -1,487 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "sj_sysvdef.h"
#include "wchar16.h"
#include "kctype.h"
#ifdef SVR4
#include <sys/stream.h>
#include <sys/stropts.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#endif
#ifdef linux
#include <sys/types.h>
#include <sys/fcntl.h>
#endif
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__) || defined(__DragonFly__)
#define USE_OLD_TTY
#include <curses.h>
#endif
#if defined(__FreeBSD__)
#include <sys/ioctl_compat.h>
#endif
#include <errno.h>
#include <sys/file.h>
#include "sj2.h"
#include "select.h"
#if !defined(FREAD) && defined(O_RDONLY)
#define FREAD (O_RDONLY+1)
#define FWRITE (O_WRONLY+1)
#endif
#define Isknj1(s) ((eucmode) ? (iseuc(s) || (SS2 == (s))) : (issjis1(s)))
#define Isknj2(s) ((eucmode) ? (SS3 == (s)) : 0)
static wchar16_t backup = (wchar16_t) 0;
static int eucmode = 0;
extern int master;
wchar16_t SJ_getchar()
{
SELECT_FD ifds;
wchar16_t c;
if (backup) {
if (SJ_read (&c, 1) > 0)
return (c);
}
for (;;) {
FD_ZERO (&ifds);
FD_SET (STDIN, &ifds);
FD_SET (master, &ifds);
if (select (master + 1, &ifds, 0, 0, 0) <= 0) {
if (errno == EINTR) {
errno = 0;
continue;
} else
return (EOF);
}
if (FD_ISSET (STDIN, &ifds)) {
if (SJ_read (&c, 1) > 0) {
if (FD_ISSET (master, &ifds)) {
output_master();
}
return (c);
}
return (EOF);
}
if (FD_ISSET (master, &ifds)) {
output_master();
}
}
}
#ifdef SVR4
#define TIOCPKT_DOSTOP 0x10
#define TIOCPKT_NOSTOP 0x20
static int stopmode = TIOCPKT_DOSTOP;
static char stopc = CTRL('s');
static char startc = CTRL('q');
static char outbuf[BUFSIZ];
extern int slave;
extern char *slave_name, *ptsname();
output_master()
{
struct strbuf ctlbuf;
struct strbuf databuf;
int flags = 0;
u_char ctlstuff;
int f, stop, ixon, ret;
register struct iocblk *ioc;
register struct termios *tp;
register struct termio *ti;
struct tchars tc, tc1;
memset((char *)&ctlbuf, '\0', sizeof(ctlbuf));
memset((char *)&databuf,'\0', sizeof(databuf));
ctlbuf.maxlen = sizeof(ctlstuff);
ctlbuf.buf = (char *)&ctlstuff;
databuf.maxlen = BUFSIZ;
databuf.buf = outbuf;
if ((ret = getmsg(master, &ctlbuf, &databuf, &flags)) == -1) {
return;
}
if (ctlbuf.len <= 0) {
errno = EWOULDBLOCK;
return;
}
if (ret & MORECTL) {
errno = EWOULDBLOCK;
return;
}
if ((ctlstuff != M_DATA) && (ret & MOREDATA)) {
errno = EWOULDBLOCK;
return;
}
if (ctlbuf.len != sizeof(ctlstuff)) {
errno = EWOULDBLOCK;
return;
}
switch (ctlstuff) {
case M_DATA:
write_stdout((u_char *)&outbuf[0], databuf.len);
fflush (stdout);
while (ret & MOREDATA) {
if ((ret = getmsg(master, &ctlbuf, &databuf, &flags)) == -1) {
return;
}
write_stdout((u_char *)&outbuf[0], databuf.len);
fflush (stdout);
}
return;
break;
case M_FLUSH:
if (databuf.len <= 0) {
errno = EWOULDBLOCK;
return;
}
fflush (stdout);
break;
case M_IOCTL:
ioc = (struct iocblk *)databuf.buf;
if (databuf.len <= sizeof(struct iocblk)) {
errno = EWOULDBLOCK;
return;
}
switch (ioc->ioc_cmd) {
case TCSETS:
case TCSETSW:
case TCSETSF:
if (databuf.len < (sizeof(struct termios)
+ sizeof(struct iocblk))) {
errno = EWOULDBLOCK;
return;
}
tp = (struct termios *)(databuf.buf + sizeof (struct iocblk));
stopc = tp->c_cc[VSTOP];
startc = tp->c_cc[VSTART];
ixon = tp->c_iflag & IXON;
break;
case TCSETA:
case TCSETAW:
case TCSETAF:
if (databuf.len < (sizeof (struct termio)
+ sizeof (struct iocblk))) {
errno = EWOULDBLOCK;
return;
}
ti = (struct termio *)(databuf.buf + sizeof (struct iocblk));
ixon = ti->c_iflag & IXON;
break;
default:
errno = EWOULDBLOCK;
return;
}
stop = (ixon && (stopc == CTRL('s')) && (startc == CTRL('q')));
if (stopmode == TIOCPKT_NOSTOP) {
if (stop) {
ioctl (STDOUT, TIOCGETC, &tc);
if (slave == 0) {
slave_name = ptsname(master);
slave = open(slave_name, O_RDWR);
}
ioctl (slave, TIOCGETC, &tc1);
tc.t_stopc = tc1.t_stopc;
tc.t_startc = tc1.t_startc;
ioctl (STDOUT, TIOCSETC, &tc);
stopmode = TIOCPKT_DOSTOP;
}
} else {
if (!stop) {
ioctl (STDOUT, TIOCGETC, &tc);
tc.t_stopc = -1;
tc.t_startc = -1;
ioctl (STDOUT, TIOCSETC, &tc);
stopmode = TIOCPKT_NOSTOP;
}
}
errno = EWOULDBLOCK;
return;
break;
default:
errno = EWOULDBLOCK;
return;
break;
}
}
#else
#if defined(linux) && defined (__GLIBC__) && (__GLIBC__ >= 2)
#include <termios.h>
#endif
output_master()
{
register int n, m;
char outbuf[BUFSIZ];
int f;
#ifdef SYSV_TERMIOS
struct termios tc, tc1;
#else
struct tchars tc, tc1;
#endif
extern int master;
if ((n = read (master, outbuf, BUFSIZ)) > 0) {
m = outbuf[0];
if (m == TIOCPKT_DATA) {
write_stdout((u_char *)&outbuf[1], n - 1);
fflush (stdout);
return;
}
else if (m & (TIOCPKT_FLUSHREAD | TIOCPKT_FLUSHWRITE)) {
f = 0;
if (m & TIOCPKT_FLUSHREAD)
f |= FREAD;
if (m & TIOCPKT_FLUSHWRITE)
f |= FWRITE;
fflush (stdout);
#ifdef TCFLSH
ioctl (STDOUT, TCFLSH, &f);
#else
ioctl (STDOUT, TIOCFLUSH, &f);
#endif
}
else if (m & TIOCPKT_NOSTOP) {
#ifdef SYSV_TERMIOS
ioctl (1, TCGETS, &tc);
tc.c_cc[VSTOP] = 0;
tc.c_cc[VSTART] = 0;
ioctl (STDOUT, TCSETS, &tc);
#else
ioctl (1, TIOCGETC, &tc);
tc.t_stopc = -1;
tc.t_startc = -1;
ioctl (STDOUT, TIOCSETC, &tc);
#endif
}
else if (m & TIOCPKT_DOSTOP) {
#ifdef SYSV_TERMIOS
ioctl (master, TCGETS, &tc1);
ioctl (STDOUT, TCGETS, &tc);
tc.c_cc[VSTOP] = tc1.c_cc[VSTOP];
tc.c_cc[VSTART] = tc1.c_cc[VSTART];
ioctl (STDOUT, TCSETS, &tc);
#else
ioctl (master, TIOCGETC, &tc1);
ioctl (STDOUT, TIOCGETC, &tc);
tc.t_stopc = tc1.t_stopc;
tc.t_startc = tc1.t_startc;
ioctl (STDOUT, TIOCSETC, &tc);
#endif
}
}
}
#endif
set_eucmode ()
{
eucmode = 1;
}
SJ_write (s, n)
wchar16_t *s;
register int n;
{
register int val;
wchar16_t wb[BUFFLENGTH];
u_char buff[BUFFLENGTH * 3];
wsncpy(wb, s, n);
wb[n] = 0;
val = wcstombs((char *) buff, wb, (size_t) n * 3);
if ((val == 0) && n) {
int i;
val = n;
for (i = 0; i <= n; i++)
buff[i] = 0;
}
if (val > 0)
val = write(master, buff, val);
return(val);
}
write_stdout(s, n)
u_char *s;
register int n;
{
static u_char knj1st = 0, knj2nd = 0;
while (n-- > 0) {
if (knj1st) {
if (knj2nd) {
putchar(knj2nd);
putchar(knj1st);
putchar(*s++);
knj2nd = 0;
knj1st = 0;
} else {
putchar(knj1st);
putchar(*s++);
knj1st = 0;
}
} else if (knj2nd) {
knj1st = *s++;
} else if (Isknj2(*s)) {
knj2nd = *s++;
} else if (Isknj1(*s))
knj1st = *s++;
else
putchar(*s++);
}
}
SJ_read (s, n)
wchar16_t *s;
int n;
{
u_char buff[BUFFLENGTH];
wchar16_t wcbuff[BUFFLENGTH];
register int i, count, remain, c;
size_t wnum;
extern int current_locale;
if (backup) {
*s = backup;
backup = 0;
return (1);
}
if ((count = read(STDIN, buff, n)) <= 0)
return (count);
remain = 0;
for (i = 0; i < count; i++) {
c = buff[i];
#ifdef __sony_news
if (is3byte(c)) {
if (i + 2 >= count) {
if (i + 2 == count) {
remain = 1;
break;
} else
remain = 2;
} else
i += 2;
} else if (is2byte(c)) {
if (i + 1 >= count)
remain = 1;
else
i++;
}
#else
if (current_locale == LC_CTYPE_EUC) {
if (iseuc3byte(c)) {
if (i + 2 >= count) {
if (i + 2 == count) {
remain = 1;
break;
} else
remain = 2;
} else
i += 2;
} else if (iseuc2byte(c)) {
if (i + 1 >= count)
remain = 1;
else
i++;
}
} else {
if (issjis1(c)) {
if (i + 1 >= count)
remain = 1;
else
i++;
}
}
#endif
}
if (remain) {
if ((i = read(STDIN, &buff[count], remain)) > 0)
count += i;
}
buff[count] = 0;
wnum = mbstowcs((wchar16_t *) wcbuff, (char *) buff, count);
if ((wnum == 0) && count) {
wnum = count;
for ( i = 0; i <= count; i++)
wcbuff[i] = (wchar16_t) 0;
}
if (wnum > n) {
backup = wcbuff[--wnum];
}
memcpy((void *) s, (void *) wcbuff, wnum * sizeof(wchar16_t));
return(wnum);
}
SJ_warnning (s)
wchar16_t *s;
{
SJ_print (s);
}
SJ_print (s)
wchar16_t *s;
{
u_char buff[BUFFLENGTH * 3];
size_t num;
num = wcstombs((char *) buff, s, (size_t ) (BUFFLENGTH * 3));
if ((int) num > 0)
printf("%s", buff);
}
SJ_through (s, n)
wchar16_t *s;
int n;
{
SJ_write (s, n);
}

View file

@ -1,851 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "wchar16.h"
#include "kctype.h"
#if defined(__sony_news) && defined(SVR4)
#include <jcode.h>
#endif
#include "common.h"
#include "key.h"
#include <locale.h>
#include "Paths.h"
int vflag = 1;
extern int shell_flag;
char RCfile[LONGLENGTH];
extern char shellprog[];
extern char home[];
extern char term_name[];
extern int current_locale;
#define GUIDELEN 80
wchar16_t guide_sj2[GUIDELEN];
wchar16_t guide_buffer[GUIDELEN];
wchar16_t guide_unbuffer[GUIDELEN];
wchar16_t guide_hira[GUIDELEN];
wchar16_t guide_zkata[GUIDELEN];
wchar16_t guide_hkata[GUIDELEN];
wchar16_t guide_halpha[GUIDELEN];
wchar16_t guide_zalpha[GUIDELEN];
wchar16_t guide_shift[GUIDELEN];
wchar16_t guide_jis[GUIDELEN];
wchar16_t guide_kuten[GUIDELEN];
wchar16_t guide_etc[GUIDELEN];
wchar16_t guide_etcfunc[GUIDELEN];
wchar16_t guide_function[GUIDELEN];
wchar16_t guide_euc[GUIDELEN];
wchar16_t guide_euc2[GUIDELEN];
wchar16_t guide_jis2[GUIDELEN];
wchar16_t guide_kuten2[GUIDELEN];
static char *rcfile = ".sjrc";
static char *rkfile = ".sjrk";
static int intr_code = 0x03;
static char goto_code[LONGLENGTH];
static int goto_num = 0;
static char trap_code[LONGLENGTH];
static int trap_num = 0;
static int def_muhenkan = KEY_HALPHA;
static int def_muedit = KEY_ZHIRA;
static int muhenkan_toggle = 1;
static int bstudy = 1;
char **dict_list = NULL;
int dict_num = 0;
#define SJ3_NO -1
#define SJ3_SJIS 0
#define SJ3_EUC 1
static int user_euc = 0;
static int file_code = SJ3_NO;
static int locale_code = SJ3_SJIS;
extern wchar16_t *Key, *Escape, *Sjxkey, *Etckey, *Intr, *Bskey, *Delkey,
*Setnormal, *Throughnext, *Initialmode, *Helpmode,
*Defaultcode, *Muhenkanmode, *Muhenkaninedit, *Muhenkantoggle,
*Guide, *Forkshell, *Execshell, *Dictionary, *Userdic,
*Maindic, *Romaji, *Bstrudy, *Silent, *Flushafterconversion,
*Rkerrbell, *Server;
extern wchar16_t *Halpha, *Zalpha, *Hkata, *Zkata, *Hira;
extern wchar16_t *Shiftjis, *Sjis, *Euc, *Euc2, *Jis, *Jis2, *Kuten, *Kuten2;
int set_func(), set_etckeys(), set_intr(),
set_delkey(), set_goto(), set_trap(), set_init_mode(),
set_helpmenu(), set_defcode(), set_muhenkan(), set_muedit(),
set_m_toggle(), set_guide(), set_forkshell(), set_bstudy(),
set_silent(), set_flush_conversion(), set_rkebell(), set_server(),
set_dicts();
extern struct functbl funcs[];
extern struct valtbl mode_val[], code_val[];
#define TOLOWER(c) (isupper(c) ? tolower(c) : (c))
sjset_code()
{
char *loc;
if (current_locale == LC_CTYPE_EUC) {
locale_code = SJ3_EUC;
user_euc = 1;
file_code = SJ3_NO;
} else
user_euc = 0;
}
sjrc_init ()
{
clear_del ();
clear_key ();
intr_code = 0x03;
goto_num = 0;
trap_num = 0;
def_muhenkan = KEY_HALPHA;
def_muedit = KEY_ZHIRA;
muhenkan_toggle = 1;
bstudy = 1;
flush_conversion = 0;
if (dict_list) {
if (dict_list[0]) free(dict_list[0]);
free(dict_list);
dict_list = NULL;
}
dict_num = 0;
}
getsjrc ()
{
register char *p;
char *getenv();
sjset_code();
mk_cvtkey(term_name);
RCfile[0] = '\0';
if ((p = getenv("SJRC")) != NULL && *p != '\0') {
if (*p != '/') {
strcpy(RCfile, home);
strcat(RCfile, "/");
}
strcat(RCfile, p);
if (setrc(RCfile) == TRUE)
return;
}
if (home[0] != '\0') {
strcpy(RCfile, home);
strcat(RCfile, "/");
strcat(RCfile, rcfile);
if (setrc(RCfile) == TRUE)
return;
}
strcpy(RCfile, DEFRCFILE);
if (setrc(RCfile) == TRUE)
return;
RCfile[0] = '\0';
}
setrc (file)
char *file;
{
register wchar16_t *p;
char line[MAXLINE];
struct wordent word[WORDN];
struct functbl *functp;
FILE *fd, *fopen();
if (vflag > 1)
aprintf ("sjrc file is %s\n", file);
if ((fd = fopen(RCfile, "r")) == NULL)
return(FALSE);
sjrc_init ();
while (fgets (line, MAXLINE, fd) != NULL) {
if (getword(line, word) <= 0)
continue;
functp = funcs;
p = word[0].word_str;
while (functp->keyword != NULL) {
if (match(p, functp->keyword)) {
(*(functp->func))(word);
break;;
}
functp++;
}
}
fclose(fd);
return(TRUE);
}
getsjrk (erase)
int erase;
{
register char *p;
register int i;
char *getenv();
char RKfile[LONGLENGTH];
RKfile[0] = '\0';
sj3_rkcode(1);
if ((p = getenv("SJRK")) != NULL && *p != '\0') {
if (*p != '/') {
strcpy(RKfile, home);
strcat(RKfile, "/");
}
strcat(RKfile, p);
if ((i = sj3_rkinit2(RKfile, erase)) == TRUE) {
if (!oasys)
mkkigou();
return;
}
if (i == FALSE)
done3();
}
if (home[0] != '\0') {
strcpy(RKfile, home);
strcat(RKfile, "/");
strcat(RKfile, rkfile);
if ((i = sj3_rkinit2(RKfile, erase)) == TRUE) {
if (!oasys)
mkkigou();
return;
}
if (i == FALSE)
done3();
}
sj3_rkcode(0);
if ((i = sj3_rkinit2(DEFRKFILE, erase)) != TRUE) {
if (i == 1) {
fprintf(stderr, "Warning cannot open rule file %s\n\r",
DEFRKFILE);
(void)sj3_rkinit2("/dev/null", erase);
} else
done3();
}
if (!oasys)
mkkigou();
}
match(s1, s2)
wchar16_t *s1, *s2;
{
register wchar16_t c1, c2;
if (s1 == NULL)
return(0);
while (*s2 != '\0') {
c1 = *s1++;
c2 = *s2++;
if (TOLOWER(WcLowByte(c1)) != TOLOWER(WcLowByte(c2)))
return(0);
}
return(1);
}
getword (s, word)
register u_char *s;
struct wordent word[];
{
register u_char c;
register wchar16_t *w;
wchar16_t wcbuf[MAXLINE*2];
wchar16_t ttmp[MAXLINE];
u_char buf[MAXLINE*2];
register u_char *p;
register int i, wcount;
u_short cc;
if (IsDelimitor(*s)) {
s++;
} else {
p = s;
while(!IsDelimitor(*s)) {
if (IsTerminator(*s) || isTerminator(*s))
break;
s++;
}
*s++ = '\0';
if (file_code == locale_code) {
(void) mbstowcs(wcbuf, (char *)p, MAXLINE*2);
} else {
if (file_code == SJ3_SJIS) {
(void) sjistoeuc(buf, MAXLINE*2, (u_char *)p, MAXLINE);
} else if (file_code == SJ3_EUC) {
(void) euctosjis(buf, MAXLINE*2, (u_char *)p, MAXLINE);
} else {
(void) strcpy(buf, p);
}
(void) mbstowcs(wcbuf, (char *)buf, MAXLINE*2);
}
(void) mbstowcs(ttmp, term_name, MAXLINE);
if (match(wcbuf, ttmp) == 0)
return(0);
}
i = wcount = 0;
w = word[wcount].word_str;
while (*s != '\0') {
c = *s++;
if (file_code == SJ3_SJIS) {
if (issjis1(c) && issjis2(*s)) {
if (i < MAXWORD - 1) {
cc = (c << 8) + *s;
*w++ = sjis2euc(cc);
i ++ ;
}
s++;
continue;
}
} else if (file_code == SJ3_EUC) {
if (iseuc(c) && iseuc(*s)) {
if (i < MAXWORD - 1) {
*w++ = (c << 8) + (*s & 0xff);
i ++;
}
s++;
continue;
}
if (iseuckana(c) && iskana2(*s))
c = *s++;
if (IsEUCHojo(c) && iseuc(*s) && iseuc(s[1])) {
cc = WcSetX0212(*s, s[1]);
*w++ = cc;
s += 2;
continue;
}
} else {
if (issjis1(c) && issjis2(*s)) {
file_code = SJ3_SJIS;
s--;
continue;
}
if ((iseuc(c) && iseuc(*s)) ||
(iseuckana(c) && iskana2(*s)) ||
(IsEUCHojo(c) && iseuc(*s) && iseuc(s[1]))) {
file_code = SJ3_EUC;
s--;
continue;
}
}
if (isTerminator(c))
break;
if (IsDelimitor(c)) {
if (i > 0) {
if (++wcount >= WORDN - 1)
break;
*w = '\0';
i = 0;
w = word[wcount].word_str;
}
continue;
}
if (IsEscape(c))
c = *s++;
if (IsTerminator(c))
break;
if (i < MAXWORD - 1) {
*w++ = c;
i++;
}
}
*w = '\0';
if (word[wcount].word_str[0] != '\0')
word[++wcount].word_str[0] = '\0';
return(wcount);
}
IsTerminator (c)
u_char c;
{
if (c == '\n')
return (1);
else
return (0);
}
isTerminator (c)
u_char c;
{
if (c == '#')
return (1);
else
return (0);
}
IsEscape (c)
u_char c;
{
if (c == '\\')
return (1);
else
return (0);
}
IsDelimitor (c)
u_char c;
{
if (c == ' ' || c == '\t' || c == '.')
return (1);
else
return (0);
}
set_forkshell (word)
struct wordent word[];
{
if (word[1].word_str[0] != '\0' && shellprog[0] == '\0') {
strcpy (shellprog, (char *)word[1].word_str);
shell_flag++;
}
}
set_intr (word)
struct wordent word[];
{
int c;
if (word[1].word_str[0] != '\0')
if ((c = eval_key (word[1].word_str)) != -1)
intr_code = c;
}
set_delkey (word)
struct wordent word[];
{
int c;
if (word[1].word_str[0] != '\0')
if ((c = eval_key (word[1].word_str)) != -1)
set_del (c);
}
isintr (c)
u_char c;
{
if (c == intr_code)
return (1);
else
return (0);
}
set_goto (word)
struct wordent word[];
{
int c;
if (word[1].word_str[0] != '\0')
if ((c = eval_key (word[1].word_str)) != -1)
goto_code[goto_num ++] = c;
}
IsGoto (c)
register u_char c;
{
register int i;
for (i = 0 ; i < goto_num ; i ++) {
if (c == goto_code[i])
return (1);
}
return (0);
}
set_trap (word)
struct wordent word[];
{
int c;
if (word[1].word_str[0] != '\0')
if ((c = eval_key (word[1].word_str)) != -1)
trap_code[trap_num ++] = c;
}
IsTrap (c)
register u_char c;
{
register int i;
for (i = 0 ; i < trap_num ; i ++) {
if (c == trap_code[i])
return (1);
}
return (0);
}
mode_key (mode)
register int mode;
{
switch (mode) {
case MODE_HALPHA:
return (KEY_HALPHA);
break;
case MODE_ZALPHA:
return (KEY_ZALPHA);
break;
case MODE_HKATA:
return (KEY_HKATA);
break;
case MODE_ZKATA:
return (KEY_ZKATA);
break;
case MODE_ZHIRA:
default:
return (KEY_ZHIRA);
break;
}
}
int Direct = 0;
set_init_mode (word)
struct wordent word[];
{
register Conversion *cv;
register int i, j;
register wchar16_t *p;
cv = GetConversion ();
j = 1;
p = word[j].word_str;
while (*p != '\0') {
if (match (p, WCBuff))
cv->BuffMode = BUFF;
else if (match (p, WCUnbuff))
cv->BuffMode = UNBUFF;
else if (match (p, WCDirect))
Direct = 1;
else {
for (i = 0 ; i < 5 ; i ++) {
if (match (p, mode_val[i].keyword)) {
cv->Imode = mode_val[i].ivalue;
break;
}
}
}
p = word[++j].word_str;
}
}
set_helpmenu (word)
struct wordent word[];
{
if (match (word[1].word_str, WCOff))
HHlevel = Hlevel = 1;
else if (match (word[1].word_str, WCOn))
HHlevel = Hlevel = 2;
}
set_defcode (word)
struct wordent word[];
{
register wchar16_t *p;
register int i;
p = word[1].word_str;
for (i = 0; i < 5; i++) {
if (match(p, code_val[i].keyword)) {
SetCode(code_val[i].ivalue);
break;
}
}
}
set_muhenkan (word)
struct wordent word[];
{
register int i;
register wchar16_t *p;
p = word[1].word_str;
for (i = 0 ; i < 5 ; i ++) {
if (match (p, mode_val[i].keyword)) {
def_muhenkan = mode_key (mode_val[i].ivalue);
break;
}
}
}
set_muedit (word)
struct wordent word[];
{
register int i;
register wchar16_t *p;
p = word[1].word_str;
for (i = 0 ; i < 5 ; i ++) {
if (match (p, mode_val[i].keyword)) {
def_muedit = mode_key (mode_val[i].ivalue);
break;
}
}
}
set_m_toggle (word)
struct wordent word[];
{
if (match (word[1].word_str, WCOn))
muhenkan_toggle = 1;
if (match (word[1].word_str, WCOff))
muhenkan_toggle = 0;
}
set_silent (word)
struct wordent word[];
{
vflag = 0;
}
set_bstudy (word)
struct wordent word[];
{
if (match (word[1].word_str, WCOn))
bstudy = 1;
if (match (word[1].word_str, WCOff))
bstudy = 0;
}
is_bstudy ()
{
return (bstudy);
}
eval_muhenkan ()
{
register Conversion *cv;
cv = GetConversion ();
if (muhenkan_toggle && (KEY_ZHIRA != mode_key (cv->Imode)))
return (KEY_ZHIRA);
else
return (def_muhenkan);
}
value_muhenkan ()
{
return (def_muedit);
}
set_guide (word)
struct wordent word[];
{
register int i;
if (*word[2].word_str == '\0') {
return;
}
else if (match (word[1].word_str, WCSj2)) {
wscpy (guide_sj2, word[2].word_str);
WCSJrun = guide_sj2;
}
else if (match (word[1].word_str, WCBuffer)) {
wscpy (guide_buffer, word[2].word_str);
WCMode_buff = guide_buffer;
}
else if (match (word[1].word_str, WCUnbuffer)) {
wscpy (guide_unbuffer, word[2].word_str);
WCMode_unbuff = guide_unbuffer;
}
else if (match (word[1].word_str, WCHira)) {
wscpy (guide_hira, word[2].word_str);
WCMode_Zhira = guide_hira;
}
else if (match (word[1].word_str, WCZkata)) {
wscpy (guide_zkata, word[2].word_str);
WCMode_Zkata = guide_zkata;
}
else if (match (word[1].word_str, WCHkata)) {
wscpy (guide_hkata, word[2].word_str);
WCMode_Hkata = guide_hkata;
}
else if (match (word[1].word_str, WCHalpha)) {
wscpy (guide_halpha, word[2].word_str);
WCMode_Halpha = guide_halpha;
}
else if (match (word[1].word_str, WCZalpha)) {
wscpy (guide_zalpha, word[2].word_str);
WCMode_Zalpha = guide_zalpha;
}
else if (match (word[1].word_str, WCShift)) {
wscpy (guide_shift, word[2].word_str);
WCGCshift = guide_shift;
}
else if (match (word[1].word_str, WCJis)) {
wscpy (guide_jis, word[2].word_str);
WCGCjis = guide_jis;
}
else if (match (word[1].word_str, WCJis2)) {
wscpy (guide_jis2, word[2].word_str);
WCGCjis2 = guide_jis2;
}
else if (match (word[1].word_str, WCKuten)) {
wscpy (guide_kuten, word[2].word_str);
WCGCkuten = guide_kuten;
}
else if (match (word[1].word_str, WCKuten2)) {
wscpy (guide_kuten2, word[2].word_str);
WCGCkuten2 = guide_kuten2;
}
else if (match (word[1].word_str, WCEuc)) {
wscpy (guide_euc, word[2].word_str);
WCGCeuc = guide_euc;
}
else if (match (word[1].word_str, WCEuc2)) {
wscpy (guide_euc2, word[2].word_str);
WCGCeuc2 = guide_euc2;
}
else if (match (word[1].word_str, WCEtc)) {
wscpy (guide_etc, word[2].word_str);
WCGEtc = guide_etc;
}
else if (match (word[1].word_str, WCFuncetc)) {
i = 2;
*guide_etcfunc = '\0';
while (*word[i].word_str != '\0') {
if (i == 2)
wscat (guide_etcfunc, WCSpace2);
else
wscat (guide_etcfunc, WCSpace);
wscat (guide_etcfunc, word[i].word_str);
i ++;
}
WCGetc = guide_etcfunc;
}
else if (match (word[1].word_str, WCFunction)) {
i = 2;
*guide_function = '\0';
while (*word[i].word_str != '\0') {
if (i == 2)
wscat (guide_function, WCSpace2);
else
wscat (guide_function, WCSpace);
wscat (guide_function, word[i].word_str);
i ++;
}
WCGmode = guide_function;
}
}
set_flush_conversion (word)
struct wordent word[];
{
if (match (word[1].word_str, WCOn))
flush_conversion = 1;
if (match (word[1].word_str, WCOff))
flush_conversion = 0;
}
set_server(word)
struct wordent word[];
{
register int i, j, size;
register char *p;
char *sbuf;
extern char *cur_serv, **serv_list;
char host[LONGLENGTH];
if (cur_serv != NULL && *cur_serv != '\0')
return;
size = 0;
i = 0;
while (word[i + 1].word_str[0] != '\0') {
if (i >= MAXSERVER)
break;
size += wslen(word[++i].word_str);
size++;
}
if ((sbuf = malloc(size)) == NULL) {
fprintf (stderr, "set_server: can't alloc memory\n\r");
done3();
}
p = sbuf;
for (j = 0; j < i; j++) {
serv_list[j] = p;
(void) wcstombs(host, word[j+1].word_str, LONGLENGTH);
strcpy(p, host);
size = strlen(p) + 1;
p += size;
}
cur_serv = serv_list[0];
}
#define DICT_SUFFIX ".dic"
set_dict(word)
struct wordent word[];
{
register int i, j, size, suffix_len;
register char *p;
char *sbuf;
char dict[LONGLENGTH];
suffix_len = strlen(DICT_SUFFIX);
size = 0;
i = 0;
while (word[i + 1].word_str[0] != '\0') {
size += wslen(word[++i].word_str) + suffix_len;
size++;
}
if ((sbuf = malloc(size)) == NULL) {
fprintf (stderr, "set_dict: can't alloc memory\n\r");
done3();
}
if ((dict_list = (char **)malloc(sizeof(char *) * i)) == NULL) {
free(sbuf);
fprintf (stderr, "set_dict: can't alloc memory\n\r");
done3();
}
dict_num = i;
p = sbuf;
for (j = 0; j < i; j++) {
dict_list[j] = p;
(void) wcstombs(dict, word[j+1].word_str, LONGLENGTH);
strcpy(p, dict);
strcat(p, DICT_SUFFIX);
size = strlen(p) + 1;
p += size;
}
}

View file

@ -1,941 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "common.h"
#include "key.h"
#include "rk.h"
extern int keyvalue;
int rkerrbell = 0;
static int delkey = -1;
static int bskey;
#define SPAN_FLUSH 0
#define SPAN_END 1
save_span (mode)
register int mode;
{
register Conversion *cv;
cv = GetConversion ();
switch (mode) {
case SPAN_FLUSH:
cv->span_point = 0;
cv->ha_point = 0;
cv->out_point = 0;
save_span_p ();
break;
case SPAN_END:
if (cv->out_point < cv->out_epoint) {
Clear_EOL();
cv->out_point = cv->out_epoint;
cv->ha_point = cv->ha_epoint;
}
break;
default:
break;
}
}
save_span_p ()
{
register Conversion *cv;
cv = GetConversion ();
cv->span_p[cv->span_point] = &(cv->out_buf[cv->out_point]);
cv->span_l[cv->span_point] = 0;
}
isspaned ()
{
register Conversion *cv;
cv = GetConversion ();
if (cv->out_buf[0] != '\0')
return (1);
else
return (0);
}
buffers_clear ()
{
register Conversion *cv;
cv = GetConversion ();
pointer_clear ();
if (flush_conversion)
cv->CurBun = -1;
else
cv->CurBun = 0;
}
pointer_clear ()
{
register Conversion *cv;
cv = GetConversion ();
cv->ha_point = cv->ha_epoint = 0;
*(cv->Halpha) = '\0';
os_point = 0;
cv->out_point = cv->out_epoint = 0;
*(cv->out_buf) = '\0';
cv->Kanji = 0;
save_span (SPAN_FLUSH);
sj3_rkclear();
}
typedef struct _SaveSet {
wchar16_t out_buf[BUFFLENGTH * 2];
u_short out_mode[BUFFLENGTH * 2];
u_short out_point;
u_short ha_point;
wchar16_t Halpha[BUFFLENGTH];
u_char in_mode[BUFFLENGTH * 2];
} SaveSet;
static SaveSet save_set0;
StoreSaveSet ()
{
register Conversion *cv;
register SaveSet *sv;
cv = GetConversion ();
if (cv->out_point) {
sv = &save_set0;
sv->out_point = cv->out_point;
sv->ha_point = cv->ha_point;
memcpy (sv->out_mode, cv->out_mode,
cv->out_point * sizeof(u_short));
memcpy (sv->in_mode, cv->in_mode,
cv->out_point * sizeof(u_char));
wscpy (sv->Halpha, cv->Halpha);
wscpy (sv->out_buf, cv->out_buf);
}
}
RestoreSaveSet ()
{
register Conversion *cv;
register SaveSet *sv;
sv = &save_set0;
if (sv->out_point) {
cv = GetConversion ();
cv->out_point = sv->out_point;
cv->ha_point = sv->ha_point;
memcpy (cv->out_mode, sv->out_mode,
sv->out_point * sizeof(u_short));
memcpy (cv->in_mode, sv->in_mode,
sv->out_point * sizeof(u_char));
wscpy (cv->Halpha, sv->Halpha);
wscpy (cv->out_buf, sv->out_buf);
}
}
history_empty ()
{
SaveSet *sv;
sv = &save_set0;
if (sv->out_point)
return (0);
else
return (1);
}
History ()
{
Conversion *cv;
SaveSet *sv;
sv = &save_set0;
if (sv->out_point) {
RestoreSaveSet ();
cv = GetConversion ();
if (flush_conversion)
cv->CurBun = -1;
else
cv->CurBun = 0;
}
}
ClearBuffer ()
{
Clear_EOL();
Ccheck ();
Cclear (1);
all_set_up ();
}
SetCflag ()
{
register Conversion *cv;
cv = GetConversion ();
cv->Cflag = 1;
}
ClearCflag ()
{
register Conversion *cv;
cv = GetConversion ();
cv->Cflag = 0;
}
IsCflag ()
{
register Conversion *cv;
cv = GetConversion ();
return (cv->Cflag);
}
exec_kettei ()
{
register Conversion *cv;
int len;
wchar16_t kanji[BUFFLENGTH * 2];
cv = GetConversion ();
save_span(SPAN_END);
if (cv->Kanji != 0) {
len = Bkanji (kanji);
Ccheck ();
Cclear (1);
master_write (kanji, len);
if (cv->word_regist) {
cv->word_regist = 0;
}
else {
if (is_bstudy ()) {
cl_gakusyuu ();
}
}
} else if (isspaned ()) {
if (BuffYes ()) {
Ccheck ();
Cclear (1);
}
if (!BuffYes ())
vbackchar (cv->out_point);
if (cv->out_point)
master_write (cv->out_buf, cv->out_point);
if (BuffYes ())
master_flush ();
StoreSaveSet ();
}
buffers_clear ();
ResetHenkan ();
SetCflag ();
}
set_rkebell(word)
struct wordent word[];
{
if (match (word[1].word_str, WCOn))
rkerrbell = 1;
if (match (word[1].word_str, WCOff))
rkerrbell = 0;
}
ChangeBuffMode ()
{
register Conversion *cv;
cv = GetConversion ();
if (cv->BuffMode == BUFF) {
sj3_rkebell(0);
cv->BuffMode = UNBUFF;
} else {
sj3_rkebell(rkerrbell);
cv->BuffMode = BUFF;
}
}
BuffYes ()
{
register Conversion *cv;
cv = GetConversion ();
if (cv->BuffMode == BUFF)
return (1);
else
return (0);
}
#define STAT_HENKAN 1
#define STAT_MUHENKAN 2
IsHenkan ()
{
Conversion *cv;
cv = GetConversion ();
return (cv->henkanflag);
}
IsMuhenkan ()
{
Conversion *cv;
cv = GetConversion ();
return (cv->henkanflag & STAT_MUHENKAN);
}
SetMuhenkan ()
{
Conversion *cv;
cv = GetConversion ();
cv->henkanflag |= STAT_MUHENKAN;
}
SetHenkan ()
{
Conversion *cv;
cv = GetConversion ();
cv->henkanflag = STAT_HENKAN;
}
ResetHenkan ()
{
Conversion *cv;
cv = GetConversion ();
cv->henkanflag = 0;
}
all_set_up ()
{
buffers_clear ();
SetCflag ();
ResetHenkan ();
}
static int convertflag;
static int small;
stat_conv_on ()
{
convertflag = 1;
}
stat_init ()
{
stat_conv_on ();
all_set_up ();
disp_mode ();
small = 0;
}
get_pseq ()
{
return (write_pseq (1));
}
stat_conv ()
{
register Conversion *cv;
extern int allways_buff;
register int inc;
register int i;
u_short svlen;
cv = GetConversion ();
cv->word_regist = 0;
while (convertflag) {
if ((inc = inkey ()) == EOF)
break;
cv = GetConversion ();
if (allways_buff)
cv->BuffMode = BUFF;
more:
switch (keyvalue) {
case KEY_NORMAL:
small = 0;
if (inc == EOF)
break;
if (IsHenkan ()) {
if (is_bsdel (inc)) {
Bdelete ();
break;
} else if (inc < ' ' && inc != '\n' &&
inc != '\r' && inc != '\t' &&
!IsESC (inc) && !isintr (inc)){
beep ();
break;
} else {
exec_kettei ();
}
}
save_obuf();
svlen = cv->Vlen;
while (exec_romaji(inc)) {
if (os_point > 0 && svlen != cv->Vlen) {
i = svlen - cv->Vlen;
svlen = cv->Vlen;
vprintU(osave_buf, 1);
if (i > 0)
Clear_EOL();
Cgoto(svlen);
}
inc = inkey();
if (keyvalue != KEY_NORMAL &&
(exec_romaji(0)==0||keyvalue == KEY_CONV)){
restore_obuf();
goto more;
}
}
restore_obuf();
if (is_del(inc) && (!IsCflag() && isspaned())) {
if (cv->out_point < cv->out_epoint) {
move_cur(KEY_RIGHT);
inc = bskey;
goto more;
}
} else
exec_ctrl(inc);
break;
case KEY_KETTEI:
small = 0;
if (!IsCflag ()) {
exec_kettei ();
} else if (cv->Imode != MODE_HALPHA || BuffYes ()) {
if (cv->Imode != MODE_HALPHA)
exec_mode (KEY_HALPHA);
if (BuffYes ())
ChangeBuffMode ();
disp_mode ();
}
break;
case KEY_CONV:
small = 0;
if (!no_flush)
exec_kettei ();
convertflag = 0;
break;
case KEY_CANCEL:
small = 0;
if (!IsCflag ())
ClearBuffer ();
else if ((inc = get_pseq ()) != 0)
exec_ctrl(inc);
break;
case KEY_RECONV:
small = 0;
if (IsCflag ()) {
if (history_empty ()) {
if ((inc = get_pseq ()) != 0)
exec_ctrl(inc);
break;
} else {
History ();
Csave ();
ClearCflag ();
}
} else {
if (IsHenkan ()) {
History ();
ResetHenkan ();
} else {
beep ();
break;
}
}
exec_henkan ();
SetHenkan ();
break;
case KEY_HENKAN:
small = 0;
if (!IsCflag ()) {
if (IsMuhenkan ()) {
exec_henkan ();
SetHenkan ();
}
if (IsHenkan ()) {
exec_douon ();
} else {
save_span (SPAN_END);
Ccheck ();
StoreSaveSet ();
exec_henkan ();
SetHenkan ();
}
} else if ((inc = write_pseq (3)) >= ' ' && inc <= '~')
exec_ctrl(inc);
else if (cv->Imode != MODE_ZHIRA || !BuffYes ()) {
if (cv->Imode != MODE_ZHIRA) {
exec_mode (KEY_ZHIRA);
}
if (!BuffYes ()) {
ChangeBuffMode ();
}
disp_mode ();
}
break;
case KEY_MUHENKAN:
small = 0;
if (flush_conversion && !IsCflag () &&
cv->CurBun == -1) {
if (IsHenkan ()) {
exec_muhenkan (0);
SetHenkan ();
} else {
save_span (SPAN_END);
Ccheck ();
exec_muhenkan (1);
SetHenkan ();
SetMuhenkan ();
}
break;
}
case KEY_TOGGLE:
case KEY_ZHIRA:
case KEY_HALPHA:
case KEY_ZALPHA:
case KEY_HKATA:
case KEY_ZKATA:
case KEY_CODE:
small = 0;
if (cv->CurBun == -1)
exec_kettei ();
else if (IsHenkan ()) {
Bchange (keyvalue);
break;
}
if (keyvalue == KEY_TOGGLE)
keyvalue = toggle_mode (cv->Imode);
exec_mode (keyvalue);
disp_mode ();
break;
case KEY_WRAP:
small = 0;
if (IsHenkan ())
wrap_douon (0);
else if ((inc = get_pseq ()) != 0)
exec_ctrl(inc);
break;
case KEY_WRAPBACK:
small = 0;
if (IsHenkan ())
wrap_douon (1);
else if ((inc = get_pseq ()) != 0)
exec_ctrl(inc);
break;
case KEY_LEFT:
case KEY_RIGHT:
case KEY_UP:
case KEY_DOWN:
if (IsHenkan ()) {
switch (keyvalue) {
case KEY_LEFT:
Bleft ();
small = 0;
break;
case KEY_RIGHT:
Bright ();
small = 0;
break;
case KEY_UP:
small = Bbig ();
break;
case KEY_DOWN:
small = Bsmall (small);
break;
}
} else if (cv->Imode == MODE_CODE) {
small = 0;
if (BuffYes () && IsCflag ()) {
Csave ();
ClearCflag ();
}
kigou ();
if (flush_conversion)
exec_kettei ();
} else if (!IsCflag() && (keyvalue == KEY_LEFT ||
keyvalue == KEY_RIGHT)) {
small = 0;
move_cur(keyvalue);
} else if (!BuffYes() && cv->Imode == MODE_HALPHA) {
small = 0;
write_pseq(0);
} else if (IsCflag() && (inc = get_pseq ()) != 0) {
small = 0;
exec_ctrl(inc);
}
break;
case KEY_TOP:
case KEY_END:
if (IsHenkan ()) {
switch (keyvalue) {
case KEY_TOP:
Btop ();
small = 0;
break;
case KEY_END:
Blast ();
small = 0;
break;
}
} else if (!IsCflag()) {
small = 0;
move_cur(keyvalue);
} else if ((inc = get_pseq ()) != 0) {
small = 0;
exec_ctrl(inc);
}
break;
case KEY_EDIT:
case KEY_TOROKU:
case KEY_SYOUKYO:
small = 0;
if (IsCflag () && (inc = get_pseq ()) != 0)
exec_ctrl(inc);
case KEY_ETC:
case KEY_HELP:
case KEY_SJRC:
case KEY_RECONNECT:
small = 0;
i = exec_etc (keyvalue);
disp_mode ();
if (i != KEY_NORMAL) {
keyvalue = i;
goto more;
}
break;
case KEY_BUFFER:
small = 0;
if (BuffYes ())
exec_kettei ();
ChangeBuffMode ();
disp_mode ();
break;
case KEY_HA_KET:
small = 0;
if (!IsCflag ()) {
if (cv->Imode != MODE_HALPHA || BuffYes ()) {
if (BuffYes ()) {
exec_kettei ();
ChangeBuffMode ();
}
if (cv->Imode != MODE_HALPHA)
exec_mode (KEY_HALPHA);
disp_mode ();
}
} else if ((inc = get_pseq ()) != 0)
exec_ctrl(inc);
break;
case KEY_FLUSH:
small = 0;
if (!IsCflag ()) {
exec_kettei ();
} else if ((inc = get_pseq ()) != 0)
exec_ctrl(inc);
break;
default:
small = 0;
if ((inc = get_pseq ()) != 0)
exec_ctrl(inc);
break;
}
if (keyvalue == KEY_CONV) {
if (!no_flush)
exec_kettei ();
convertflag = 0;
}
}
}
save_obuf()
{
register Conversion *cv;
register int i, cur;
cv = GetConversion();
if (cv->out_point < cv->out_epoint) {
cur = cv->out_point;
if (!(cv->out_mode[cur] & OMODE_MASK)) {
chhstr(cv->Halpha, cv->out_buf, cv->out_mode, cur);
cv->ha_epoint = wslen(cv->Halpha);
}
cv->ha_point = getipos(cur);
hs_point = 0;
for (i = cv->ha_point; i < cv->ha_epoint; i++)
hsave_buf[hs_point++] = cv->Halpha[i];
hsave_buf[hs_point] = '\0';
os_point = 0;
for (i = cv->out_point; i < cv->out_epoint; i++) {
osave_buf[os_point] = cv->out_buf[i];
osave_mode[os_point] = cv->out_mode[i];
isave_mode[os_point] = cv->in_mode[i];
os_point++;
}
osave_buf[os_point] = '\0';
}
}
restore_obuf()
{
register Conversion *cv;
register int i;
cv = GetConversion();
cv->out_epoint = cv->out_point;
cv->ha_epoint = cv->ha_point;
if (os_point > 0) {
for (i = 0; i < (unsigned int)os_point; i++) {
cv->out_buf[cv->out_epoint] = osave_buf[i];
cv->out_mode[cv->out_epoint] = osave_mode[i];
cv->in_mode[cv->out_epoint] = isave_mode[i];
cv->out_epoint++;
}
cv->out_buf[cv->out_epoint] = '\0';
for (i = 0; i < (unsigned int)hs_point; i++)
cv->Halpha[cv->ha_epoint++] = hsave_buf[i];
cv->Halpha[cv->ha_epoint] = '\0';
}
}
exec_ctrl(c)
register int c;
{
register Conversion *cv;
wchar16_t s[3];
extern wchar16_t pars_seq[];
cv = GetConversion ();
*s = c;
s[1] = 0;
exec_kettei();
if (c == ' ' && keyvalue == KEY_HENKAN && cv->Imode & MODE_ZEN) {
s[0] = 0xa1a1;
s[1] = 0;
master_write (s, 1);
} else
master_write (s, 1);
if (IsGoto (c) && (BuffYes() || cv->Imode != MODE_HALPHA)) {
cv->BuffMode = UNBUFF;
cv->Imode = MODE_HALPHA;
disp_mode();
sj3_rkebell(0);
}
if (IsTrap (c)) {
*s = inkey ();
if (keyvalue != KEY_NORMAL)
*s = pars_seq[0];
master_write (s, 1);
}
}
exec_mode (key)
register int key;
{
register Conversion *cv;
cv = GetConversion ();
if (key == KEY_MUHENKAN)
key = eval_muhenkan ();
if (key == KEY_CODE) {
if (cv->Imode == MODE_CODE)
ChangeCode();
else
cv->Imode = MODE_CODE;
} else
cv->Imode = eval_mode(key);
}
toggle_mode (mod)
register int mod;
{
register int value;
switch (mod) {
case MODE_ZHIRA:
value = KEY_ZKATA;
break;
case MODE_ZKATA:
value = KEY_HKATA;
break;
case MODE_HKATA:
value = KEY_ZALPHA;
break;
case MODE_ZALPHA:
value = KEY_HALPHA;
break;
default:
value = KEY_ZHIRA;
break;
}
return (value);
}
eval_mode (key)
register int key;
{
int mod;
switch (key) {
case KEY_ZHIRA:
mod = MODE_ZHIRA;
break;
case KEY_ZKATA:
mod = MODE_ZKATA;
break;
case KEY_HKATA:
mod = MODE_HKATA;
break;
case KEY_ZALPHA:
mod = MODE_ZALPHA;
break;
default:
mod = MODE_HALPHA;
break;
}
return (mod);
}
IsESC (c)
wchar16_t c;
{
if (c == ESC)
return (1);
else
return (0);
}
Strncpy (d, s, len)
wchar16_t *d, *s;
int len;
{
if ((len > 0) && (s != (wchar16_t *) NULL))
(void)wsncpy(d, s, len);
}
is_bsdel (c)
register int c;
{
if (is_bs (c) || is_del (c))
return (1);
else
return (0);
}
clear_del ()
{
delkey = -1;
}
set_bs (c)
int c;
{
bskey = c;
}
set_del (c)
int c;
{
delkey = c;
}
is_bs (c)
register int c;
{
if (c == bskey)
return (1);
else
return (0);
}
is_del (c)
register int c;
{
if (c == delkey)
return (1);
else
return (0);
}
static Conversion *saved_conversion;
SaveConversion ()
{
saved_conversion = GetConversion ();
}
AnotherConversion ()
{
if (saved_conversion == GetConversion ())
return (0);
else
return (1);
}

View file

@ -1,56 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "sj2.h"
char *n_key_set ="\033P%d|%02x;%02x;%02xp";
char *s_key_set ="\033P%d|%02x;%02x;%02xP";
#define ESCAPE '\033'
set_news ()
{
aprintf (s_key_set, 24, ESCAPE, 'O', 'H');
aprintf (n_key_set, 24, ESCAPE, 'O', 'P');
aprintf (n_key_set, 23, ESCAPE, 'O', 'Q');
aprintf (n_key_set, 25, ESCAPE, 'O', 'S');
fflush (stdout);
}

View file

@ -1,476 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "common.h"
#include "key.h"
#include "wchar16.h"
#define YOMILEN 32
#define KLEN 64
extern struct valtbl hin_val[];
extern int keyvalue;
exec_toroku ()
{
register Conversion *cv;
wchar16_t yomi[YOMILEN+1], kanji[KLEN+1];
wchar16_t *hinshi;
int inc;
int h_code, retv;
int val;
if (IsDcflag())
return(0);
cv = GetConversion ();
val = getkstr (kanji, KLEN, WCGtoroku);
if (*kanji == '\0')
return (val);
while (1) {
if (getyomi (yomi, YOMILEN, WCGtoroku, kanji) || *yomi == '\0')
break;
h_code = gethinshi();
hinshi= hin_val[h_code - 1].keyword;
if (getcheck (yomi, kanji, hinshi, WCGtoroku))
break;
}
if (*yomi == '\0')
return (val);
TopGuide ();
printR (WCGtoroku);
Clear_EOL ();
Flush ();
cv->word_regist = 1;
if ((retv = SJ2_toroku(yomi, kanji, hin_val[h_code -1].ivalue)) != 0) {
switch (retv) {
case -1:
(void)dconnect(0);
return(val);
case SJ3_WORD_EXIST:
SJ_print(WCExist);
break;
case SJ3_BAD_YOMI_STR:
SJ_print(WCYomiTouroku);
break;
case SJ3_BAD_KANJI_STR:
SJ_print(WCKanjiTouroku);
break;
case SJ3_DOUON_FULL:
SJ_print(WCOnajiTouroku);
break;
case SJ3_DICT_FULL:
SJ_print(WCUserTouroku);
break;
case SJ3_DICT_LOCKED:
SJ_print(WCJishoLock);
break;
default:
SJ_print(WCSystemError);
break;
}
} else
SJ_print (WCTOUROKU_SUCC);
Clear_EOL ();
Flush ();
inc = inkey ();
if (AnotherConversion ()) {
unget_key (inc);
}
return (val);
}
getyomi (yomi, lim, prompt, kanji)
wchar16_t *yomi, *prompt, *kanji;
int lim;
{
register int inc, c;
register Conversion *cv;
int len;
wchar16_t wtmp[BUFFLENGTH], ytmp[YOMILEN+1], ktmp[KLEN+1];
u_char tmp[BUFFLENGTH];
cv = GetConversion();
TopGuide ();
printR (prompt);
len = cv->column - (wcbyte(kanji) + 24);
if (len >= lim)
{
(void) wcstombs((char *)ytmp, WCMyomi, YOMILEN+1);
(void) wcstombs((char *)ktmp, kanji, KLEN+1);
sprintf ((char *)tmp, (char *)ytmp, ktmp);
(void) mbstowcs(wtmp, (char *)tmp, BUFFLENGTH);
}
else
{
(void) wcstombs((char *)ytmp, WCMyomi, YOMILEN+1);
(void) sprintf ((char *)tmp, (char *)ytmp);
(void) mbstowcs(wtmp, (char *)tmp, BUFFLENGTH);
}
SJ_print (wtmp);
Clear_EOL ();
Flush ();
*wtmp = '\0';
*tmp = '\0';
*yomi = '\0';
wrap_off();
SaveConversion ();
while ((inc = inkey ()) != EOF) {
if (AnotherConversion ()) {
unget_key (inc);
sj3_rkclear();
wrap_on();
return (1);
}
if (keyvalue == KEY_CONV) {
sj3_rkclear();
wrap_on();
return (1);
}
if (keyvalue == KEY_KETTEI || keyvalue == KEY_HENKAN) {
break;
}
else if (keyvalue != KEY_NORMAL) {
if ((c = write_pseq (2)) != 0)
inc = c;
}
if (inc == '\n' || inc == '\r'|| IsESC (inc))
break;
else if (iscntrl(inc) && !is_bs(inc))
beep();
else if ((len = wslen(wtmp)) >= lim && !is_bs(inc))
beep();
else
(void)exec_romaji2(inc, NULL, wtmp, NULL, len, -1);
}
(void)exec_romaji2(0, NULL, wtmp, NULL, wslen(wtmp), -1);
wscpy(yomi, wtmp);
sj3_rkclear();
wrap_on();
return (0);
}
gethinshi()
{
register int inc, hcode;
TopGuide();
printR(WCGtoroku);
SJ_print (WCTOUROKU_HIN);
Clear_EOL();
SJ_print(WCOne);
Backspace();
Flush();
inc = inkey();
if (inc >= '2' && inc <= '5')
hcode = inc - '0';
else
hcode = 1;
return(hcode);
}
getcheck (yomi, kanji, hinshi, prompt)
wchar16_t *yomi, *kanji, *hinshi, *prompt;
{
register int c;
u_char tmp[BUFFLENGTH + KLEN];
extern wchar16_t *Y;
wchar16_t wtmp[BUFFLENGTH + KLEN];
u_char ktmp[KLEN+1], ytmp[YOMILEN+1], htmp[YOMILEN+1],
ttmp[BUFFLENGTH];
TopGuide ();
printR (prompt);
if (hinshi == NULL)
{
(void) wcstombs((char *)ktmp, kanji, KLEN+1);
(void) wcstombs((char *)ytmp, yomi, YOMILEN+1);
(void) wcstombs((char *)ttmp, WCSYOUKYO_OK, BUFFLENGTH);
sprintf ((char *)tmp, (char *)ttmp, ktmp, ytmp);
}
else
{
(void) wcstombs((char *)ktmp, kanji, KLEN+1);
(void) wcstombs((char *)ytmp, yomi, YOMILEN+1);
(void) wcstombs((char *)htmp, hinshi, YOMILEN+1);
(void) wcstombs((char *)ttmp, WCTOUROKU_OK, BUFFLENGTH);
sprintf ((char *)tmp, (char *)ttmp, ktmp, ytmp, htmp);
}
(void) mbstowcs(wtmp, (char *)tmp, BUFFLENGTH + KLEN);
SJ_print (wtmp);
Clear_EOL ();
SJ_print (WCY);
Backspace ();
Flush ();
SaveConversion ();
c = inkey ();
if (AnotherConversion ()) {
unget_key (c);
return (0);
}
if (keyvalue == KEY_CONV) {
*yomi = '\0';
return (1);
}
if (c == 'y' || c == 'Y' || c == '\n' || c == '\r' || c == ' ')
return (1);
if (keyvalue == KEY_HENKAN || keyvalue == KEY_KETTEI)
return (1);
if (IsESC (c)) {
*yomi = '\0';
return (1);
}
return (0);
}
getkstr (s, lim, guide)
wchar16_t *s, *guide;
int lim;
{
register Conversion *cv;
register int i;
wchar16_t tmp[BUFFLENGTH * 2];
wchar16_t *p;
int plen, chbun;
chbun = 0;
cv = GetConversion ();
if (cv->Kanji != 0) {
if (cv->Bnum > 1) {
Ssbun(0);
chbun++;
plen = getbunsetu (tmp, guide);
} else
plen = Bkanji (tmp);
}
else if (isspaned ()) {
plen = cv->out_point;
Strncpy (tmp, cv->out_buf, plen);
tmp[plen] = '\0';
}
p = tmp;
for (i = 0 ; i < plen && i < lim ; i ++)
*(s ++) = *(p ++);
*s = '\0';
return (chbun);
}
getbunsetu (kanji, guide)
wchar16_t *kanji, *guide;
{
register Conversion *cv;
register int c;
register int bstart, bend;
register int i;
u_short row, col;
wchar16_t *p;
int plen, len;
cv = GetConversion ();
len = 0;
p = kanji;
*p = '\0';
bstart = bend = cv->CurBun;
StartGuide (&row, &col);
printR (guide);
SJ_print (WCMhani);
Clear_EOL ();
EndGuide (row, col);
Flush ();
SaveConversion ();
while ((c = inkey ()) != EOF) {
if (AnotherConversion ()) {
unget_key (c);
return (0);
}
cv = GetConversion ();
if (keyvalue == KEY_RIGHT) {
if ((bend == bstart) && (bend < cv->Bnum - 1)) {
cv->PreBun = bend;
bend ++;
cv->CurBun = bstart = bend;
Rdisp ();
}
else
beep ();
}
else if (keyvalue == KEY_LEFT) {
if ((bend == bstart) && (bend > 0)) {
cv->PreBun = bend;
bend --;
cv->CurBun = bstart = bend;
Rdisp ();
}
else
beep ();
}
else if (keyvalue == KEY_UP) {
if (bend < cv->Bnum - 1) {
bend ++;
cv->CurBun = cv->PreBun = bend;
Rdisp ();
}
else
beep ();
}
else if (keyvalue == KEY_DOWN) {
if (bend > bstart) {
cv->PreBun = bend;
bend --;
cv->CurBun = bend;
Rdisp ();
}
else
beep ();
}
else if (keyvalue == KEY_HENKAN || keyvalue == KEY_KETTEI ||
keyvalue == KEY_FLUSH) {
break;
}
else if (keyvalue == KEY_NORMAL) {
if (c == '\n' || c == '\r') {
bstart = 0;
bend = cv->Bnum - 1;
break;
}
else if (c == ' ') {
break;
}
else if (IsESC (c)) {
return (0);
}
else
beep ();
}
else
beep ();
Flush ();
}
for (i = bstart ; i <= bend ; i ++) {
if ((plen = Bstr (i, p)) <= 0)
continue;
p += plen;
len += plen;
}
return (len);
}
exec_syoukyo ()
{
register int i;
wchar16_t yomi[YOMILEN+1], kanji[KLEN+1];
wchar16_t tmp[BUFFLENGTH], tmp2[BUFFLENGTH * 2];
u_char ytmp[YOMILEN+1], ktmp[KLEN+1],
mtmp[BUFFLENGTH], mtmp2[BUFFLENGTH * 2],
ttmp[BUFFLENGTH];
int inc;
int val, retv;
if (IsDcflag())
return(0);
val = getkstr (kanji, KLEN, WCGsyoukyo);
if (*kanji == '\0')
return (val);
while (1) {
if (getyomi (yomi, YOMILEN, WCGsyoukyo, kanji) || *yomi == '\0')
break;
if (getcheck (yomi, kanji, NULL, WCGsyoukyo))
break;
}
if (*yomi == '\0')
return (val);
TopGuide ();
printR (WCGsyoukyo);
tmp[0] = '\0';
for (i = 0; i < 5; i++) {
retv = SJ2_syoukyo (yomi, kanji, hin_val[i].ivalue);
if (retv == 0) {
wscat(tmp, hin_val[i].keyword);
wscat(tmp, WCKanma);
} else if (retv != SJ3_WORD_NOT_EXIST)
break;
}
if (tmp[0] == '\0') {
switch (retv) {
case -1:
(void)dconnect(0);
return(val);
case SJ3_WORD_NOT_EXIST:
SJ_print(WCNotExist);
break;
case SJ3_DICT_LOCKED:
SJ_print(WCUserLock);
break;
case SJ3_BAD_YOMI_STR:
SJ_print(WCYomiShokyo);
break;
case SJ3_BAD_KANJI_STR:
SJ_print(WCKanjiShokyo);
break;
default:
SJ_print(WCShokyoError);
break;
}
} else {
i = wslen(tmp);
tmp[i - 1] = '\0';
(void) wcstombs((char *)mtmp, tmp, BUFFLENGTH);
(void) wcstombs((char *)ytmp, yomi, YOMILEN+1);
(void) wcstombs((char *)ktmp, kanji, KLEN+1);
(void) wcstombs((char *)ttmp, WCSYOUKYO_SUCC, BUFFLENGTH);
sprintf((char *)mtmp2, (char *)ttmp, ktmp, ytmp, mtmp);
(void) mbstowcs(tmp2, (char *)mtmp2, BUFFLENGTH * 2);
SJ_print(tmp2);
}
Clear_EOL ();
Flush ();
inc = inkey ();
if (AnotherConversion ()) {
unget_key (inc);
}
return (val);
}

View file

@ -1,270 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include <signal.h>
#include <termio.h>
#include <stdio.h>
#include <fcntl.h>
#include <stropts.h>
#include <sys/types.h>
#define PTY_MASTER "/dev/ptmx"
#define BUFFSIZE 512
#define err_sys(x) fprintf(stderr, (x))
#define err_quit(x) { \
fprintf(stderr, (x)); \
exit(0); \
}
static struct termio tty_termio;
static struct termio tty_mode;
static int sigcaught;
exec_shell(fd, argv, envp)
int fd;
char **argv;
char **envp;
{
char *shell;
char *getenv(), *rindex();
struct termio b;
close(0); close(1); close(2);
if (dup(fd) != 0 || dup(fd) != 1 || dup(fd) != 2)
err_sys("dup error");
close(fd);
if ((shell = getenv("SHELL")) == NULL)
shell = "/bin/sh";
if ((argv[0] = rindex(shell, '/')) != NULL)
argv[0]++;
else
argv[0] = shell;
if (ioctl(0, TCGETA, (char *) &b) < 0)
return(-1);
fprintf(stderr, "erase=%x\n", b.c_cc[VERASE]);
execve(shell, argv, envp);
err_sys("execve error");
}
pass_all(fd, childpid)
int fd;
int childpid;
{
int newpid, nread;
int sig_term();
char buff[BUFFSIZE];
if ((newpid = fork()) < 0) {
err_sys("parent1: can't fork");
} else if (newpid == 0) {
for ( ; ; ) {
nread = read(0, buff, BUFFSIZE);
if (nread < 0)
err_sys("read error fram stdin");
else if (nread == 0)
break;
if (write(fd, buff, nread) != nread)
err_sys("writen error to stream pipe");
}
kill(getppid(), SIGTERM);
exit(0);
}
sigcaught = 0;
for ( ; ; ) {
if ((nread = read(fd, buff, BUFFSIZE)) <= 0)
break;
if (write(1, buff, nread) != nread)
err_sys("write error to stdout");
}
if (sigcaught == 0)
kill(newpid, SIGTERM);
return;
}
int
pty_master()
{
int master_fd;
if ((master_fd = open(PTY_MASTER, O_RDWR)) < 0)
return(-1);
return(master_fd);
}
int
pty_slave(master_fd)
int master_fd;
{
int slave_fd;
char *slavename;
int grantpt();
int unlockpt();
char *ptsname();
if (grantpt(master_fd) < 0) {
close(master_fd);
return(-1);
}
if (unlockpt(master_fd) < 0) {
close(master_fd);
return(-1);
}
slavename = ptsname(master_fd);
if (slavename == NULL) {
close(master_fd);
return(-1);
}
slave_fd = open(slavename, O_RDWR);
if (slave_fd < 0) {
close(master_fd);
return(-1);
}
if (ioctl(slave_fd, I_PUSH, "ptem") < 0 ) {
close(master_fd);
return(-1);
}
if (ioctl(slave_fd, I_PUSH, "ldterm") < 0) {
close(master_fd);
return(-1);
}
return(slave_fd);
}
int
tty_raw(fd)
int fd;
{
struct termio temp_mode;
if (ioctl(fd, TCGETA, (char *) &temp_mode) < 0)
return(-1);
tty_mode = temp_mode;
temp_mode.c_iflag = 0;
temp_mode.c_oflag &= ~OPOST;
temp_mode.c_lflag &= ~(ISIG | ICANON | ECHO | XCASE);
temp_mode.c_cflag &= ~(CSIZE | PARENB);
temp_mode.c_cflag |= CS8;
temp_mode.c_cc[VMIN] = 1;
temp_mode.c_cc[VTIME] = 1;
if (ioctl(fd, TCSETA, (char *) &temp_mode) <0)
return(-1);
return(0);
}
int
tty_reset(fd)
int fd;
{
if (ioctl(fd, TCSETA, (char *) &tty_mode) < 0)
return(-1);
return(0);
}
int tty_getmode(oldfd)
int oldfd;
{
if (ioctl(oldfd, TCGETA, (char *) &tty_termio) < 0)
return(-1);
fprintf(stderr, "tty_getmode erase=%x\n", tty_termio.c_cc[VERASE]);
return(0);
}
int
tty_setmode(newfd)
int newfd;
{
if (ioctl(newfd, TCSETA, (char *) &tty_termio) < 0)
return(-1);
fprintf(stderr, "tty_setmode erase=%x\n", tty_termio.c_cc[VERASE]);
return(0);
}
main(argc, argv, envp)
int argc;
char **argv;
char **envp;
{
int master_fd, slave_fd, childpid;
if (!isatty(0) || !isatty(1))
err_quit("stdin and stdout must be a terminal");
if ((master_fd = pty_master()) < 0)
err_sys("can't open master pty");
if(tty_getmode(0) < 0)
err_sys("can't get tty mode of standard input");
if ((childpid = fork()) < 0)
err_sys("can't fork");
else if (childpid == 0) {
setpgrp();
if ((slave_fd = pty_slave(master_fd)) < 0)
err_sys("can't open pty slave");
close(master_fd);
if (tty_setmode(slave_fd) < 0)
err_sys("can't set tty mode of pty slave");
exec_shell(slave_fd, argv, envp);
}
if (tty_raw(0) < 0)
err_sys("tty_raw error");
pass_all(master_fd, childpid);
if (tty_reset(0) < 0)
err_sys("tty_reset error");
exit(0);

View file

@ -1,42 +0,0 @@
/*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*/
#include "sj2.h"
char *Version = "SJ3 2.09C (sjis/euc version)";
char *version = "SJ3 Version 2.09C (sjis/euc version)";
char *Copyright = "Copyright (c) 1990-1996 Sony Corporation";
char *Allrights = "All Rights Reserved";
char *Date = "Fri Feb 23 19:31:47 JST 1996";