Import SJ3 2.0.1.20

Signed-off-by: Masanori Ogino <mogino@acm.org>
This commit is contained in:
Masanori Ogino 2023-11-26 06:45:00 +09:00
commit b568905e51
208 changed files with 89304 additions and 0 deletions

81
sj3dic/Imakefile Normal file
View file

@ -0,0 +1,81 @@
/*
* Copyright (c) 1991-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.
*/
/*
* $SonyRCSfile: Imakefile,v $
* $SonyRevision: 1.3 $
* $SonyDate: 1997/01/23 11:20:54 $
*/
/*
* Change some make rules.
* Patched by Hidekazu Kuroki(hidekazu@cs.titech.ac.jp) 1996/8/10
*/
#include "../sj3.tmpl"
INCLUDES = -I../include -I../sj3lib
#if SystemV4 || SystemV
#if defined(SonySysvArchitecture)
CODE_LIBS = -ljcode
#endif
#endif
SYS_LIBRARIES = $(CODE_LIBS)
LIBDIR = ../sj3lib
SJLIB = $(LIBDIR)/libsj3lib.a
DEPLIBS = $(SJLIB)
LOCAL_LIBRARIES = $(SJLIB)
INSTFLAGS = -o $(SJ3OWNER) -g $(SJ3GROUP) -m 755
SRCS = codecnv.c \
dictdisp.c \
dictmake.c \
hinsi.c \
sj3dic.c \
sj3err.c \
sjrc.c
OBJS = codecnv.o \
sj3err.o \
sj3dic.o \
dictdisp.o \
dictmake.o \
hinsi.o \
sjrc.o
PROGRAMS = sj3dic
AllTarget($(PROGRAMS))
NormalProgramTarget(sj3dic,$(OBJS),$(DEPLIBS),$(LOCAL_LIBRARIES),)
DependTarget()
InstallProgramWithFlags(sj3dic,$(SJ3BINDIR),$(INSTFLAGS))

154
sj3dic/codecnv.c Normal file
View file

@ -0,0 +1,154 @@
/*
* Copyright (c) 1991-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.
*
*/
/*
* $SonyRCSfile: codecnv.c,v $
* $SonyRevision: 1.3 $
* $SonyDate: 1997/01/23 11:26:31 $
*/
#include <stdio.h>
#include <ctype.h>
#include <locale.h>
#include "sjctype.h"
#include "sjtool.h"
static int euc_mode;
init_code()
{
char *loc;
#ifdef LACKOF_SETLOCALE
loc = getenv("LANG");
#else
loc = setlocale(LC_CTYPE, "");
#endif
if (!loc) {
fprintf(stderr, "Error: can't get current locale\n");
exit(1);
}
if (strncmp(loc, "ja_JP.SJIS", 10) == 0) {
euc_mode = 0;
} else if (strncmp(loc, "ja", 2) == 0 ||
strncmp(loc, "Ja", 2) == 0) {
euc_mode = -1;
} else
#ifdef __sony_news
return 0;
#else
{
fprintf(stderr, "Warrning: In this locale japanese will not be used.\n");
euc_mode = -1;
}
#endif
return 1;
}
cnvcode(s)
unsigned char *s;
{
if (euc_mode) {
unsigned short i;
unsigned char *d = s;
while (i = *s++) {
if (iseuckana(i)) {
if (*s) {
*d++ = *s++;
}
else {
*d++ = i;
break;
}
}
else if (iseuc(i)) {
if (*s) {
i = euc2sjis((i << 8) + *s++);
*d++ = (i >> 8);
*d++ = i;
}
else {
*d++ = i;
break;
}
}
else {
*d++ = i;
}
}
*d = 0;
}
}
printout_mb(fp, s)
FILE *fp;
unsigned char *s;
{
fputs((char *)s, fp);
fflush(fp);
}
printout(fp, s)
FILE *fp;
unsigned char *s;
{
unsigned char buf[BUFSIZ];
if (euc_mode)
strcpy((char *)buf, s);
else
euctosjis(buf, BUFSIZ, s, strlen(s)+1);
fputs((char *)buf, fp);
fflush(fp);
}
normal_out(fmt, p1, p2, p3, p4, p5)
char *fmt;
int p1, p2, p3, p4, p5;
{
char buf[BUFSIZ];
sprintf(buf, fmt, p1, p2, p3, p4, p5);
printout(stdout, buf);
}
error_out(fmt, p1, p2, p3, p4, p5)
char *fmt;
int p1, p2, p3, p4, p5;
{
char buf[BUFSIZ];
sprintf(buf, fmt, p1, p2, p3, p4, p5);
strcat(buf, "\n");
printout(stderr, buf);
}

91
sj3dic/dictdisp.c Normal file
View file

@ -0,0 +1,91 @@
/*
* Copyright (c) 1991-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.
*
*/
/*
* $SonyRCSfile: dictdisp.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:03:34 $
*/
#include <stdio.h>
#include <ctype.h>
dictdisp(output)
char *output;
{
unsigned char buf[BUFSIZ];
unsigned char *p;
FILE *fp;
int flg;
int i;
if (output && *output) {
fp = fopen(output, "w");
if (!fp) {
error_out("%s \244\254\245\252\241\274\245\327\245\363\244\307\244\255\244\336\244\273\244\363", output);
exit(1);
}
}
else
fp = stdout;
flg = sj3_getdict_mb(buf);
while (flg == 0) {
p = buf;
printout_mb(fp, p);
i = strlen(p);
if (i < 24)
while (i < 24) {
printout_mb(fp, "\t");
i += 8;
}
else
printout_mb(fp, " ");
while (*p++) ;
printout_mb(fp, p);
i = strlen(p);
if (i < 24)
while (i < 24) {
printout_mb(fp, "\t");
i += 8;
}
else
printout_mb(fp, " ");
while (*p++) ;
printout(fp, hns2str(*p));
printout_mb(fp, ":\n");
flg = sj3_nextdict_mb(buf);
}
if (fp != stdout) fclose(fp);
}

223
sj3dic/dictmake.c Normal file
View file

@ -0,0 +1,223 @@
/*
* Copyright (c) 1991-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.
*
*/
/*
* $SonyRCSfile: dictmake.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:03:35 $
*/
#include "sj_sysvdef.h"
#include <stdio.h>
#ifdef SVR4
#include <string.h>
#else
#include <strings.h>
#endif
#include <ctype.h>
#include "sjctype.h"
#include "sj3lib.h"
#include "sjtool.h"
#define IsEOL(c) ((c) == '\0')
#define IsBlank(c) ((c) == ' ' || (c) == '\t')
extern int force_flag;
extern int verbose_flag;
extern int _sys_code;
static void touroku(y, k, h)
char *y, *k, *h;
{
int err;
int grm;
unsigned char buf[BUFSIZ], *hp;
extern int sjistoeuc();
if (_sys_code == SYS_SJIS) {
(void) sjistoeuc(buf, BUFSIZ, h, strlen(h)+1);
hp = buf;
} else {
hp = (unsigned char *) h;
}
if (!(grm = str2hns(hp))) {
error_out("\311\312\273\354\312\270\273\372\316\363\244\362\262\341\244\303\244\306\244\244\244\336\244\271 %s:%s:%s", y, k, h);
if (force_flag) return;
exit(1);
}
err = sj3_touroku_mb(y, k, grm);
switch (err) {
case -1:
error_out("\245\265\241\274\245\320\244\254\315\356\244\301\244\336\244\267\244\277");
exit(1);
case 0:
if (verbose_flag)
normal_out("%s:%s:%s \244\362\305\320\317\277\244\267\244\336\244\267\244\277\n", y, k, h);
break;
case SJ3_DICT_ERROR:
error_out("\274\255\275\361\244\254\244\312\244\244\241\242\244\242\244\353\244\244\244\317\274\255\275\361\244\313\275\361\244\255\271\376\244\341\244\336\244\273\244\363");
exit(1);
case SJ3_DICT_LOCKED:
error_out("\274\255\275\361\244\254\245\355\245\303\245\257\244\265\244\354\244\306\244\244\244\306\275\361\244\255\271\376\244\341\244\336\244\273\244\363");
exit(1);
case SJ3_WORD_EXIST:
if (verbose_flag)
normal_out("%s:%s:%s \244\317\305\320\317\277\244\265\244\354\244\306\244\244\244\336\244\271\n", y, k, h);
break;
case SJ3_DOUON_FULL:
error_out("\244\263\244\354\260\312\276\345\306\261\262\273\270\354\244\362\305\320\317\277\244\307\244\255\244\336\244\273\244\363 %s:%s:%s", y, k, h);
break;
case SJ3_DICT_FULL:
error_out("\244\263\244\354\260\312\276\345\274\255\275\361\244\362\302\347\244\255\244\257\244\307\244\255\244\336\244\273\244\363 %s:%s:%s", y, k, h);
if (force_flag) break;
exit(1);
case SJ3_BAD_YOMI_STR:
error_out("\305\320\317\277\244\307\244\255\244\312\244\244\306\311\244\337\244\307\244\271 %s", y);
if (force_flag) break;
exit(1);
case SJ3_BAD_KANJI_STR:
error_out("\305\320\317\277\244\307\244\255\244\312\244\244\264\301\273\372\244\307\244\271 %s:%s", y, k);
if (force_flag) break;
exit(1);
case SJ3_BAD_HINSI_CODE:
error_out("\305\320\317\277\244\307\244\255\244\312\244\244\311\312\273\354\244\307\244\271 %s:%s:%s", y, k, h);
if (force_flag) break;
exit(1);
case SJ3_INDEX_FULL:
error_out("\245\244\245\363\245\307\245\303\245\257\245\271\244\254\244\244\244\303\244\321\244\244\244\307\244\271");
case SJ3_TOUROKU_FAILED:
default:
error_out("\305\320\317\277\244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277 %s:%s:%s(%d)",
y, k, hns2str(h), h);
break;
}
}
dictmake(input)
char *input;
{
unsigned char buf[BUFSIZ];
FILE *fp;
unsigned char *p;
unsigned char *yom, *knj, *grm;
int c;
int flg;
static char *FormatErrorString = "\245\325\245\251\241\274\245\336\245\303\245\310\245\250\245\351\241\274:%s";
if (input && *input) {
fp = fopen(input, "r");
if (!fp) {
error_out("%s \244\254\245\252\241\274\245\327\245\363\244\307\244\255\244\336\244\273\244\363", input);
exit(1);
}
}
else
fp = stdin;
while (fgets((char *)buf, sizeof(buf), fp)) {
if (p = (unsigned char *)strchr((char *)buf, '\n'))
*p = '\0';
else {
do {
c = fgetc(fp);
} while (c != '\n' && c != EOF);
}
yom = buf;
while (IsBlank(*yom)) yom++;
if (IsEOL(*yom)) {
error_out(FormatErrorString, buf);
if (force_flag) continue;
break;
}
knj = yom;
while (!IsEOL(*knj) && !IsBlank(*knj)) knj++;
if (IsEOL(*knj)) {
error_out(FormatErrorString, buf);
if (force_flag) continue;
break;
}
*knj++ = '\0';
while (IsBlank(*knj)) knj++;
if (IsEOL(*knj)) {
error_out(FormatErrorString, buf);
if (force_flag) continue;
break;
}
grm = knj;
while (!IsEOL(*grm) && !IsBlank(*grm)) grm++;
if (IsEOL(*grm)) {
error_out(FormatErrorString, buf);
if (force_flag) continue;
break;
}
*grm++ = '\0';
while (IsBlank(*grm)) grm++;
if (IsEOL(*grm)) {
error_out(FormatErrorString, buf);
if (force_flag) continue;
break;
}
flg = -1;
while (*grm && flg) {
p = grm;
while (!IsEOL(*p) && !IsBlank(*p) && (*p != ':')) p++;
if (IsEOL(*p))
flg = 0;
else
*p++ = '\0';
touroku(yom, knj, grm);
if (flg) {
grm = p;
while (IsBlank(*grm)) grm++;
}
}
}
}

259
sj3dic/hinsi.c Normal file
View file

@ -0,0 +1,259 @@
/*
* Copyright (c) 1991-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.
*
*/
/*
* $SonyRCSfile: hinsi.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:03:36 $
*/
#include "sj_hinsi.h"
static struct hlist {
int code;
char *str;
} hinsi[] = {
MEISI_1, "\314\276\273\354",
MEISI_1, "\314\276\243\261",
MEISI_2, "\314\276\243\262",
MEISI_3, "\314\276\243\263",
MEISI_4, "\314\276\243\264",
MEISI_5, "\314\276\243\265",
MEISI_6, "\314\276\243\266",
MEISI_7, "\314\276\243\267",
MEISI_8, "\314\276\243\270",
MEISI_9, "\314\276\243\271",
MEISI_10, "\314\276\243\261\243\260",
MEISI_11, "\314\276\243\261\243\261",
MEISI_20, "\314\276\243\262\243\260",
D_MEISI_1, "\302\345\314\276\273\354",
D_MEISI_1, "\302\345\243\261",
D_MEISI_2, "\302\345\243\262",
D_MEISI_3, "\302\345\243\263",
D_MEISI_4, "\302\345\243\264",
D_MEISI_5, "\302\345\243\265",
D_MEISI_6, "\302\345\243\266",
MYOUJI, "\311\304\273\372",
NAMAE, "\314\276\301\260",
KIGYOU, "\264\353\266\310",
TIMEI, "\303\317\314\276",
KEN_KU, "\270\251\241\277\266\350\314\276",
KEN_KU, "\270\251\266\350",
RENTAISI, "\317\242\302\316\273\354",
RENTAISI, "\317\242\302\316",
SETUZOKU, "\300\334\302\263\273\354",
SETUZOKU, "\300\334\302\263",
KANDOUSI, "\264\266\306\260",
JOSUUSI, "\275\365\277\364\273\354",
JOSUUSI, "\275\365\277\364",
SUUSI, "\277\364\273\354",
SETTOU_1, "\300\334\306\254\270\354",
SETTOU_1, "\300\334\306\254\243\261",
SETTOU_2, "\300\334\306\254\243\262",
SETTOU_3, "\300\334\306\254\243\263",
SETTOU_4, "\300\334\306\254\243\264",
SETTOU_5, "\300\334\306\254\243\265",
SETUBI_1, "\300\334\310\370\270\354",
SETUBI_1, "\300\334\310\370\243\261",
SETUBI_2, "\300\334\310\370\243\262",
SETUBI_3, "\300\334\310\370\243\263",
SETUBI_4, "\300\334\310\370\243\264",
SETUBI_5, "\300\334\310\370\243\265",
SETUBI_6, "\300\334\310\370\243\266",
SETUBI_7, "\300\334\310\370\243\267",
SETUBI_8, "\300\334\310\370\243\270",
SETUBI_9, "\300\334\310\370\243\271",
FUKUSI_1, "\311\373\273\354",
FUKUSI_1, "\311\373\243\261",
FUKUSI_2, "\311\373\243\262",
FUKUSI_3, "\311\373\243\263",
FUKUSI_4, "\311\373\243\264",
FUKUSI_5, "\311\373\243\265",
FUKUSI_6, "\311\373\243\266",
FUKUSI_7, "\311\373\243\267",
FUKUSI_8, "\311\373\243\270",
FUKUSI_9, "\311\373\243\271",
JOSUUSI2, "\275\365\277\364\243\262",
KEIYOUSI_1, "\267\301\315\306\273\354",
KEIYOUSI_1, "\267\301\243\261",
KEIYOUSI_2, "\267\301\243\262",
KEIYOUSI_3, "\267\301\243\263",
KEIYOUSI_4, "\267\301\243\264",
KEIYOUSI_5, "\267\301\243\265",
KEIYOUSI_6, "\267\301\243\266",
KEIYOUSI_7, "\267\301\243\267",
KEIYOUSI_8, "\267\301\243\270",
KEIYOUSI_9, "\267\301\243\271",
KEIYOUSI_10, "\267\301\243\261\243\260",
KEIYOUSI_11, "\267\301\243\261\243\261",
KE_DOUSI_1, "\267\301\315\306\306\260\273\354",
KE_DOUSI_1, "\267\301\306\260\243\261",
KE_DOUSI_2, "\267\301\306\260\243\262",
KE_DOUSI_3, "\267\301\306\260\243\263",
KE_DOUSI_4, "\267\301\306\260\243\264",
KE_DOUSI_5, "\267\301\306\260\243\265",
KE_DOUSI_6, "\267\301\306\260\243\266",
KE_DOUSI_7, "\267\301\306\260\243\267",
KE_DOUSI_8, "\267\301\306\260\243\270",
KE_DOUSI_9, "\267\301\306\260\243\271",
DO_SAHEN, "\306\260\241\246\245\265\312\321",
DO_SAHEN, "\245\265\312\321",
DO_ZAHEN, "\306\260\241\246\245\266\312\321",
DO_ZAHEN, "\245\266\312\321",
DO_1DAN_1, "\306\260\241\246\260\354\303\312",
DO_1DAN_1, "\260\354\303\312\243\261",
DO_KAGO_1, "\306\260\241\246\245\253\270\336",
DO_KAGO_1, "\245\253\270\336\243\261",
DO_GAGO_1, "\306\260\241\246\245\254\270\336",
DO_GAGO_1, "\245\254\270\336\243\261",
DO_SAGO_1, "\306\260\241\246\245\265\270\336",
DO_SAGO_1, "\245\265\270\336\243\261",
DO_TAGO_1, "\306\260\241\246\245\277\270\336",
DO_TAGO_1, "\245\277\270\336\243\261",
DO_NAGO_1, "\306\260\241\246\245\312\270\336",
DO_NAGO_1, "\245\312\270\336",
DO_BAGO_1, "\306\260\241\246\245\320\270\336",
DO_BAGO_1, "\245\320\270\336\243\261",
DO_MAGO_1, "\306\260\241\246\245\336\270\336",
DO_MAGO_1, "\245\336\270\336\243\261",
DO_RAGO_1, "\306\260\241\246\245\351\270\336",
DO_RAGO_1, "\245\351\270\336\243\261",
DO_WAGO_1, "\306\260\241\246\245\357\270\336",
DO_WAGO_1, "\245\357\270\336\243\261",
DO_1DAN_2, "\260\354\303\312\243\262",
DO_KAGO_2, "\245\253\270\336\243\262",
DO_GAGO_2, "\245\254\270\336\243\262",
DO_SAGO_2, "\245\265\270\336\243\262",
DO_TAGO_2, "\245\277\270\336\243\262",
DO_BAGO_2, "\245\320\270\336\243\262",
DO_MAGO_2, "\245\336\270\336\243\262",
DO_RAGO_2, "\245\351\270\336\243\262",
DO_WAGO_2, "\245\357\270\336\243\262",
DO_KAGO_5, "\245\253\270\336\243\265",
DO_GAGO_5, "\245\254\270\336\243\265",
DO_SAGO_5, "\245\265\270\336\243\265",
DO_TAGO_5, "\245\277\270\336\243\265",
DO_BAGO_5, "\245\320\270\336\243\265",
DO_MAGO_5, "\245\336\270\336\243\265",
DO_RAGO_5, "\245\351\270\336\243\265",
DO_WAGO_5, "\245\357\270\336\243\265",
DO_KAGO_6, "\245\253\270\336\243\266",
DO_GAGO_6, "\245\254\270\336\243\266",
DO_SAGO_6, "\245\265\270\336\243\266",
DO_TAGO_6, "\245\277\270\336\243\266",
DO_BAGO_6, "\245\320\270\336\243\266",
DO_MAGO_6, "\245\336\270\336\243\266",
DO_RAGO_6, "\245\351\270\336\243\266",
DO_WAGO_6, "\245\357\270\336\243\266",
DO_1DAN_3, "\260\354\303\312\243\263",
DO_KAGO_3, "\245\253\270\336\243\263",
DO_GAGO_3, "\245\254\270\336\243\263",
DO_SAGO_3, "\245\265\270\336\243\263",
DO_TAGO_3, "\245\277\270\336\243\263",
DO_BAGO_3, "\245\320\270\336\243\263",
DO_MAGO_3, "\245\336\270\336\243\263",
DO_RAGO_3, "\245\351\270\336\243\263",
DO_WAGO_3, "\245\357\270\336\243\263",
DO_1DAN_4, "\260\354\303\312\243\264",
DO_KAGO_4, "\245\253\270\336\243\264",
DO_GAGO_4, "\245\254\270\336\243\264",
DO_SAGO_4, "\245\265\270\336\243\264",
DO_TAGO_4, "\245\277\270\336\243\264",
DO_BAGO_4, "\245\320\270\336\243\264",
DO_MAGO_4, "\245\336\270\336\243\264",
DO_RAGO_4, "\245\351\270\336\243\264",
DO_WAGO_4, "\245\357\270\336\243\264",
DO_KAGO_7, "\245\253\270\336\243\267",
DO_GAGO_7, "\245\254\270\336\243\267",
DO_SAGO_7, "\245\265\270\336\243\267",
DO_TAGO_7, "\245\277\270\336\243\267",
DO_BAGO_7, "\245\320\270\336\243\267",
DO_MAGO_7, "\245\336\270\336\243\267",
DO_RAGO_7, "\245\351\270\336\243\267",
DO_WAGO_7, "\245\357\270\336\243\267",
DO_KAGO_8, "\245\253\270\336\243\270",
DO_GAGO_8, "\245\254\270\336\243\270",
DO_SAGO_8, "\245\265\270\336\243\270",
DO_TAGO_8, "\245\277\270\336\243\270",
DO_BAGO_8, "\245\320\270\336\243\270",
DO_MAGO_8, "\245\336\270\336\243\270",
DO_RAGO_8, "\245\351\270\336\243\270",
DO_WAGO_8, "\245\357\270\336\243\270",
SP_SA_MI1, "\245\265\312\321\314\244\243\261",
SP_SA_MI2, "\245\265\312\321\314\244\243\262",
SP_SA_YOU, "\245\265\312\321\314\244\315\321",
SP_SA_SYU, "\245\265\312\321\275\252\302\316",
SP_SA_KAT, "\245\265\312\321\262\276",
SP_SA_ME1, "\245\265\312\321\314\277\243\261",
SP_SA_ME2, "\245\265\312\321\314\277\243\262",
SP_KA_MIZ, "\245\253\312\321\314\244",
SP_KA_YOU, "\245\253\312\321\315\321",
SP_KA_SYU, "\245\253\312\321\275\252\302\316",
SP_KA_KAT, "\245\253\312\321\262\276",
SP_KA_MEI, "\245\253\312\321\314\277",
TEINEI1, "\303\372\307\253\243\261",
TEINEI2, "\303\372\307\253\243\262",
SP_KA_ONB, "\245\253\270\336\262\273\312\330",
SP_FUKUSI, "\306\303\274\354\311\373",
AISATU, "\260\247\273\242",
SP_KEIYOUSI, "\306\303\274\354\267\301\315\306",
TANKANJI, "\303\261\264\301\273\372",
TANKANJI, "\303\261\264\301",
IKKATU, "\260\354\263\347",
0, 0
};
char *hns2str(code)
int code;
{
struct hlist *p;
for (p = hinsi ; p -> code ; p++) {
if (p -> code == code)
return p -> str;
}
return "ERROR";
}
int str2hns(str)
char *str;
{
struct hlist *p;
for (p = hinsi ; p -> code ; p++) {
if (strcmp(p -> str, str) == 0)
return p -> code;
}
return 0;
}

332
sj3dic/sj3dic.c Normal file
View file

@ -0,0 +1,332 @@
/*
* Copyright (c) 1991-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.
*
*/
/*
* $SonyRCSfile: sj3dic.c,v $
* $SonyRevision: 1.2 $
* $SonyDate: 1996/02/15 02:22:58 $
*/
#include "sj_sysvdef.h"
#include <stdio.h>
#ifdef SVR4
#include <string.h>
#else
#include <strings.h>
#endif
#include <ctype.h>
#include <pwd.h>
#include <locale.h>
#include "sjtool.h"
#include "sj3lib.h"
char *getlogin(), *getenv();
struct passwd *getpwnam(), *getpwuid();
static _open_error();
static _close_error();
void make_dicname();
void setsjserv();
#ifdef __sony_news
extern int _sys_code;
#else
int _sys_code = SYS_EUC;
#endif
#ifndef lint
static char rcsid_sony[] = "$Header: /export/work/contrib/sj3/sj3dic/RCS/sj3dic.c,v 1.11 1994/06/03 07:41:59 notanaka Exp $ SONY;";
#endif
static struct option {
char *str;
int code;
} options[] = {
"text", EXEC_TEXT,
"dict", EXEC_DICT,
"init", EXEC_INIT,
"verbose", EXEC_VERBOSE,
"host", EXEC_SERVER,
"server", EXEC_SERVER,
"force", EXEC_FORCE,
0, 0
};
char prog_name[LONGLENGTH];
char home_dir[LONGLENGTH];
char user_name[LONGLENGTH];
char term_name[LONGLENGTH];
char serv_name[LONGLENGTH];
char file_name[LONGLENGTH];
char dict_name[LONGLENGTH];
int verbose_flag = 0;
int init_flag = 0;
int force_flag = 0;
main(argc, argv)
int argc;
char **argv;
{
int err;
int mode;
if (!init_code()) {
fprintf(stderr, "Can't excute on this locale\n");
exit(1);
}
init_env();
mode = parsearg(argc, argv);
setsjserv(getenv("SJ3SERV"));
getsjrc();
make_dicname();
if (err = sj3_open(serv_name, user_name, prog_name)) _open_error(err);
switch (mode) {
case EXEC_TEXT:
dictdisp(file_name);
break;
case EXEC_DICT:
dictmake(file_name);
break;
default:
break;
}
if (err = sj3_close()) _close_error(err);
}
init_env()
{
char *un, *hp, *tn;
struct passwd *pwd;
prog_name[0] =
home_dir[0] =
user_name[0] =
term_name[0] =
serv_name[0] =
file_name[0] =
dict_name[0] = '\0';
un = getlogin();
hp = getenv("HOME");
setpwent();
pwd = (un == NULL || *un == '\0') ? getpwuid(getuid()) : getpwnam(un);
if (pwd != NULL) {
strcpy(user_name, pwd -> pw_name);
if (hp == NULL) hp = pwd -> pw_dir;
endpwent();
}
if (hp != NULL) strcpy(home_dir, hp);
if ((tn = getenv("TERM")) == NULL) {
fprintf(stderr, "Can't getenv TERM\n\r");
perror("getenv");
exit(1);
}
strcpy(term_name, tn);
}
usage(ret)
int ret;
{
fprintf(stderr,
"Usage: %s -{text|dict} [-H host_name] [file_name]\n",
prog_name);
exit(ret);
}
parsearg(argc, argv)
int argc;
char *argv[];
{
int errflg = 0;
int i, j;
char *p, *q;
struct option *opt;
int cmd;
int mode = 0;
char tmp[LONGLENGTH];
extern char *strrchr();
strcpy(prog_name, (p = strrchr(argv[0], '/')) ? p + 1 : argv[0]);
for (i = 1 ; i < argc ; i++) {
if (*argv[i] == '-') {
for (p = argv[i]+1, q = tmp ; *p ; p++)
*q++ = isupper(*p) ? tolower(*p) : *p;
*q = 0;
j = strlen(tmp);
cmd = 0;
for (opt = options ; opt -> code ; opt++) {
if (strncmp(opt -> str, tmp, j))
continue;
else if (cmd) {
errflg++; break;
}
else
cmd = opt -> code;
}
if (errflg) break;
if (cmd == 0) { errflg++; break; }
switch (cmd) {
case EXEC_TEXT:
case EXEC_DICT:
if (mode)
errflg++;
else
mode = cmd;
break;
case EXEC_INIT:
init_flag++; break;
case EXEC_VERBOSE:
verbose_flag++; break;
case EXEC_SERVER:
if (++i >= argc) { errflg++; break; }
setsjserv(argv[i]);
break;
case EXEC_FORCE:
force_flag++; break;
default:
errflg++; break;
}
}
else if (file_name[0]) {
errflg++; break;
}
else
strcpy(file_name, argv[i]);
}
if (errflg || mode == 0) usage(1);
return mode;
}
void
make_dicname()
{
if (dict_name[0] != '\0') return;
strcpy(dict_name, home_dir);
strcat(dict_name, "/");
strcat(dict_name, "sj2usr.dic");
}
void
setdicname(dictname)
char *dictname;
{
if (dict_name[0] != '\0') return;
if (dictname == NULL) return;
strcpy(dict_name, dictname);
}
void
setsjserv(hostname)
char *hostname;
{
if (serv_name[0] != '\0') return;
if (hostname == NULL) return;
strcpy(serv_name, hostname);
}
struct errlist {
int code;
char *msg;
int flg;
};
static _error_and(err, list)
int err;
struct errlist *list;
{
int flag = 0;
while (list -> code) {
if (err & list -> code) {
error_out(list -> msg);
err &= ~(list -> code);
if (list -> flg) flag++;
}
list++;
}
if (flag) exit(1);
}
static _open_error(err)
int err;
{
static struct errlist err_msg[] = {
SJ3_SERVER_DEAD, "\245\265\241\274\245\320\244\254\273\340\244\363\244\307\244\244\244\336\244\271", 1,
SJ3_CONNECT_ERROR, "\245\265\241\274\245\320\244\310\300\334\302\263\244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277", 1,
SJ3_ALREADY_CONNECTED, "\245\265\241\274\245\320\244\310\300\334\302\263\272\321\244\307\244\271", 1,
SJ3_CANNOT_OPEN_MDICT, "\245\341\245\244\245\363\274\255\275\361\244\254\245\252\241\274\245\327\245\363\244\307\244\255\244\336\244\273\244\363", 0,
SJ3_CANNOT_OPEN_UDICT, "\245\346\241\274\245\266\274\255\275\361\244\254\245\252\241\274\245\327\245\363\244\307\244\255\244\336\244\273\244\363", 1,
SJ3_CANNOT_OPEN_STUDY, "\263\330\275\254\245\325\245\241\245\244\245\353\244\254\245\252\241\274\245\327\245\363\244\307\244\255\244\336\244\273\244\363", 0,
SJ3_CANNOT_MAKE_UDIR, "\245\346\241\274\245\266\241\274\245\307\245\243\245\354\245\257\245\310\245\352\244\254\272\356\300\256\244\307\244\255\244\336\244\273\244\363", 1,
SJ3_CANNOT_MAKE_UDICT, "\245\346\241\274\245\266\274\255\275\361\244\254\272\356\300\256\244\307\244\255\244\336\244\273\244\363", 1,
SJ3_CANNOT_MAKE_STUDY, "\263\330\275\254\245\325\245\241\245\244\245\353\244\254\272\356\300\256\244\307\244\255\244\336\244\273\244\363", 0,
-1, "\245\250\245\351\241\274", 1,
0, 0, 0
};
_error_and(err, err_msg);
}
static _close_error(err)
int err;
{
static struct errlist err_msg[] = {
SJ3_SERVER_DEAD, "\245\265\241\274\245\320\241\274\244\254\273\340\244\363\244\307\244\244\244\336\244\271", 1,
SJ3_DISCONNECT_ERROR, "\300\332\244\352\312\374\244\267\244\307\245\250\245\351\241\274\244\254\244\242\244\352\244\336\244\267\244\277", 1,
SJ3_NOT_CONNECTED, "\245\265\241\274\245\320\244\310\300\334\302\263\244\265\244\354\244\306\244\244\244\336\244\273\244\363", 1,
SJ3_NOT_OPENED_MDICT, "\245\341\245\244\245\363\274\255\275\361\244\317\245\252\241\274\245\327\245\363\244\265\244\354\244\306\244\244\244\336\244\273\244\363", 0,
SJ3_NOT_OPENED_UDICT, "\245\346\241\274\245\266\274\255\275\361\244\317\245\252\241\274\245\327\245\363\244\265\244\354\244\306\244\244\244\336\244\273\244\363", 1,
SJ3_NOT_OPENED_STUDY, "\263\330\275\254\245\325\245\241\245\244\245\353\244\317\245\252\241\274\245\327\245\363\244\265\244\354\244\306\244\244\244\336\244\273\244\363", 0,
SJ3_CLOSE_MDICT_ERROR, "\245\341\245\244\245\363\274\255\275\361\244\254\245\257\245\355\241\274\245\272\244\307\244\255\244\336\244\273\244\363", 0,
SJ3_CLOSE_UDICT_ERROR, "\245\346\241\274\245\266\274\255\275\361\244\254\245\257\245\355\241\274\245\272\244\307\244\255\244\336\244\273\244\363", 1,
SJ3_CLOSE_STUDY_ERROR, "\263\330\275\254\245\325\245\241\245\244\245\353\244\254\245\257\245\355\241\274\245\272\244\307\244\255\244\336\244\273\244\363", 0,
-1, "\245\250\245\351\241\274", 1,
0, 0, 0
};
_error_and(err, err_msg);
}

109
sj3dic/sj3err.c Normal file
View file

@ -0,0 +1,109 @@
/*
* Copyright (c) 1991-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.
*
*/
/*
* $SonyRCSfile: sj3err.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:03:38 $
*/
#include <stdio.h>
#include "sj3err.h"
sj3error(fp, code)
FILE *fp;
int code;
{
unsigned char tmp[BUFSIZ];
switch (code) {
#define CASE(X, str) case (X): printout(fp, str); break;
CASE(SJ3_InternalError, "\245\244\245\363\245\277\241\274\245\312\245\353\245\250\245\351\241\274");
CASE(SJ3_NormalEnd, "\300\265\276\357\275\252\316\273");
CASE(SJ3_ServerDown, "\245\265\241\274\245\320\241\274\244\254\315\356\244\301\244\306\244\244\244\336\244\271");
CASE(SJ3_OpenSocket, "socket \244\316 open \244\313\274\272\307\324\244\267\244\336\244\267\244\277");
CASE(SJ3_ConnectSocket, "socket \244\316 connect \244\313\274\272\307\324\244\267\244\336\244\267\244\277");
CASE(SJ3_GetHostByName, "gethostbyname \244\313\274\272\307\324\244\267\244\336\244\267\244\277");
CASE(SJ3_NotOpened, "\245\252\241\274\245\327\245\363\244\265\244\354\244\306\244\244\244\336\244\273\244\363");
CASE(SJ3_NotEnoughMemory, "\245\341\245\342\245\352\244\254\302\255\244\352\244\336\244\273\244\363");
CASE(SJ3_IllegalCommand, "\245\263\245\336\245\363\245\311\244\254\304\352\265\301\244\265\244\354\244\306\244\244\244\336\244\273\244\363");
CASE(SJ3_DifferentVersion, "\245\320\241\274\245\270\245\347\245\363\244\254\260\343\244\244\244\336\244\271");
CASE(SJ3_NoHostName, "\245\333\245\271\245\310\314\276\244\254\244\242\244\352\244\336\244\273\244\363");
CASE(SJ3_NoUserName, "\245\346\241\274\245\266\314\276\244\254\244\242\244\352\244\336\244\273\244\363");
CASE(SJ3_NotAllowedUser, "\300\334\302\263\244\362\265\366\244\265\244\354\244\306\244\244\244\336\244\273\244\363");
CASE(SJ3_AlreadyConnected, "\300\334\302\263\272\321\244\307\244\271");
CASE(SJ3_NotConnected, "\300\334\302\263\244\265\244\354\244\306\244\244\244\336\244\273\244\363");
CASE(SJ3_TooLongParameter, "\245\321\245\351\245\341\241\274\245\277\244\254\304\271\244\271\244\256\244\336\244\271");
CASE(SJ3_IllegalParameter, "\245\321\245\351\245\341\241\274\245\277\244\254\260\333\276\357\244\307\244\271");
CASE(SJ3_BadDictID, "\244\275\244\316\244\350\244\246\244\312\274\255\275\361\244\317\244\242\244\352\244\336\244\273\244\363");
CASE(SJ3_IllegalDictFile, "\274\255\275\361\245\325\245\241\245\244\245\353\244\254\260\333\276\357\244\307\244\271");
CASE(SJ3_IllegalStdyFile, "\263\330\275\254\245\325\245\241\245\244\245\353\244\254\260\333\276\357\244\307\244\271");
CASE(SJ3_IncorrectPasswd, "\245\321\245\271\245\357\241\274\245\311\244\254\260\333\244\312\244\352\244\336\244\271");
CASE(SJ3_FileNotExist, "\245\325\245\241\245\244\245\353\244\254\302\270\272\337\244\267\244\336\244\273\244\363");
CASE(SJ3_CannotAccessFile, "\245\325\245\241\245\244\245\353\244\313\245\242\245\257\245\273\245\271\244\307\244\255\244\336\244\273\244\363");
CASE(SJ3_CannotOpenFile, "\245\325\245\241\245\244\245\353\244\254\245\252\241\274\245\327\245\363\244\307\244\255\244\336\244\273\244\363");
CASE(SJ3_CannotCreateFile, "\245\325\245\241\245\244\245\353\244\254\272\356\300\256\244\307\244\255\244\336\244\273\244\363");
CASE(SJ3_FileReadError, "\245\352\241\274\245\311\245\250\245\351\241\274\244\254\244\242\244\352\244\336\244\267\244\277");
CASE(SJ3_FileWriteError, "\245\351\245\244\245\310\245\250\245\351\241\274\244\254\244\242\244\352\244\336\244\267\244\277");
CASE(SJ3_FileSeekError, "\245\267\241\274\245\257\245\250\245\351\241\274\244\254\244\242\244\352\244\336\244\267\244\277");
CASE(SJ3_StdyAlreadyOpened, "\263\330\275\254\245\325\245\241\245\244\245\353\244\317\245\252\241\274\245\327\245\363\244\265\244\354\244\306\244\244\244\336\244\271");
CASE(SJ3_StdyFileNotOpened, "\263\330\275\254\245\325\245\241\245\244\245\353\244\254\245\252\241\274\245\327\245\363\244\265\244\354\244\306\244\244\244\336\244\273\244\363");
CASE(SJ3_TooSmallStdyArea, "\312\270\300\341\304\271\263\330\275\254\316\316\260\350\244\254\276\256\244\265\244\271\244\256\244\336\244\271");
CASE(SJ3_LockedByOther, "\302\276\244\316\245\257\245\351\245\244\245\242\245\363\245\310\244\313\245\355\245\303\245\257\244\265\244\354\244\306\244\336\244\271");
CASE(SJ3_NotLocked, "\245\355\245\303\245\257\244\265\244\354\244\306\244\244\244\336\244\273\244\363");
CASE(SJ3_NoSuchDict, "\244\275\244\316\244\350\244\246\244\312\274\255\275\361\244\317\244\242\244\352\244\336\244\273\244\363");
CASE(SJ3_ReadOnlyDict, "\275\361\244\255\271\376\244\337\244\307\244\255\244\312\244\244\274\255\275\361\244\307\244\271");
CASE(SJ3_DictLocked, "\274\255\275\361\244\254\245\355\245\303\245\257\244\265\244\354\244\306\244\244\244\336\244\271");
CASE(SJ3_BadYomiString, "\265\366\244\265\244\354\244\312\244\244\306\311\244\337\312\270\273\372\316\363\244\307\244\271");
CASE(SJ3_BadKanjiString, "\265\366\244\265\244\354\244\312\244\244\264\301\273\372\312\270\273\372\316\363\244\307\244\271");
CASE(SJ3_BadHinsiCode, "\311\312\273\354\245\263\241\274\245\311\260\333\276\357\244\307\244\271");
CASE(SJ3_AddDictFailed, "\274\255\275\361\305\320\317\277\244\362\274\272\307\324\244\267\244\336\244\267\244\277");
CASE(SJ3_AlreadyExistWord, "\244\271\244\307\244\313\302\270\272\337\244\267\244\306\244\244\244\336\244\271");
CASE(SJ3_NoMoreDouonWord, "\244\263\244\354\260\312\276\345\306\261\262\273\270\354\244\362\305\320\317\277\244\307\244\255\244\336\244\273\244\363");
CASE(SJ3_NoMoreUserDict, "\244\263\244\354\260\312\276\345\274\255\275\361\244\313\305\320\317\277\244\307\244\255\244\336\244\273\244\363");
CASE(SJ3_NoMoreIndexBlock, "\244\263\244\354\260\312\276\345\245\244\245\363\245\307\245\303\245\257\245\271\244\313\305\320\317\277\244\307\244\255\244\336\244\273\244\363");
CASE(SJ3_DelDictFailed, "\274\255\275\361\272\357\275\374\244\362\274\272\307\324\244\267\244\336\244\267\244\277");
CASE(SJ3_NoSuchWord, "\244\275\244\316\244\350\244\246\244\312\275\317\270\354\244\317\244\242\244\352\244\336\244\273\244\363");
CASE(SJ3_DirAlreadyExist, "\244\275\244\316\245\307\245\243\245\354\245\257\245\310\245\352\244\254\302\270\272\337\244\267\244\306\244\244\244\336\244\271");
CASE(SJ3_CannotCreateDir, "\245\307\245\243\245\354\245\257\245\310\245\352\244\254\272\356\300\256\244\307\244\255\244\336\244\273\244\363");
CASE(SJ3_NoMoreDictData, "\244\263\244\354\260\312\276\345\274\255\275\361\245\307\241\274\245\277\244\254\244\242\244\352\244\336\244\273\244\363");
CASE(SJ3_UserConnected, "\300\334\302\263\244\267\244\306\244\244\244\353\245\346\241\274\245\266\244\254\244\242\244\352\244\336\244\271");
CASE(SJ3_TooLongPasswd, "\245\321\245\271\245\357\241\274\245\311\244\254\304\271\244\271\244\256\244\336\244\271");
CASE(SJ3_TooLongComment, "\245\263\245\341\245\363\245\310\244\254\304\271\244\271\244\256\244\336\244\271");
#undef CASE
default:
sprintf((char *)tmp, "\314\244\304\352\265\301\244\316\245\250\245\351\241\274(%d)", code);
printout(fp, tmp);
break;
}
printout(fp, "\r\n");
}

82
sj3dic/sjctype.h Normal file
View file

@ -0,0 +1,82 @@
/*
* Copyright (c) 1991-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.
*
*/
/*
* $SonyRCSfile: sjctype.h,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:03:39 $
*/
#ifndef __sony_news
#ifndef __SJCTYPE
#define __SJCTYPE
#include "sj_sysvdef.h"
#define sjis2euc sj3_sjis2euc
#define jis2sjis sj3_jis2sjis
#define euctosjis sj3_euctosjis
#define sjis2jis sj3_sjis2jis
#define euc2sjis sj3_euc2sjis
#define jis2euc sj3_jis2euc
#define sjistoeuc sj3_sjistoeuc
#define issjis1(c) (((0x81 <= ((unsigned char)(c))) && (((unsigned char)(c)) <= 0x9f)) || \
((0xe0 <= ((unsigned char)(c))) && (((unsigned char)(c)) <= 0xfc)))
#define issjis2(c) (((0x40 <= ((unsigned char)(c))) && (((unsigned char)(c)) <= 0xfc)) && (((unsigned char)(c)) != 0x7f))
#define iseuc(c) ((0xa1 <= ((unsigned char)(c))) && (((unsigned char)(c)) <= 0xfe))
#define iseuckana(c) (((unsigned char)(c)) == 0x8e)
#define iskana2(c) ((0xa1 <= ((unsigned char)(c))) && (((unsigned char)(c)) <= 0xdf))
#define jiszen(c) (issjis1(((c) >> 8) & 0xff) && issjis2((c) & 0xff))
#define isjjis(c) ((0x21 <= (c)) && ((c) <= 0x7e))
#define jstrlen(s) euclen(s, 65535)
#define iseuc3byte(c) ((c) == 0x8f)
#define iseuc2byte(c) (iseuc(c) || ((c) == 0x8e))
#define iskanji issjis1
#define iskanji2 issjis2
#define iskana iskana2
#endif
#else
#ifndef SVR4
#define euctosjis sj3_euctosjis
#define sjistoeuc sj3_sjistoeuc
#endif
#endif

310
sj3dic/sjrc.c Normal file
View file

@ -0,0 +1,310 @@
/*
* Copyright (c) 1991-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.
*
*/
/*
* $SonyRCSfile: sjrc.c,v $
* $SonyRevision: 1.3 $
* $SonyDate: 1997/01/23 11:26:31 $
*/
#include <stdio.h>
#include <locale.h>
#include <ctype.h>
#include <sys/types.h>
#include "sjctype.h"
#include "sjtool.h"
struct wordent {
char word_str[MAXWORD];
};
extern char home_dir[];
extern char term_name[];
char RCfile[LONGLENGTH];
static char *rcfile = ".sjrc";
static int user_euc = 0;
static int file_code = SYS_SJIS;
int set_dict(), set_server();
struct functbl {
char *keyword;
int (*func)();
} funcs[] = {
"dictionary", set_dict,
"userdic", set_dict,
"server", set_server,
NULL, NULL
};
#define TOLOWER(c) (isupper(c) ? tolower(c) : (c))
sjset_code()
{
char *loc;
#ifdef LACKOF_SETLOCALE
loc = getenv("LANG");
#else
loc = setlocale(LC_CTYPE, "");
#endif
if (!loc) {
fprintf(stderr, "Error: can't get current locale\n");
exit(1);
}
if (strncmp(loc, "ja_JP.SJIS", 10) == 0) {
user_euc = 0;
} else if (strncmp(loc, "ja", 2) == 0 ||
strncmp(loc, "Ja", 2) == 0) {
user_euc = 1;
file_code = -1;
} else
#ifdef __sony_news
return 0;
#else
{
fprintf(stderr, "Warrning: In this locale japanese will not be used.\n");
user_euc = 1;
file_code = -1;
}
#endif
return 1;
}
getsjrc ()
{
FILE *fd, *fopen();
register char *p;
char *getenv();
sjset_code();
RCfile[0] = '\0';
if ((p = getenv("SJRC")) != NULL && *p != '\0') {
if (*p != '/') {
strcpy(RCfile, home_dir);
strcat(RCfile, "/");
}
strcat(RCfile, p);
if ((fd = fopen (RCfile, "r")) != NULL) {
setrc (RCfile, fd);
fclose (fd);
return TRUE;
}
}
if (home_dir[0] != '\0') {
strcpy(RCfile, home_dir);
strcat(RCfile, "/");
strcat(RCfile, rcfile);
if ((fd = fopen (RCfile, "r")) != NULL) {
setrc (RCfile, fd);
fclose (fd);
return TRUE;
}
}
RCfile[0] = '\0';
return FALSE;
}
setrc (file, fd)
char *file;
FILE *fd;
{
char line[MAXLINE];
register int w;
struct wordent word[WORDN];
register char *p;
struct functbl *functp;
while ((p = fgets (line, MAXLINE, fd)) != NULL) {
if ((w = getword(line, word)) <= 0)
continue;
functp = funcs;
p = word[0].word_str;
while (functp->keyword != NULL) {
if (much(p, functp->keyword)) {
if (functp->func) (*(functp->func))(word);
break;;
}
functp++;
}
}
}
much(s1, s2)
char *s1, *s2;
{
register char c1, c2;
if (s1 == NULL)
return 0;
while (*s2 != '\0') {
c1 = *s1++;
c2 = *s2++;
if (TOLOWER(c1) != TOLOWER(c2))
return 0;
}
return 1;
}
getword (s, word)
register char *s;
struct wordent word[];
{
register u_char c, cc;
register char *p;
register int i, wcount;
if (IsDelimitor(*s)) {
s++;
} else {
p = s;
while(!IsDelimitor(*s)) {
if (IsTerminator(*s) || isTerminator(*s))
break;
s++;
}
*s++ = '\0';
if (much(p, term_name) == 0)
return 0;
}
i = wcount = 0;
p = word[wcount].word_str;
while (*s != '\0') {
c = *s++;
if (file_code == SYS_SJIS) {
if (issjis1(c) && issjis2(*s)) {
if (i < MAXWORD - 2) {
*p++ = c;
*p++ = *s;
i += 2;
}
s++;
continue;
}
} else if (file_code == SYS_EUC) {
if (iseuc(c) && iseuc(*s)) {
if (i < MAXWORD - 2) {
cc = (c << 8) + (*s & 0xff);
cc = euc2sjis(cc);
*p++ = (cc >> 8) & 0xff;
*p++ = cc & 0xff;
i += 2;
}
s++;
continue;
}
if (iseuckana(c) && iskana2(*s))
c = *s++;
} else {
if (issjis1(c) && issjis2(*s)) {
file_code = SYS_SJIS;
s--;
continue;
}
if ((iseuc(c) && iseuc(*s)) ||
(iseuckana(c) && iskana2(*s))) {
file_code = SYS_EUC;
s--;
continue;
}
}
if (isTerminator(c))
break;
if (IsDelimitor(c)) {
if (i > 0) {
if (++wcount >= WORDN - 1)
break;
*p = '\0';
i = 0;
p = word[wcount].word_str;
}
continue;
}
if (IsEscape(c))
c = *s++;
if (IsTerminator(c))
break;
if (i < MAXWORD - 1) {
*p++ = c;
i++;
}
}
*p = '\0';
if (word[wcount].word_str[0] != '\0')
word[++wcount].word_str[0] = '\0';
return wcount;
}
IsTerminator (c)
u_char c;
{
return (c == '\n') ? 1 : 0;
}
isTerminator (c)
u_char c;
{
return (c == '#') ? 1 : 0;
}
IsEscape (c)
u_char c;
{
return (c == '\\') ? 1 : 0;
}
IsDelimitor (c)
u_char c;
{
return (c == ' ' || c == '\t' || c == '.') ? 1 : 0;
}
set_dict (word)
struct wordent word[];
{
setdicname(word[1].word_str);
}
set_server(word)
struct wordent word[];
{
setsjserv(word[1].word_str);
}

63
sj3dic/sjtool.h Normal file
View file

@ -0,0 +1,63 @@
/*
* Copyright (c) 1991-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.
*
*/
/*
* $SonyRCSfile: sjtool.h,v $
* $SonyRevision: 1.2 $
* $SonyDate: 1996/02/15 02:22:59 $
*/
#if defined(__NetBSD__)
#define LACKOF_SETLOCALE
#endif
#define LONGLENGTH 256
#define MAXLINE 256
#define MAXWORD 256
#define WORDN 32
#ifndef SYS_SJIS
# define SYS_SJIS 0
#endif
#ifndef SYS_EUC
# define SYS_EUC 1
#endif
#define TRUE -1
#define FALSE !(TRUE)
#define EXEC_TEXT 1
#define EXEC_DICT 2
#define EXEC_CONV 3
#define EXEC_INIT 10
#define EXEC_VERBOSE 11
#define EXEC_SERVER 12
#define EXEC_FORCE 13
#define SingleShift2 0x8e