Import sj3-patches-20040916

Original description for the changes:

sj3 の patch をまとめました。
基本的に、SUS v2 の範囲に対応しているシステムを考えています。ですので、
autoconf 的な #ifdef はあまり使うつもりはありません。
FreeBSD の ports 向けを第一目的にしているので、strlcpy() のような非標準の
関数も使ってしまっていますが、それについては要望があれば存在しないシステム
でも make できるように対応するつもりです。

この patch set に関する要望がもしもあるようでしたら、
	小野 寛生 (hiroo+sj3 at oikumene.gcd.org)
までご連絡ください。

---- patch 部分の Changelog
2004年 9月16日 木曜日 02時57分06秒 JST
* server/execute.c で malloc が失敗したときに dictlist を消去する処理が
  バグで動かない状態だったのを修正した。ただし、その直後に segfault する
  ようなコードになっているので問題は解消されていない。
  エラー回復時にどのような処理が意図されていたか理解しないと、修正は無理
  なので、そのままにしておく。

2004年 8月28日 土曜日 15時04分33秒 JST
* Move include/sj3lowlib.h and sj3lib/sj3lib_func.h to sj3lib/sj3lib.h.
  It will enable softwares depending on sj3lib.h compile again.

2004年 7月24日 土曜日
* ヘッダの重複 include を許容する。
	include/sj3lowlib.h, sj3lib/sj3lib_func.h
* 必要な型宣言のため、ヘッダを include する。

2004年 7月21日 水曜日 01時00分11秒 JST
* ISO C に適合するよういろいろ修正。(ただし、部分的)。
  修正内容は7/3に準ずる。
  修正したファイル名は省略する。
* dict/tool/makeseg.c の static index[] が <string.h> の index() と衝突
  しないように、segindex[] に改名した。
  (FreeBSD 4-stable/GCC 2.95.4 で compile に失敗していたものの修正)。

2004年 7月 4日 日曜日 17時47分33秒 JST
* ISO C に適合するよういろいろ修正。(ただし、部分的)。
  修正内容は7/3に準ずる。
  FreeBSD/amd64 上の gcc version 3.3.3 [FreeBSD] 20031106 では、致命的と
  思われる error/warning はなくなった。動作確認は sj3serv が起動すること
  のみ。

2004年 7月 3日 土曜日 03時53分23秒 JST
* スタイル修正を以下のファイルについて行なった。
  - 関数宣言を ISO C スタイルにした。
  - register キーワードを削除した。
  - 構造体、配列の初期化に適切な {} をつけた。
  - 条件判定文を if((something) != NULL) のような形式に変更した。
	kanakan/alloc.c,
	server/comuni.c, error.c, execute.c, setup.c
	sj3/funckey.c, sj3.c, sjgetchar.c
	sj3lib/Imakefile, sj.c, sj3lib.h
  - プロトタイプ宣言をいれたヘッダファイルを追加作成。
  	kanakan/kanakan.h, sj3/sj3.h, sj3lib/sj3lib_func.h

2004年 7月 2日 金曜日 01時09分09秒 JST
* FreeBSD の ports にある patch を大部分もってきた。
  注意点:
  - server/execute.c, setup.c
    snprintf と strlcpy を使っているコードがあり、将来は存在しない system の
    ためにコードをもってきて、sj3.tmpl あたりに knob を設けるべきである。
    現時点では、上記関数が存在しないシステムは、単にコンパイルに失敗する。
  - FreeBSD の -lxpg4 は外した。古い release では、有効にする必要あり。(sj3.tmpl)
* dict/tool を ISO C style に変更した。
  - amd64/FreeBSD で build できるようになったのを確認。
    (sporsored by: AMD64JP Project, AMD developer support program).
  - server は起動する。動作確認は未実施。

Signed-off-by: Masanori Ogino <mogino@acm.org>
This commit is contained in:
Hiroo Ono 2023-12-04 14:18:05 +09:00 • committed by Masanori Ogino
commit 4a2d141541
77 changed files with 3421 additions and 3850 deletions

115
dict/include/dicttool.h Normal file
View file

@ -0,0 +1,115 @@
/*
* Copyright (c) 2004 Hiroo Ono <hiroo at oikumene.gcd.org>
*
* 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.
*
*/
/*
* $Id: dicttool.h,v 1.1 2004/07/01 17:11:27 hiroo Exp $
*/
#ifndef _DICTTOLL_H_
#define _DICTTOLL_H_ 1
#include <stdio.h>
#include <sys/types.h>
#include "sj_struct.h"
/* char.c */
int cnvyomi (int code);
int h2kcode (int code);
int codesize (u_char code);
void output_knj (FILE* fp, u_char* p, int l);
void output_str (FILE* fp, char* p);
void output_int (FILE* fp, int* p);
void output_yomi (FILE* fp, u_char* p);
/* cnvhinsi.c */
int cnvhinsi (u_char *buf);
/* file.c */
FILE* Fopen (char* filename, char* type);
void Fclose (FILE* fp);
int Fseek (FILE* fp, long ofs, int ptr);
long Ftell (FILE* fp);
off_t Fsize (char* filename);
int Fread (char* p, int s, int n, FILE* fp);
int Fwrite (char* p, int s, int n, FILE* fp);
int Fgetc (FILE* fp);
void Fflush (FILE* fp);
/* hindo.c */
int check_hindo (u_char* ptr, int len);
void knjhnd_set (u_char* p, int l);
void knjhnd_reset (u_char* p, int l);
int decide_knjask (void);
void clear_hindo (void);
void clear_assyuku (void);
/* knjcvt.c */
u_char* knjofscvt (u_char* ptr, int len, int* ret);
u_char* knjcvt (u_char* ptr, int len, int* ret);
/* makedict.c */
void parse (int argc, char** argv);
void usage (char* name);
int getch (void);
void mark_file (FILE* out);
/* makelist.c */
void clear_list (void);
void flush_douon (void);
void makelist (int* yomi, int* kanji, int hinsi, int* atr);
/* makeseg.c */
size_t make_knjstr (u_char* src, int len, u_char* dst);
void makeseg (void);
void makehead (u_char* dict_name);
/* memory.c */
void* Malloc (size_t size);
void* Zalloc (size_t size);
void Free (void *p);
/* offset.c */
void set_ofsrec (u_char* ptr, int len, int ofs);
int isknjexist (u_char* knj, int len);
void clear_ofsrec (void);
OffsetRec* real_ofsrec (u_char* ptr);
/* readline.c */
int* readline (void);
void setline (void (*func)(int*, int*, int, int*));
/* string.c */
int bubun_str (u_char* p1, int l1, u_char* p2, int l2);
int overlap_str (u_char *p1, int l1, u_char* p2, int l2);
int top_strcmp (int* src, int* dst);
int last_strcmp (int* src, int* dst);
int string_cmp (u_char* p1, int l1, u_char* p2, int l2);
#endif /* _DICTTOLL_H_ */

View file

@ -1,198 +1,198 @@
"カ五1", 91,
"カ五2", 101,
"カ五3", 131,
"カ五4", 141,
"カ五5", 111,
"カ五6", 121,
"カ五7", 151,
"カ五8", 161,
"カ五音便", 185,
"カ変仮", 181,
"カ変終体", 180,
"カ変未", 178,
"カ変命", 182,
"カ変用", 179,
"ガ五1", 92,
"ガ五2", 102,
"ガ五3", 132,
"ガ五4", 142,
"ガ五5", 112,
"ガ五6", 122,
"ガ五7", 152,
"ガ五8", 162,
"サ五1", 93,
"サ五2", 103,
"サ五3", 133,
"サ五4", 143,
"サ五5", 113,
"サ五6", 123,
"サ五7", 153,
"サ五8", 163,
"サ変", 80,
"サ変仮", 175,
"サ変終体", 174,
"サ変未1", 171,
"サ変未2", 172,
"サ変未用", 173,
"サ変命1", 176,
"サ変命2", 177,
"ザ変", 81,
"タ五1", 94,
"タ五2", 104,
"タ五3", 134,
"タ五4", 144,
"タ五5", 114,
"タ五6", 124,
"タ五7", 154,
"タ五8", 164,
"ナ五", 95,
"バ五1", 96,
"バ五2", 105,
"バ五3", 135,
"バ五4", 145,
"バ五5", 115,
"バ五6", 125,
"バ五7", 155,
"バ五8", 165,
"マ五1", 97,
"マ五2", 106,
"マ五3", 136,
"マ五4", 146,
"マ五5", 116,
"マ五6", 126,
"マ五7", 156,
"マ五8", 166,
"ラ五1", 98,
"ラ五2", 107,
"ラ五3", 137,
"ラ五4", 147,
"ラ五5", 117,
"ラ五6", 127,
"ラ五7", 157,
"ラ五8", 167,
"ワ五1", 99,
"ワ五2", 108,
"ワ五3", 138,
"ワ五4", 148,
"ワ五5", 118,
"ワ五6", 128,
"ワ五7", 158,
"ワ五8", 168,
"挨拶", 187,
"衣服", -11,
"一括", 200,
"一段1", 90,
"一段2", 100,
"一段3", 130,
"一段4", 140,
"雨", -21,
"音楽", -20,
"海", -31,
"開閉", -4,
"活動", -5,
"感動", 28,
"企業", 23,
"魚", -14,
"形1", 60,
"形10", 69,
"形11", 70,
"形2", 61,
"形3", 62,
"形4", 63,
"形5", 64,
"形6", 65,
"形7", 66,
"形8", 67,
"形9", 68,
"形動1", 71,
"形動2", 72,
"形動3", 73,
"形動4", 74,
"形動5", 75,
"形動6", 76,
"形動7", 77,
"形動8", 78,
"形動9", 79,
"建築", -13,
"県区", 25,
"湖", -33,
"国", -12,
"試合", -10,
"事件", -27,
"時", -25,
"酒", -23,
"州", -29,
"出版", -18,
"所", -2,
"助数", 29,
"助数2", 54,
"乗物", -17,
"植物", -6,
"食物", -16,
"身体", -8,
"人", -1,
"数詞", 30,
"数詞2", 55,
"接続", 27,
"接頭1", 31,
"接頭2", 32,
"接頭3", 33,
"接頭4", 34,
"接頭5", 35,
"接尾1", 36,
"接尾2", 37,
"接尾3", 38,
"接尾4", 39,
"接尾5", 40,
"接尾6", 41,
"接尾7", 42,
"接尾8", 43,
"接尾9", 44,
"川", -30,
"組織", -3,
"贈物", -26,
"代1", 12,
"代2", 13,
"代3", 14,
"代4", 15,
"代5", 16,
"代6", 17,
"単漢", 189,
"地位", -7,
"地名", 24,
"丁寧1", 183,
"丁寧2", 184,
"電車", -34,
"都市", -24,
"島", -32,
"動物", -9,
"特殊形容", 188,
"特殊副", 186,
"病気", -15,
"苗字", 21,
"副1", 45,
"副2", 46,
"副3", 47,
"副4", 48,
"副5", 49,
"副6", 50,
"副7", 51,
"副8", 52,
"副9", 53,
"文字", -19,
"法", -35,
"名1", 1,
"名10", 10,
"名11", 11,
"名2", 2,
"名20", 18,
"名3", 3,
"名4", 4,
"名5", 5,
"名6", 6,
"名7", 7,
"名8", 8,
"名9", 9,
"名前", 22,
"鳴物", -28,
"連体", 26
{"カ五1", 91},
{"カ五2", 101},
{"カ五3", 131},
{"カ五4", 141},
{"カ五5", 111},
{"カ五6", 121},
{"カ五7", 151},
{"カ五8", 161},
{"カ五音便", 185},
{"カ変仮", 181},
{"カ変終体", 180},
{"カ変未", 178},
{"カ変命", 182},
{"カ変用", 179},
{"ガ五1", 92},
{"ガ五2", 102},
{"ガ五3", 132},
{"ガ五4", 142},
{"ガ五5", 112},
{"ガ五6", 122},
{"ガ五7", 152},
{"ガ五8", 162},
{"サ五1", 93},
{"サ五2", 103},
{"サ五3", 133},
{"サ五4", 143},
{"サ五5", 113},
{"サ五6", 123},
{"サ五7", 153},
{"サ五8", 163},
{"サ変", 80},
{"サ変仮", 175},
{"サ変終体", 174},
{"サ変未1", 171},
{"サ変未2", 172},
{"サ変未用", 173},
{"サ変命1", 176},
{"サ変命2", 177},
{"ザ変", 81},
{"タ五1", 94},
{"タ五2", 104},
{"タ五3", 134},
{"タ五4", 144},
{"タ五5", 114},
{"タ五6", 124},
{"タ五7", 154},
{"タ五8", 164},
{"ナ五", 95},
{"バ五1", 96},
{"バ五2", 105},
{"バ五3", 135},
{"バ五4", 145},
{"バ五5", 115},
{"バ五6", 125},
{"バ五7", 155},
{"バ五8", 165},
{"マ五1", 97},
{"マ五2", 106},
{"マ五3", 136},
{"マ五4", 146},
{"マ五5", 116},
{"マ五6", 126},
{"マ五7", 156},
{"マ五8", 166},
{"ラ五1", 98},
{"ラ五2", 107},
{"ラ五3", 137},
{"ラ五4", 147},
{"ラ五5", 117},
{"ラ五6", 127},
{"ラ五7", 157},
{"ラ五8", 167},
{"ワ五1", 99},
{"ワ五2", 108},
{"ワ五3", 138},
{"ワ五4", 148},
{"ワ五5", 118},
{"ワ五6", 128},
{"ワ五7", 158},
{"ワ五8", 168},
{"挨拶", 187},
{"衣服", -11},
{"一括", 200},
{"一段1", 90},
{"一段2", 100},
{"一段3", 130},
{"一段4", 140},
{"雨", -21},
{"音楽", -20},
{"海", -31},
{"開閉", -4},
{"活動", -5},
{"感動", 28},
{"企業", 23},
{"魚", -14},
{"形1", 60},
{"形10", 69},
{"形11", 70},
{"形2", 61},
{"形3", 62},
{"形4", 63},
{"形5", 64},
{"形6", 65},
{"形7", 66},
{"形8", 67},
{"形9", 68},
{"形動1", 71},
{"形動2", 72},
{"形動3", 73},
{"形動4", 74},
{"形動5", 75},
{"形動6", 76},
{"形動7", 77},
{"形動8", 78},
{"形動9", 79},
{"建築", -13},
{"県区", 25},
{"湖", -33},
{"国", -12},
{"試合", -10},
{"事件", -27},
{"時", -25},
{"酒", -23},
{"州", -29},
{"出版", -18},
{"所", -2},
{"助数", 29},
{"助数2", 54},
{"乗物", -17},
{"植物", -6},
{"食物", -16},
{"身体", -8},
{"人", -1},
{"数詞", 30},
{"数詞2", 55},
{"接続", 27},
{"接頭1", 31},
{"接頭2", 32},
{"接頭3", 33},
{"接頭4", 34},
{"接頭5", 35},
{"接尾1", 36},
{"接尾2", 37},
{"接尾3", 38},
{"接尾4", 39},
{"接尾5", 40},
{"接尾6", 41},
{"接尾7", 42},
{"接尾8", 43},
{"接尾9", 44},
{"川", -30},
{"組織", -3},
{"贈物", -26},
{"代1", 12},
{"代2", 13},
{"代3", 14},
{"代4", 15},
{"代5", 16},
{"代6", 17},
{"単漢", 189},
{"地位", -7},
{"地名", 24},
{"丁寧1", 183},
{"丁寧2", 184},
{"電車", -34},
{"都市", -24},
{"島", -32},
{"動物", -9},
{"特殊形容", 188},
{"特殊副", 186},
{"病気", -15},
{"苗字", 21},
{"副1", 45},
{"副2", 46},
{"副3", 47},
{"副4", 48},
{"副5", 49},
{"副6", 50},
{"副7", 51},
{"副8", 52},
{"副9", 53},
{"文字", -19},
{"法", -35},
{"名1", 1},
{"名10", 10},
{"名11", 11},
{"名2", 2},
{"名20", 18},
{"名3", 3},
{"名4", 4},
{"名5", 5},
{"名6", 6},
{"名7", 7},
{"名8", 8},
{"名9", 9},
{"名前", 22},
{"鳴物", -28},
{"連体", 26}

View file

@ -31,6 +31,8 @@
* $SonyRCSfile: char.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:32 $
*
* $Id$
*/
@ -40,13 +42,12 @@
#include "sj_const.h"
cnvyomi(code)
int code;
int
cnvyomi(int code)
{
register u_short hh;
register u_char high;
register u_char low;
u_short hh;
u_char high;
u_char low;
hh = ((code >> 16) & 0xffff);
high = ((code >> 8) & 0xff);
@ -98,13 +99,12 @@ int code;
}
h2kcode(code)
int code;
int
h2kcode(int code)
{
register u_short hh;
register u_char high;
register u_char low;
u_short hh;
u_char high;
u_char low;
hh = ((code >> 16) & 0xffff);
high = ((code >> 8) & 0xff);
@ -116,12 +116,15 @@ int code;
else
return (code + 0x0100);
}
/* XXX: what should we do if we reach here?
* XXX: I do not know if it is correct, but return 0 for now.
* XXX: Hiroo Ono (2004/07/01) */
return (0);
}
codesize(code)
u_char code;
int
codesize(u_char code)
{
switch (code&KanjiModeMask) {
case ZenHiraAssyuku:
@ -139,11 +142,8 @@ u_char code;
}
output_knj(fp, p, l)
FILE *fp;
register u_char *p;
register int l;
void
output_knj(FILE* fp, u_char* p, int l)
{
while (l > 0) {
switch (*p & KanjiModeMask) {
@ -192,19 +192,15 @@ register int l;
}
output_str(fp, p)
FILE *fp;
char *p;
void
output_str(FILE* fp, char* p)
{
while (*p) { fputc(*p, fp); p++; }
}
output_int(fp, p)
FILE *fp;
int *p;
void
output_int(FILE* fp, int* p)
{
while (*p) {
if (*p < 0x100) {
@ -229,9 +225,8 @@ int *p;
}
yomi2zen(code)
int code;
static int
yomi2zen(int code)
{
static char num[] = {
'0', '1', '2', '3', '4', '5', '6', '7',
@ -268,10 +263,8 @@ int code;
}
output_yomi(fp, p)
FILE *fp;
u_char *p;
void
output_yomi(FILE* fp, u_char* p)
{
int i;

View file

@ -36,7 +36,7 @@
#include <stdio.h>
#include <sys/types.h>
#include "dicttool.h"
struct gram_code {
@ -44,15 +44,14 @@ struct gram_code {
int code;
} gramtbl[] = {
#include "GramTable"
};
#define GramMax (sizeof(gramtbl)/sizeof(struct gram_code) - 1)
int u_strcmp(a, b)
u_char *a, *b;
int
u_strcmp(u_char* a, u_char* b)
{
if (!a || !b) return 0;
@ -68,13 +67,13 @@ u_char *a, *b;
}
int cnvhinsi(buf)
u_char *buf;
int
cnvhinsi(u_char *buf)
{
register int min;
register int max;
register int mid;
register int i;
int min;
int max;
int mid;
int i;
min = 0;
max = GramMax;
@ -105,8 +104,8 @@ u_char *buf;
char *hinsi_str(code)
int code;
char*
hinsi_str(int code)
{
int i;

View file

@ -35,10 +35,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
char *Malloc();
#include "dicttool.h"
typedef struct filelist {
FILE *fp;
@ -48,8 +49,8 @@ typedef struct filelist {
static FileList *flist = NULL;
static char *get_fname(fp)
FILE *fp;
static char*
get_fname(FILE* fp)
{
FileList *p;
@ -58,11 +59,10 @@ FILE *fp;
return "some file";
}
FILE *Fopen(filename, type)
char *filename, *type;
FILE*
Fopen(char* filename, char* type)
{
FILE *fp;
char *p;
FileList *fl;
if (!(fp = fopen(filename, type))) {
@ -79,8 +79,8 @@ char *filename, *type;
return fp;
}
Fclose(fp)
FILE *fp;
void
Fclose(FILE* fp)
{
FileList *p, *q;
@ -102,10 +102,8 @@ FILE *fp;
}
}
Fseek(fp, ofs, ptr)
FILE *fp;
long ofs;
int ptr;
int
Fseek(FILE* fp, long ofs, int ptr)
{
if (fseek(fp, ofs, ptr) == 0) return 0;
@ -113,14 +111,14 @@ int ptr;
exit(1);
}
Ftell(fp)
FILE *fp;
long
Ftell(FILE* fp)
{
return ftell(fp);
}
Fsize(filename)
char *filename;
off_t /* XXX: just looked in FreeBSD's sys/stat.h, need to check SUS spec. */
Fsize(char* filename)
{
struct stat buf;
@ -134,10 +132,8 @@ char *filename;
exit(1);
}
Fread(p, s, n, fp)
char *p;
int s, n;
FILE *fp;
int
Fread(char* p, int s, int n, FILE* fp)
{
if (fread(p, s, n, fp) == n) return n;
@ -145,10 +141,8 @@ FILE *fp;
exit(1);
}
Fwrite(p, s, n, fp)
char *p;
int s, n;
FILE *fp;
int
Fwrite(char* p, int s, int n, FILE* fp)
{
if (fwrite(p, s, n, fp) == n) return n;
@ -156,14 +150,14 @@ FILE *fp;
exit(1);
}
Fgetc(fp)
FILE *fp;
int
Fgetc(FILE* fp)
{
return fgetc(fp);
}
Fflush(fp)
FILE *fp;
void
Fflush(FILE* fp)
{
fflush(fp);
}

View file

@ -31,15 +31,16 @@
* $SonyRCSfile: hindo.c,v $
* $SonyRevision: 1.2 $
* $SonyDate: 1994/08/17 01:50:26 $
*
* $Id$
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include "sj_struct.h"
#include "dicttool.h"
extern HindoRec *hindo[];
extern int hindo_num;
@ -48,13 +49,9 @@ extern HindoRec *askknj[];
extern int askknj_num;
extern int kanji_num;
OffsetRec *real_ofsrec();
check_hindo(ptr, len)
u_char *ptr;
int len;
int
check_hindo(u_char* ptr, int len)
{
int low, high, mid;
int i;
@ -80,8 +77,8 @@ int len;
static AssyukuRec *makeassyuku(num)
int num;
static AssyukuRec*
makeassyuku (int num)
{
AssyukuRec *arec;
@ -101,9 +98,8 @@ int num;
}
static assyuku_len(hrec)
HindoRec *hrec;
static int
assyuku_len(HindoRec* hrec)
{
int org;
int old;
@ -142,12 +138,12 @@ HindoRec *hrec;
static void set_assyuku(hrec)
HindoRec *hrec;
static void
set_assyuku(HindoRec* hrec)
{
register AssyukuRec *arec;
register AssyukuRec *aprev;
register int len;
AssyukuRec *arec;
AssyukuRec *aprev;
int len;
len = assyuku_len(hrec);
@ -195,8 +191,8 @@ HindoRec *hrec;
static void reset_assyuku(hrec)
HindoRec *hrec;
static void
reset_assyuku(HindoRec* hrec)
{
AssyukuRec *arec;
AssyukuRec *aptr;
@ -265,10 +261,8 @@ HindoRec *hrec;
static HindoRec *makehindo(ptr, len, alen)
u_char *ptr;
int len;
int alen;
static HindoRec*
makehindo(u_char* ptr, int len, int alen)
{
HindoRec *hrec;
u_char *p;
@ -306,10 +300,8 @@ int alen;
static void set_hindo(ptr, len, alen)
u_char *ptr;
int len;
int alen;
static void
set_hindo(u_char* ptr, int len, int alen)
{
HindoRec *hrec;
int low, high, mid;
@ -383,9 +375,8 @@ int alen;
static void reset_hindo(p, l)
u_char *p;
int l;
static void
reset_hindo(u_char* p, int l)
{
HindoRec *hrec;
int low, high, mid;
@ -436,15 +427,13 @@ int l;
}
knjhnd_set(p, l)
u_char *p;
int l;
void
knjhnd_set(u_char* p, int l)
{
register u_char *kp1;
register u_char *kp2;
register int i;
register int kl1;
u_char *kp1;
u_char *kp2;
int i;
int kl1;
u_char tmp[MaxKanjiLength * 2 + MaxAtrNumber * 2 + 1];
for (kp1 = p, kl1 = l ; kl1 > 0 ; ) {
@ -472,15 +461,13 @@ int l;
}
knjhnd_reset(p, l)
u_char *p;
int l;
void
knjhnd_reset(u_char* p, int l)
{
register u_char *kp1;
register u_char *kp2;
register int i;
register int kl1;
u_char *kp1;
u_char *kp2;
int i;
int kl1;
u_char tmp[MaxKanjiLength * 2 + MaxAtrNumber * 2 + 1];
for (kp1 = p, kl1 = l ; kl1 > 0 ; ) {
@ -509,9 +496,8 @@ int l;
static check_assyuku(p, q)
register HindoRec *p;
register HindoRec *q;
static int
check_assyuku(HindoRec* p, HindoRec* q)
{
u_char ptmp[128], qtmp[128];
int plen;
@ -536,8 +522,8 @@ register HindoRec *q;
}
decide_knjask()
int
decide_knjask(void)
{
int i, j;
AssyukuRec *p;
@ -616,10 +602,10 @@ end:
}
clear_hindo()
void
clear_hindo(void)
{
register int i;
int i;
for (i = 0 ; i < hindo_num ; i++) {
Free(hindo[i]->kptr);
@ -630,10 +616,10 @@ clear_hindo()
}
clear_assyuku()
void
clear_assyuku(void)
{
register AssyukuRec *p;
AssyukuRec *p;
while (assyuku) {
p = assyuku;

View file

@ -31,15 +31,19 @@
* $SonyRCSfile: knjcvt.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:37 $
*
* $Id$
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include "sj_const.h"
#include "sj_struct.h"
#include "dicttool.h"
typedef struct div_list {
int len;
@ -52,10 +56,10 @@ extern int askknj_num;
static free_divlist(p)
register DivList *p;
static void
free_divlist(DivList* p)
{
register DivList *q;
DivList *q;
while (p) {
q = p -> child;
@ -66,9 +70,10 @@ register DivList *p;
static DivList *make_divrec()
static DivList*
make_divrec(void)
{
register DivList *p;
DivList *p;
p = (DivList *)Malloc(sizeof(DivList));
if (!p) {
@ -82,10 +87,8 @@ static DivList *make_divrec()
static make_divlist(parent, knj, len)
DivList *parent;
u_char *knj;
int len;
static int
make_divlist(DivList* parent, u_char *knj, int len)
{
int i, j;
int num;
@ -192,10 +195,8 @@ int len;
u_char *knjofscvt(ptr, len, ret)
u_char *ptr;
int len;
int *ret;
u_char*
knjofscvt(u_char* ptr, int len, int* ret)
{
int i;
u_char *p, *q;
@ -233,10 +234,8 @@ int *ret;
u_char *knjcvt(ptr, len, ret)
u_char *ptr;
int len;
int *ret;
u_char*
knjcvt(u_char* ptr, int len, int* ret)
{
int i;
u_char *p, *q;
@ -273,4 +272,3 @@ if (i != q - p) {
return p;
}

View file

@ -31,42 +31,32 @@
* $SonyRCSfile: makedict.c,v $
* $SonyRevision: 1.2 $
* $SonyDate: 1994/12/09 11:27:05 $
*
* $Id$
*/
#include "sj_sysvdef.h"
/* #include "sj_sysvdef.h" */ /* XXX: no more need it? */
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#ifdef SVR4
#include <string.h>
#else
#include <strings.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include "sj_const.h"
#include "dicttool.h"
FILE *infp = NULL;
FILE *outfp = NULL;
char *Zalloc();
FILE *Fopen();
static char *idxtop = NULL;
main(argc, argv)
int argc;
char **argv;
int
main(int argc, char** argv)
{
int makelist();
parse(argc, argv);
while (readline()) setline(makelist);
@ -77,9 +67,8 @@ char **argv;
}
char *make_idxlist(name)
char *name;
char*
make_idxlist(char* name)
{
int i;
char *p;
@ -89,8 +78,9 @@ char *name;
strcpy(p, name);
return p;
}
char *get_idxlist(name)
char *name;
char*
get_idxlist(char* name)
{
FILE *fp;
int i;
@ -120,7 +110,7 @@ char *name;
i = 0;
for (q = p ; *q ; ) {
if (fp = fopen(q, "r"))
if ((fp = fopen(q, "r"))!=NULL)
fclose(fp);
else {
fprintf(stderr, "Can't open %s mode \"r\"\n", q);
@ -134,18 +124,14 @@ char *name;
}
parse(argc, argv)
int argc;
char **argv;
void
parse(int argc, char** argv)
{
int i;
char *progname = NULL;
char *p;
extern char *strrchr();
if (progname = strrchr(argv[0], '/'))
if ((progname = strrchr(argv[0], '/'))!=NULL)
progname++;
else
progname = argv[0];
@ -161,11 +147,10 @@ char **argv;
}
get_number(ptr)
register char *ptr;
int
get_number(char* ptr)
{
register int i = 0;
int i = 0;
while (*ptr >= '0' && *ptr <= '9') {
i = i * 10 + (*ptr++ - '0');
@ -175,9 +160,8 @@ register char *ptr;
}
usage(name)
char *name;
void
usage(char* name)
{
fprintf(stderr, "Usage: %s text_file binary_file\n",
name ? name : "encode");
@ -185,8 +169,8 @@ char *name;
}
int getch()
int
getch(void)
{
if (infp) {
int c;
@ -212,9 +196,8 @@ int getch()
}
mark_file(out)
FILE *out;
void
mark_file(FILE* out)
{
static char pathname[MAXPATHLEN];
static long pos;

View file

@ -31,12 +31,17 @@
* $SonyRCSfile: makelist.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:39 $
*
* $Id$
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "sj_struct.h"
#include "dicttool.h"
#ifndef SS2
#define SS2 0x8e
@ -57,10 +62,10 @@ static DouonRec *drectmp = NULL;
static clearklist(krec)
register KanjiRec *krec;
static void
clearklist(KanjiRec* krec)
{
register KanjiRec *p;
KanjiRec *p;
while (krec) {
@ -79,10 +84,10 @@ register KanjiRec *krec;
static clearhlist(hrec)
register HinsiRec *hrec;
static void
clearhlist(HinsiRec* hrec)
{
register HinsiRec *p;
HinsiRec *p;
while (hrec) {
@ -99,11 +104,11 @@ register HinsiRec *hrec;
}
clear_list()
void
clear_list(void)
{
register DouonRec *p;
register DouonRec *drec = douon_ptr;
DouonRec *p;
DouonRec *drec = douon_ptr;
while (drec) {
@ -126,16 +131,13 @@ clear_list()
static u_char *makekanji(yomi, kanji, atr, len)
int *yomi;
int *kanji;
int *atr;
int *len;
static u_char*
makekanji(int *yomi, int* kanji, int* atr, int* len)
{
int kana[MaxYomiLength + 1];
u_char ktmp[MaxKanjiLength * 3 + MaxAtrNumber * 2 + 1];
register int i;
register int pos = 0;
int i;
int pos = 0;
int *p;
u_char *q;
@ -154,12 +156,12 @@ int *len;
}
if (i = top_strcmp(yomi, kanji)) {
if ((i = top_strcmp(yomi, kanji))!=0) {
kanji += i;
ktmp[pos++] = (ZenHiraAssyuku | (i - 1));
}
else if (i = top_strcmp(kana, kanji)) {
else if ((i = top_strcmp(kana, kanji))!=0) {
kanji += i;
ktmp[pos++] = (ZenKataAssyuku | (i - 1));
}
@ -167,12 +169,12 @@ int *len;
while (*kanji) {
if (i = last_strcmp(yomi, kanji)) {
if ((i = last_strcmp(yomi, kanji))!=0) {
kanji += i;
ktmp[pos++] = (ZenHiraAssyuku | (i - 1));
}
else if (i = last_strcmp(kana, kanji)) {
else if ((i = last_strcmp(kana, kanji))!=0) {
kanji += i;
ktmp[pos++] = (ZenKataAssyuku | (i - 1));
}
@ -216,14 +218,14 @@ int *len;
static u_char *makeyomi(yomi)
int *yomi;
static u_char*
makeyomi(int* yomi)
{
u_char tmp[MaxYomiLength + 1];
register int i;
register int j;
register int *y = yomi;
register u_char *p;
int i;
int j;
int *y = yomi;
u_char *p;
for (i = 0 ; *y ; ) {
@ -250,11 +252,10 @@ int *yomi;
static KanjiRec *make_krec(kcode, klen)
u_char *kcode;
int klen;
static KanjiRec*
make_krec(u_char* kcode, int klen)
{
register KanjiRec *krec;
KanjiRec *krec;
krec = (KanjiRec *)Malloc(sizeof(KanjiRec));
@ -275,10 +276,10 @@ int klen;
static HinsiRec *make_hrec(hinsi)
int hinsi;
static HinsiRec*
make_hrec(int hinsi)
{
register HinsiRec *hrec;
HinsiRec *hrec;
hrec = (HinsiRec *)Malloc(sizeof(HinsiRec));
@ -297,10 +298,10 @@ int hinsi;
static DouonRec *make_drec(ycode)
u_char *ycode;
static DouonRec*
make_drec(u_char* ycode)
{
register DouonRec *drec;
DouonRec *drec;
drec = (DouonRec *)Malloc(sizeof(DouonRec));
@ -320,14 +321,14 @@ u_char *ycode;
static diff_ylen(drec)
DouonRec *drec;
static int
diff_ylen(DouonRec *drec)
{
register DouonRec *dptr;
register DouonRec *dprev;
register u_char *p1;
register u_char *p2;
register int ylen = 0;
DouonRec *dptr;
DouonRec *dprev;
u_char *p1;
u_char *p2;
int ylen = 0;
dptr = douon_ptr; dprev = NULL;
@ -364,8 +365,8 @@ DouonRec *drec;
static douon_knj(drec)
DouonRec *drec;
static int
douon_knj(DouonRec* drec)
{
int i;
int len = 0;
@ -402,8 +403,8 @@ DouonRec *drec;
static void make_d_list(drec)
DouonRec *drec;
static void
make_d_list(DouonRec* drec)
{
DouonRec *dptr, *dprev;
HinsiRec *hptr;
@ -528,8 +529,8 @@ start:
}
flush_douon()
void
flush_douon(void)
{
if (drectmp) {
@ -561,11 +562,7 @@ flush_douon()
void
makelist(yomi, kanji, hinsi, atr)
int *yomi;
int *kanji;
int hinsi;
int *atr;
makelist(int* yomi, int* kanji, int hinsi, int* atr)
{
u_char *ycode;
u_char *kcode;

View file

@ -31,13 +31,20 @@
* $SonyRCSfile: makeseg.c,v $
* $SonyRevision: 1.2 $
* $SonyDate: 1994/12/09 11:27:05 $
*
* $Id$
*/
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>
#include "sj_struct.h"
#include "../../include/Dict.h"
#include "dicttool.h"
extern HindoRec *askknj[];
extern int askknj_num;
@ -45,18 +52,13 @@ extern DouonRec *douon_ptr;
extern FILE *outfp;
extern int douon_num;
static u_char index[MainSegmentLength];
static u_char segindex[MainSegmentLength];
static int idxpos = 0;
static int idxnum = 0;
OffsetRec *real_ofsrec();
u_char *knjcvt();
static u_char *set_ofsask(src, dst)
u_char *src;
u_char *dst;
static u_char*
set_ofsask(u_char* src, u_char* dst)
{
int len;
u_char *ptr;
@ -106,11 +108,8 @@ u_char *dst;
}
make_knjstr(src, len, dst)
u_char *src;
int len;
u_char *dst;
size_t
make_knjstr(u_char* src, int len, u_char* dst)
{
u_char *keep = dst;
@ -157,9 +156,10 @@ u_char *dst;
static make_knjask()
static int
make_knjask(void)
{
int i, j;
int i;
u_char *p;
u_char buf[128];
int len;
@ -195,7 +195,7 @@ static make_knjask()
void
makeseg()
makeseg(void)
{
u_char buf[MainSegmentLength];
DouonRec *drec;
@ -307,7 +307,7 @@ makeseg()
for (p = douon_ptr -> yptr ; ; ) {
if (idxpos < MainIndexLength) {
index[idxpos++] = *p;
segindex[idxpos++] = *p;
}
else {
fprintf(stderr, "\245\244\245\363\245\307\245\303\245\257\245\271\244\254\244\242\244\325\244\354\244\336\244\267\244\277\n");
@ -316,7 +316,7 @@ makeseg()
if (!*p++) break;
}
if (idxpos < MainIndexLength) {
index[idxpos] = 0;
segindex[idxpos] = 0;
}
else {
fprintf(stderr, "\245\244\245\363\245\307\245\303\245\257\245\271\244\254\244\242\244\325\244\354\244\336\244\267\244\277\n");
@ -374,9 +374,8 @@ err:
#undef datset
}
static void put4byte(p, n)
u_char *p;
long n;
static void
put4byte(u_char* p, size_t n)
{
p += 3;
*p-- = n; n >>= 8;
@ -384,27 +383,28 @@ long n;
*p-- = n; n >>= 8;
*p = n;
}
void makehead(dict_name)
u_char *dict_name;
void
makehead(u_char* dict_name)
{
u_char header[HeaderLength + CommentLength];
long i;
u_char *p;
time_t curtime;
#define IndexPos (HeaderLength + CommentLength)
memset(header, '\0', sizeof(header));
put4byte(header + VersionPos, DictVersion);
time(&i);
time(&curtime);
p = header + CommentPos;
sprintf((char *)p, "%s : %s", dict_name, ctime(&i));
sprintf((char *)p, "%s : %s", dict_name, ctime(&curtime));
while (*p) {
if (*p == '\n') { *p = 0; break; }
p++;
}
}
i = IndexPos;
put4byte(header + DictIdxPos, i);
put4byte(header + DictIdxLen, MainIndexLength);
i += MainIndexLength;
@ -423,7 +423,7 @@ u_char *dict_name;
Fseek(outfp, (long)HeaderPos, 0);
Fwrite(header, sizeof(header), 1, outfp);
Fseek(outfp, (long)IndexPos, 0);
Fwrite(index, MainIndexLength, 1, outfp);
Fwrite(segindex, MainIndexLength, 1, outfp);
#undef IndexPos
}

View file

@ -31,16 +31,21 @@
* $SonyRCSfile: memory.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:42 $
*
* $Id$
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "dicttool.h"
char *Malloc(size)
unsigned size;
void*
Malloc(size_t size)
{
char *p;
char *malloc();
void* p;
p = malloc(size);
if (p == NULL) {
@ -50,18 +55,18 @@ unsigned size;
return p;
}
char *Zalloc(size)
int size;
void*
Zalloc (size_t size)
{
char *p;
void* p;
p = Malloc(size);
memset(p, '\0', size);
return p;
}
void Free(p)
char *p;
void
Free(void *p)
{
free(p);
}

View file

@ -37,18 +37,19 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "sj_struct.h"
#include "dicttool.h"
extern OffsetRec *ofsrec[];
extern int ofsrec_num;
static OffsetRec *makeoffset(ptr, len, ofs)
u_char *ptr;
int len;
int ofs;
static OffsetRec*
makeoffset(u_char* ptr, int len, int ofs)
{
OffsetRec *orec;
u_char *p;
@ -73,10 +74,7 @@ int ofs;
void
set_ofsrec(ptr, len, ofs)
u_char *ptr;
int len;
int ofs;
set_ofsrec(u_char* ptr, int len, int ofs)
{
OffsetRec *orec;
int low, high, mid;
@ -122,10 +120,8 @@ int ofs;
}
isknjexist(knj, len)
u_char *knj;
int len;
int
isknjexist(u_char* knj, int len)
{
int low, high, mid;
int i;
@ -150,8 +146,8 @@ int len;
}
clear_ofsrec()
void
clear_ofsrec(void)
{
int i;
@ -165,8 +161,8 @@ clear_ofsrec()
OffsetRec *real_ofsrec(ptr)
u_char *ptr;
OffsetRec*
real_ofsrec(u_char* ptr)
{
int ofs;
int i;

View file

@ -31,18 +31,20 @@
* $SonyRCSfile: readline.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:44 $
*
* $Id$
*/
#include <stdio.h>
#include <stdlib.h>
#include "sj_euc.h"
#include "sj_const.h"
#include "sj_macro.h"
#include "dicttool.h"
static long lineloc;
/* static long lineloc; */
static int yomi[MaxYomiLength + 1];
static int kanji[MaxKanjiLength + 1];
static int hinsi[MaxHinsiNumber + 1];
@ -50,11 +52,9 @@ static int atr[MaxAtrNumber + 1];
static error(s)
char *s;
static void
error(char *s)
{
register int c;
if (s) fprintf(stderr, "%s\n", s);
mark_file(stderr);
@ -63,10 +63,11 @@ char *s;
static readchar()
static int
readchar(void)
{
register int c1;
register int c2;
int c1;
int c2;
c1 = getch(); if (c1 == EOF) return EOF;
@ -89,9 +90,10 @@ static readchar()
static skip_blank()
static int
skip_blank(void)
{
register int c;
int c;
c = readchar();
while (Isblank(c)) c = readchar();
@ -102,10 +104,11 @@ static skip_blank()
static readhinsi()
static int
readhinsi(void)
{
static int c = 0;
register int i;
int i;
unsigned char hinsi[128];
int flg;
@ -182,11 +185,12 @@ retry:
int *readline()
int*
readline(void)
{
register int c;
register int i;
register int j;
int c;
int i;
int j;
for ( ; ; ) {
@ -243,7 +247,7 @@ int *readline()
i = j = 0;
while (c = readhinsi()) {
while ((c = readhinsi())!=0) {
if (c < 0) {
if (i >= MaxAtrNumber) error(TooManyAtr);
atr[i++] = -c;
@ -262,11 +266,10 @@ int *readline()
}
setline(func)
int (*func)();
void
setline(void (*func)(int*, int*, int, int*))
{
register int i;
int i;
for (i = 0 ; hinsi[i] ; i++) (*func)(yomi, kanji, hinsi[i], atr);
}

View file

@ -31,24 +31,23 @@
* $SonyRCSfile: string.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:45 $
*
* $id$
*/
#include <stdio.h>
#include <sys/types.h>
#include "sj_const.h"
#include "dicttool.h"
bubun_str(p1, l1, p2, l2)
u_char *p1;
int l1;
u_char *p2;
int l2;
int
bubun_str(u_char* p1, int l1, u_char* p2, int l2)
{
register u_char *p;
register int l;
register int i;
u_char *p;
int l;
int i;
for (p = p1, l = l1 ; l > 0 ; ) {
@ -83,16 +82,13 @@ int l2;
overlap_str(p1, l1, p2, l2)
u_char *p1;
u_char *p2;
int l1;
int l2;
int
overlap_str(u_char *p1, int l1, u_char* p2, int l2)
{
register u_char *p;
register int l;
register int i;
register int j;
u_char *p;
int l;
int i;
int j;
u_char tmp[MaxKanjiLength * 2 + MaxAtrNumber * 2];
for (p = p1, l = l1 ; l > 0 ; ) {
@ -150,11 +146,10 @@ int l2;
}
istrlen(s)
int *s;
size_t
istrlen(int* s)
{
register int *p;
int *p;
for (p = s ; *p ; p++) ;
@ -162,10 +157,8 @@ int *s;
}
istrcmp(s, d)
register int *s;
register int *d;
int
istrcmp(int* s, int* d)
{
for ( ; *s && (*s == *d) ; s++, d++) ;
@ -173,12 +166,10 @@ register int *d;
}
top_strcmp(src, dst)
register int *src;
register int *dst;
int
top_strcmp(int* src, int* dst)
{
register int i = 0;
int i = 0;
for (i = 0 ; *src && (*src == *dst) ; src++, dst++)
@ -189,10 +180,8 @@ register int *dst;
}
last_strcmp(src, dst)
int *src;
int *dst;
int
last_strcmp(int* src, int* dst)
{
int slen, dlen;
@ -213,12 +202,8 @@ int *dst;
}
string_cmp(p1, l1, p2, l2)
register u_char *p1;
register u_char *p2;
register int l1;
register int l2;
int
string_cmp(u_char* p1, int l1, u_char* p2, int l2)
{
while (l1 > 0 && l2 > 0) {
if (*p1 != *p2) return (*p1 - *p2);

View file

@ -31,6 +31,8 @@
* $SonyRCSfile: Const.h,v $
* $SonyRevision: 1.4 $
* $SonyDate: 1997/01/23 11:20:52 $
*
* $Id$
*/
/*
@ -38,6 +40,9 @@
* Patched by Hidekazu Kuroki(hidekazu@cs.titech.ac.jp) 1996/8/10
*/
#ifndef _Const_H_
#define _Const_H_ 1
#include "Paths.h"
#define HostNameLen 128
@ -96,3 +101,4 @@
# define FALSE (!TRUE)
#endif
#endif /* _Const_H_ */

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 1997 Sony Corporation
* Copyright (c) 1996 Hidekazu Kuroki <hidekazu at cs.titech.ac.jp>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the

View file

@ -31,15 +31,22 @@
* $SonyRCSfile: Struct.h,v $
* $SonyRevision: 1.3 $
* $SonyDate: 1994/10/21 05:13:34 $
*
* $Id$
*/
#ifndef _Struct_H_
#define _Struct_H_ 1
#include <sys/types.h>
#include <stdio.h>
#include "sj_const.h"
#include "sj_dict.h"
#include "sj_struct.h"
#include "sj_var.h"
#include "Const.h"
typedef struct global {
JREC *Jmaxjptr;
CLREC *Jmaxclptr;
JREC *Jjrt1st;
@ -48,111 +55,76 @@ typedef struct global {
CLREC *Jclt2nd;
CLREC *Jselcl;
short Jselectid;
short Jtrank;
short Jnrank;
u_char *Jinputyomi;
u_char *Jcnvstart;
short Jcnvlen;
u_char *Jystart;
u_char Jhyomi[MaxPhInputLen+1];
u_char Jorgyomi[MaxClInputLen*2+1];
Short Jselectid;
Short Jtrank;
Short Jnrank;
u_char Jkanjibuf[MinPhOutputLen];
u_char *Jkanjipos;
u_char *Jkanjitmp;
short Jkanjilen;
Uchar *Jinputyomi;
Uchar *Jcnvstart;
Short Jcnvlen;
Uchar *Jystart;
Uchar Jhyomi[MaxPhInputLen+1];
Uchar Jorgyomi[MaxClInputLen*2+1];
Uchar Jkanjibuf[MinPhOutputLen];
Uchar *Jkanjipos;
Uchar *Jkanjitmp;
Short Jkanjilen;
Uchar Jdicinl;
Uchar Jdicsaml;
u_char Jdicinl;
u_char Jdicsaml;
TypeDicSeg Jprevseg;
Uchar Jfzkcount;
Uchar Jfzk_ka_flg;
u_char Jfzkcount;
u_char Jfzk_ka_flg;
FREC Jfzktbl[MAXFREC];
u_char Jheadcode;
u_char Jheadlen;
Uchar Jheadcode;
Uchar Jheadlen;
Uchar Jgobilen;
u_char Jgobilen;
TypeGram Jprevclgrm;
TypeCnct Jprevclrow;
Uchar Jnextcllen;
u_char Jnextcllen;
Short Jkhcount;
Short Jnkhcount;
short Jkhcount;
short Jnkhcount;
KHREC Jkouhotbl[MaxKouhoNumber];
STDYIN *Jstdytop;
DICT *Jcurdict;
DICTL *Jdictlist;
Uchar *Jdicbuf;
Uchar *Jidxbuf;
u_char *Jdicbuf;
u_char *Jidxbuf;
TypeIdxOfs *Jidxofs;
Uchar *Jaskknj[MaxKnjAskNumber];
Uchar *Jaskknj_k[MaxKnjAskNumber];
u_char *Jaskknj[MaxKnjAskNumber];
u_char *Jaskknj_k[MaxKnjAskNumber];
STDY *Jcurstdy;
Ushort Jsuuji_wbuf[NumWordBuf];
Uchar Jsuuji_ubuf[NumKetaLength];
u_short Jsuuji_wbuf[NumWordBuf];
u_char Jsuuji_ubuf[NumKetaLength];
TypeClass Jsuuji_class;
Uchar Jsuuji_comma;
Uchar Jsuuji_keta;
Uchar *Jsuuji_yptr;
Uchar Jsuuji_len;
Uchar Jsuuji_exit;
Ushort *Jsuuji_wkeep;
Uchar *Jsuuji_ukeep;
u_char Jsuuji_comma;
u_char Jsuuji_keta;
u_char *Jsuuji_yptr;
u_char Jsuuji_len;
u_char Jsuuji_exit;
u_short *Jsuuji_wkeep;
u_char *Jsuuji_ukeep;
Uchar Jpeepyomi[MaxWdYomiLen * 2 + 1];
Uchar Jpeepknj[MaxWdKanjiLen + 1];
u_char Jpeepyomi[MaxWdYomiLen * 2 + 1];
u_char Jpeepknj[MaxWdKanjiLen + 1];
TypeGram Jpeepgrm;
Uchar *Jpeepdptr;
Uchar *Jpeephptr;
Uchar *Jpeepkptr;
u_char *Jpeepdptr;
u_char *Jpeephptr;
u_char *Jpeepkptr;
TypeDicSeg Jpeepidx;
} Global;
typedef struct dictfile {
DICT dict;
int refcnt;
@ -160,7 +132,7 @@ typedef struct dictfile {
FILE *fp;
int fd;
Uchar *buffer;
u_char *buffer;
long bufsiz;
long idxstrt;
@ -172,8 +144,6 @@ typedef struct dictfile {
} DictFile;
typedef struct stdyfile {
STDY stdy;
int refcnt;
@ -181,14 +151,12 @@ typedef struct stdyfile {
FILE *fp;
int fd;
Uchar *header;
u_char *header;
struct stdyfile *link;
} StdyFile;
typedef struct workarea {
int refcnt;
int lock;
@ -199,8 +167,6 @@ typedef struct workarea {
} WorkArea;
typedef struct client {
int fd;
char host[HostNameLen];
@ -210,10 +176,13 @@ typedef struct client {
WorkArea *work;
StdyFile *stdy;
short version;
unsigned char def_char[2];
u_char def_char[2];
#if (defined(TLI) && defined(SOCK_UNIX))
int unix_flag;
#endif
uid_t uid;
struct client *next;
} Client;
#endif /* _Struct_H_ */

View file

@ -1,66 +0,0 @@
/*
* 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: sj3lowlib.h,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:59 $
*/
typedef struct sj3_client_env {
int fd;
int serv_dead_flg;
int stdy_size;
short svr_version;
short cli_version;
char default_char[2];
} SJ3_CLIENT_ENV;
#ifndef SJ3_NAME_LENGTH
# define SJ3_NAME_LENGTH 128
#endif
typedef struct sj3_who_struct {
int fd;
char hostname[SJ3_NAME_LENGTH];
char username[SJ3_NAME_LENGTH];
char progname[SJ3_NAME_LENGTH];
} SJ3_WHO_STRUCT;
#define MBCODE_SJIS 1
#define MBCODE_EUC 2

View file

@ -31,15 +31,15 @@
* $SonyRCSfile: sj_const.h,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:01 $
*
* $Id$
*/
#ifndef _SJ_CONST_H_
#define _SJ_CONST_H_ 1
#ifndef _SJ_CONST
#define _SJ_CONST
#include "sj_euc.h"
@ -50,11 +50,10 @@
#define UNDER 4
#ifndef FALSE
#define FALSE 0
#define TRUE -1
#endif /* FALSE */
@ -196,4 +195,4 @@
#define NumWordBuf ((NumKetaLength+3)/4)
#endif
#endif /* _SJ_CONST_H_ */

51
include/sj_func.h Normal file
View file

@ -0,0 +1,51 @@
/*
* Copyright (c) 2004 Hiroo Ono <hiroo+sj3 at oikumene.gcd.org>
*
* 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.
*
*/
/*
* $Id: sj_func.h,v 1.1 2004/07/04 08:15:19 hiroo Exp $
*/
#ifndef _SJ_FUNC
#define _SJ_FUNC 1
#include <sys/types.h>
#include "sj_typedef.h"
#include "sj_struct.h"
#include "Struct.h"
typedef void (*VFuncNT)(u_char*, u_char*, JREC*);
typedef int (*IFuncSetj)(u_char*);
typedef int (*IFuncHira)(u_char*, int*);
typedef u_char* (*UCPFuncGK)(u_char*, u_char*, u_char*, int, int);
typedef u_char* (*UCPFuncMK)(u_char*, u_char*, int);
#endif /* _SJ_FUNC */

View file

@ -467,15 +467,9 @@
#define memcpy Jmemcpy
#define sstrncpy Jsstrncpy
#define memset Jmemset
#define mvmemd Jmvmemd

View file

@ -31,32 +31,31 @@
* $SonyRCSfile: sj_struct.h,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:16 $
*
* $Id$
*/
#ifndef _SJ_STRUCT
#define _SJ_STRUCT 1
#define _SJ_STRUCT
#include <sys/types.h>
#include "sj_typedef.h"
typedef struct jiritu {
struct jiritu *jsort;
TypeDicSeg jseg;
TypeDicOfs jofsst;
TypeDicOfs jofsed;
Ushort flags;
u_short flags;
TypeClass class;
TypeDicID dicid;
Uchar jlen;
u_char jlen;
TypeGram hinsi;
Uchar sttofs;
Uchar stbofs;
Uchar count;
Uchar numlen;
u_char sttofs;
u_char stbofs;
u_char count;
u_char numlen;
} JREC;
@ -65,16 +64,16 @@ typedef struct jiritu {
typedef struct bunsetu {
JREC *jnode;
struct bunsetu *clsort;
Uchar gobiln;
Uchar cllen;
u_char gobiln;
u_char cllen;
TypeCnct right;
Uchar cl2len;
Uchar kubun;
u_char cl2len;
u_char kubun;
#if __STDC__
unsigned fzk_ka : 1;
u_int fzk_ka : 1;
#else
Uchar fzk_ka : 1;
u_char fzk_ka : 1;
#endif
} CLREC;
@ -85,19 +84,19 @@ typedef struct kouho {
CLREC *clrec;
TypeDicOfs offs;
TypeStyNum styno;
Uchar rank;
u_char rank;
#if __STDC__
unsigned sttfg : 1;
unsigned sttkj : 1;
unsigned ka_fg : 1;
unsigned ka_kj : 1;
unsigned mode : 4;
u_int sttfg : 1;
u_int sttkj : 1;
u_int ka_fg : 1;
u_int ka_kj : 1;
u_int mode : 4;
#else
Uchar sttfg : 1;
Uchar sttkj : 1;
Uchar ka_fg : 1;
Uchar ka_kj : 1;
Uchar mode : 4;
u_char sttfg : 1;
u_char sttkj : 1;
u_char ka_fg : 1;
u_char ka_kj : 1;
u_char mode : 4;
#endif
} KHREC;
@ -105,7 +104,7 @@ typedef struct kouho {
typedef struct conj {
Uchar len;
u_char len;
TypeCnct right;
} CREC;
@ -113,8 +112,8 @@ typedef struct conj {
typedef struct fuzoku {
Uchar *yomip;
Uchar TFar *fzkp;
u_char *yomip;
u_char *fzkp;
} FREC;
@ -126,13 +125,13 @@ typedef struct study_in {
TypeStyNum styno;
TypeDicID dicid;
#if __STDC__
unsigned sttkj : 1;
unsigned ka_kj : 1;
unsigned nmflg : 1;
u_int sttkj : 1;
u_int ka_kj : 1;
u_int nmflg : 1;
#else
Uchar sttkj : 1;
Uchar ka_kj : 1;
Uchar nmflg : 1;
u_char sttkj : 1;
u_char ka_kj : 1;
u_char nmflg : 1;
#endif
} STDYIN;
@ -142,20 +141,22 @@ typedef struct study_in {
typedef struct study_out {
STDYIN stdy1;
TypeGram hinshi;
Uchar len;
u_char len;
#if __STDC__
unsigned sttlen : 2;
unsigned sttfg : 1;
unsigned ka_fg : 1;
u_int sttlen : 2;
u_int sttfg : 1;
u_int ka_fg : 1;
#else
Uchar sttlen : 2;
Uchar sttfg : 1;
Uchar ka_fg : 1;
u_char sttlen : 2;
u_char sttfg : 1;
u_char ka_fg : 1;
#endif
} STDYOUT;
struct dictfile; /* defined later in Struct.h refering DICT */
typedef int (*IFuncDF)(struct dictfile*);
typedef int (*IFuncDFTD)(struct dictfile*, TypeDicSeg);
typedef struct dict {
TypeDicID dicid;
@ -166,12 +167,12 @@ typedef struct dict {
TypeDicSeg segunit;
TypeDicSeg maxunit;
IFunc getofs;
IFunc getidx;
IFunc getdic;
IFunc putidx;
IFunc putdic;
IFunc rszdic;
IFuncDF getofs;
IFuncDF getidx;
IFuncDFTD getdic;
IFuncDFTD putidx;
IFuncDFTD putdic;
IFuncDFTD rszdic;
} DICT;
@ -186,15 +187,15 @@ typedef struct dictl {
typedef struct stdy {
Short stdycnt;
Short stdymax;
short stdycnt;
short stdymax;
STDYIN *stdydic;
Short clstdystep;
Ushort *clstdyidx;
short clstdystep;
u_short *clstdyidx;
Short clstdylen;
Uchar *clstdydic;
short clstdylen;
u_char *clstdydic;
} STDY;
#endif

View file

@ -31,80 +31,66 @@
* $SonyRCSfile: sj_table.h,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:21 $
*
* $Id$
*/
#ifndef _SJ_TABLE
#define _SJ_TABLE 1
#define _SJ_TABLE
#include "sj_typedef.h"
#include "sj_func.h"
#define isdpnd(c) (Chrtbl[c] & DEPEND)
#define CnjAskLen(p) (((unsigned int) *(p) & 0x70) >> 4)
#define CnjNkrLen(p) (*(p) & 0x0f)
#define CnjRight(p) *(p + CnjNkrLen(p) + 1)
#define CnjRecLen(p) (CnjNkrLen(p) + 2)
#define FzkAskLen(p) ((unsigned int) *(p) >> 5)
#define FzkNkrLen(p) (*(p) & 0x07)
#define FzkStrKa(p) (((unsigned int) *(p) >> 3) & 1)
#define FzkHasCode(p) (*(p) & 0x10)
#define FzkLeft(p) (*((p) + nlen + 1))
#define FzkRight(p) (*((p) + nlen + 2))
#define SttYomiLen(p) (*(p) & 0x0f)
#define SttHiraKnj(p) (*(p) & 0x80)
#define StbKnjLen(p) (*(p) & 0x07)
#define StbYomiLen(p) (*(p) >> 4)
#define StbYomiTop(p) ((p) + 2)
#define StbBakeru(p) (*(p) & 0x08)
#define StbHinsi(p) (*((p) + 1))
extern Uchar charsize[], chrtbl[], *conjadr[], connadr[];
extern Uchar *fzkadr[], kigou[], kurai1_tbl[], kurai2_tbl[];
extern Uchar num1tbl[], num2tbl[], num3tbl[], num4tbl[];
extern Uchar num5tbl[], num6tbl[], *rigtadr[], scncttbl[2][24];
extern Uchar *settou_ptr[], *stbadr[], sttpri[5][31];
extern Uchar suuji_tbl[], taipri[7][45], termtbl[];
extern Ushort *selsjadrs[];
extern UCPFunc getkan_func[], makekan_func[];
extern VFunc cvtnum_func[];
extern IFunc hiraknj_func[], setjrec_func[], srchg_func[];
extern u_char charsize[], chrtbl[], *conjadr[], connadr[];
extern u_char *fzkadr[], kigou[], kurai1_tbl[], kurai2_tbl[];
extern u_char num1tbl[], num2tbl[], num3tbl[], num4tbl[];
extern u_char num5tbl[], num6tbl[], *rigtadr[], scncttbl[2][24];
extern u_char *settou_ptr[], *stbadr[], sttpri[5][31];
extern u_char suuji_tbl[], taipri[7][45], termtbl[];
extern u_short *selsjadrs[];
extern UCPFuncGK getkan_func[];
extern UCPFuncMK makekan_func[];
extern VFuncNT cvtnum_func[];
extern IFuncSetj setjrec_func[];
/* extern IFunc srchg_func[]; */ /* does it exist? */
extern IFuncHira hiraknj_func[];
#define Charsize charsize
#define Chrtbl chrtbl
#define Conjadr(i) conjadr[i]
@ -135,4 +121,4 @@ extern IFunc hiraknj_func[], setjrec_func[], srchg_func[];
#define Taipri(i, j) taipri[i][j]
#define Termtbl termtbl
#endif
#endif /* _SJ_TABLE */

View file

@ -31,13 +31,13 @@
* $SonyRCSfile: sj_typedef.h,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:22 $
*
* $Id$
*/
#ifndef _SJ_TYPEDEF
#define _SJ_TYPEDEF
#define _SJ_TYPEDEF 1
#define RECURS
@ -62,27 +62,23 @@
#define Long long
#define Ulong unsigned long
typedef Void (*VFunc)();
typedef Uchar *(*UCPFunc)();
typedef Int (*IFunc)();
#include <sys/types.h>
typedef Uchar TypeGroup;
typedef Uchar TypeGram;
typedef Ushort TypeIdxOfs;
typedef Short TypeDicSeg;
typedef Ushort TypeDicOfs;
typedef u_char TypeGroup;
typedef u_char TypeGram;
typedef u_short TypeIdxOfs;
typedef short TypeDicSeg;
typedef u_short TypeDicOfs;
typedef ino_t TypeDicID;
typedef Uchar TypeCnct;
typedef Ushort TypeStyNum;
typedef Uchar TypeClass;
typedef Uchar TypeBunNum;
typedef u_char TypeCnct;
typedef u_short TypeStyNum;
typedef u_char TypeClass;
typedef u_char TypeBunNum;
#ifndef NULL
# define NULL 0
#endif
#endif
#endif /* _SJ_TYPEDEF */

View file

@ -31,49 +31,34 @@
* $SonyRCSfile: adddic.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:26 $
*
* $Id$
*/
#include <sys/types.h>
#include <string.h>
#include "sj_euc.h"
#include "sj_kcnv.h"
#include "kanakan.h"
Uchar *srchdict(), *skipkstr(), *get_idxptr();
Int sstrncmp(), study(), cmpstr();
Int cvtknj();
Int srchkana(), srchgram(), getkanji();
Int sstrlen(), srchkanji();
Uint addel_arg();
Void memset(), mvmemi(), mkclidx(), mkidxtbl();
Void mvmemd(), set_size(), delclsub();
TypeDicSeg srchidx();
TypeIdxOfs count_uidx();
static u_int checkdict(u_char* kanji, TypeGram grm);
static int cal_nextym(u_char* ptr);
static int usr_freelen(void);
static void sprt_seg(TypeDicSeg seg, TypeDicOfs ofs);
static void apnd_uidx(TypeDicSeg seg, u_char* yomi, int len);
Void chg_uidx();
Static Void sprt_seg(), apnd_uidx();
Static Int cal_nextym(), usr_freelen();
Static Uint checkdict();
Uint adddic(yomi, kanji, hinsi)
Uchar *yomi;
Uchar *kanji;
TypeGram hinsi;
u_int
adddic(u_char* yomi, u_char* kanji, TypeGram hinsi)
{
Uint err;
Uchar yptr[MaxWdYomiLen+1];
Uchar kptr[MaxWdKanjiLen+1];
Int klen;
u_int err;
u_char yptr[MaxWdYomiLen+1];
u_char kptr[MaxWdKanjiLen+1];
int klen;
TypeDicSeg segnum;
Int saml;
int saml;
TypeDicOfs dstofs;
TypeDicOfs douofs;
TypeDicOfs hnsofs;
@ -83,56 +68,46 @@ TypeGram hinsi;
TypeDicOfs oldsiz;
TypeDicOfs fresiz;
TypeIdxOfs freidx;
Uchar *douptr;
Uchar *dstptr;
u_char *douptr;
u_char *dstptr;
TypeDicOfs pos;
Uchar *p1;
Int i;
Int nlen, plen;
Int size;
u_char *p1;
int i;
int nlen, plen;
int size;
STDYIN *stdy;
STDYOUT stdydat;
if (err = addel_arg(yomi, kanji, hinsi, yptr, sizeof(yptr)))
if ((err = addel_arg(yomi, kanji, hinsi, yptr, sizeof(yptr))) != 0)
return err;
inputyomi = yomi;
cnvstart = ystart = yptr;
cnvlen = sstrlen(yptr);
if (err = checkdict(kanji, hinsi)) return err;
cnvlen = strlen(yptr);
if ((err = checkdict(kanji, hinsi)) != 0)
return err;
if (!curdict -> maxunit) return AD_NotUserDict;
klen = cvtknj(yomi, kanji, kptr);
newsiz = DouonBlkSizeNumber + cnvlen + (klen !=0 ? klen+1 : 0) + 2;
if (newsiz > MaxDouonBlk) return AD_OvflwDouBlk;
if (newsiz > curdict->seglen) return AD_OvflwDouBlk;
segnum = srchidx((TypeDicSeg)DicSegBase, cnvlen);
for ( ; ; ) {
(*curdict->getdic)(curdict, segnum);
i = srchkana(&p1, &saml);
dstofs = douofs = p1 - dicbuf;
hnsofs = knjofs = 0;
if (i) {
i = srchgram(p1, &p1, hinsi);
dstofs = hnsofs = p1 - dicbuf;
if (i) {
srchkanji(&p1, kptr, klen);
if (*p1 != HinsiBlkTerm) return AD_ArExist;
dstofs = knjofs = p1 - dicbuf;
@ -141,13 +116,11 @@ TypeGram hinsi;
p1 = dicbuf + douofs;
if (!hnsofs) {
oldsiz = 0;
nlen = cnvlen - saml;
newsiz = DouonBlkSizeNumber + nlen;
nxtask = cal_nextym(p1);
}
else {
@ -158,61 +131,45 @@ TypeGram hinsi;
newsiz += (klen != 0 ? klen+1 : 0);
fresiz = usr_freelen();
if ((unsigned int) (newsiz - oldsiz - nxtask) <=
(unsigned int) fresiz) break;
if (segend(p1) && (segnum + 1 < curdict->segunit)) {
segnum++;
continue;
}
if (curdict->segunit >= curdict->maxunit)
return AD_OvflwUsrDic;
freidx = count_uidx();
if ((unsigned int) (douofs + newsiz) <= curdict->seglen) {
if (hnsofs) p1 = getntag(p1);
pos = p1 - dicbuf;
nlen = getnlen(p1);
if ((unsigned int) freidx < getplen(p1) + nlen + 1)
return AD_OvflwIndex;
if ((*curdict->putdic)(curdict, curdict->segunit))
return AD_OvflwUsrDic;
sprt_seg(segnum, pos);
nxtask = 0;
break;
}
if (segend(p1)) {
if ((unsigned int) freidx < cnvlen + 1) return AD_OvflwIndex;
if ((*curdict->putdic)(curdict, curdict->segunit))
return AD_OvflwUsrDic;
curdict->segunit++;
(*curdict->getdic)(curdict, curdict->segunit - 1);
memset(dicbuf, DicSegTerm, (Int)curdict->seglen);
dicbuf[0] = 0;
@ -220,13 +177,10 @@ TypeGram hinsi;
(*curdict->rszdic)(curdict, curdict->segunit);
mkidxtbl(curdict);
segnum++;
}
else {
nlen = getnlen(p1);
if ((unsigned int) freidx < getplen(p1) + nlen + 1)
return AD_OvflwIndex;
@ -234,20 +188,16 @@ TypeGram hinsi;
if ((*curdict->putdic)(curdict, curdict->segunit))
return AD_OvflwUsrDic;
sprt_seg(segnum, douofs);
segnum++;
}
}
douptr = dicbuf + douofs;
if (nxtask) {
Uchar *tp;
u_char *tp;
size = getsize(douptr) - nxtask;
plen = getplen(douptr) + nxtask;
@ -258,27 +208,21 @@ TypeGram hinsi;
*(douptr + 1) = size;
*(douptr + 2) = ((nlen & 0x0f) | ((plen & 0x0f) << 4));
p1 = douptr + DouonBlkSizeNumber;
tp = p1 + nxtask;
mvmemi(tp, p1, dicbuf + curdict->seglen - tp);
}
dstptr = dicbuf + dstofs;
size = newsiz - oldsiz;
p1 = dicbuf + curdict->seglen;
mvmemd(p1 - size, p1, p1 - dstptr - size);
if (!hnsofs) {
if (douofs == segtop() - dicbuf) {
chg_uidx(segnum, yptr, cnvlen);
}
*dstptr = 0;
nlen = cnvlen - saml;
if (nlen & 0x10) *dstptr |= NokoriYomiTop;
@ -287,7 +231,6 @@ TypeGram hinsi;
*dstptr++ = size;
*dstptr++ = ((nlen&0x0f)|((saml&0x0f)<<4));
while (saml < cnvlen) *dstptr++ = yptr[saml++];
}
@ -301,22 +244,17 @@ TypeGram hinsi;
*(douptr + 2) = ((nlen & 0x0f) | ((plen & 0x0f) << 4));
}
if (!knjofs) *dstptr++ = hinsi;
stdydat.stdy1.offset = dstptr - dicbuf;
for (saml = 0 ; saml < klen ; ) *dstptr++ = kptr[saml++];
if (klen > 0) *dstptr++ = KanjiStrEnd;
if (!knjofs) *dstptr++ = HinsiBlkTerm;
(*curdict->putdic)(curdict, segnum);
if (StudyExist()) {
size -= nxtask;
for (i = StudyCount, stdy = StudyDict ; i-- ; stdy++) {
if (stdy -> dicid != curdict->dicid) continue;
@ -324,9 +262,8 @@ TypeGram hinsi;
if (stdy -> offset >= dstofs) stdy -> offset += size;
}
for (p1 = ClStudyDict ; !iseocl(p1) ; p1 = ClNextTag(p1)) {
err = sstrncmp(yptr, (Uchar TFar *)ClYomiPos(p1),
err = strncmp(yptr, (u_char*)ClYomiPos(p1),
(Int)ClYomiLen(p1));
if (err == MATCH) {
delclsub(p1);
@ -339,7 +276,6 @@ TypeGram hinsi;
}
}
stdydat.stdy1.seg = segnum;
stdydat.stdy1.dicid = curdict->dicid;
stdydat.stdy1.styno = 0;
@ -357,18 +293,15 @@ TypeGram hinsi;
}
Static Int checksub(kanji, grm)
Uchar *kanji;
TypeGram grm;
static int
checksub(u_char* kanji, TypeGram grm)
{
Reg1 Uchar *tagp;
Reg2 Uchar *ptr;
Reg3 Uchar *endp;
Int flg, nlen;
Int dounum;
Uchar buf[MaxWdKanjiLen + 1];
u_char *tagp;
u_char *ptr;
u_char *endp;
int flg, nlen;
int dounum;
u_char buf[MaxWdKanjiLen + 1];
dicinl = cnvlen;
dicsaml = 0;
@ -379,63 +312,41 @@ TypeGram grm;
break;
}
dounum = 0;
nlen = getnlen(tagp);
ptr = tagp + DouonBlkSizeNumber + nlen;
endp = tagp + getsize(tagp);
while (ptr < endp) {
flg = (grm == *ptr++);
while (*ptr != HinsiBlkTerm) {
if (flg) {
buf[getkanji(inputyomi, cnvlen, ptr, buf)] = 0;
if (cmpstr(kanji, buf)) return -1;
}
dounum++;
ptr = skipkstr(ptr);
}
ptr++;
}
return dounum;
}
Static Uint checkdict(kanji, grm)
Uchar *kanji;
TypeGram grm;
static u_int
checkdict(u_char* kanji, TypeGram grm)
{
Reg1 DICTL *dp;
Reg2 Int dounum = 0;
Reg3 Int tmp;
DICTL *dp;
int dounum = 0;
int tmp;
DICT *tmpdict;
tmpdict = curdict;
for (dp = dictlist ; dp ; dp = dp -> next) {
curdict = dp -> dict;
if ((tmp = checksub(kanji, grm)) < 0) {
curdict = tmpdict;
return AD_ArExist;
@ -445,32 +356,24 @@ TypeGram grm;
}
curdict = tmpdict;
if (MaxKouhoNumber <= dounum) return AD_OvflwDouNum;
return 0;
}
Static Int cal_nextym(ptr)
Reg1 Uchar *ptr;
static int
cal_nextym(u_char* ptr)
{
Reg2 Int count = 0;
Reg3 Uchar *src;
Reg4 Int len;
int count = 0;
u_char *src;
int len;
if (!segend(ptr)) {
src = cnvstart + getplen(ptr);
len = getnlen(ptr);
ptr += DouonBlkSizeNumber;
while (len--) {
if (*ptr++ == *src++)
count++;
@ -479,39 +382,34 @@ Reg1 Uchar *ptr;
}
}
return count;
}
Static Int usr_freelen()
static int
usr_freelen(void)
{
Reg1 Uchar *ptr;
u_char* ptr;
ptr = segtop();
while (!segend(ptr)) ptr += getsize(ptr);
return(curdict->seglen - (ptr - dicbuf));
}
Static Void sprt_seg(seg, ofs)
TypeDicSeg seg;
TypeDicOfs ofs;
static void
sprt_seg(TypeDicSeg seg, TypeDicOfs ofs)
{
Reg3 TypeDicSeg s;
Uchar *pos;
Reg1 Uchar *p;
Reg2 Uchar *q;
Int i;
Int j;
Int ylen, nlen;
TypeDicSeg s;
u_char *pos;
u_char *p;
u_char *q;
int i;
int j;
int ylen, nlen;
TypeDicID dicid;
Uchar yomi[MaxWdYomiLen];
u_char yomi[MaxWdYomiLen];
STDYIN *stdy;
for (s = curdict->segunit - 1 ; s >= seg ; s--) {
@ -521,13 +419,10 @@ TypeDicOfs ofs;
curdict->segunit++;
(*curdict->rszdic)(curdict, curdict->segunit);
(*curdict->getdic)(curdict, seg + 1);
pos = dicbuf + ofs;
for (p = segtop() ; (p <= pos) && !segend(p) ; p = q) {
q = getntag(p);
i = getplen(p);
@ -537,34 +432,26 @@ TypeDicOfs ofs;
while (j-- > 0) yomi[i++] = *p++;
}
nlen = getnlen(pos);
ylen = (i = getplen(pos)) + (j = nlen);
apnd_uidx(seg, yomi, ylen);
set_size(segtop(), getsize(pos) + i, 0, ylen);
mvmemi(yomi, (p = segtop() + DouonBlkSizeNumber), ylen);
q = pos + DouonBlkSizeNumber + j;
i = dicbuf + curdict->seglen - q;
mvmemi(q, p += ylen, i);
j = q - p;
p += i;
memset(p, DicSegTerm, (dicbuf + curdict->seglen - p));
(*curdict->putdic)(curdict, seg + 1);
if (StudyExist()) {
dicid = curdict -> dicid;
for (i = StudyCount, stdy = StudyDict ; i-- > 0 ; stdy++) {
if (stdy -> dicid != dicid)
@ -580,37 +467,28 @@ TypeDicOfs ofs;
}
}
(*curdict->getdic)(curdict, seg);
memset(dicbuf + ofs, DicSegTerm, (Int)(curdict->seglen - ofs));
(*curdict->putdic)(curdict, seg);
}
Static Void apnd_uidx(seg, yomi, len)
TypeDicSeg seg;
Uchar *yomi;
Int len;
static void
apnd_uidx(TypeDicSeg seg, u_char* yomi, int len)
{
Reg1 Uchar *p;
Reg1 Uchar *q;
u_char *p;
u_char *q;
p = get_idxptr(seg);
while (*p++) ;
q = idxbuf + curdict->idxlen;
mvmemd(q - (len + 1), q, (Int)(q - (len + 1) - p));
while (len--) *p++ = *yomi++;
*p = 0;
(*curdict->putidx)(curdict, 0);
mkidxtbl(curdict);
}

View file

@ -31,30 +31,26 @@
* $SonyRCSfile: addelcmn.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:27 $
*
* $Id$
*/
#include <string.h>
#include "sj_euc.h"
#include "sj_kcnv.h"
#include "sj_hinsi.h"
#include "sj_yomi.h"
#include "kanakan.h"
Uchar *get_idxptr();
Int sj2cd_str(), yomicmp(), codesize();
Int sstrlen(), sstrcmp();
Int sj2cd_str();
Void mvmemi(), mvmemd(), mkidxtbl();
Void set_size(p, size, plen, nlen)
Reg1 Uchar *p;
Int size;
Int plen;
Int nlen;
void
set_size (Uchar *p, Int size, Int plen, Int nlen)
{
*p = (Uchar)(size >> 8);
if (nlen & 0x10) *p |= NokoriYomiTop;
@ -65,21 +61,17 @@ Int nlen;
Static Int isvyomi(yp)
Reg1 Uchar *yp;
static Int
isvyomi (Uchar *yp)
{
Reg2 Int len;
Int len;
if (!*yp) return FALSE;
if (!(Chrtbl[*yp] & DICTOP)) return FALSE;
for (len = 0 ; *yp ; yp++) {
if (!(Chrtbl[*yp]) || (*yp >= Y_KUTEN)) return FALSE;
if (++len > MaxWdYomiLen) return FALSE;
}
@ -88,14 +80,13 @@ Reg1 Uchar *yp;
Static Int isvknj(kanji)
Reg1 Uchar *kanji;
static Int
isvknj(Uchar *kanji)
{
Reg2 Int len;
Int len;
if (!*kanji) return FALSE;
for (len = 0 ; *kanji ; ) {
if (*kanji == SS3) {
kanji += 3;
@ -106,7 +97,6 @@ Reg1 Uchar *kanji;
kanji += 2;
len += 2;
}
else {
kanji++;
len += 2;
@ -120,10 +110,10 @@ Reg1 Uchar *kanji;
Static Int isgrm(gram)
TypeGram gram;
static Int
isgrm (TypeGram gram)
{
Reg1 Int grm = gram;
Int grm = gram;
if (MEISI_1 <= grm && grm <= D_MEISI_6) return TRUE;
if (MYOUJI <= grm && grm <= JOSUUSI2) return TRUE;
@ -142,49 +132,33 @@ TypeGram gram;
Uint addel_arg(yp, kp, grm, nyp, len)
Uchar *yp;
Uchar *kp;
TypeGram grm;
Uchar *nyp;
Int len;
Uint
addel_arg (Uchar *yp, Uchar *kp, TypeGram grm, Uchar *nyp, Int len)
{
Reg1 Ushort err = 0;
Ushort err = 0;
if (!sj2cd_str(yp, nyp, len)) err |= AD_BadYomi;
if (!isvyomi(nyp)) err |= AD_BadYomi;
if (!isvknj(kp)) err |= AD_BadKanji;
if (!isgrm(grm)) err |= AD_BadHinsi;
return err;
}
Static Void yomi2kata(src, dst)
Reg2 Uchar *src;
Reg1 Uchar *dst;
static void
yomi2kata (Uchar *src, Uchar *dst)
{
Reg3 Int first;
Reg4 Int second;
Int first;
Int second;
while (first = *src++) {
while ((first = *src++) != 0) {
second = *src++;
if (first != 0xa4) {
*dst++ = first;
*dst++ = second;
}
else {
*dst++ = 0xa5;
*dst++ = second;
@ -196,86 +170,64 @@ Reg1 Uchar *dst;
Static Int top_strcmp(src, dst)
Reg1 Uchar *src;
Reg3 Uchar *dst;
static Int
top_strcmp (Uchar *src, Uchar *dst)
{
Reg2 Int i;
Int i;
for (i = 0 ; *src && (*src == *dst) ; src++, dst++) i++;
i /= 2;
return (i > MaxYomiAskNumber) ? MaxYomiAskNumber : i;
}
Static Int last_strcmp(src, dst)
Uchar *src;
Uchar *dst;
static Int
last_strcmp (Uchar *src, Uchar *dst)
{
Int slen;
Reg1 Int dlen;
slen = sstrlen(src);
dlen = sstrlen(dst);
Int dlen;
slen = strlen(src);
dlen = strlen(dst);
if (dlen > MaxYomiAskNumber * 2) return 0;
if (sstrcmp(src + (slen - dlen), dst)) return 0;
if (strcmp(src + (slen - dlen), dst)) return 0;
return (dlen / 2);
}
Int cvtknj(yomi, knj, dst)
Uchar *yomi;
Uchar *knj;
Reg1 Uchar *dst;
Int
cvtknj (Uchar *yomi, Uchar *knj, Uchar *dst)
{
Uchar kana[MaxWdYomiLen * 2 + 1];
Reg2 Int len;
Int len;
Uchar *keep;
keep = dst;
yomi2kata(yomi, kana);
if (len = top_strcmp(yomi, knj)) {
if ((len = top_strcmp(yomi, knj)) != 0) {
*dst = (Uchar)(ZenHiraAssyuku | (len - 1));
}
else if (len = top_strcmp(kana, knj)) {
else if ((len = top_strcmp(kana, knj)) != 0) {
*dst = (Uchar)(ZenKataAssyuku | (len - 1));
}
if (len) {
knj += len * 2;
dst++;
}
if (*knj) {
for ( ; ; ) {
if (len = last_strcmp(yomi, knj)) {
if ((len = last_strcmp(yomi, knj)) != 0) {
*dst++ = (Uchar)(ZenHiraAssyuku | (len - 1));
break;
}
else if (len = last_strcmp(kana, knj)) {
else if ((len = last_strcmp(kana, knj)) != 0) {
*dst++ = (Uchar)(ZenKataAssyuku | (len - 1));
break;
}
@ -287,62 +239,48 @@ Reg1 Uchar *dst;
knj++;
*dst++ = (*knj & NormalKanjiMask); knj++;
*dst++ = *knj++;
} else if (*knj & 0x80) {
*dst++ = (*knj & NormalKanjiMask); knj++;
*dst++ = (*knj & NormalKanjiMask); knj++;
}
else {
*dst++ = (Uchar)LeadingHankaku;
*dst++ = *knj++;
}
if (!*knj) {
break;
}
}
}
*dst = 0;
return (dst - keep);
}
Int srchkana(ptr, saml)
Uchar **ptr;
Int *saml;
Int
srchkana (Uchar **ptr, Int *saml)
{
Uchar *p;
Int cmp;
Int cnt = 0;
Uchar same;
Reg1 Int flg = 0;
Int flg = 0;
same = 0;
p = segtop();
while (!segend(p)) {
if (flg == 0) {
cmp = yomicmp(cnvstart, p, &same);
if (cmp == OVER) break;
if (cmp == MATCH && *(cnvstart + same) == 0) {
*ptr = p;
*saml = same;
@ -350,15 +288,12 @@ Int *saml;
}
}
p = getntag(p);
cnt++;
}
if (flg != 0) return cnt;
*ptr = p;
*saml = same;
return 0;
@ -366,30 +301,23 @@ Int *saml;
Int srchgram(ptr, dst, hinsi)
Reg1 Uchar *ptr;
Uchar **dst;
TypeGram hinsi;
Int
srchgram (Uchar *ptr, Uchar **dst, TypeGram hinsi)
{
Uchar *endp;
Int cnt = 0, nlen;
Int flg = FALSE;
endp = getntag(ptr);
nlen = getnlen(ptr);
ptr += DouonBlkSizeNumber + nlen;
while (ptr < endp) {
if (*ptr == hinsi) {
*dst = ptr;
flg = TRUE;
}
do {
ptr += codesize(*ptr);
} while (*ptr != HinsiBlkTerm);
@ -397,43 +325,34 @@ TypeGram hinsi;
cnt++;
}
if (flg) return cnt;
*dst = ptr;
return 0;
}
Int srchkanji(dst, knj, klen)
Uchar **dst;
Uchar *knj;
Int klen;
Int
srchkanji (Uchar **dst, Uchar *knj, Int klen)
{
Reg1 Uchar *ptr;
Uchar *ptr;
Uchar *p, *q;
Int len;
Int flg = FALSE;
Int cnt = 0;
ptr = *dst + 1;
while (*ptr != HinsiBlkTerm) {
for (p = ptr, q = knj, len = klen ; len ; len--)
if (*p++ != *q++) break;
if (!len) {
*dst = ptr;
flg = TRUE;
}
while (!(*ptr == KanjiStrEnd)) {
ptr += codesize(*ptr);
}
@ -441,62 +360,49 @@ Int klen;
cnt++;
}
if (!flg) *dst = ptr;
return cnt;
}
TypeIdxOfs count_uidx()
TypeIdxOfs
count_uidx (void)
{
Uchar *p;
p = get_idxptr(curdict->segunit - 1);
while (*p++) ;
return (curdict->idxlen - (p - idxbuf));
}
Void chg_uidx(seg, yomi, len)
TypeDicSeg seg;
Uchar *yomi;
Int len;
void
chg_uidx (TypeDicSeg seg, Uchar *yomi, Int len)
{
Uchar *p, *q;
Int olen;
p = get_idxptr(seg);
olen = sstrlen(p);
olen = strlen(p);
q = idxbuf + curdict->idxlen;
if (len > olen) {
mvmemd(q - (len-olen), q, (Int)(q - (len-olen) - p));
}
else {
mvmemi(p + (olen-len), p, (Int)(q - (p + (olen-len))));
}
while (len--) *p++ = *yomi++;
(*curdict->putidx)(curdict, 0);
mkidxtbl(curdict);
}

View file

@ -31,16 +31,20 @@
* $SonyRCSfile: alloc.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:28 $
*
* $Id$
*/
#include <stdlib.h>
#include <sys/types.h>
#include "sj_rename.h"
#include "sj_typedef.h"
#include "sj_const.h"
#include "sj_var.h"
#include "sj_struct.h"
#include "kanakan.h"
#define JREC_NUM 128
#define CLREC_NUM 128
@ -48,10 +52,11 @@
static JREC *jrec = NULL;
static CLREC *clrec = NULL;
JREC *alloc_jrec()
JREC*
alloc_jrec(void)
{
register JREC *p;
register int i;
JREC *p;
int i;
if (jrec == NULL) {
jrec = (JREC *)malloc(sizeof(JREC) * JREC_NUM);
@ -66,8 +71,8 @@ JREC *alloc_jrec()
return p;
}
Void free_jrec(p)
JREC *p;
void
free_jrec(JREC *p)
{
if (p != NULL) {
p -> jsort = jrec;
@ -75,10 +80,11 @@ JREC *p;
}
}
CLREC *alloc_clrec()
CLREC*
alloc_clrec(void)
{
register CLREC *p;
register int i;
CLREC *p;
int i;
if (clrec == NULL) {
clrec = (CLREC *)malloc(sizeof(CLREC) * CLREC_NUM);
@ -93,8 +99,8 @@ CLREC *alloc_clrec()
return p;
}
Void free_clrec(p)
CLREC *p;
void
free_clrec(CLREC* p)
{
if (p != NULL) {
p -> clsort = clrec;

View file

@ -31,19 +31,19 @@
* $SonyRCSfile: charsize.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:29 $
*
* $Id$
*/
#include "sj_euc.h"
#include "sj_rename.h"
#include "sj_typedef.h"
#include "sj_dict.h"
#include "kanakan.h"
codesize(code)
u_char code;
int
codesize(u_char code)
{
switch (code & KanjiModeMask) {
case ZenHiraAssyuku:

View file

@ -31,47 +31,38 @@
* $SonyRCSfile: cl2knj.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:31 $
*
* $Id$
*/
#include <string.h>
#include "sj_kcnv.h"
#include "kanakan.h"
Int sj2cd_chr(), hzstrlen(), sstrlen();
Void sstrncpy(), mkjiritu(), mkbunsetu(), wakachi();
Void mkkouho(), getrank(), cvtclknj(), freework();
Void memset();
Int sj2cd_chr();
void cvtclknj(), freework();
Static CLREC *nextrecblk(), *prevrecblk();
Static Void initkbuf();
static CLREC* nextrecblk(void);
static CLREC* prevrecblk(void);
static void initkbuf(u_char* kouho);
Int cl2knj(yomi, len, kouho)
Uchar *yomi;
Reg4 Int len;
Uchar *kouho;
int
cl2knj(u_char* yomi, int len, u_char* kouho)
{
Reg1 Uchar *ptr1;
Reg2 Uchar *ptr2;
Reg3 Int i;
u_char *ptr1;
u_char *ptr2;
int i;
khcount = nkhcount = 0;
initkbuf(kouho);
if (len > MaxClInputLen * 2) len = MaxClInputLen * 2;
ptr1 = yomi; ptr2 = hyomi;
for (i = 0 ; i < len ; i++) {
if (isknj1(*ptr1)) {
@ -81,79 +72,53 @@ Uchar *kouho;
}
*ptr2 = 0;
sstrncpy(yomi, orgyomi, (Int)(ptr1 - yomi));
strlcpy(yomi, orgyomi, (int)(ptr1 - yomi));
if (!hyomi[0]) return 0;
freework();
inputyomi = orgyomi;
cnvstart = ystart = hyomi;
cnvlen = sstrlen(hyomi);
cnvlen = strlen(hyomi);
mkjiritu(0);
mkbunsetu();
if (!maxclptr) wakachi();
jrt1st = maxjptr;
clt1st = maxclptr;
mkkouho();
getrank();
selectid = 1;
cvtclknj();
return hzstrlen(inputyomi, (Int)clt1st -> cllen);
return hzstrlen(inputyomi, (int)clt1st -> cllen);
}
Int nextcl(kouho, mode)
Uchar *kouho;
Int mode;
int
nextcl(u_char* kouho, int mode)
{
CLREC *clptr;
initkbuf(kouho);
if (!khcount) return 0;
if (!mode && (selectid < khcount))
if (!mode && (selectid < khcount)) {
selectid++;
}
else if((mode < 2) && (clptr = nextrecblk())) {
selectid = 1;
clt1st = clptr;
mkkouho();
getrank();
}
else {
cvtclknj();
return 0;
@ -161,62 +126,44 @@ Int mode;
cvtclknj();
return hzstrlen(inputyomi, (Int)clt1st -> cllen);
return hzstrlen(inputyomi, (int)clt1st -> cllen);
}
Static CLREC *nextrecblk()
static CLREC*
nextrecblk(void)
{
Reg1 CLREC *clptr;
Reg2 Int keeplen;
CLREC *clptr;
int keeplen;
keeplen = clt1st -> cllen;
clptr = clt1st -> clsort;
while (clptr && (Int)clptr -> cllen == keeplen)
while (clptr && (int)clptr -> cllen == keeplen)
clptr = clptr -> clsort;
return clptr;
}
Int prevcl(kouho, mode)
Uchar *kouho;
Int mode;
int
prevcl(u_char* kouho, int mode)
{
CLREC *clptr;
initkbuf(kouho);
if (!khcount) return 0;
if (!mode && (selectid > 1))
if (!mode && (selectid > 1)) {
selectid--;
}
else if ((mode < 2) && (clptr = prevrecblk())) {
clt1st = clptr;
mkkouho();
getrank();
selectid = khcount;
}
else {
cvtclknj();
return 0;
@ -224,56 +171,45 @@ Int mode;
cvtclknj();
return hzstrlen(inputyomi, (Int)clt1st -> cllen);
return hzstrlen(inputyomi, (int)clt1st -> cllen);
}
Static CLREC *prevrecblk()
static CLREC*
prevrecblk(void)
{
Reg1 CLREC *clptr;
CLREC *clptr;
CLREC *keepptr;
Reg2 Int keeplen;
Int cllen;
int keeplen;
int cllen;
clptr = maxclptr;
if ((cllen = clt1st -> cllen) == clptr -> cllen)
return NULL;
while ((Int)clptr -> cllen > cllen) {
while ((int)clptr -> cllen > cllen) {
keeplen = clptr -> cllen;
keepptr = clptr;
while ((Int)clptr -> cllen == keeplen)
while ((int)clptr -> cllen == keeplen)
clptr = clptr -> clsort;
}
return keepptr;
}
Static Void initkbuf(kouho)
Uchar *kouho;
static void
initkbuf(u_char* kouho)
{
kanjitmp = kouho;
memset(kanjitmp, 0, sizeof(STDYOUT) + 1);
}
Int selectnum()
int
selectnum(void)
{
return selectid;
}

View file

@ -31,97 +31,74 @@
* $SonyRCSfile: clstudy.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:32 $
*
* $Id$
*/
#include <string.h>
#include <sys/types.h>
#include "sj_kcnv.h"
#include "kanakan.h"
int sj2cd_str();
void mvmemd(), mvmemi();
Int sj2cd_str(), sstrlen();
Void memcpy(), memset(), mvmemd(), mvmemi();
static u_char* delcldata(u_char* ycode);
static int delclold(void);
static u_char* srchclpos(u_char* ycode);
Static Uchar *delcldata(), *srchclpos();
Void delclsub(), mkclidx();
Static Int delclold();
Int clstudy(yomi1, yomi2, stdy)
Uchar *yomi1;
Uchar *yomi2;
STDYOUT *stdy;
int
clstudy(u_char* yomi1, u_char* yomi2, STDYOUT *stdy)
{
Uchar ytmp[CLSTDY_TMPLEN];
Uchar *dst, *ptr;
Int ret;
Int len1, len2;
Int alen, blen;
Int i;
u_char ytmp[CLSTDY_TMPLEN];
u_char *dst, *ptr;
int ret;
int len1, len2;
int alen, blen;
int i;
if (!StudyExist()) return ClstudyNoDict;
if (!yomi1 || !*yomi1) return ClstudyParaErr;
if (!yomi2 || !*yomi2) {
if (!sj2cd_str(yomi1, ytmp, CLSTDY_TMPLEN))
return ClstudyYomiErr;
(Void)delcldata(ytmp);
ret = ClstudyNormEnd;
}
else if (!stdy)
else if (!stdy) {
return ClstudyParaErr;
}
else {
if (!sj2cd_str(yomi1, ytmp, CLSTDY_TMPLEN))
return ClstudyYomiErr;
len1 = sstrlen(ytmp);
len1 = strlen(ytmp);
if (!sj2cd_str(yomi2, ytmp + len1, CLSTDY_TMPLEN - len1))
return ClstudyYomiErr;
len2 = len1 + stdy -> len;
ytmp[len2] = 0;
alen = len2 + CL_HDLEN;
if (alen + 1 >= ClStudyLen) return ClstudyNoArea;
blen = ClStudyTail - delcldata(ytmp) - 1;
while (blen < alen) {
if (!(i = delclold())) break;
blen += i;
}
if (blen >= alen) {
dst = srchclpos(ytmp);
ptr = ClStudyTail - alen;
mvmemd(ptr, ClStudyTail, (ptr - dst));
ClYomiLen(dst) = (Uchar)len2;
@ -132,40 +109,32 @@ STDYOUT *stdy;
ret = ClstudyNormEnd;
}
else
else {
ret = ClstudyNoArea;
}
}
mkclidx();
putcldic();
return ret;
}
Static Uchar *delcldata(ycode)
Uchar *ycode;
static u_char*
delcldata(u_char* ycode)
{
Reg1 Uchar *tagptr;
Reg2 Uchar *ptr1;
Reg3 Uchar *ptr2;
Int len1;
u_char *tagptr;
u_char *ptr1;
u_char *ptr2;
int len1;
tagptr = ClStudyDict;
while (!iseocl(tagptr)) {
ptr1 = ycode;
ptr2 = ClYomiPos(tagptr);
len1 = ClYomiLen(tagptr);
while (*ptr1 && len1) {
if (*ptr1 != *ptr2) break;
ptr1++;
@ -173,134 +142,98 @@ Uchar *ycode;
len1--;
}
if (!*ptr1 || !len1) {
delclsub(tagptr);
}
else {
tagptr = ClNextTag(tagptr);
}
}
return tagptr;
}
Void delclsub(target)
Uchar *target;
void
delclsub(u_char* target)
{
Reg1 Uchar *src;
Int num;
Int tmp;
Int len;
u_char *src;
int num;
int tmp;
int len;
num = ClGetNum(target);
len = ClBlkLen(target);
src = target + len;
mvmemi(src, target, (ClStudyTail - src));
memset(ClStudyTail - len, 0, len);
src = ClStudyDict;
while (!iseocl(src)) {
tmp = ClGetNum(src);
if (tmp > num) {
tmp -= 1;
ClSetNum(src, tmp);
}
src = ClNextTag(src);
}
}
Static Int delclold()
static int
delclold(void)
{
Reg1 Uchar *tagptr;
Reg2 Uchar *target;
Int num;
Int tmp;
u_char *tagptr;
u_char *target;
int num;
int tmp;
target = NULL;
num = 0;
tagptr = ClStudyDict;
while (!iseocl(tagptr)) {
tmp = ClGetNum(tagptr);
if (tmp >= num) {
num = tmp;
target = tagptr;
}
tagptr = ClNextTag(tagptr);
}
if (target) {
num = ClBlkLen(tagptr);
delclsub(target);
}
return num;
}
Static Uchar *srchclpos(ycode)
Uchar *ycode;
static u_char*
srchclpos(u_char* ycode)
{
Reg1 Uchar *tagptr;
Reg3 Uchar *target;
Reg2 Uchar *ptr1;
Reg4 Uchar *ptr2;
Reg5 Int len;
Int tmp;
u_char *tagptr;
u_char *target;
u_char *ptr1;
u_char *ptr2;
int len;
int tmp;
target = NULL;
tagptr = ClStudyDict;
while (!iseocl(tagptr)) {
tmp = ClGetNum(tagptr);
tmp++;
ClSetNum(tagptr, tmp);
ptr1 = ycode;
ptr2 = ClYomiPos(tagptr);
len = ClYomiLen(tagptr);
@ -311,36 +244,28 @@ Uchar *ycode;
len--;
}
if (!target) {
if (!len)
;
else if (!*ptr1)
target = tagptr;
else if (*ptr1 < *ptr2)
target = tagptr;
}
tagptr = ClNextTag(tagptr);
}
return target ? target : tagptr;
}
Void mkclidx()
void
mkclidx(void)
{
Reg1 Uchar *ptr;
Reg2 Int num;
Int st, ed;
u_char *ptr;
int num;
int st, ed;
if (!StudyExist()) return;

View file

@ -31,33 +31,26 @@
* $SonyRCSfile: cvtdict.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:40 $
*
* $Id$
*/
#include "sj_euc.h"
#include "sj_kcnv.h"
#include "kanakan.h"
Int getkanji(), seldict();
Uchar TFar *getstb();
Void get_askknj();
Void cvtdict(krec, clrec, flg)
KHREC *krec;
CLREC *clrec;
Int flg;
void
cvtdict(KHREC *krec, CLREC *clrec, int flg)
{
TypeDicOfs ofs;
Uchar *yptr;
Int jlen;
Int stblen;
Int sttlen;
Uchar TFar *fptr;
Uchar *fptr;
Int cllen;
JREC *jrec;
Int i, j;
@ -73,7 +66,7 @@ Int flg;
jlen = jrec -> jlen;
if (i = jrec -> sttofs) {
if ((i = jrec -> sttofs) != 0) {
if (i == SETTOU_KIGOU) {
sttlen = 1;
@ -166,8 +159,8 @@ Int flg;
Void cvtminasi(len)
Int len;
void
cvtminasi(Int len)
{
Uchar *ptr;
@ -193,8 +186,8 @@ Int len;
Void cvtwakachi(clrec)
CLREC *clrec;
void
cvtwakachi(CLREC *clrec)
{
Int jlen;
Uchar *ym;

View file

@ -31,28 +31,24 @@
* $SonyRCSfile: cvtkanji.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:41 $
*
* $Id$
*/
#include <string.h>
#include "sj_kcnv.h"
#include "kanakan.h"
Void mkknjmax();
Void mvmemi(), free_clall();
Void free_jall();
Int hzstrlen(), ph_khtbl();
Void cvtdict(), cvtminasi();
Void cvtwakachi(), setstyrec(), cvtkouho(), mkknjmax();
Void ph_setkouho(), mvmemi(), free_clall();
Void free_jall(), memcpy(), cvtphknj();
Uchar TFar *getstb();
STDYIN *srchstdy();
Void cvtphknj(num)
Int num;
void
cvtphknj (void)
{
Int i, j;
CLREC *clrec;
@ -119,8 +115,8 @@ not_enough_memory:
Void cvtkouho(krec)
KHREC *krec;
void
cvtkouho (KHREC *krec)
{
CLREC *clrec;
@ -161,13 +157,13 @@ KHREC *krec;
Void setstyrec(krec)
KHREC *krec;
void
setstyrec (KHREC *krec)
{
JREC *jrec;
KHREC *kptr;
Int ii;
Uchar TFar *fptr;
Uchar *fptr;
STDYOUT stdy;
jrec = krec -> clrec -> jnode;
@ -201,11 +197,11 @@ KHREC *krec;
stdy.ka_fg = krec -> ka_fg;
if (jrec -> stbofs && (fptr = getstb(jrec -> hinsi)))
if (jrec -> stbofs && (fptr = getstb(jrec -> hinsi)) != NULL)
stdy.len -= StbYomiLen(fptr + jrec -> stbofs - 1);
if (fptr = Settou_ptr(jrec -> sttofs))
if ((fptr = Settou_ptr(jrec -> sttofs)) != NULL)
stdy.sttlen = SttYomiLen(fptr);
else
stdy.sttlen = 0;
@ -214,3 +210,4 @@ KHREC *krec;
memcpy((Uchar *)&stdy, kanjitmp, sizeof(STDYOUT));
kanjitmp += sizeof(STDYOUT);
}

View file

@ -31,217 +31,165 @@
* $SonyRCSfile: deldic.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:42 $
*
* $Id$
*/
#include <sys/types.h>
#include <string.h>
#include "sj_kcnv.h"
#include "kanakan.h"
Uchar *skipkstr(), *get_idxptr();
Int sstrlen(), srchkana(), srchgram();
Int srchkanji(), cvtknj();
Uint addel_arg();
Void mvmemi(), memset(), set_size(), chg_uidx();
Void mkidxtbl();
TypeDicSeg srchidx();
TypeIdxOfs count_uidx();
void mvmemi();
void mkidxtbl();
Static Int del_douon(), del_segment();
Static Void del_uidx(), del_stdy();
static int del_douon(TypeDicSeg seg, u_char* ptr, TypeDicOfs ofs);
static int del_segment(TypeDicSeg seg);
static void del_uidx(TypeDicSeg seg);
static void del_stdy(TypeDicSeg seg, TypeDicOfs ofs, int size);
Uint deldic(yomi, kanji, hinsi)
Uchar *yomi;
Uchar *kanji;
TypeGram hinsi;
u_int
deldic(u_char* yomi, u_char* kanji, TypeGram hinsi)
{
Uchar yptr[MaxWdYomiLen + 1];
Uchar kptr[MaxWdKanjiLen + 1];
Ushort err;
Int knjlen;
u_char yptr[MaxWdYomiLen + 1];
u_char kptr[MaxWdKanjiLen + 1];
u_short err;
int knjlen;
TypeDicSeg useg;
TypeDicOfs ofs;
Uchar *p1, *p2, *p3;
Int dblknum;
Int hblknum;
Int kblknum;
Int samlen;
Uchar *stp, *edp;
Int size, len;
u_char *p1, *p2, *p3;
int dblknum;
int hblknum;
int kblknum;
int samlen;
u_char *stp, *edp;
int size, len;
if (err = addel_arg(yomi, kanji, hinsi, yptr, sizeof(yptr)))
if ((err = addel_arg(yomi, kanji, hinsi, yptr, sizeof(yptr))) != 0)
return err;
if (!curdict -> maxunit) return AD_NotUserDict;
if ((curdict -> maxunit) == 0) return AD_NotUserDict;
knjlen = cvtknj(yomi, kanji, kptr);
cnvstart = yptr;
cnvlen = sstrlen(yptr);
cnvlen = strlen(yptr);
useg = srchidx((TypeDicSeg)DicSegBase, cnvlen);
(*curdict->getdic)(curdict, useg);
if ((dblknum = srchkana(&p1, &samlen)) == 0) return AD_NoMidasi;
if (!(dblknum = srchkana(&p1, &samlen))) return AD_NoMidasi;
if (!(hblknum = srchgram(p1, &p2, hinsi))) return AD_NoHinsi;
if ((hblknum = srchgram(p1, &p2, hinsi)) == 0) return AD_NoHinsi;
p3 = p2;
kblknum = srchkanji(&p3, kptr, knjlen);
if (*p3 == HinsiBlkTerm) return AD_NoKanji;
ofs = p3 - dicbuf;
edp = skipkstr(p3);
if (kblknum == 1) {
if (hblknum == 1) {
if (dblknum == 1) {
return del_segment(useg);
}
else {
return del_douon(useg, p1, ofs);
}
}
else {
stp = p2;
edp++;
}
}
else {
stp = p3;
}
size = edp - stp;
len = dicbuf + (curdict->seglen) - edp;
mvmemi(edp, stp, len);
edp += len;
memset(edp, DicSegTerm, dicbuf + curdict->seglen - edp);
set_size(p1, (Int)(getsize(p1) - size),
(Int)getplen(p1), (Int)getnlen(p1));
set_size(p1, (int)(getsize(p1) - size),
(int)getplen(p1), (int)getnlen(p1));
(*curdict->putdic)(curdict, useg);
del_stdy(useg, ofs, size);
return AD_Done;
}
Static Int del_douon(seg, ptr, ofs)
TypeDicSeg seg;
Uchar *ptr;
TypeDicOfs ofs;
static int
del_douon(TypeDicSeg seg, u_char* ptr, TypeDicOfs ofs)
{
Uchar *nxt, *p1, *p2;
Int size;
Int nlen, plen, len;
u_char *nxt, *p1, *p2;
int size;
int nlen, plen, len;
nxt = getntag(ptr);
if (segend(nxt)) {
size = nxt - ptr;
memset(ptr, DicSegTerm, dicbuf + curdict->seglen - nxt);
}
else {
size = getsize(nxt);
nlen = getnlen(nxt);
plen = getplen(nxt);
if (ptr == segtop()) {
if (nlen + plen > (unsigned int) count_uidx()
+ sstrlen(get_idxptr(seg)))
+ strlen(get_idxptr(seg)))
return AD_OvflwIndex;
}
len = ((len = getplen(ptr)) < plen) ? plen - len : 0;
set_size(ptr, size + len, plen - len, nlen + len);
p1 = nxt + DouonBlkSizeNumber;
p2 = ptr + DouonBlkSizeNumber + len;
mvmemi(p1, p2, dicbuf + curdict->seglen - p1);
size = p1 - p2;
memset(dicbuf + curdict->seglen - size, DicSegTerm, size);
if (ptr == segtop()) {
chg_uidx(seg, ptr + DouonBlkSizeNumber, nlen + len);
}
}
(*curdict->putdic)(curdict, seg);
del_stdy(seg, ofs, size);
return AD_Done;
}
Static Int del_segment(seg)
TypeDicSeg seg;
static int
del_segment(TypeDicSeg seg)
{
Int i;
int i;
STDYIN *styp;
TypeDicID dicid;
TypeStyNum stdynum;
TypeDicSeg sg;
if (curdict->segunit > 1) {
for (sg = seg + 1 ; sg < curdict->segunit ; sg++) {
(*curdict->getdic)(curdict, sg);
(*curdict->putdic)(curdict, sg - 1);
@ -249,19 +197,16 @@ TypeDicSeg seg;
curdict->segunit--;
}
else {
memset(dicbuf, DicSegTerm, (Int)curdict->seglen);
memset(dicbuf, DicSegTerm, (int)curdict->seglen);
dicbuf[0] = 0;
(*curdict->putdic)(curdict, DicSegBase);
}
(*curdict->rszdic)(curdict, curdict->segunit);
del_uidx(seg);
if (StudyExist()) {
dicid = curdict->dicid;
for (i = 0, styp = StudyDict ; i < StudyCount ; ) {
if (styp -> dicid != dicid)
@ -271,10 +216,9 @@ TypeDicSeg seg;
else if (styp -> seg < seg)
;
else {
stdynum = styp -> styno;
StudyCount--;
mvmemi((Uchar *)(styp + 1), (Uchar *)styp,
mvmemi((u_char*)(styp + 1), (u_char*)styp,
sizeof(*styp) * (StudyCount - i));
continue;
}
@ -285,7 +229,6 @@ TypeDicSeg seg;
for (i = 0, styp = StudyDict ; i < StudyCount ; i++, styp++)
if (styp -> styno > stdynum) styp -> styno -= 1;
putstydic();
}
@ -293,40 +236,31 @@ TypeDicSeg seg;
}
Static Void del_uidx(seg)
TypeDicSeg seg;
static void
del_uidx(TypeDicSeg seg)
{
Uchar *p, *q;
Int len;
u_char *p, *q;
int len;
p = get_idxptr(seg);
for (q = p ; *q++; )
;
mvmemi(q, p, idxbuf + curdict->idxlen - q);
len = q - p;
memset(idxbuf + curdict->idxlen - len, 0, len);
(*curdict->putidx)(curdict, 0);
mkidxtbl(curdict);
}
Static Void del_stdy(seg, ofs, size)
TypeDicSeg seg;
TypeDicOfs ofs;
Int size;
static void
del_stdy(TypeDicSeg seg, TypeDicOfs ofs, int size)
{
Int i;
int i;
TypeStyNum stdynum;
STDYIN *stdy;
TypeDicID dicid;
@ -344,10 +278,9 @@ Int size;
stdy -> offset -= size;
else if (stdy -> offset == ofs) {
stdynum = stdy -> styno;
StudyCount--;
mvmemi((Uchar *)(stdy + 1), (Uchar *)stdy,
mvmemi((u_char*)(stdy + 1), (u_char*)stdy,
sizeof(*stdy) * (StudyCount - i));
continue;
}
@ -358,7 +291,6 @@ Int size;
for (i = 0, stdy = StudyDict ; i < StudyCount ; i++, stdy++)
if (stdy -> styno > stdynum) (stdy -> styno)--;
putstydic();
}
}

View file

@ -31,18 +31,22 @@
* $SonyRCSfile: depend.c,v $
* $SonyRevision: 1.4 $
* $SonyDate: 1997/10/07 07:39:45 $
*
* $Id$
*/
#include <sys/types.h>
#include "sj_kcnv.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <unistd.h>
#include "Dict.h"
#include "sj3err.h"
#include "kanakan.h"
#if defined(__FD_SET) && !defined(FD_SET)
@ -52,22 +56,14 @@
extern int serv_errno;
extern Global *work_base;
char *malloc();
DictFile *dictlink = NULL;
StdyFile *stdylink = NULL;
static long get4byte(p)
Uchar *p;
static long
get4byte(u_char* p)
{
long i;
@ -76,9 +72,9 @@ Uchar *p;
i = (i << 8) + *++p;
return ((i << 8) + *++p);
}
static void Put4byte(p, n)
Uchar *p;
long n;
static void
Put4byte(u_char* p, long n)
{
p += 3;
*p-- = n; n >>= 8;
@ -86,15 +82,12 @@ long n;
*p-- = n; n >>= 8;
*p = n;
}
#define put4byte(p, n) Put4byte((p), (long)(n))
static int fgetfile(fp, pos, len, p)
FILE *fp;
long pos;
int len;
Uchar *p;
static int
fgetfile(FILE* fp, long pos, int len, void* p)
{
if (fseek(fp, pos, 0) == ERROR) {
serv_errno = SJ3_FileSeekError; return ERROR;
@ -104,11 +97,9 @@ Uchar *p;
}
return SJ3_NormalEnd;
}
static int fputfile(fp, pos, len, p)
FILE *fp;
long pos;
int len;
Uchar *p;
static int
fputfile(FILE* fp, long pos, int len, u_char* p)
{
if (fseek(fp, pos, 0) == ERROR) {
serv_errno = SJ3_FileSeekError; return ERROR;
@ -118,11 +109,9 @@ Uchar *p;
}
return SJ3_NormalEnd;
}
static int getfile(fd, pos, len, p)
int fd;
int pos;
int len;
Uchar *p;
static int
getfile(int fd, off_t pos, int len, void* p)
{
if (lseek(fd, pos, L_SET) == ERROR) {
serv_errno = SJ3_FileSeekError; return ERROR;
@ -132,11 +121,9 @@ Uchar *p;
}
return SJ3_NormalEnd;
}
static int putfile(fd, pos, len, p)
int fd;
int pos;
int len;
Uchar *p;
static int
putfile(int fd, off_t pos, int len, void* p)
{
if (lseek(fd, pos, L_SET) == ERROR) {
serv_errno = SJ3_FileSeekError; return ERROR;
@ -148,33 +135,29 @@ Uchar *p;
}
static int check_passwd(buf, passwd)
Uchar *buf;
char *passwd;
static int
check_passwd(u_char* buf, char* passwd)
{
buf += PasswdPos;
return (*buf && strncmp(passwd, buf, PasswdLen)) ? FALSE : TRUE;
}
static void set_passwd(buf, passwd)
Uchar *buf;
char *passwd;
static void
set_passwd(u_char* buf, char* passwd)
{
strncpy(buf + PasswdPos, passwd, PasswdLen);
}
static int check_dictfile(buf)
Uchar *buf;
static int
check_dictfile(u_char* buf)
{
return (DictVersion != get4byte(buf + VersionPos)) ? FALSE : TRUE;
}
static DictFile *search_same_dict(ino)
ino_t ino;
static DictFile*
search_same_dict(ino_t ino)
{
DictFile *p;
@ -185,43 +168,44 @@ ino_t ino;
}
static Int getofs(dp)
register DictFile *dp;
static int
getofs(DictFile* dp)
{
idxofs = dp -> ofsptr;
return 0;
}
static Int getidx(dp)
register DictFile *dp;
static int
getidx(DictFile* dp)
{
idxbuf = dp -> buffer + dp -> idxstrt;
return 0;
}
static Int getdic(dp, seg)
register DictFile *dp;
TypeDicSeg seg;
static int
getdic(DictFile* dp, TypeDicSeg seg)
{
if (seg >= dp->dict.segunit) return -1;
dicbuf = dp->buffer + dp->segstrt + dp->dict.seglen * seg;
return 0;
}
static Int putidx(dp)
register DictFile *dp;
static int
putidx(DictFile* dp, TypeDicSeg seg)
{
return putfile(dp->fd, dp->idxstrt, dp->dict.idxlen, idxbuf);
}
static Int putdic(dp, seg)
register DictFile *dp;
TypeDicSeg seg;
static int
putdic(DictFile* dp, TypeDicSeg seg)
{
Uchar *p;
u_char *p;
long i, j;
if (seg >= dp->dict.maxunit) return -1;
i = dp->segstrt + dp->dict.seglen * (seg + 1);
if (i > dp->bufsiz) {
if (!(p = (Uchar *)malloc(i))) return -1;
if (!(p = (u_char *)malloc(i))) return -1;
memcpy(dp->buffer, p, dp->bufsiz);
if (idxbuf - dp->buffer == dp->idxstrt)
@ -240,16 +224,16 @@ TypeDicSeg seg;
return putfile(dp->fd, i, dp->dict.seglen, p);
}
static Int rszdic(dp, seg)
register DictFile *dp;
TypeDicSeg seg;
static int
rszdic(DictFile* dp, TypeDicSeg seg)
{
long i;
Uchar *p;
u_char *p;
i = dp->segstrt + dp->dict.seglen * seg;
if (dp->bufsiz != i) {
if (!(p = (Uchar *)malloc(i))) return -1;
if (!(p = (u_char *)malloc(i))) return -1;
memcpy(dp->buffer, p, ((i > dp->bufsiz) ? dp->bufsiz : i));
if (idxbuf - dp->buffer == dp->idxstrt)
@ -268,17 +252,15 @@ TypeDicSeg seg;
}
DictFile *opendict(name, passwd)
char *name;
char *passwd;
DictFile*
opendict(char* name, char* passwd)
{
FILE *fp;
struct stat sbuf;
DictFile *dfp;
Uchar tmp[HeaderLength];
u_char tmp[HeaderLength];
int i;
Uchar *dp;
u_char *dp;
if (stat(name, &sbuf) == ERROR) {
@ -376,9 +358,8 @@ error1: fclose(fp);
}
int closedict(dfp)
DictFile *dfp;
int
closedict(DictFile* dfp)
{
DictFile *df;
@ -408,38 +389,36 @@ DictFile *dfp;
}
static fd_set zero_fd_set = { { 0 } };
static fd_set zero_fd_set = { 0 };
void lock_dict(p, fd)
DictFile *p;
int fd;
void
lock_dict(DictFile* p, int fd)
{
FD_SET(fd, &(p -> lock));
}
void unlock_dict(p, fd)
DictFile *p;
int fd;
void
unlock_dict(DictFile* p, int fd)
{
FD_CLR(fd, &(p -> lock));
}
int is_dict_locked(p)
DictFile *p;
int
is_dict_locked(DictFile* p)
{
return memcmp(&(p -> lock), &zero_fd_set, sizeof(zero_fd_set));
}
static int check_stdyfile(buf)
Uchar *buf;
static int
check_stdyfile(u_char* buf)
{
return (StdyVersion != get4byte(buf + VersionPos)) ? FALSE : TRUE;
}
static StdyFile *search_same_stdy(ino)
ino_t ino;
static StdyFile*
search_same_stdy(ino_t ino)
{
StdyFile *p;
@ -450,18 +429,16 @@ ino_t ino;
}
StdyFile *openstdy(name, passwd)
char *name;
char *passwd;
StdyFile*
openstdy(char* name, char* passwd)
{
FILE *fp;
struct stat sbuf;
StdyFile *sfp;
Uchar *hd;
u_char *hd;
STDYIN *sp;
Ushort *cip;
Uchar *clp;
u_char *clp;
long stdycnt, stdypos, stdylen, stdymax;
long clidxpos, clidxlen;
long clstdypos, clstdylen, clstdystep;
@ -482,7 +459,7 @@ char *passwd;
}
if ((hd = (Uchar *)malloc(HeaderLength+CommentLength)) == NULL) {
if ((hd = (u_char *)malloc(HeaderLength+CommentLength)) == NULL) {
serv_errno = SJ3_NotEnoughMemory; return NULL;
}
@ -528,7 +505,7 @@ char *passwd;
if ((cip = (Ushort *)malloc(clidxlen)) == NULL) {
serv_errno = SJ3_NotEnoughMemory; goto error3;
}
if ((clp = (Uchar *)malloc(clstdylen)) == NULL) {
if ((clp = (u_char *)malloc(clstdylen)) == NULL) {
serv_errno = SJ3_NotEnoughMemory; goto error4;
}
@ -569,9 +546,8 @@ error0: free((char *)hd);
}
int closestdy(sfp)
StdyFile *sfp;
int
closestdy(StdyFile* sfp)
{
StdyFile *sf;
@ -603,11 +579,11 @@ StdyFile *sfp;
}
int putstydic()
int
putstydic(void)
{
int fd;
Uchar *hd;
u_char *hd;
StdyFile *sf;
long len;
@ -628,10 +604,12 @@ int putstydic()
return putfile(fd, get4byte(hd + StdyNormPos), len, sf -> stdy.stdydic);
}
int putcldic()
int
putcldic(void)
{
int fd;
Uchar *hd;
u_char *hd;
StdyFile *sf;
sf = (StdyFile *)stdy_base;
@ -646,15 +624,11 @@ int putcldic()
}
makedict(path, idxlen, seglen, segnum)
char *path;
int idxlen;
int seglen;
int segnum;
int
makedict(char* path, int idxlen, int seglen, int segnum)
{
FILE *fp;
Uchar tmp[HeaderLength + CommentLength];
u_char tmp[HeaderLength + CommentLength];
long pos = HeaderLength + CommentLength;
int ret = ERROR;
int i;
@ -708,15 +682,11 @@ error:
}
makestdy(path, stynum, clstep, cllen)
char *path;
int stynum;
int clstep;
int cllen;
int
makestdy(char* path, int stynum, int clstep, int cllen)
{
FILE *fp;
Uchar tmp[HeaderLength + CommentLength];
u_char tmp[HeaderLength + CommentLength];
long pos = HeaderLength + CommentLength;
int ret = ERROR;
int i, j;
@ -792,24 +762,23 @@ error:
}
void sj_closeall()
void
sj_closeall(void)
{
while (dictlink) closedict(dictlink);
while (stdylink) closestdy(stdylink);
}
set_dictpass(dp, pass)
DictFile *dp;
char *pass;
int
set_dictpass(DictFile* dp, char* pass)
{
set_passwd(dp -> buffer, pass);
return putfile(dp->fd, 0, HeaderLength+CommentLength, dp->buffer);
}
set_stdypass(pass)
char *pass;
int
set_stdypass(char* pass)
{
StdyFile *sp;
@ -820,22 +789,21 @@ char *pass;
static set_comment(buf, comment)
Uchar *buf;
char *comment;
static void
set_comment(u_char* buf, char* comment)
{
strncpy(buf + HeaderLength, comment, CommentLength);
}
set_dictcmnt(dp, cmnt)
DictFile *dp;
char *cmnt;
int
set_dictcmnt(DictFile* dp, char* cmnt)
{
set_comment(dp -> buffer, cmnt);
return putfile(dp->fd, 0, HeaderLength+CommentLength, dp->buffer);
}
set_stdycmnt(cmnt)
char *cmnt;
int
set_stdycmnt(char* cmnt)
{
StdyFile *sp;
@ -845,9 +813,8 @@ char *cmnt;
}
get_stdysize(stynum, clstep, cllen)
int *stynum, *clstep, *cllen;
void
get_stdysize(int* stynum, int* clstep, int* cllen)
{
*stynum = StudyMax;
*clstep = ClStudyStep;

View file

@ -31,38 +31,31 @@
* $SonyRCSfile: dict.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:45 $
*
* $Id$
*/
#include <sys/types.h>
#include "sj_euc.h"
#include "sj_kcnv.h"
Int codesize();
#include "kanakan.h"
Void get_askknj()
void
get_askknj(void)
{
Reg1 Uchar *p;
Reg3 Uchar *q;
Reg2 Uchar *r;
Int i = 0, csize;
Int flg;
u_char *p;
u_char *q;
u_char *r;
int i = 0, csize;
int flg;
p = q = dicbuf;
q += *p++;
while (p < q) {
askknj[i] = p;
r = NULL;
flg = TRUE;
do {
@ -76,15 +69,13 @@ Void get_askknj()
} while (flg);
p++;
askknj_k[i++] = r;
}
}
Int seldict(id)
TypeDicID id;
int
seldict(TypeDicID id)
{
DICTL *dp;
@ -98,9 +89,8 @@ TypeDicID id;
}
Uchar *get_idxptr(seg)
TypeDicSeg seg;
u_char*
get_idxptr(TypeDicSeg seg)
{
(*curdict->getofs)(curdict);
(*curdict->getidx)(curdict);

View file

@ -31,53 +31,38 @@
* $SonyRCSfile: functbl.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:46 $
*
* $Id$
*/
#include "sj_rename.h"
#include "sj_typedef.h"
#include "sj_func.h"
#include "kanakan.h"
Void num_type00(), num_type01(), num_type02(), num_type03();
Void num_type04(), num_type05(), num_type06(), num_type07();
Void num_type08(), num_type09(), num_type10(), num_type11();
Void num_type12(), num_type13(), num_type14();
VFunc cvtnum_func[] = {
VFuncNT cvtnum_func[] = {
num_type00, num_type01, num_type02, num_type03,
num_type04, num_type05, num_type06, num_type07,
num_type08, num_type09, num_type10, num_type11,
num_type12, num_type13, num_type14
};
Uchar *getkan_hira(), *getkan_kata(), *getkan_knj(), *getkan_ofs();
Uchar *getkan_norm(), *getkan_none();
UCPFunc getkan_func[] = {
UCPFuncGK getkan_func[] = {
getkan_norm, getkan_norm, getkan_hira, getkan_kata,
getkan_knj, getkan_ofs, getkan_norm, getkan_none,
getkan_norm, getkan_norm, getkan_hira, getkan_kata,
getkan_knj, getkan_ofs, getkan_norm, getkan_none
};
Int setj_norm1(), setj_norm2(), setj_knj(), setj_ofs(), setj_atrb();
IFunc setjrec_func[] = {
IFuncSetj setjrec_func[] = {
setj_norm2, setj_norm2, setj_norm1, setj_norm1,
setj_knj, setj_ofs, setj_norm2, setj_atrb,
setj_norm2, setj_norm2, setj_norm1, setj_norm1,
setj_knj, setj_ofs, setj_norm2, setj_atrb
};
Int hiraknj_atrb(), hiraknj_ofs(), hiraknj_knj(), hiraknj_hask();
Int hiraknj_kask(), hiraknj_norm(), hiraknj_hira();
IFunc hiraknj_func[] = {
IFuncHira hiraknj_func[] = {
hiraknj_hira, hiraknj_norm, hiraknj_hask, hiraknj_kask,
hiraknj_knj, hiraknj_ofs, hiraknj_norm, hiraknj_atrb,
hiraknj_hira, hiraknj_norm, hiraknj_hask, hiraknj_kask,
@ -85,10 +70,7 @@ IFunc hiraknj_func[] = {
};
Uchar *makekan_1byte(), *makekan_knj(), *makekan_ofs();
Uchar *makekan_norm(), *makekan_none();
UCPFunc makekan_func[] = {
UCPFuncMK makekan_func[] = {
makekan_norm, makekan_norm, makekan_1byte, makekan_1byte,
makekan_knj, makekan_ofs, makekan_norm, makekan_none,
makekan_norm, makekan_norm, makekan_1byte, makekan_1byte,

View file

@ -31,41 +31,30 @@
* $SonyRCSfile: getkanji.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:49 $
*
* $Id$
*/
#include "sj_euc.h"
#include "sj_kcnv.h"
#include "kanakan.h"
static u_char*
code2kanji(u_char* s, u_char* d, u_char* ym, int yl, int flg);
Static Uchar *code2kanji();
Int codesize();
Uchar *getkan_none(s, d, ym, yl, flg)
Uchar *s;
Uchar *d;
Uchar *ym;
Int yl;
Int flg;
u_char*
getkan_none(u_char* s, u_char* d, u_char* ym, int yl, int flg)
{
return d;
}
Uchar *getkan_hira(s, d, ym, yl, flg)
Uchar *d;
Reg2 Uchar *ym;
Uchar *s;
Int yl;
Int flg;
u_char*
getkan_hira(u_char* s, u_char* d, u_char* ym, int yl, int flg)
{
Reg1 Int cnt, csize;
int cnt, csize;
csize = codesize(*s);
@ -82,15 +71,11 @@ Int flg;
}
Uchar *getkan_kata(s, d, ym, yl, flg)
Reg1 Uchar *d;
Reg2 Uchar *ym;
Uchar *s;
Int flg;
u_char*
getkan_kata(u_char* s, u_char* d, u_char* ym, int yl, int flg)
{
Reg3 Int cnt, csize;
Reg4 Uchar ch;
int cnt, csize;
u_char ch;
csize = codesize(*s);
@ -123,26 +108,16 @@ Int flg;
}
Uchar *getkan_knj(s, d, ym, yl, flg)
Uchar *s;
Uchar *d;
Uchar *ym;
Int yl;
Int flg;
u_char*
getkan_knj(u_char* s, u_char* d, u_char* ym, int yl, int flg)
{
return code2kanji(askknj[*s & KnjAssyukuMask], d, ym, yl, flg);
}
Uchar *getkan_ofs(s, d, ym, yl, flg)
Uchar *s;
Uchar *d;
Uchar *ym;
Int yl;
Int flg;
u_char*
getkan_ofs(u_char* s, u_char* d, u_char* ym, int yl, int flg)
{
return code2kanji(dicbuf + ((*s & KanjiCodeMask) << 8) + *(s + 1),
@ -150,16 +125,10 @@ Int flg;
}
Uchar *getkan_norm(s, d, ym, yl, flg)
Uchar *s;
Uchar *d;
Uchar *ym;
Int yl;
Int flg;
u_char*
getkan_norm(u_char* s, u_char* d, u_char* ym, int yl, int flg)
{
Reg2 Int i, csize;
Reg2 Uchar c;
u_char c;
if (*s != 0) {
c = s[1];
@ -174,15 +143,10 @@ Int flg;
}
Uchar *getkan_ascii(s, d, ym, yl, flg)
Uchar *s;
Uchar *d;
Uchar *ym;
Int yl;
Int flg;
u_char*
getkan_ascii(u_char* s, u_char* d, u_char* ym, int yl, int flg)
{
Reg2 Uchar c;
u_char c;
c = s[1];
if (c & 0x80)
@ -193,15 +157,10 @@ Int flg;
}
Static Uchar *code2kanji(s, d, ym, yl, flg)
Uchar *s;
Uchar *d;
Uchar *ym;
Int yl;
Int flg;
static u_char*
code2kanji(u_char* s, u_char* d, u_char* ym, int yl, int flg)
{
Reg2 Int csize;
int csize;
for ( ; ; ) {
csize = codesize(*s);
@ -261,19 +220,13 @@ Int flg;
}
Int getkanji(ym, yl, ptr, buf)
Uchar *ym;
Int yl;
Uchar *ptr;
Uchar *buf;
int
getkanji(u_char* ym, int yl, u_char* ptr, u_char* buf)
{
Uchar *q;
u_char *q;
q = code2kanji(ptr, buf, ym, yl, TRUE);
return q - buf;
}

View file

@ -31,112 +31,79 @@
* $SonyRCSfile: getrank.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:50 $
*
* $Id$
*/
#include "sj_kcnv.h"
#include "kanakan.h"
static void setstynum (void);
static void setnspr (KHREC *kptr, STDYIN *sptr);
static void regetrank (void);
STDYIN *srchstdy();
Static Void setstynum(), setnspr(), regetrank();
Void getrank()
void
getrank (void)
{
trank = nrank = 1;
setstynum();
regetrank();
}
Static Void setstynum()
static void
setstynum (void)
{
KHREC *kptr;
STDYIN *sptr;
Int count;
for (kptr = kouhotbl, count = khcount ; count-- ; kptr++) {
sptr = srchstdy(kptr -> clrec -> jnode -> jseg, kptr -> offs,
kptr -> clrec -> jnode -> dicid);
if (!sptr) continue;
setnspr(kptr, sptr);
}
}
Static Void setnspr(kptr, sptr)
KHREC *kptr;
STDYIN *sptr;
static void
setnspr (KHREC *kptr, STDYIN *sptr)
{
KHREC *ptr;
Int keepnm;
TypeStyNum styno;
styno = kptr -> styno = sptr -> styno;
keepnm = trank;
for (ptr = kouhotbl ; ptr < kptr ; ptr++) {
if (styno < ptr -> styno) {
ptr -> rank++;
keepnm--;
}
else if (styno == ptr -> styno) {
if (kptr -> sttfg && kptr -> ka_fg) {
if ((sptr -> sttkj == kptr -> sttkj) &&
(sptr -> ka_kj == kptr -> ka_kj)) {
ptr -> rank++;
keepnm--;
}
}
else if (kptr -> sttfg) {
if (sptr -> sttkj == kptr -> sttkj) {
ptr -> rank++;
keepnm--;
}
}
else if (kptr -> ka_fg) {
if (sptr -> ka_kj == kptr -> ka_kj) {
ptr -> rank++;
keepnm--;
@ -145,41 +112,30 @@ STDYIN *sptr;
}
}
kptr -> rank = (Uchar)keepnm;
trank++;
if (keepnm <= nrank) nrank++;
if (sptr -> nmflg && (nrank > keepnm)) nrank = keepnm;
}
Static Void regetrank()
static void
regetrank (void)
{
KHREC *kptr;
Int count;
Int tmp;
if (nrank < trank) {
tmp = nrank;
trank += nkhcount;
}
else {
nkhcount = tmp = 0;
}
for (count = khcount, kptr = kouhotbl ; count-- ; kptr++) {
if (!(kptr -> rank)) {
if (tmp && kptr -> mode && !(kptr -> offs)) {
kptr -> rank = (Uchar)tmp++;
@ -187,8 +143,6 @@ Static Void regetrank()
else
kptr -> rank = (Uchar)trank++;
}
else if ((Short)kptr -> rank >= nrank)
kptr -> rank += (Uchar)nkhcount;
}

View file

@ -31,19 +31,20 @@
* $SonyRCSfile: hzstrlen.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:52 $
*
* $Id$
*/
#include "sj_euc.h"
#include "sj_rename.h"
#include "sj_typedef.h"
#include "sj_const.h"
#include "sj_dict.h"
#include "kanakan.h"
Int euc_codesize(c)
Reg1 Uchar c;
Int
euc_codesize (Uchar c)
{
if ((c & KanjiModeMask) == 0x90) {
return 1;
@ -56,17 +57,12 @@ Reg1 Uchar c;
}
}
Int hzstrlen(ptr, len)
Reg1 Uchar *ptr;
Reg2 Int len;
Int
hzstrlen (Uchar *ptr, Int len)
{
Uchar *head;
head = ptr;
while (len-- > 0) ptr += euc_codesize(*ptr);
return (ptr - head);
}

224
kanakan/kanakan.h Normal file
View file

@ -0,0 +1,224 @@
/*
* Copyright (c) 2004 Hiroo Ono <hiroo+sj3 at oikumene.gcd.org>
*
* 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.
*
*/
/*
* $Id: kanakan.h,v 1.2 2004/07/04 08:11:10 hiroo Exp $
*/
#ifndef _KANAKAN_H_
#define _KANAKAN_H_ 1
#include "sj_struct.h"
#include "Struct.h"
/* adddic.c */
u_int adddic(u_char *yomi, u_char *kanji, TypeGram hinsi);
/* addelcmn.c */
void set_size(unsigned char *p, int size, int plen, int nlen);
unsigned int addel_arg(unsigned char *yp, unsigned char *kp, TypeGram grm, unsigned char *nyp, int len);
int cvtknj(unsigned char *yomi, unsigned char *knj, unsigned char *dst);
int srchkana(unsigned char **ptr, int *saml);
int srchgram(unsigned char *ptr, unsigned char **dst, TypeGram hinsi);
int srchkanji(unsigned char **dst, unsigned char *knj, int klen);
TypeIdxOfs count_uidx(void);
void chg_uidx(TypeDicSeg seg, unsigned char *yomi, int len);
/* alloc.c */
JREC *alloc_jrec(void);
void free_jrec(JREC *p);
CLREC *alloc_clrec(void);
void free_clrec(CLREC *p);
/* charsize.c */
int codesize(u_char code);
/* cl2knj.c */
int cl2knj(u_char *yomi, int len, u_char *kouho);
int nextcl(u_char *kouho, int mode);
int prevcl(u_char *kouho, int mode);
int selectnum(void);
/* clstudy.c */
int clstudy(u_char *yomi1, u_char *yomi2, STDYOUT *stdy);
void delclsub(u_char *target);
void mkclidx(void);
/* cvtdict.c */
void cvtdict(KHREC *krec, CLREC *clrec, int flg);
void cvtminasi(int len);
void cvtwakachi(CLREC *clrec);
/* cvtkanji.c */
void cvtphknj(void);
void cvtkouho(KHREC *krec);
void setstyrec(KHREC *krec);
/* deldic.c */
u_int deldic(u_char *yomi, u_char *kanji, TypeGram hinsi);
/* depend.c */
DictFile *opendict(char *name, char *passwd);
int closedict(DictFile *dfp);
void lock_dict(DictFile *p, int fd);
void unlock_dict(DictFile *p, int fd);
int is_dict_locked(DictFile *p);
StdyFile *openstdy(char *name, char *passwd);
int closestdy(StdyFile *sfp);
int putstydic(void);
int putcldic(void);
int makedict(char *path, int idxlen, int seglen, int segnum);
int makestdy(char *path, int stynum, int clstep, int cllen);
void sj_closeall(void);
int set_dictpass(DictFile *dp, char *pass);
int set_stdypass(char *pass);
int set_dictcmnt(DictFile *dp, char *cmnt);
int set_stdycmnt(char *cmnt);
void get_stdysize(int *stynum, int *clstep, int *cllen);
/* dict.c */
void get_askknj(void);
int seldict(TypeDicID id);
u_char *get_idxptr(TypeDicSeg seg);
/* getkanji.c */
u_char *getkan_none(u_char *s, u_char *d, u_char *ym, int yl, int flg);
u_char *getkan_hira(u_char *s, u_char *d, u_char *ym, int yl, int flg);
u_char *getkan_kata(u_char *s, u_char *d, u_char *ym, int yl, int flg);
u_char *getkan_knj(u_char *s, u_char *d, u_char *ym, int yl, int flg);
u_char *getkan_ofs(u_char *s, u_char *d, u_char *ym, int yl, int flg);
u_char *getkan_norm(u_char *s, u_char *d, u_char *ym, int yl, int flg);
u_char *getkan_ascii(u_char *s, u_char *d, u_char *ym, int yl, int flg);
int getkanji(u_char *ym, int yl, u_char *ptr, u_char *buf);
/* getrank.c */
void getrank(void);
/* hzstrlen.c */
int euc_codesize(unsigned char c);
int hzstrlen(unsigned char *ptr, int len);
/* mkbunset.c */
void mkbunsetu(void);
CLREC* argclrec(int len);
/* mkjiritu.c */
void mkjiritu(int mode);
JREC *argjrec(int len, JREC *rec);
/* mkkouho.c */
u_char *makekan_none(u_char *s, u_char *d, int flg);
u_char *makekan_1byte(u_char *s, u_char *d, int flg);
u_char *makekan_knj(u_char *s, u_char *d, int flg);
u_char *makekan_ofs(u_char *s, u_char *d, int flg);
u_char *makekan_norm(u_char *s, u_char *d, int flg);
u_char *makekan_ascii(u_char *s, u_char *d, int flg);
void mkkouho(void);
int sel_sjmode(JREC *jrec);
/* mknumber.c */
void num_type00(u_char *s1, u_char *s2, JREC *jrec);
void num_type01(u_char *s1, u_char *s2, JREC *jrec);
void num_type02(u_char *s1, u_char *s2, JREC *jrec);
void num_type03(u_char *s1, u_char *s2, JREC *jrec);
void num_type04(u_char *s1, u_char *s2, JREC *jrec);
void num_type05(u_char *s1, u_char *s2, JREC *jrec);
void num_type06(u_char *s1, u_char *s2, JREC *jrec);
void num_type07(u_char *s1, u_char *s2, JREC *jrec);
void num_type08(u_char *s1, u_char *s2, JREC *jrec);
void num_type09(u_char *s1, u_char *s2, JREC *jrec);
void num_type10(u_char *s1, u_char *s2, JREC *jrec);
void num_type11(u_char *s1, u_char *s2, JREC *jrec);
void num_type12(u_char *s1, u_char *s2, JREC *jrec);
void num_type13(u_char *s1, u_char *s2, JREC *jrec);
void num_type14(u_char *s1, u_char *s2, JREC *jrec);
/* peepdic.c */
int getusr(unsigned char *buf);
int nextusr(unsigned char *buf);
int prevusr(unsigned char *buf);
/* ph2knj.c */
int ph2knj(unsigned char *zyomi, unsigned char *kanji, int knjlen);
/* ph_khtbl.c */
int ph_khtbl(CLREC *clrec);
/* setconj.c */
int setconj(TypeGram hinsi, JREC *jrec, CREC *crec);
/* setjrec.c */
int setj_atrb(u_char* p);
int setj_ofs(u_char* p);
int setj_knj(u_char* p);
int setj_norm1(u_char* p);
int setj_norm2(u_char* p);
int setj_norm3(u_char* p);
void setjrec(u_char* tagp, int mode);
void setnumrec(u_char* tagp, JREC* rec, TypeGram gram);
void setcrec(u_char* tagp);
/* setkouho.c */
void setkouho(CLREC* clrec, TypeDicOfs offs, int mode);
void ph_setkouho(CLREC* clrec, TypeDicOfs offs, STDYIN* sptr);
int hiraknj_atrb(u_char*, int*);
int hiraknj_ofs (u_char*, int*);
int hiraknj_knj (u_char*, int*);
int hiraknj_hask(u_char*, int*);
int hiraknj_kask(u_char*, int*);
int hiraknj_norm(u_char*, int*);
int hiraknj_hira(u_char*, int*);
/* setubi.c */
unsigned char *getstb(TypeGram hinsi);
void setubi(JREC *rec, unsigned char *stbtbl);
/* skipkstr.c */
u_char* skipkstr(u_char* ptr);
/* srchdict.c */
int yomicmp(u_char *ptr1, u_char *ptr2, u_char *saml);
u_char *srchdict(u_char *tagp);
/* srchidx.c */
TypeDicSeg srchidx(TypeDicSeg low, int len);
/* srchnum.c */
void srchnum(void);
void setwdnum(u_char *p, int len, u_short *wd);
int setucnum(u_char *p, int len, u_char *ud);
/* study.c */
int study(STDYOUT *stdy);
STDYIN *srchstdy(TypeDicSeg seg, TypeDicOfs ofs, TypeDicID dicid);
/* wakachi.c */
void wakachi(void);
#endif /* _KANAKAN_H_ */

View file

@ -1,57 +0,0 @@
/*
* 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: memcpy.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:56 $
*/
#include "sj_rename.h"
#include "sj_typedef.h"
Void memcpy (src, dst, n)
Reg1 Uchar *src;
Reg2 Uchar *dst;
Reg3 Int n;
{
while (n-- > 0) *dst++ = *src++;
}
Void sstrncpy(src, dst, n)
Reg2 Uchar *src;
Reg1 Uchar *dst;
Reg3 Int n;
{
while (n-- > 0) *dst++ = *src++;
*dst = 0;
}

View file

@ -1,48 +0,0 @@
/*
* 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: memset.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:59 $
*/
#include "sj_rename.h"
#include "sj_typedef.h"
Void memset(p, c, n)
Reg1 Uchar *p;
Reg3 Uchar c;
Reg2 Int n;
{
while (n-- > 0) *p++ = c;
}

View file

@ -31,27 +31,30 @@
* $SonyRCSfile: mkbunset.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:02 $
*
* $Id$
*/
#include <sys/types.h>
#include <string.h>
#include "sj_kcnv.h"
#include "sj_hinsi.h"
#include "kanakan.h"
CLREC *alloc_clrec();
Uchar TFar *getstb();
Int terminate(), setconj();
Void setclrec(), srchfzk(), memset();
Int terminate();
Void setclrec(), srchfzk();
Void mkbunsetu()
void
mkbunsetu(void)
{
Reg1 JREC *jrec;
JREC *jrec;
TypeGram hinsi;
Uchar TFar *cnj;
u_char *cnj;
CREC crec[4];
Int count;
int count;
TypeCnct right;
Uchar *next;
u_char *next;
int i;
fzkcount = 0;
@ -67,7 +70,7 @@ Void mkbunsetu()
else
hinsi = jrec -> hinsi;
if (right = Connadr[hinsi]) {
if ((right = Connadr[hinsi]) != '\0') {
gobilen = 0;
next = cnvstart + jrec->jlen;
@ -79,7 +82,7 @@ Void mkbunsetu()
srchfzk(jrec, next, right, 0);
}
else if (count = setconj(hinsi, jrec, crec)) {
else if ((count = setconj(hinsi, jrec, crec)) != 0) {
for (i = count ; i-- > 0 ; ) {
@ -101,26 +104,26 @@ Void mkbunsetu()
}
CLREC *argclrec(len)
Int len;
CLREC*
argclrec(int len)
{
Reg1 CLREC *ptr;
Reg2 CLREC *rec;
Reg3 CLREC *child;
CLREC *ptr;
CLREC *rec;
CLREC *child;
rec = alloc_clrec();
if (!rec) {
if (!maxclptr) return NULL;
if (maxclptr == NULL) return NULL;
ptr = NULL;
rec = maxclptr;
while (child = rec -> clsort) {
while ((child = rec -> clsort) != NULL) {
ptr = rec;
rec = child;
}
if (len <= (Int) rec -> cllen) return NULL;
if (len <= (int) rec -> cllen) return NULL;
if (ptr)
ptr -> clsort = NULL;
@ -129,8 +132,8 @@ Int len;
if (rec -> jnode) (rec -> jnode)--;
}
memset((Uchar *)rec, 0, sizeof(*rec));
rec -> cllen = rec -> cl2len = (Uchar)len;
memset((u_char*)rec, 0, sizeof(*rec));
rec -> cllen = rec -> cl2len = (u_char)len;
if (!maxclptr) {
maxclptr = rec;
@ -139,17 +142,17 @@ Int len;
ptr = maxclptr;
if (((Int)ptr -> cllen < len) ||
(((Int)ptr -> cllen == len) &&
if (((int)ptr -> cllen < len) ||
(((int)ptr -> cllen == len) &&
(ptr -> jnode -> hinsi == TANKANJI))) {
rec -> clsort = maxclptr;
maxclptr = rec;
return rec;
}
while (child = ptr -> clsort) {
if ((Int)child -> cllen < len ||
((Int)child -> cllen == len &&
while ((child = ptr -> clsort) != NULL) {
if ((int)child -> cllen < len ||
((int)child -> cllen == len &&
child->jnode->hinsi == TANKANJI)){
ptr -> clsort = rec;
rec -> clsort = child;
@ -159,7 +162,6 @@ Int len;
ptr = child;
}
ptr -> clsort = rec;
return rec;
}

View file

@ -31,28 +31,28 @@
* $SonyRCSfile: mkjiritu.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:03 $
*
* $Id$
*/
#include <sys/types.h>
#include <string.h>
#include "sj_kcnv.h"
#include "kanakan.h"
Uchar *srchdict();
Uchar TFar *getstb();
Int srchhead(), sstrncmp();
JREC *alloc_jrec();
Void srchnum(), setubi(), setjrec();
Void setcrec(), memcpy(), memset();
Int srchhead();
Static Void dic_mu(), dic_cl();
static void dic_mu(int mode);
static void dic_cl(void);
Void mkjiritu(mode)
Int mode;
void
mkjiritu(int mode)
{
Uchar chkind1;
Uchar chkind2;
u_char chkind1;
u_char chkind2;
JREC *jrec;
Uchar TFar *stb;
u_char *stb;
headcode = headlen = 0;
@ -87,15 +87,15 @@ Int mode;
}
for (jrec = maxjptr ; jrec ; jrec = jrec -> jsort) {
if (stb = getstb(jrec -> hinsi))
if ((stb = getstb(jrec -> hinsi)) != NULL)
setubi(jrec, stb);
}
}
Static Void dic_mu(mode)
Int mode;
static void
dic_mu(int mode)
{
Uchar *tagp;
u_char *tagp;
DICTL *dp;
for (dp = dictlist ; dp ; dp = dp -> next) {
@ -104,17 +104,16 @@ Int mode;
dicsaml = 0;
prevseg = -1;
while (tagp = srchdict(tagp)) setjrec(tagp, mode);
while ((tagp = srchdict(tagp)) != NULL) setjrec(tagp, mode);
}
}
JREC *argjrec(len, rec)
Int len;
JREC *rec;
JREC*
argjrec(int len, JREC* rec)
{
Reg1 JREC *ptr;
Reg2 JREC *jrec;
Reg3 JREC *child;
JREC *ptr;
JREC *jrec;
JREC *child;
jrec = alloc_jrec();
@ -123,12 +122,12 @@ JREC *rec;
ptr = NULL;
jrec = maxjptr;
while (child = jrec -> jsort) {
while ((child = jrec -> jsort) != NULL) {
ptr = jrec;
jrec = child;
}
if (len <= (Int) jrec -> jlen) return NULL;
if (len <= (int) jrec -> jlen) return NULL;
if (ptr)
ptr -> jsort = NULL;
@ -137,10 +136,10 @@ JREC *rec;
}
if (rec)
memcpy((Uchar *)rec, (Uchar *)jrec, sizeof(JREC));
memcpy((u_char*)rec, (u_char*)jrec, sizeof(JREC));
else
memset((Uchar *)jrec, 0, sizeof(*jrec));
jrec -> jlen = (Uchar)len;
memset((u_char*)jrec, 0, sizeof(*jrec));
jrec -> jlen = (u_char)len;
if (!maxjptr) {
maxjptr = jrec;
@ -150,14 +149,14 @@ JREC *rec;
ptr = maxjptr;
if ((Int)ptr -> jlen < len) {
if ((int)ptr -> jlen < len) {
jrec -> jsort = maxjptr;
maxjptr = jrec;
return jrec;
}
while (child = ptr -> jsort) {
if ((Int)child -> jlen < len) break;
while ((child = ptr -> jsort) != NULL) {
if ((int)child -> jlen < len) break;
ptr = child;
}
@ -167,19 +166,20 @@ JREC *rec;
return jrec;
}
Static Void dic_cl()
static void
dic_cl(void)
{
Uchar *p;
Ushort pos;
Int len;
Int cmp;
u_char *p;
u_short pos;
int len;
int cmp;
if (!StudyExist()) return;
if ((pos = ClStudyIdx[(Short) *cnvstart / ClStudyStep]) != (Ushort)-1) {
if ((pos = ClStudyIdx[(Short) *cnvstart / ClStudyStep]) != (u_short)-1) {
for (p = ClStudyDict + pos ; !iseocl(p) ; p = ClNextTag(p)) {
cmp = sstrncmp(cnvstart, (Uchar TFar *)ClYomiPos(p),
cmp = strncmp(cnvstart, (u_char*)ClYomiPos(p),
len = ClYomiLen(p));
if (cmp == MATCH) {

View file

@ -31,36 +31,31 @@
* $SonyRCSfile: mkkouho.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:04 $
*
* $Id$
*/
#include "sj_euc.h"
#include "sj_kcnv.h"
#include "sj_hinsi.h"
#include "sj_suuji.h"
#include "sj_dict.h"
#include "kanakan.h"
Uchar *skipkstr();
Void setkouho(), setwdnum(), get_askknj();
Int seldict(), codesize();
static void getkhtbl(CLREC* clrec);
static void cl_kanji(JREC* jrec, CLREC* clrec);
static u_char* makekan(u_char* s, u_char* d, int flg);
static int diffknj(JREC* jrec, u_char* ptr, int num);
static void cl_numcmn(JREC* jrec, CLREC* clrec);
Static Void getkhtbl(), cl_kanji();
Static Int diffknj();
Static Void cl_numcmn();
Static Uchar *makekan();
Void mkkouho()
void
mkkouho(void)
{
CLREC *clrec;
Int keeplen;
int keeplen;
khcount = nkhcount = 0;
@ -79,19 +74,15 @@ Void mkkouho()
}
Static Void getkhtbl(clrec)
CLREC *clrec;
static void
getkhtbl(CLREC* clrec)
{
JREC *jrec;
jrec = clrec -> jnode;
switch (jrec -> class) {
case C_DICT:
cl_kanji(jrec, clrec);
break;
@ -114,20 +105,17 @@ CLREC *clrec;
case C_MINASI:
case C_WAKACHI:
setkouho(clrec, (TypeDicOfs)0, 0);
break;
}
}
Static Void cl_kanji(jrec, clrec)
JREC *jrec;
CLREC *clrec;
static void
cl_kanji(JREC* jrec, CLREC* clrec)
{
Uchar *ptr;
Int kcount = khcount;
u_char *ptr;
int kcount = khcount;
if (seldict(jrec -> dicid)) {
@ -156,21 +144,15 @@ CLREC *clrec;
}
Uchar *makekan_none(s, d, flg)
Uchar *s;
Uchar *d;
Int flg;
u_char*
makekan_none(u_char* s, u_char* d, int flg)
{
return d;
}
Uchar *makekan_1byte(s, d, flg)
Uchar *s;
Uchar *d;
Int flg;
u_char*
makekan_1byte(u_char* s, u_char* d, int flg)
{
if ((*s & KanjiModeMask) == ZenHiraAssyuku)
*d++ = 0x10 | (*s & KnjAssyukuMask);
@ -182,22 +164,16 @@ Int flg;
}
Uchar *makekan_knj(s, d, flg)
Uchar *s;
Uchar *d;
Int flg;
u_char*
makekan_knj(u_char* s, u_char* d, int flg)
{
return makekan(askknj[*s & KnjAssyukuMask], d, flg);
}
Uchar *makekan_ofs(s, d, flg)
Uchar *s;
Uchar *d;
Int flg;
u_char*
makekan_ofs(u_char* s, u_char* d, int flg)
{
return makekan(dicbuf + ((*s & KanjiCodeMask) << 8) + *(s + 1),
@ -205,14 +181,10 @@ Int flg;
}
Uchar *makekan_norm(s, d, flg)
Uchar *s;
Uchar *d;
Int flg;
u_char*
makekan_norm(u_char* s, u_char* d, int flg)
{
Reg1 Int i, csize;
Reg1 Uchar c;
u_char c;
if (*s != 0) {
c = s[1];
@ -229,13 +201,10 @@ Int flg;
}
Uchar *makekan_ascii(s, d, flg)
Uchar *s;
Uchar *d;
Int flg;
u_char*
makekan_ascii(u_char* s, u_char* d, int flg)
{
Reg1 Uchar c;
u_char c;
c = s[1];
if (c & 0x80)
@ -248,13 +217,10 @@ Int flg;
}
Static Uchar *makekan(s, d, flg)
Uchar *s;
Uchar *d;
Int flg;
static u_char*
makekan(u_char* s, u_char* d, int flg)
{
Reg1 Int csize;
int csize;
for ( ; ; ) {
csize = codesize(*s);
@ -314,26 +280,19 @@ Int flg;
}
#define PEND 2
#define QEND 1
Static Int sameknj(p, plen, q, qlen)
Reg1 Uchar *p;
Uchar plen;
Reg2 Uchar *q;
Uchar qlen;
static int
sameknj(u_char* p, int plen, u_char* q, int qlen)
{
Int i;
Int j;
Int endf = 0;
Int brkf;
extern Int euc_codesize();
int i;
int j;
int endf = 0;
int brkf;
do {
if ((i = euc_codesize(*p)) != euc_codesize(*q)) return FALSE;
brkf = 0;
for (j = 0; j < i; j++) {
if (p[j] != q[j] ) {
@ -343,37 +302,30 @@ Uchar qlen;
}
if (brkf) break;
if (p[i] == KanjiStrEnd) endf += PEND;
if (q[i] == KanjiStrEnd) endf += QEND;
p += i;
q += i;
} while (!endf);
switch (endf) {
case (PEND | QEND):
if (plen == qlen) return TRUE;
break;
case PEND:
i = plen;
plen = qlen;
qlen = i;
p = q;
case QEND:
if (p[euc_codesize(*p)] != KanjiStrEnd) break;
if ((*p & KanjiModeMask) != 0x10 ) break;
if (qlen != plen - (*p & KanjiCodeMask) - 1) break;
return TRUE;
default:
if (q[euc_codesize(*q)] != KanjiStrEnd) break;
if (p[euc_codesize(*p)] != KanjiStrEnd) break;
@ -390,72 +342,52 @@ Uchar qlen;
#undef QEND
Static Int diffknj(jrec, ptr, num)
JREC *jrec;
Uchar *ptr;
Int num;
static int
diffknj(JREC* jrec, u_char* ptr, int num)
{
KHREC *kptr;
JREC *jptr;
Int i;
Uchar kbuf1[MaxWdKanjiLen];
Uchar kbuf2[MaxWdKanjiLen];
int i;
u_char kbuf1[MaxWdKanjiLen];
u_char kbuf2[MaxWdKanjiLen];
if (jrec -> hinsi == TANKANJI) return TRUE;
makekan(ptr, kbuf1, TRUE);
for (i = 0, kptr = kouhotbl ; i < num ; i++, kptr++) {
if ((jptr = kptr -> clrec -> jnode) == jrec)
return FALSE;
if (jptr -> hinsi == TANKANJI) continue;
if (jptr -> class != jrec -> class) continue;
if (jptr -> dicid != jrec -> dicid) continue;
if (jptr -> jseg != jrec -> jseg) continue;
if (jptr -> sttofs != jrec -> sttofs) continue;
if (jptr -> stbofs != jrec -> stbofs) continue;
makekan(dicbuf + kptr -> offs, kbuf2, TRUE);
if (sameknj(kbuf1, jrec -> jlen, kbuf2, jptr -> jlen))
return FALSE;
}
return TRUE;
}
Static Int chrck_numtbl(flg, cond)
Ushort flg;
Ushort cond;
static int
chrck_numtbl(u_short flg, u_short cond)
{
Ushort must;
u_short must;
if (cond = SelNumCond(cond)) {
if (must = (cond & SelNumMust)) {
if ((cond = SelNumCond(cond)) != 0) {
if ((must = (cond & SelNumMust)) != 0) {
if ((flg & must) != must) return FALSE;
cond &= ~must;
}
@ -466,13 +398,12 @@ Ushort cond;
}
Int sel_sjmode(jrec)
JREC *jrec;
int
sel_sjmode(JREC* jrec)
{
Ushort i;
Ushort TFar *p;
Ushort TFar *q;
u_short i;
u_short *p;
u_short *q;
switch (jrec -> class) {
case C_N_ARABIA:
@ -504,15 +435,13 @@ JREC *jrec;
}
Static Void cl_numcmn(jrec, clrec)
JREC *jrec;
CLREC *clrec;
static void
cl_numcmn(JREC* jrec, CLREC* clrec)
{
Uchar *p;
Int i;
Ushort j;
Ushort TFar *tbl;
u_char *p;
int i;
u_short j;
u_short *tbl;
p = cnvstart;
@ -556,7 +485,7 @@ CLREC *clrec;
if (!chrck_numtbl(jrec -> flags, j)) continue;
setkouho(clrec, (TypeDicOfs)0, (Int)SelNumFunc(j));
setkouho(clrec, (TypeDicOfs)0, (int)SelNumFunc(j));
}
}
}

View file

@ -31,32 +31,24 @@
* $SonyRCSfile: mknumber.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:05 $
*
* $Id$
*/
#include <sys/types.h>
#include "sj_kcnv.h"
#include "sj_yomi.h"
#include "sj_suuji.h"
#include "kanakan.h"
Void setwdnum();
Int setucnum();
Static Int word2char(wd, tbl, keta, flg)
Ushort wd;
Uchar TFar *tbl;
Int keta;
Int flg;
static int
word2char(u_short wd, u_char* tbl, int keta, int flg)
{
Int mask;
Int num;
Uchar TFar *src;
int mask;
int num;
u_char* src;
for (mask = 0x1000 ; mask ; mask >>= 4) {
@ -90,16 +82,13 @@ Int flg;
}
Static Void words2num(wd, tbl, flgc)
Ushort *wd;
Uchar TFar *tbl;
Int flgc;
static void
words2num(u_short* wd, u_char* tbl, int flgc)
{
Int i;
Int keta;
Int flg;
Uchar *kp = kanjitmp;
int i;
int keta;
int flg;
u_char *kp = kanjitmp;
if (flgc) {
keta = NumKetaLength - 1;
@ -124,149 +113,122 @@ Int flgc;
}
Void num_type00(s1, s2, jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
void
num_type00(u_char* s1, u_char* s2, JREC* jrec)
{
Ushort num[NumWordBuf];
u_short num[NumWordBuf];
setwdnum(s1, (Int)jrec -> numlen, num);
setwdnum(s1, (int)jrec -> numlen, num);
words2num(num, Num1tbl, FALSE);
}
Void num_type01(s1, s2, jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
void
num_type01(u_char* s1, u_char* s2, JREC* jrec)
{
Ushort num[NumWordBuf];
u_short num[NumWordBuf];
setwdnum(s1, (Int)jrec -> numlen, num);
setwdnum(s1, (int)jrec -> numlen, num);
words2num(num, Num1tbl, FALSE);
}
Void num_type02(s1, s2, jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
void
num_type02(u_char* s1, u_char* s2, JREC* jrec)
{
Ushort num[NumWordBuf];
u_short num[NumWordBuf];
setwdnum(s1, (Int)jrec -> numlen, num);
setwdnum(s1, (int)jrec -> numlen, num);
words2num(num, Num1tbl, TRUE);
}
Void num_type03(s1, s2, jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
void
num_type03(u_char* s1, u_char* s2, JREC* jrec)
{
Ushort num[NumWordBuf];
u_short num[NumWordBuf];
setwdnum(s1, (Int)jrec -> numlen, num);
setwdnum(s1, (int)jrec -> numlen, num);
words2num(num, Num2tbl, FALSE);
}
Void num_type04(s1, s2, jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
void
num_type04(u_char* s1, u_char* s2, JREC* jrec)
{
Ushort num[NumWordBuf];
u_short num[NumWordBuf];
setwdnum(s1, (Int)jrec -> numlen, num);
setwdnum(s1, (int)jrec -> numlen, num);
words2num(num, Num2tbl, FALSE);
}
Void num_type05(s1, s2, jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
void
num_type05(u_char* s1, u_char* s2, JREC* jrec)
{
Ushort num[NumWordBuf];
u_short num[NumWordBuf];
setwdnum(s1, (Int)jrec -> numlen, num);
setwdnum(s1, (int)jrec -> numlen, num);
words2num(num, Num2tbl, TRUE);
}
Void num_type06(s1, s2, jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
void
num_type06(u_char* s1, u_char* s2, JREC* jrec)
{
Ushort num[NumWordBuf];
u_short num[NumWordBuf];
setwdnum(s1, (Int)jrec -> numlen, num);
setwdnum(s1, (int)jrec -> numlen, num);
words2num(num, Num3tbl, FALSE);
}
Void num_type07(s1, s2, jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
void
num_type07(u_char* s1, u_char* s2, JREC* jrec)
{
Ushort num[NumWordBuf];
u_short num[NumWordBuf];
setwdnum(s1, (Int)jrec -> numlen, num);
setwdnum(s1, (int)jrec -> numlen, num);
words2num(num, Num3tbl, FALSE);
}
Static Void kan_num(wd, tbl1, tbl2)
Ushort *wd;
Uchar TFar *tbl1;
Uchar TFar *tbl2;
static void
kan_num(u_short* wd, u_char* tbl1, u_char* tbl2)
{
Int ii;
Ushort tmp;
Int mask;
Int num;
Int flg;
Uchar TFar *kurai1;
Uchar TFar *kurai2;
Uchar TFar *src;
Uchar *keep = kanjitmp;
int ii;
u_short tmp;
int mask;
int num;
int flg;
u_char* kurai1;
u_char* kurai2;
u_char* src;
u_char* keep = kanjitmp;
kurai2 = Num6tbl - 2;
@ -325,45 +287,36 @@ Uchar TFar *tbl2;
}
Void num_type08(s1, s2, jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
void
num_type08(u_char* s1, u_char* s2, JREC* jrec)
{
Ushort num[NumWordBuf];
u_short num[NumWordBuf];
setwdnum(s1, (Int)jrec -> numlen, num);
setwdnum(s1, (int)jrec -> numlen, num);
kan_num(num, Num2tbl, Num4tbl);
}
Void num_type09(s1, s2, jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
void
num_type09(u_char* s1, u_char* s2, JREC* jrec)
{
Ushort num[NumWordBuf];
u_short num[NumWordBuf];
setwdnum(s1, (Int)jrec -> numlen, num);
setwdnum(s1, (int)jrec -> numlen, num);
kan_num(num, Num3tbl, Num5tbl);
}
Void num_type10(s1, s2, jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
void
num_type10(u_char* s1, u_char* s2, JREC* jrec)
{
Int i;
int i;
for (i = jrec -> numlen ; i > 0 ; i--) {
@ -379,14 +332,11 @@ JREC *jrec;
}
Void num_type11(s1, s2, jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
void
num_type11(u_char* s1, u_char* s2, JREC* jrec)
{
Int i;
Int j;
int i;
int j;
i = j = jrec -> numlen;
@ -412,14 +362,11 @@ JREC *jrec;
}
Void num_type12(s1, s2, jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
void
num_type12(u_char* s1, u_char* s2, JREC* jrec)
{
Int i;
Int j;
int i;
int j;
for (i = jrec -> numlen ; i > 0 ; i--) {
@ -433,26 +380,23 @@ JREC *jrec;
}
Static Void num_kurai(p, len, tbl)
Uchar *p;
Int len;
Uchar TFar *tbl;
static void
num_kurai(u_char* p, int len, u_char* tbl)
{
Int i;
Int j;
Uchar tmp;
int i;
int j;
u_char tmp;
for (i = 0 ; i < len ; i++) {
tmp = *p++;
*kanjitmp++ = tbl[j = ((tmp & 0x0f) - _Num0) * 2];
*kanjitmp++ = tbl[j + 1];
if (j = ((tmp >> 4) & 3)) {
if ((j = ((tmp >> 4) & 3)) != 0) {
*kanjitmp++ = Num4tbl[j = (3 - j) * 2];
*kanjitmp++ = Num4tbl[j + 1];
}
if (j = ((tmp >> 6) & 3)) {
if ((j = ((tmp >> 6) & 3)) != 0) {
*kanjitmp++ = Num6tbl[j = (3 - j) * 2];
*kanjitmp++ = Num6tbl[j + 1];
}
@ -460,34 +404,28 @@ Uchar TFar *tbl;
}
Void num_type13(s1, s2, jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
void
num_type13(u_char* s1, u_char* s2, JREC* jrec)
{
Uchar num[NumKetaLength];
Int len;
u_char num[NumKetaLength];
int len;
len = setucnum(s1, (Int)jrec -> numlen, num);
len = setucnum(s1, (int)jrec -> numlen, num);
num_kurai(num, len, Num1tbl);
}
Void num_type14(s1, s2, jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
void
num_type14(u_char* s1, u_char* s2, JREC* jrec)
{
Uchar num[NumKetaLength];
Int len;
u_char num[NumKetaLength];
int len;
len = setucnum(s1, (Int)jrec -> numlen, num);
len = setucnum(s1, (int)jrec -> numlen, num);
num_kurai(num, len, Num2tbl);

View file

@ -31,122 +31,100 @@
* $SonyRCSfile: peepdic.c,v $
* $SonyRevision: 1.2 $
* $SonyDate: 1995/07/21 05:22:51 $
*
* $Id$
*/
#include "sj_kcnv.h"
#include "sj_yomi.h"
#include "kanakan.h"
Uchar *skiphblk();
static void add_yomi (void);
static void cd2sjh_chr (Uchar ch, Uchar *dst);
static Int next_douon (void);
static Int next_hinsi (void);
static Int next_kanji (void);
static Int prev_douon (void);
static Int prev_hinsi (void);
static Int prev_kanji (void);
static void set_buf (Uchar *buf);
static void set_idxyomi (void);
static void set_kanji (void);
Uchar *skipkstr(), *skiphblk(), *get_idxptr();
Int getkanji(), codesize();
Static Int prev_kanji(), prev_hinsi(), prev_douon();
Static Int next_kanji(), next_hinsi(), next_douon();
Static Void set_kanji(), set_buf(), add_yomi(), cd2sjh_chr();
Static Void set_idxyomi();
Int getusr(buf)
Uchar *buf;
Int
getusr (Uchar *buf)
{
Int nlen;
peepyomi[0] = peepknj[0] = peepgrm = 0;
(*curdict->getdic)(curdict, peepidx = DicSegBase);
get_askknj();
peepdptr = segtop();
if (segend(peepdptr)) return 0;
add_yomi();
nlen = getnlen(peepdptr);
peephptr = peepdptr + DouonBlkSizeNumber + nlen;
peepgrm = *peephptr;
peepkptr = peephptr + 1;
set_kanji();
set_buf(buf);
return -1;
}
Int nextusr(buf)
Uchar *buf;
Int
nextusr (Uchar *buf)
{
(*curdict->getdic)(curdict, peepidx);
get_askknj();
if (next_kanji()) {
set_kanji();
set_buf(buf);
return -1;
}
return 0;
}
Int prevusr(buf)
Uchar *buf;
Int
prevusr (Uchar *buf)
{
(*curdict->getdic)(curdict, peepidx);
get_askknj();
if (prev_kanji()) {
set_kanji();
set_buf(buf);
return -1;
}
return 0;
}
Static Void set_kanji()
static void
set_kanji (void)
{
Int len;
@ -157,40 +135,36 @@ Static Void set_kanji()
Static Void set_buf(buf)
Reg2 Uchar *buf;
static void
set_buf (Uchar *buf)
{
Reg1 Uchar *p;
Reg2 Int i, csize;
Uchar *p;
Int i, csize;
for (p = peepyomi ; *p ; ) *buf++ = *p++;
*buf++ = 0;
for (p = peepknj ; *p ; ) {
csize = euc_codesize(*p);
for (i = 0; i < csize; i++ ) *buf++ = *p++;
}
*buf++ = 0;
*buf++ = peepgrm;
*buf++ = 0;
}
Static Int prev_kanji()
static Int
prev_kanji (void)
{
Uchar *p1;
Uchar *p2;
p1 = peephptr + 1;
if (peepkptr <= p1) return prev_hinsi();
p2 = peepkptr;
while (p1 < p2) {
peepkptr = p1;
@ -202,35 +176,29 @@ Static Int prev_kanji()
Static Int prev_hinsi()
static Int
prev_hinsi (void)
{
Uchar *p1;
Uchar *p2;
Int nlen;
nlen = getnlen(peepdptr);
p1 = peepdptr + DouonBlkSizeNumber + nlen;
if (peephptr <= p1) return prev_douon();
p2 = peephptr;
while (p1 < p2) {
peephptr = p1;
p1 = skiphblk(p1);
}
peepgrm = *peephptr;
p1 = peephptr + 1;
while (*p1 != HinsiBlkTerm) {
peepkptr = p1;
p1 = skipkstr(p1);
}
@ -239,184 +207,133 @@ Static Int prev_hinsi()
Static Int prev_douon()
static Int
prev_douon (void)
{
Uchar *p1;
Uchar *p2;
Int nlen;
if (peepdptr <= segtop()) {
if (peepidx <= DicSegBase) return 0;
(*curdict->getdic)(curdict, --peepidx);
get_askknj();
set_idxyomi();
p1 = segtop();
do {
peepdptr = p1;
add_yomi();
p1 = getntag(p1);
} while (!segend(p1));
}
else {
set_idxyomi();
p1 = segtop();
p2 = peepdptr;
do {
peepdptr = p1;
add_yomi();
p1 = getntag(p1);
} while (p1 < p2);
}
nlen = getnlen(peepdptr);
p1 = peepdptr + DouonBlkSizeNumber + nlen;
p2 = getntag(peepdptr);
do {
peephptr = p1;
p1 = skiphblk(p1);
} while (p1 < p2);
peepgrm = *peephptr;
p1 = peephptr + 1;
do {
peepkptr = p1;
p1 = skipkstr(p1);
} while (*p1 != HinsiBlkTerm);
return -1;
}
Static Int next_kanji()
static Int
next_kanji (void)
{
Uchar *p1;
p1 = skipkstr(peepkptr);
if (*p1 == HinsiBlkTerm) return next_hinsi();
peepkptr = p1;
return -1;
}
Static Int next_hinsi()
static Int
next_hinsi (void)
{
Uchar *p1;
p1 = skiphblk(peephptr);
if (p1 >= getntag(peepdptr)) return next_douon();
peephptr = p1;
peepgrm = *p1;
peepkptr = p1 + 1;
return -1;
}
Static Int next_douon()
static Int
next_douon (void)
{
Uchar *p1;
Int nlen;
p1 = getntag(peepdptr);
if (segend(p1)) {
if (peepidx + 1 < curdict->segunit) {
(*curdict->getdic)(curdict, ++peepidx);
get_askknj();
peepdptr = segtop();
set_idxyomi();
}
else
return 0;
}
else {
peepdptr = p1;
}
add_yomi();
nlen = getnlen(peepdptr);
peephptr = peepdptr + DouonBlkSizeNumber + nlen;
peepgrm = *peephptr;
peepkptr = peephptr + 1;
return -1;
}
Static Void set_idxyomi()
static void
set_idxyomi (void)
{
Uchar *p1, *p2;
if (p2 = get_idxptr(peepidx)) {
if ((p2 = get_idxptr(peepidx)) != NULL) {
p1 = peepyomi;
while (*p2) {
cd2sjh_chr(*p2++, p1);
@ -428,35 +345,28 @@ Static Void set_idxyomi()
Static Void add_yomi()
static void
add_yomi (void)
{
Int nlen;
Uchar *p1, *p2;
nlen = getnlen(peepdptr);
p1 = peepyomi + getplen(peepdptr) * 2;
p2 = peepdptr + DouonBlkSizeNumber;
while (nlen--) {
cd2sjh_chr(*p2++, p1);
p1 += 2;
}
*p1 = 0;
}
Static Void cd2sjh_chr(ch, dst)
Uchar ch;
Reg1 Uchar *dst;
static void
cd2sjh_chr (Uchar ch, Uchar *dst)
{
if (ch == _TYOUON) {
*dst++ = 0xa1;
@ -499,3 +409,4 @@ Reg1 Uchar *dst;
else {
}
}

View file

@ -31,19 +31,19 @@
* $SonyRCSfile: ph2knj.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:09 $
*
* $Id$
*/
#include <string.h>
#include "sj_kcnv.h"
#include "sj_yomi.h"
#include "kanakan.h"
Int sj2cd_chr(), sstrlen();
Void mkjiritu(), mkbunsetu(), wakachi(), mk2claus();
Int sj2cd_chr();
void mk2claus();
Void freework();
Void selclrec();
CLREC *free_clst();
@ -51,23 +51,19 @@ JREC *free_jlst();
Int ph2knj(zyomi, kanji, knjlen)
Uchar *zyomi;
Uchar *kanji;
Int knjlen;
Int ph2knj
(Uchar *zyomi, Uchar *kanji, Int knjlen)
{
Uchar *ptr;
Uchar *dst;
Int i;
for (ptr = zyomi, dst = hyomi, i = 0 ; *ptr ; ) {
if (i++ >= MaxPhInputLen) { *kanji = 0; return 0; }
ptr += sj2cd_chr(ptr, dst++);
}
*dst = 0;
freework();
prevclgrm = 0;
prevclrow = 0;
@ -75,47 +71,32 @@ Int knjlen;
khcount = 0;
nextcllen = 0;
inputyomi = zyomi;
cnvstart = ystart = hyomi;
cnvlen = sstrlen(hyomi);
cnvlen = strlen(hyomi);
kanjipos = kanji;
kanjilen = knjlen;
while (cnvlen && kanjilen) {
if (!clt1st) {
mkjiritu(DO_CLSTUDY | DO_IKKATU);
mkbunsetu();
if (!maxclptr) wakachi();
jrt1st = maxjptr;
clt1st = maxclptr;
}
mk2claus();
selclrec();
prevclgrm = selcl -> jnode -> hinsi;
prevclrow = selcl -> right;
clt1st = free_clst(clt1st, (Int)selcl -> cllen);
jrt1st = free_jlst(jrt1st);
cnvstart += selcl -> cllen;
cnvlen -= selcl -> cllen;
@ -135,4 +116,3 @@ Int knjlen;
return(inputyomi - zyomi);
}

View file

@ -31,19 +31,18 @@
* $SonyRCSfile: ph_khtbl.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:09 $
*
* $Id$
*/
#include "sj_kcnv.h"
#include "kanakan.h"
Uchar *skipkstr();
STDYIN *srchstdy();
Void ph_setkouho();
Int seldict();
Static Void ph_setsty(clrec)
CLREC *clrec;
static void
ph_setsty (CLREC *clrec)
{
JREC *jrec;
TypeDicOfs offset;
@ -60,9 +59,7 @@ CLREC *clrec;
ptr = dicbuf + jrec->jofsst + 1;
for ( ; *ptr != HinsiBlkTerm ; ptr = skipkstr(ptr)) {
offset = ptr - dicbuf;
sptr = srchstdy(jrec -> jseg, offset, jrec -> dicid);
if (!khcount){
@ -75,7 +72,6 @@ CLREC *clrec;
if (sptr -> styno < kouhotbl[0].styno) {
ph_setkouho(clrec, offset, sptr);
}
else if (sptr -> styno == kouhotbl -> styno) {
if (!(kouhotbl[0].ka_fg &&
sptr -> ka_kj == kouhotbl[0].ka_kj)) {
@ -87,8 +83,8 @@ CLREC *clrec;
Int ph_khtbl(clrec)
CLREC *clrec;
Int
ph_khtbl (CLREC *clrec)
{
JREC *jrec;
Int flg = FALSE;

View file

@ -31,19 +31,19 @@
* $SonyRCSfile: setconj.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:16 $
*
* $Id$
*/
#include "sj_kcnv.h"
#include "sj_right.h"
#include "sj_hinsi.h"
#include "sj_yomi.h"
#include "kanakan.h"
Static Int cnjstrcmp(yptr, cnjp, saml)
Uchar *yptr;
Uchar TFar *cnjp;
Int *saml;
static Int
cnjstrcmp (Uchar *yptr, Uchar *cnjp, Int *saml)
{
Int asklen;
Int nkrlen;
@ -78,9 +78,8 @@ Int *saml;
return MATCH;
}
Static TypeCnct cnvrow(rec, row)
JREC *rec;
TypeCnct row;
static TypeCnct
cnvrow (JREC *rec, TypeCnct row)
{
TypeGram hinsi;
Int stt;
@ -112,10 +111,8 @@ TypeCnct row;
return row;
}
Int setconj(hinsi, jrec, crec)
TypeGram hinsi;
JREC *jrec;
CREC *crec;
Int
setconj (TypeGram hinsi, JREC *jrec, CREC *crec)
{
Uchar *yptr;
Int cmp;
@ -123,9 +120,9 @@ CREC *crec;
Int saml;
Int ofslen;
int count = 0;
Uchar TFar *cnj;
Uchar *cnj;
if (cnj = Conjadr(hinsi)) {
if ((cnj = Conjadr(hinsi)) != NULL) {
saml = ofslen = 0;
yptr = cnvstart + jrec -> jlen;
@ -148,7 +145,7 @@ CREC *crec;
if (isdpnd(*(yptr + saml))) continue;
if (right = cnvrow(jrec, (TypeCnct)CnjRight(cnj))) {
if ((right = cnvrow(jrec, (TypeCnct)CnjRight(cnj))) != '\0') {
crec -> len = (Uchar)(ofslen + saml);
crec -> right = right;
count++;

View file

@ -31,34 +31,28 @@
* $SonyRCSfile: setjrec.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:17 $
*
* $Id$
*/
#include "sj_euc.h"
#include "sj_kcnv.h"
#include "sj_hinsi.h"
#include "kanakan.h"
JREC *argjrec();
Int codesize();
Int setj_atrb(p)
Uchar *p;
int
setj_atrb(u_char* p)
{
return 2;
}
Int setj_ofs(p)
Uchar *p;
int
setj_ofs(u_char* p)
{
Int contf = TRUE;
int contf = TRUE;
p = dicbuf + ((*p & KanjiCodeMask) << 8) + *(p + 1);
@ -97,11 +91,10 @@ Uchar *p;
}
Int setj_knj(p)
Uchar *p;
int
setj_knj(u_char* p)
{
Int contf = TRUE;
int contf = TRUE;
p = askknj[*p & KnjAssyukuMask];
@ -140,31 +133,29 @@ Uchar *p;
}
Int setj_norm1(p)
Uchar *p;
int
setj_norm1(u_char* p)
{
return 1;
}
Int setj_norm2(p)
Uchar *p;
int
setj_norm2(u_char* p)
{
return 2;
}
Int setj_norm3(p)
Uchar *p;
int
setj_norm3(u_char* p)
{
return 3;
}
Static Uchar chkhead(gram)
TypeGram gram;
static int
chkhead(TypeGram gram)
{
if (!headcode) return TRUE;
@ -187,19 +178,17 @@ TypeGram gram;
}
Void setjrec(tagp, mode)
Uchar *tagp;
Int mode;
void
setjrec(u_char* tagp, int mode)
{
TypeGram gram;
Uchar *ptr;
Uchar *endp;
Uchar *tmp;
u_char *ptr;
u_char *endp;
u_char *tmp;
JREC *rec;
Int plen;
Int nlen;
Int len;
int plen;
int nlen;
int len;
plen = getplen(tagp);
@ -270,16 +259,13 @@ Int mode;
}
Void setnumrec(tagp, rec, gram)
Uchar *tagp;
JREC *rec;
TypeGram gram;
void
setnumrec(u_char* tagp, JREC* rec, TypeGram gram)
{
Uchar *ptr;
Uchar *endp;
Uchar *tmp;
Int plen, nlen, len;
u_char *ptr;
u_char *endp;
u_char *tmp;
int plen, nlen, len;
JREC *jrec;
@ -331,7 +317,7 @@ TypeGram gram;
if (gram != *ptr) continue;
if (!(jrec = argjrec((Int)(rec -> jlen + len), rec))) continue;
if (!(jrec = argjrec((int)(rec -> jlen + len), rec))) continue;
jrec -> jseg = prevseg;
@ -342,9 +328,8 @@ TypeGram gram;
}
Void setcrec(tagp)
Uchar *tagp;
void
setcrec(u_char* tagp)
{
JREC *rec;

View file

@ -31,35 +31,27 @@
* $SonyRCSfile: setkouho.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:20 $
*
* $Id$
*/
#include "sj_euc.h"
#include "sj_kcnv.h"
#include "sj_hinsi.h"
#include "kanakan.h"
static int hiraknj(u_char *p);
Int sel_sjmode(), codesize();
Static Int hiraknj();
Void setkouho(clrec, offs, mode)
CLREC *clrec;
TypeDicOfs offs;
Int mode;
void
setkouho(CLREC* clrec, TypeDicOfs offs, int mode)
{
JREC *jrec;
KHREC *kptr;
Uchar TFar *fptr;
Int flg;
Int i;
u_char TFar *fptr;
int flg;
int i;
if (khcount >= MaxKouhoNumber) return;
@ -76,7 +68,7 @@ Int mode;
kptr -> offs = offs;
kptr -> rank = 0;
kptr -> styno = 0;
kptr -> mode = (Uchar)mode;
kptr -> mode = (u_char)mode;
if (jrec -> flags & JFLAG_KA) {
@ -130,7 +122,7 @@ Int mode;
kptr -> offs = offs;
kptr -> rank = 0;
kptr -> styno = 0;
kptr -> mode = (Uchar)mode;
kptr -> mode = (u_char)mode;
kptr -> sttfg = 1;
kptr -> sttkj = 1;
@ -144,14 +136,11 @@ Int mode;
}
Void ph_setkouho(clrec, offs, sptr)
CLREC *clrec;
TypeDicOfs offs;
STDYIN *sptr;
void
ph_setkouho(CLREC* clrec, TypeDicOfs offs, STDYIN* sptr)
{
JREC *jrec;
Uchar TFar *p;
u_char TFar *p;
if (sptr) {
@ -174,7 +163,7 @@ STDYIN *sptr;
kouhotbl[0].mode = sel_sjmode(jrec = clrec -> jnode);
kouhotbl[0].sttfg = (Uchar)
kouhotbl[0].sttfg = (u_char)
((p = Settou_ptr(jrec->sttofs)) ? (SttHiraKnj(p)?1:0) : 0);
@ -197,13 +186,12 @@ STDYIN *sptr;
}
Static Int hiraknj(p)
Reg1 Uchar *p;
static int
hiraknj(u_char *p)
{
char flg = TRUE;
Int i;
Int result;
int i;
int result;
do {
if (p[codesize(*p)] == KanjiStrEnd) flg = FALSE;
@ -239,72 +227,58 @@ Reg1 Uchar *p;
}
Int hiraknj_atrb(p, len)
Uchar *p;
Int *len;
int
hiraknj_atrb(u_char* p, int* len)
{
*len = 2;
return 0;
}
Int hiraknj_ofs(p, len)
Uchar *p;
Int *len;
int
hiraknj_ofs(u_char* p, int* len)
{
*len = 2;
return hiraknj(dicbuf + ((*p & KanjiCodeMask) << 8) + *(p + 1));
}
Int hiraknj_knj(p, len)
Uchar *p;
Int *len;
int
hiraknj_knj(u_char* p, int* len)
{
*len = 1;
return hiraknj(askknj[*p & KnjAssyukuMask]);
}
Int hiraknj_hask(p, len)
Uchar *p;
Int *len;
int
hiraknj_hask(u_char* p, int* len)
{
*len = 1;
return 2;
}
Int hiraknj_kask(p, len)
Uchar *p;
Int *len;
int
hiraknj_kask(u_char* p, int* len)
{
*len = 1;
return 3;
}
Int hiraknj_norm(p, len)
Uchar *p;
Int *len;
int
hiraknj_norm(u_char* p, int* len)
{
*len = codesize(*p);
return 1;
}
Int hiraknj_hira(p, len)
Uchar *p;
Int *len;
int
hiraknj_hira(u_char* p, int* len)
{
Uchar ch;
u_char ch;
*len = codesize(*p);
ch = *(p + 1);

View file

@ -31,19 +31,18 @@
* $SonyRCSfile: setubi.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:22 $
*
* $Id$
*/
#include <string.h>
#include "sj_kcnv.h"
#include "sj_hinsi.h"
#include "kanakan.h"
JREC *argjrec();
Void memcpy();
Int sstrncmp();
Uchar TFar *getstb(hinsi)
TypeGram hinsi;
Uchar*
getstb(TypeGram hinsi)
{
if (hinsi < MEISI_1 || hinsi > TIMEI) return NULL;
@ -51,13 +50,12 @@ TypeGram hinsi;
}
Void setubi(rec, stbtbl)
JREC *rec;
Uchar TFar *stbtbl;
void
setubi(JREC *rec, Uchar *stbtbl)
{
Uchar TFar *stb;
Uchar *stb;
Uchar *yptr;
Uchar TFar *sptr;
Uchar *sptr;
Int slen;
JREC *new;
Int cmp;
@ -71,7 +69,7 @@ Uchar TFar *stbtbl;
slen = StbYomiLen(stb);
sptr = StbYomiTop(stb);
cmp = sstrncmp(yptr, sptr, slen);
cmp = strncmp(yptr, sptr, slen);
if (cmp == OVER || cmp == PARTLY) break;

View file

@ -31,34 +31,30 @@
* $SonyRCSfile: skipkstr.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:25 $
*
* $Id$
*/
#include "sj_euc.h"
#include "sj_rename.h"
#include "sj_typedef.h"
#include "sj_const.h"
#include "sj_dict.h"
#include "sj_table.h"
#include "kanakan.h"
Int codesize();
Uchar *skipkstr(ptr)
Reg1 Uchar *ptr;
u_char*
skipkstr(u_char* ptr)
{
Reg2 Int contf = TRUE, csize;
int contf = TRUE, csize;
do {
csize = codesize(*ptr);
if (ptr[csize] == KanjiStrEnd) contf = FALSE;
ptr += csize;
} while (contf);
ptr++;
return ptr;

View file

@ -31,24 +31,22 @@
* $SonyRCSfile: srchdict.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:26 $
*
* $Id$
*/
#include <sys/types.h>
#include <string.h>
#include "sj_kcnv.h"
#include "kanakan.h"
Uchar *get_idxptr();
Int yomicmp(), sstrlen();
Void get_askknj();
TypeDicSeg srchidx();
Int yomicmp(ptr1, ptr2, saml)
Reg1 Uchar *ptr1;
Reg2 Uchar *ptr2;
Uchar *saml;
int
yomicmp(u_char* ptr1, u_char* ptr2, u_char* saml)
{
Int i, j;
Int same;
int i, j;
int same;
same = *saml;
@ -61,7 +59,7 @@ Uchar *saml;
for (i = same ; i ; i--)
if (*ptr1++ != *ptr2++) return OVER;
j = sstrlen(ptr2);
j = strlen(ptr2);
}
else if (i > same)
@ -89,12 +87,12 @@ Uchar *saml;
}
Uchar *srchdict(tagp)
Uchar *tagp;
u_char*
srchdict(u_char* tagp)
{
TypeDicSeg segno;
Int cmp;
Int maxlen;
int cmp;
int maxlen;
maxlen = (cnvlen > MaxWdYomiLen) ? MaxWdYomiLen : cnvlen;

View file

@ -31,23 +31,25 @@
* $SonyRCSfile: srchidx.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:29 $
*
* $Id$
*/
#include <sys/types.h>
#include <string.h>
#include "sj_kcnv.h"
#include "kanakan.h"
Uchar *get_idxptr();
Int sstrlen(), istrcmp();
Int istrcmp();
TypeDicSeg srchidx(low, len)
TypeDicSeg low;
Int len;
TypeDicSeg
srchidx(TypeDicSeg low, int len)
{
TypeDicSeg high;
TypeDicSeg mid;
Int cmp;
Uchar *target;
int cmp;
u_char *target;
if ((high = curdict->segunit - 1) < 1) return 0;
@ -59,7 +61,7 @@ Int len;
target = get_idxptr(mid);
cmp = istrcmp(cnvstart, target, len, sstrlen(target));
cmp = istrcmp(cnvstart, target, len, strlen(target));
if (cmp == OVER) {
high = mid - 1;

View file

@ -31,26 +31,27 @@
* $SonyRCSfile: srchnum.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:30 $
*
* $Id$
*/
#include <sys/types.h>
#include <string.h>
#include "sj_kcnv.h"
#include "sj_yomi.h"
#include "sj_hinsi.h"
#include "sj_suuji.h"
#include "kanakan.h"
JREC *argjrec();
Uchar *srchdict();
Void setnumrec(), memcpy(), memset();
Static Void srch_kurai1(), srch_kurai2();
static void srch_kurai1(u_char* ptr, u_char* cnct);
static void srch_kurai2(u_char* ptr, u_char* cnct);
Static Void srch_josuu_sub(jrec, gram)
JREC *jrec;
TypeGram gram;
static void
srch_josuu_sub(JREC *jrec, TypeGram gram)
{
Uchar *tagp;
u_char *tagp;
DICTL *dp;
for (dp = dictlist ; dp ; dp = dp -> next) {
@ -58,16 +59,17 @@ TypeGram gram;
dicinl = 1;
dicsaml = 0;
prevseg = -1;
while (tagp = srchdict(tagp)) setnumrec(tagp, jrec, gram);
while ((tagp = srchdict(tagp)) != NULL)
setnumrec(tagp, jrec, gram);
}
}
Static Void srch_josuu(jrec)
JREC *jrec;
static void
srch_josuu(JREC *jrec)
{
Uchar *kp;
Int klen;
Int len;
u_char *kp;
int klen;
int len;
if (headcode && headcode != SETTOU_DAI) return;
@ -85,22 +87,20 @@ JREC *jrec;
cnvlen = klen;
}
Static Void setnrec_sub(p, flag, stb)
Uchar *p;
Ushort flag;
Int stb;
static void
setnrec_sub(u_char* p, u_short flag, int stb)
{
JREC *rec;
Int len1;
Int len2;
int len1;
int len2;
len1 = len2 = p - suuji_yptr;
if (headcode) len1 += headlen;
if (stb) len2--;
if ((Int)suuji_len == len2) {
if ((int)suuji_len == len2) {
if (suuji_wkeep) {
memcpy((Uchar *)suuji_wbuf, (Uchar *)suuji_wkeep,
memcpy((u_char*)suuji_wbuf, (u_char*)suuji_wkeep,
sizeof(suuji_wbuf[0]) * NumWordBuf);
}
if (suuji_ukeep) {
@ -110,21 +110,20 @@ Int stb;
return;
}
if (rec = argjrec(len1, (JREC *)NULL)) {
if ((rec = argjrec(len1, (JREC *)NULL)) != NULL) {
rec -> class = suuji_class;
rec -> hinsi = SUUSI;
rec -> sttofs = headcode;
rec -> stbofs = (Uchar)stb;
rec -> stbofs = (u_char)stb;
rec -> flags = flag;
rec -> numlen = (Uchar)len2;
rec -> numlen = (u_char)len2;
if (!stb) srch_josuu(rec);
}
}
Static Void setnrec(p, flag)
Uchar *p;
Ushort flag;
static void
setnrec(u_char* p, u_short flag)
{
setnrec_sub(p, flag, 0);
@ -133,14 +132,11 @@ Ushort flag;
}
}
Static Uchar TFar *srchtbl(ch, tbl, rec, n)
Uchar ch;
Uchar TFar *tbl;
Int rec;
Int n;
static u_char*
srchtbl(u_char ch, u_char* tbl, int rec, int n)
{
Int high, low, mid;
Uchar TFar *p;
int high, low, mid;
u_char *p;
if (!ch) return NULL;
@ -168,19 +164,16 @@ Int n;
return p;
}
Static Int isconnect(cnct, num)
Uchar TFar *cnct;
Int num;
static int
isconnect(u_char* cnct, int num)
{
return (cnct[num / 8] & (0x80 >> (num % 8)));
}
Static Int string_cmp(s, l, d)
Reg3 Uchar TFar *s;
Reg1 Int l;
Reg2 Uchar *d;
static int
string_cmp(u_char* s, int l, u_char* d)
{
Uchar TFar *p;
u_char *p;
p = s;
@ -193,27 +186,27 @@ Reg2 Uchar *d;
return (s - p);
}
Static Int check_num(ptr)
Uchar *ptr;
static int
check_num(u_char* ptr)
{
Int i;
Int j;
Int k;
int i;
int j;
int k;
int tmp;
Int hketa;
Int lketa;
Int flg = FALSE;
Int cnt;
Ushort flag;
int hketa;
int lketa;
int flg = FALSE;
int cnt;
u_short flag;
memset((Uchar *)suuji_wbuf, 0, sizeof(Ushort) * NumWordBuf);
memset((u_char*)suuji_wbuf, 0, sizeof(u_short) * NumWordBuf);
flag = 0;
hketa = lketa = cnt = 0;
for (i = suuji_keta ; --i >= 0 ;) {
if (hketa >= 4) return FALSE;
tmp = suuji_ubuf[i];
if (j = ((tmp >> 6) & 3)) {
if ((j = ((tmp >> 6) & 3)) != 0) {
if (j < hketa) return FALSE;
if (j > hketa) {
flag |= JFLAG_N01;
@ -282,16 +275,16 @@ Uchar *ptr;
return TRUE;
}
Static Void srch_number1(ptr)
Uchar *ptr;
static void
srch_number1(u_char* ptr)
{
Uchar ch;
Uchar mode;
Uchar TFar *p;
Int l;
u_char ch;
u_char mode;
u_char TFar *p;
int l;
TypeClass cls;
Int len;
Uchar *tptr;
int len;
u_char *tptr;
if (suuji_keta >= NumKetaLength) return;
@ -315,7 +308,7 @@ Uchar *ptr;
check_num(tptr);
srch_number1(tptr);
srch_kurai2(tptr, (Uchar TFar *)NULL);
srch_kurai2(tptr, (u_char*)NULL);
break;
@ -324,8 +317,8 @@ Uchar *ptr;
check_num(tptr);
srch_number1(tptr);
srch_kurai1(tptr, (Uchar TFar *)NULL);
srch_kurai2(tptr, (Uchar TFar *)NULL);
srch_kurai1(tptr, (u_char*)NULL);
srch_kurai2(tptr, (u_char*)NULL);
break;
@ -349,7 +342,7 @@ Uchar *ptr;
suuji_class = C_N_ARABIA;
check_num(tptr);
srch_number1(tptr);
srch_kurai2(tptr, (Uchar TFar *)NULL);
srch_kurai2(tptr, (u_char*)NULL);
suuji_class = C_N_KAZU;
}
@ -382,18 +375,17 @@ Uchar *ptr;
}
}
Static Void srch_kurai1(ptr, cnct)
Uchar *ptr;
Uchar TFar *cnct;
static void
srch_kurai1(u_char* ptr, u_char* cnct)
{
Uchar ch;
Uchar TFar *p;
Int l;
Int keta;
Int mode;
u_char ch;
u_char *p;
int l;
int keta;
int mode;
TypeClass cls;
Int len;
Uchar *tptr;
int len;
u_char *tptr;
if (!(p = srchtbl((ch = *ptr), Kurai1_tbl, Kr1TblRecLen, Kr1TblRecNum)))
return;
@ -421,7 +413,7 @@ Uchar TFar *cnct;
}
if (cnct) {
if (!isconnect(cnct, (Int)Kr1TblCnct(mode))) continue;
if (!isconnect(cnct, (int)Kr1TblCnct(mode))) continue;
suuji_ubuf[suuji_keta - 1] |= (keta << 4);
}
else {
@ -433,7 +425,7 @@ Uchar TFar *cnct;
check_num(tptr);
srch_number1(tptr);
srch_kurai1(tptr, (Uchar TFar *)NULL);
srch_kurai1(tptr, (u_char*)NULL);
srch_kurai2(tptr, Kr1TblCnctP(p));
if (cnct)
@ -443,18 +435,17 @@ Uchar TFar *cnct;
}
}
Static Void srch_kurai2(ptr, cnct)
Uchar *ptr;
Uchar TFar *cnct;
static void
srch_kurai2(u_char* ptr, u_char* cnct)
{
Uchar ch;
Uchar TFar *p;
Int l;
Int keta;
Int mode;
u_char ch;
u_char *p;
int l;
int keta;
int mode;
TypeClass cls;
Int len;
Uchar *tptr;
int len;
u_char *tptr;
if ((suuji_ubuf[0] & 0x0f) == _Num0) return;
@ -484,7 +475,7 @@ Uchar TFar *cnct;
}
if (cnct) {
if (!isconnect(cnct, (Int)Kr2TblCnct(mode))) continue;
if (!isconnect(cnct, (int)Kr2TblCnct(mode))) continue;
suuji_ubuf[suuji_keta - 1] |= (keta << 6);
}
else {
@ -495,7 +486,7 @@ Uchar TFar *cnct;
check_num(tptr);
srch_number1(tptr);
srch_kurai1(tptr, (Uchar TFar *)NULL);
srch_kurai1(tptr, (u_char*)NULL);
if (cnct)
suuji_ubuf[suuji_keta - 1] &= 0x3f;
@ -504,11 +495,11 @@ Uchar TFar *cnct;
}
}
Static Void srch_number2(p)
Uchar *p;
static void
srch_number2(u_char* p)
{
Uchar ch;
Int i;
u_char ch;
int i;
suuji_class = (*p == N_0) ? C_N_SUUJILONG : C_N_KAZULONG;
@ -559,8 +550,8 @@ Uchar *p;
}
}
Static Void srchnum_sub(p)
Uchar *p;
static void
srchnum_sub(u_char* p)
{
suuji_yptr = p;
@ -570,13 +561,14 @@ Uchar *p;
suuji_keta = 0;
suuji_class = C_N_KAZU;
srch_kurai1(p, (Uchar TFar *)NULL);
srch_kurai1(p, (u_char*)NULL);
if (suuji_exit) return;
srch_number2(p);
}
Void srchnum()
void
srchnum(void)
{
suuji_len = suuji_exit = 0;
@ -592,12 +584,10 @@ Void srchnum()
}
}
Void setwdnum(p, len, wd)
Uchar *p;
Int len;
Ushort *wd;
void
setwdnum(u_char* p, int len, u_short* wd)
{
suuji_len = (Uchar)len;
suuji_len = (u_char)len;
suuji_wkeep = wd;
suuji_ukeep = NULL;
headcode = headlen = 0;
@ -606,12 +596,10 @@ Ushort *wd;
srchnum_sub(p);
}
Int setucnum(p, len, ud)
Uchar *p;
Int len;
Uchar *ud;
int
setucnum(u_char* p, int len, u_char* ud)
{
suuji_len = (Uchar)len;
suuji_len = (u_char)len;
suuji_wkeep = NULL;
suuji_ukeep = ud;
headcode = headlen = 0;
@ -619,6 +607,6 @@ Uchar *ud;
srchnum_sub(p);
return (Int)suuji_exit;
return (int)suuji_exit;
}

View file

@ -1,50 +0,0 @@
/*
* 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: sstrcmp.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:31 $
*/
#include "sj_rename.h"
#include "sj_typedef.h"
Int sstrcmp(src, dst)
Reg1 Uchar *src;
Reg2 Uchar *dst;
{
for ( ; *src ; src++, dst++)
if (*src != *dst) break;
return (*src - *dst);
}

View file

@ -1,52 +0,0 @@
/*
* 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: sstrlen.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:32 $
*/
#include "sj_rename.h"
#include "sj_typedef.h"
Int sstrlen(ptr)
Reg1 Uchar *ptr;
{
Reg2 Uchar *head;
head = ptr;
while (*ptr) ptr++;
return (ptr - head);
}

View file

@ -1,63 +0,0 @@
/*
* 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: sstrncmp.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:33 $
*/
#include "sj_rename.h"
#include "sj_typedef.h"
#include "sj_const.h"
Int sstrncmp(src, dst, len)
Reg1 Uchar *src;
Reg2 Uchar TFar *dst;
Reg3 Int len;
{
while (len-- > 0) {
if (*src > *dst)
return CONT;
if (*src < *dst) {
if (!*src) return PARTLY;
return OVER;
}
src++;
dst++;
}
return MATCH;
}

View file

@ -31,18 +31,19 @@
* $SonyRCSfile: study.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:38 $
*
* $Id$
*/
#include <string.h>
#include "sj_kcnv.h"
#include "kanakan.h"
Void mvmemi(), mvmemd(), memcpy();
Void mvmemi(), mvmemd();
STDYIN *srchstdy();
Int study(stdy)
STDYOUT *stdy;
Int
study(STDYOUT *stdy)
{
STDYOUT outp;
STDYIN *p1;
@ -138,10 +139,10 @@ STDYOUT *stdy;
return ret;
}
STDYIN *srchstdy(seg, ofs, dicid)
TypeDicSeg seg;
TypeDicOfs ofs;
TypeDicID dicid;
STDYIN* srchstdy(
TypeDicSeg seg,
TypeDicOfs ofs,
TypeDicID dicid)
{
Int high;
Int mid;

View file

@ -31,20 +31,21 @@
* $SonyRCSfile: wakachi.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:43 $
*
* $Id$
*/
#include "sj_kcnv.h"
#include "sj_right.h"
#include "sj_hinsi.h"
#include "kanakan.h"
JREC *argjrec();
CLREC *argclrec();
Int terminate(), setconj();
Int terminate();
Void setclrec(), srchfzk();
Void wakachi()
void
wakachi (void)
{
JREC *jrec;
CLREC *clrec;
@ -123,7 +124,7 @@ Void wakachi()
return;
if (jrec -> jlen) {
if (clrec = argclrec((Int)jrec -> jlen)) {
if ((clrec = argclrec((Int)jrec -> jlen)) != NULL) {
clrec -> jnode = jrec;
clrec -> right = R_MEISI;
clrec -> kubun = K_TAIGEN;

View file

@ -31,13 +31,15 @@
* $SonyRCSfile: comuni.c,v $
* $SonyRevision: 1.4 $
* $SonyDate: 1994/11/16 07:34:05 $
*
* $Id$
*/
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include "sj_sysvdef.h"
#include "sj_kcnv.h"
#include <sys/socket.h>
@ -109,8 +111,8 @@ static int buflen = 0;
static int getpos = 0;
socket_init()
void
socket_init(void)
{
#ifdef SVR4
int i;
@ -129,8 +131,8 @@ socket_init()
static void set_fd(fd)
int fd;
static void
set_fd(int fd)
{
#ifdef SVR4
poll_fds[maxfds].fd = fd;
@ -144,11 +146,11 @@ int fd;
static void clr_fd(fd)
int fd;
static void
clr_fd(int fd)
{
#ifdef SVR4
register int i, j;
int i, j;
for (i = 0; i < maxfds; i++) {
if (poll_fds[i].fd == fd) {
@ -178,7 +180,8 @@ int fd;
#if (!defined(TLI) || (defined(TLI) && defined(SOCK_UNIX)))
static void open_af_unix()
static void
open_af_unix(void)
{
struct sockaddr_un sunix;
@ -223,7 +226,8 @@ struct netconfig *nconf;
#endif
static void open_af_inet()
static void
open_af_inet(void)
{
#ifdef TLI
struct t_bind *req;
@ -335,7 +339,7 @@ static void open_af_inet()
inet_callptr->udata.len = 0;
inet_callptr->udata.buf = (char *) NULL;
#else
if (sp = getservbyname(port_name, "tcp"))
if ((sp = getservbyname(port_name, "tcp")) != NULL)
port = ntohs(sp -> s_port);
else
port = port_number;
@ -379,7 +383,9 @@ static void open_af_inet()
#endif
set_fd(fd_inet);
}
open_socket()
void
open_socket(void)
{
open_af_inet();
#if (!defined(TLI) || (defined(TLI) && defined(SOCK_UNIX)))
@ -390,7 +396,8 @@ open_socket()
#if (!defined(TLI) || (defined(TLI) && defined(SOCK_UNIX)))
static int connect_af_unix()
static int
connect_af_unix(void)
{
struct sockaddr_un sunix;
int i = sizeof(sunix);
@ -401,13 +408,10 @@ static int connect_af_unix()
return fd;
}
#endif
#ifdef TLI
int
accept_func(fd, callptr, name, closeflg)
int fd;
struct t_call *callptr;
char *name;
int closeflg;
accept_func(int fd, struct t_call* callptr, char* name, int closeflg)
{
int newfd;
int look;
@ -441,7 +445,8 @@ int closeflg;
static int connect_af_inet()
static int
connect_af_inet(void)
{
#ifndef TLI
struct sockaddr_in sin;
@ -466,7 +471,8 @@ static int connect_af_inet()
#if (!defined(TLI) || (defined(TLI) && defined(SOCK_UNIX)))
static void close_af_unix()
static void
close_af_unix(void)
{
struct sockaddr_un sunix;
int true = 1;
@ -486,7 +492,8 @@ static void close_af_unix()
static void close_af_inet()
static void
close_af_inet(void)
{
#ifndef TLI
struct sockaddr_in sin;
@ -514,7 +521,9 @@ static void close_af_inet()
clr_fd(fd_inet);
#endif
}
close_socket()
void
close_socket(void)
{
#if (!defined(TLI) || (defined(TLI) && defined(SOCK_UNIX)))
close_af_unix();
@ -524,11 +533,11 @@ close_socket()
static void connect_client(readfds)
static void
#ifdef SVR4
struct pollfd *readfds;
connect_client(struct pollfd *readfds)
#else
fd_set *readfds;
connect_client(fd_set *readfds)
#endif
{
int fd;
@ -591,7 +600,7 @@ fd_set *readfds;
logging_out("connect to client on %d", fd);
if (client_tmp = (Client *)malloc(sizeof(Client))) {
if ((client_tmp = (Client *)malloc(sizeof(Client))) != NULL) {
memset(client_tmp, 0, sizeof(Client));
client_tmp->fd = fd;
#if (defined(TLI) && defined(SOCK_UNIX))
@ -629,17 +638,16 @@ fd_set *readfds;
static Client *disconnect_client(cp)
Client *cp;
static Client*
disconnect_client(Client *cp)
{
WorkArea *wp;
StdyFile *sp;
int fd;
Client *cl_tmp, *cl_before;
int i;
if (sp = cp->stdy) closestdy(sp);
if (wp = cp->work) free_workarea(wp);
if ((sp = cp->stdy) != NULL) closestdy(sp);
if ((wp = cp->work) != NULL) free_workarea(wp);
debug_out(1, "client dead(%d)\r\n", cp->fd);
logging_out("disconnect from client on %d", cp->fd);
@ -692,7 +700,8 @@ Client *cp;
#include <signal.h>
#endif
void communicate()
void
communicate(void)
{
signal(SIGPIPE, SIG_IGN);
@ -751,12 +760,12 @@ void communicate()
}
void put_flush()
void
put_flush(void)
{
register int len;
register int i;
register char *p;
int len;
int i;
char *p;
for (len = putpos, p = putbuf ; len > 0 ; ) {
if ((i = write(client_fd, p, len)) == ERROR) {
@ -767,28 +776,36 @@ void put_flush()
}
putpos = 0;
}
void put_byte(c)
register int c;
void
put_byte(int c)
{
putbuf[putpos++] = c;
if (putpos >= sizeof(putbuf)) put_flush();
}
void put_work(c)
register int c;
void
put_work(int c)
{
put_byte(c >> 8);
put_byte(c & 0xff);
}
void put_int(c)
register int c;
void
put_int(int c)
{
put_byte(c >> (8 * 3));
put_byte(c >> (8 * 2));
put_byte(c >> (8 * 1));
put_byte(c);
}
Uchar *put_string(p)
register Uchar *p;
u_char*
put_string(u_char* p)
{
if (p) {
do {
@ -799,19 +816,20 @@ register Uchar *p;
put_byte(0);
return p;
}
Uchar *put_ndata(p, n)
register Uchar *p;
register int n;
u_char*
put_ndata(u_char* p, int n)
{
while (n-- > 0) put_byte(p ? *p++ : 0);
return p;
}
void get_buf()
void
get_buf(void)
{
register int i;
int i;
for (;;) {
if ((i = read(client_fd, getbuf, sizeof(getbuf))) > 0) break;
@ -824,34 +842,44 @@ void get_buf()
buflen = i;
getpos = 0;
}
int get_byte()
int
get_byte(void)
{
if (getpos >= buflen) get_buf();
return (getbuf[getpos++] & 0xff);
}
int get_word()
int
get_word(void)
{
register int i;
int i;
i = get_byte();
return ((i << 8) | get_byte());
}
int get_int()
int
get_int(void)
{
register int i0;
register int i1;
register int i2;
int i0;
int i1;
int i2;
i0 = get_byte();
i1 = get_byte();
i2 = get_byte();
return((i0 << (8*3)) | (i1 << (8*2)) | (i2 << (8*1)) | get_byte());
}
int get_nstring(p, n)
register Uchar *p;
register int n;
int
get_nstring(u_char* p, int n)
{
register int c;
int c;
do {
c = get_byte();
@ -860,9 +888,10 @@ register int n;
return (n < 0) ? ERROR : 0;
}
Uchar *get_ndata(p, n)
register Uchar *p;
register int n;
u_char*
get_ndata(u_char* p, int n)
{
while (n-- > 0) *p++ = get_byte();
return p;

View file

@ -31,13 +31,19 @@
* $SonyRCSfile: error.c,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:51 $
*
* $Id$
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "sj_typedef.h"
#include "server.h"
extern char program_name[];
extern int debug_level;
@ -49,8 +55,8 @@ static FILE *logfp = NULL;
static FILE *dbgfp = NULL;
open_error()
int
open_error(void)
{
extern char *error_file;
int flg = 0;
@ -69,9 +75,9 @@ open_error()
return flg;
}
error_out(s, p1, p2, p3, p4, p5)
char *s;
int p1, p2, p3, p4, p5;
void
error_out(char* s, int p1, int p2, int p3, int p4, int p5)
{
char tmp[BUFSIZ];
@ -83,9 +89,9 @@ int p1, p2, p3, p4, p5;
exit(1);
}
warning_out(s, p1, p2, p3, p4, p5)
char *s;
int p1, p2, p3, p4, p5;
void
warning_out(char* s, int p1, int p2, int p3, int p4, int p5)
{
char tmp[BUFSIZ];
@ -97,8 +103,8 @@ int p1, p2, p3, p4, p5;
}
open_log()
int
open_log(void)
{
extern char *log_file;
int flg = 0;
@ -111,7 +117,7 @@ open_log()
else
logfp = fopen(log_file, "a");
if (logfp) {
long t;
time_t t;
time(&t);
fprintf(logfp, "%s: log started at %s\r",
@ -127,9 +133,9 @@ open_log()
return flg;
}
logging_out(s, p1, p2, p3, p4, p5)
char *s;
int p1, p2, p3, p4, p5;
void
logging_out(char* s, int p1, int p2, int p3, int p4, int p5)
{
char tmp[BUFSIZ];
@ -141,8 +147,8 @@ int p1, p2, p3, p4, p5;
}
open_debug()
int
open_debug(void)
{
extern char *debug_file;
int flg = 0;
@ -161,10 +167,9 @@ open_debug()
return flg;
}
debug_out(lvl, s, p1, p2, p3, p4, p5)
int lvl;
char *s;
int p1, p2, p3, p4, p5;
void
debug_out(int lvl, char* s, int p1, int p2, int p3, int p4, int p5)
{
if (lvl <= debug_level && dbgfp) {
fprintf(dbgfp, s, p1, p2, p3, p4, p5);

View file

@ -31,21 +31,24 @@
* $SonyRCSfile: execute.c,v $
* $SonyRevision: 1.7 $
* $SonyDate: 1998/04/13 11:20:12 $
*
* $Id$
*/
#include "sj_kcnv.h"
#include <stdlib.h>
#include <string.h>
#include <pwd.h>
#include <setjmp.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <errno.h>
#include <unistd.h>
#include "sj3cmd.h"
#include "sj3err.h"
#include "Dict.h"
#include "server.h"
#define rmemcpy(a, b, n) memcpy((b), (a), (n))
@ -89,10 +92,9 @@ Uchar *put_ndata(), *put_string();
make_full_path(path)
char *path;
int
make_full_path (char *path)
{
extern char *strtok();
char tmp[PathNameLen];
char *index;
int i;
@ -102,11 +104,11 @@ char *path;
i = strlen(dict_dir) + 1 + strlen(path) + 1;
if (i > sizeof(tmp)) return ERROR;
strcpy(tmp, path);
strlcpy(tmp, path, sizeof(tmp));
index = strtok(tmp, "/");
do {
if (!strcmp(index, "..")) return ERROR;
} while (index = strtok(NULL, "/"));
} while ((index = strtok(NULL, "/")) != NULL);
if (*path == '/') {
if (strncmp(path, dict_dir, strlen(dict_dir)) == 0) {
@ -115,16 +117,15 @@ char *path;
return ERROR;
}
}
strcpy(tmp, dict_dir);
strcat(tmp, "/");
strcat(tmp, path);
snprintf(tmp, sizeof(tmp), "%s/%s", dict_dir, path);
strcpy(path, tmp);
return 0;
}
WorkArea *alloc_workarea()
WorkArea*
alloc_workarea (void)
{
WorkArea *p;
@ -144,8 +145,7 @@ WorkArea *alloc_workarea()
}
void
free_workarea(p)
WorkArea *p;
free_workarea (WorkArea *p)
{
if (!p) return;
if (--(p -> refcnt)) return;
@ -153,7 +153,7 @@ WorkArea *p;
if (worklist == p)
worklist = p -> link;
else {
register WorkArea *q;
WorkArea *q;
for (q = worklist ; q ; q = q -> link) {
if (q -> link == p) {
@ -171,7 +171,8 @@ WorkArea *p;
exec_connect()
void
exec_connect (void)
{
int version;
char hostname[HostNameLen];
@ -226,7 +227,8 @@ exec_connect()
exec_disconnect()
void
exec_disconnect (void)
{
if (cur_cli -> stdy) {
closestdy(cur_cli -> stdy);
@ -244,12 +246,13 @@ exec_disconnect()
exec_opendict()
void
exec_opendict (void)
{
char filename[PathNameLen];
char password[PassWordLen];
DICT *dict;
DICTL *dictl, *dltp, *tmp;
DICTL *dictl, *dltp, *tmp, *tmp1;
get_nstring(filename, sizeof(filename));
get_nstring(password, sizeof(password));
@ -267,8 +270,23 @@ exec_opendict()
while (dltp) {
dictl = (DICTL *)malloc(sizeof *dictl);
if (!dictl) {
for (tmp = dictlist; tmp; tmp->next)
free(tmp);
/* XXX 2004.09.16 Hiroo Ono
* Fixed list deletion when malloc() returns
* NULL, but it will segfault anyway just after
* getting out of this if block.
* Maybe continue, break or return lack in
* this block, but I don't know what was
* intended to be done when malloc() caused
* an error. So just fix the list deletion bug
* in this block and leave the code causing
* segfault when malloc() fails.
*/
tmp = dictlist;
while (tmp != NULL) {
tmp1 = tmp;
tmp = tmp->next;
free (tmp1);
}
dictlist = NULL;
}
if (!dictlist) dictlist = dictl;
@ -301,7 +319,11 @@ exec_opendict()
put_int(SJ3_NormalEnd);
put_int((int)dict->dicid);
}
exec_closedict()
void
exec_closedict (void)
{
TypeDicID id;
DICTL *dictl;
@ -332,8 +354,11 @@ exec_closedict()
free((char *)dictl);
put_int(SJ3_NormalEnd);
}
close_dictlist(dictl)
DICTL *dictl;
void
close_dictlist(DICTL *dictl)
{
DICTL *p;
@ -348,7 +373,8 @@ DICTL *dictl;
exec_openstdy()
void
exec_openstdy (void)
{
char filename[PathNameLen];
char password[PassWordLen];
@ -366,7 +392,11 @@ exec_openstdy()
put_int(SJ3_NormalEnd);
}
exec_closestdy()
void
exec_closestdy (void)
{
if (!cur_cli -> stdy) longjmp(error_ret, SJ3_StdyFileNotOpened);
@ -378,7 +408,8 @@ exec_closestdy()
exec_stdysize()
void
exec_stdysize (void)
{
put_int(SJ3_NormalEnd);
put_int(sizeof(STDYOUT));
@ -386,7 +417,8 @@ exec_stdysize()
static void exec_lock()
static void
exec_lock (void)
{
int lock;
DICTL *dl;
@ -407,7 +439,11 @@ static void exec_lock()
put_int(SJ3_NormalEnd);
}
static void exec_unlock()
static void
exec_unlock (void)
{
int lock;
DICTL *dl;
@ -428,7 +464,11 @@ static void exec_unlock()
put_int(SJ3_NormalEnd);
}
static void lock_check_for_read()
static void
lock_check_for_read (void)
{
int lock;
@ -445,8 +485,7 @@ static void lock_check_for_read()
void
exec_ph2knj(mb_flag)
int mb_flag;
exec_ph2knj (int mb_flag)
{
int i, j, l, stdy_size, buf_size, srchead = 0, srclen;
Uchar *p,*q;
@ -523,8 +562,7 @@ CCONVERR:
void
exec_cl2knj(mb_flag)
int mb_flag;
exec_cl2knj (int mb_flag)
{
int len, stdy_size, buf_size;
int i, j, l;
@ -589,8 +627,7 @@ CCONVERR:
void
exec_nextcl(mb_flag)
int mb_flag;
exec_nextcl (int mb_flag)
{
int mode, stdy_size, buf_size;
int i, l;
@ -643,8 +680,7 @@ CCONVERR:
void
exec_prevcl(mb_flag)
int mb_flag;
exec_prevcl (int mb_flag)
{
int mode, stdy_size, buf_size;
int i, l;
@ -698,8 +734,7 @@ CCONVERR:
void
exec_cl2knj_cnt(mb_flag)
int mb_flag;
exec_cl2knj_cnt(int mb_flag)
{
int len, buf_size, stdy_size;
int i;
@ -747,8 +782,7 @@ CCONVERR:
void
exec_cl2knj_all(mb_flag)
int mb_flag;
exec_cl2knj_all (int mb_flag)
{
int len, stdy_size, buf_size;
int i, l;
@ -847,9 +881,10 @@ CCONVERR:
exec_study()
void
exec_study (void)
{
register int err;
int err;
STDYOUT stdy;
get_ndata(&stdy, sizeof(stdy));
@ -875,10 +910,9 @@ exec_study()
void
exec_clstudy(mb_flag)
int mb_flag;
exec_clstudy (int mb_flag)
{
register int err;
int err;
STDYOUT stdy;
err = get_nstring(buf1, sizeof(buf1));
@ -921,12 +955,11 @@ CCONVERR:
void
exec_adddict(mb_flag)
int mb_flag;
exec_adddict (int mb_flag)
{
TypeDicID dicid;
TypeGram gram;
register int err;
int err;
int err1;
DICTL *dl;
@ -985,12 +1018,11 @@ CCONVERR:
}
void
exec_deldict(mb_flag)
int mb_flag;
exec_deldict (int mb_flag)
{
TypeDicID dicid;
TypeGram gram;
register int err;
int err;
int err1;
DICTL *dl;
@ -1047,8 +1079,7 @@ CCONVERR:
void
exec_getdict(mb_flag)
int mb_flag;
exec_getdict (int mb_flag)
{
TypeDicID dicid;
int err, buf_size, l;
@ -1129,9 +1160,10 @@ CCONVERR:
return;
}
void
exec_nextdict(mb_flag)
int mb_flag;
exec_nextdict (int mb_flag)
{
TypeDicID dicid;
int err, buf_size, l;
@ -1212,9 +1244,10 @@ CCONVERR:
return;
}
void
exec_prevdict(mb_flag)
int mb_flag;
exec_prevdict (int mb_flag)
{
TypeDicID dicid;
int err, buf_size, l;
@ -1297,7 +1330,8 @@ CCONVERR:
exec_makedict()
void
exec_makedict (void)
{
struct stat sbuf;
char path[PathNameLen];
@ -1326,7 +1360,8 @@ exec_makedict()
exec_makestdy()
void
exec_makestdy (void)
{
struct stat sbuf;
char path[PathNameLen];
@ -1354,7 +1389,8 @@ exec_makestdy()
exec_access()
void
exec_access (void)
{
char path[PathNameLen];
int mode;
@ -1370,7 +1406,8 @@ exec_access()
exec_makedir()
void
exec_makedir (void)
{
char path[PathNameLen];
int i;
@ -1392,10 +1429,11 @@ exec_makedir()
exec_who()
void
exec_who (void)
{
register int i;
register Client *cli;
int i;
Client *cli;
i = 0;
cli = client;
@ -1418,14 +1456,19 @@ exec_who()
exec_kill()
void
exec_kill (void)
{
put_int(SJ3_NormalEnd);
put_flush();
server_terminate();
}
exec_quit()
void
exec_quit (void)
{
if (client_num > 1) longjmp(error_ret, SJ3_UserConnected);
exec_kill();
@ -1433,7 +1476,8 @@ exec_quit()
exec_version()
void
exec_version (void)
{
extern char *version_number, *time_stamp;
static char *Version = "version : ";
@ -1449,11 +1493,12 @@ exec_version()
exec_dictpass()
void
exec_dictpass (void)
{
TypeDicID dicid;
char buf[PasswdLen + 1];
register int err;
int err;
DICTL *dl;
@ -1471,11 +1516,15 @@ exec_dictpass()
if (set_dictpass(dl -> dict, buf)) longjmp(error_ret, serv_errno);
put_int(SJ3_NormalEnd);
}
exec_dictcmnt()
void
exec_dictcmnt (void)
{
TypeDicID dicid;
char buf[CommentLength + 1];
register int err;
int err;
DICTL *dl;
@ -1493,10 +1542,14 @@ exec_dictcmnt()
if (set_dictcmnt(dl -> dict, buf)) longjmp(error_ret, serv_errno);
put_int(SJ3_NormalEnd);
}
exec_stdypass()
void
exec_stdypass (void)
{
char buf[PasswdLen + 1];
register int err;
int err;
err = get_nstring(buf, sizeof(buf));
@ -1508,10 +1561,14 @@ exec_stdypass()
if (set_stdypass(buf)) longjmp(error_ret, serv_errno);
put_int(SJ3_NormalEnd);
}
exec_stdycmnt()
void
exec_stdycmnt (void)
{
char buf[CommentLength + 1];
register int err;
int err;
err = get_nstring(buf, sizeof(buf));
@ -1526,7 +1583,8 @@ exec_stdycmnt()
exec_stdypara()
void
exec_stdypara (void)
{
int stynum, clstep, cllen;
@ -1542,11 +1600,12 @@ exec_stdypara()
void execute_cmd()
void
execute_cmd (void)
{
int i;
if (i = setjmp(error_ret)) {
if ((i = setjmp(error_ret)) != 0) {
debug_out(1, "%d: error code = %d\r\n", client_fd, i);
put_int(i);
}

View file

@ -31,24 +31,28 @@
* $SonyRCSfile: main.c,v $
* $SonyRevision: 1.3 $
* $SonyDate: 1995/02/03 07:38:44 $
*
* $Id$
*/
#include "sj_sysvdef.h"
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <unistd.h>
#ifdef SVR4
#include <sys/fcntl.h>
#include <sys/termios.h>
#endif
#include "Const.h"
#include "server.h"
#ifndef lint
static char rcsid_sony[] = "$Header: /export/work/contrib/sj3/server/RCS/main.c,v 1.12 1994/06/03 07:41:30 notanaka Exp $ SONY;";
@ -58,14 +62,13 @@ static char rcsid_sony[] = "$Header: /export/work/contrib/sj3/server/RCS/main.c,
#define signal sigset
#endif
void _exit();
extern int fork_flag;
extern char *lock_file;
static void opening()
static void
opening (void)
{
extern char *version_number;
extern char *time_stamp;
@ -78,7 +81,8 @@ static void opening()
#ifdef LOCK_FILE
int make_lockfile()
int
make_lockfile (void)
{
int fd;
@ -87,7 +91,10 @@ int make_lockfile()
close(fd);
return 0;
}
int erase_lockfile()
int
erase_lockfile (void)
{
return unlink(lock_file);
}
@ -97,14 +104,14 @@ int erase_lockfile()
#if !defined(__sony_news) || defined(SVR4)
static int signal_handler(sig)
int sig;
static int
signal_handler (int sig)
{
warning_out("signal %d catched.", sig);
}
static int terminate_handler(sig)
int sig;
static int
terminate_handler (int sig)
{
close_socket();
sj_closeall();
@ -113,8 +120,10 @@ int sig;
#endif
exit(0);
}
#else
static int signal_handler(sig, code, scp)
#else /* __sony_news && !SVR4 */
static int
signal_handler (sig, code, scp)
int sig;
int code;
struct sigcontext *scp;
@ -134,8 +143,11 @@ struct sigcontext *scp;
#endif
exit(0);
}
#endif
server_terminate()
#endif /* __sony_news && !SVR4 */
void
server_terminate (void)
{
close_socket();
sj_closeall();
@ -147,7 +159,8 @@ server_terminate()
static void exec_fork()
static void
exec_fork (void)
{
int tmp;
@ -180,8 +193,8 @@ static void exec_fork()
static void leave_tty()
static void
leave_tty (void)
{
int tmp;
@ -207,9 +220,8 @@ static void leave_tty()
int main(argc, argv)
int argc;
char **argv;
int
main (int argc, char **argv)
{
#ifdef __sony_news
(void) setlocale(LC_CTYPE, "ja_JP.EUC");

124
server/server.h Normal file
View file

@ -0,0 +1,124 @@
/*
* Copyright (c) 2004 Hiroo Ono <hiroo+sj3 at oikumene.gcd.org>
*
* 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.
*
*/
/*
* $Id: server.h,v 1.1 2004/07/02 16:49:29 hiroo Exp $
*/
#ifndef _SERVER_H_
#define _SERVER_H_ 1
#include "Struct.h"
/* comuni.c */
void socket_init(void);
void open_socket(void);
void close_socket(void);
void communicate(void);
void put_flush(void);
void put_byte(int c);
void put_work(int c);
void put_int(int c);
u_char *put_string(u_char *p);
u_char *put_ndata(u_char *p, int n);
void get_buf(void);
int get_byte(void);
int get_word(void);
int get_int(void);
int get_nstring(u_char *p, int n);
u_char *get_ndata(u_char *p, int n);
/* error.c */
int open_debug(void);
int open_error(void);
int open_log(void);
#if 0
void error_out(char *s, int p1, int p2, int p3, int p4, int p5);
void warning_out(char *s, int p1, int p2, int p3, int p4, int p5);
void logging_out(char *s, int p1, int p2, int p3, int p4, int p5);
void debug_out(int lvl, char *s, int p1, int p2, int p3, int p4, int p5);
#else /* correct solution is to make the functions take arbitrary parameters... */
void error_out ();
void warning_out ();
void logging_out ();
void debug_out ();
#endif
/* execute.c */
int make_full_path(char *path);
WorkArea *alloc_workarea(void);
void free_workarea(WorkArea *p);
void exec_connect(void);
void exec_disconnect(void);
void exec_opendict(void);
void exec_closedict(void);
void close_dictlist(DICTL *dictl);
void exec_openstdy(void);
void exec_closestdy(void);
void exec_stdysize(void);
void exec_ph2knj(int mb_flag);
void exec_cl2knj(int mb_flag);
void exec_nextcl(int mb_flag);
void exec_prevcl(int mb_flag);
void exec_cl2knj_cnt(int mb_flag);
void exec_cl2knj_all(int mb_flag);
void exec_study(void);
void exec_clstudy(int mb_flag);
void exec_adddict(int mb_flag);
void exec_deldict(int mb_flag);
void exec_getdict(int mb_flag);
void exec_nextdict(int mb_flag);
void exec_prevdict(int mb_flag);
void exec_makedict(void);
void exec_makestdy(void);
void exec_access(void);
void exec_makedir(void);
void exec_who(void);
void exec_kill(void);
void exec_quit(void);
void exec_version(void);
void exec_dictpass(void);
void exec_dictcmnt(void);
void exec_stdypass(void);
void exec_stdycmnt(void);
void exec_stdypara(void);
void execute_cmd(void);
/* setup.c */
void RcError(char *p);
void RcWarning(char *p);
int read_line(FILE *fp, char *buf, int len);
void read_runcmd(void);
void set_default(void);
void parse_arg(int argc, char **argv);
void preload_dict(void);
void preopen_dict(void);
int check_user(char *user, char *host);
#endif /* _SERVER_H_ */

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 1991-1994 Sony Corporation
* Copyright (c) 1996 Hidekazu Kuroki <hidekazu at cs.titech.ac.jp>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -31,22 +32,22 @@
* $SonyRCSfile: setup.c,v $
* $SonyRevision: 1.3 $
* $SonyDate: 1994/12/09 11:27:07 $
*
* $Id$
*/
#include "sj_sysvdef.h"
#include <stdio.h>
#include <ctype.h>
#ifdef SVR4
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#else
#include <strings.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <unistd.h>
#include "sj_typedef.h"
#include "sj_const.h"
#include "sj_var.h"
@ -56,6 +57,8 @@
#include "Const.h"
#include "Struct.h"
#include "sj_global.h"
#include "kanakan.h"
#include "server.h"
typedef struct strlist {
u_char *str1;
@ -95,33 +98,30 @@ char *proto_name = NULL;
static int line_number;
char *malloc();
#ifdef OLD
#else
RcError(p)
char *p;
#else /* !OLD */
void
RcError(char* p)
{
fprintf(stderr, "%s: \"%s\", line %d: %s\r\n",
program_name, runcmd_file, line_number, p);
fflush(stderr);
exit(1);
}
RcWarning(p)
char *p;
void
RcWarning(char* p)
{
fprintf(stderr, "%s: warning: \"%s\", line %d: %s\r\n",
program_name, runcmd_file, line_number, p);
fflush(stderr);
}
#endif
#endif /* !OLD */
static cmpstr(src, dst)
u_char *src, *dst;
static int
cmpstr(u_char* src, u_char* dst)
{
int flg;
int c;
@ -185,9 +185,10 @@ void *pv_dst;
while (*p++) ;
return p;
}
static u_char *get_list(p, dst)
u_char *p;
StrList **dst;
static u_char*
get_list(u_char* p, StrList** dst)
{
StrList *s1, *s2;
@ -357,10 +358,9 @@ int len;
return c;
}
read_line(fp, buf, len)
FILE *fp;
char *buf;
int len;
int
read_line(FILE* fp, char* buf, int len)
{
int flg;
@ -374,13 +374,13 @@ int len;
void read_runcmd()
void
read_runcmd(void)
{
FILE *fp;
u_char buf[BUFSIZ];
struct optlist *opt;
u_char *p;
int i;
if (!(fp = fopen(runcmd_file, "r"))) {
warning_out("Can't open run-command file \"%s\"", runcmd_file);
@ -388,7 +388,7 @@ void read_runcmd()
}
line_number = 0;
while (read_line(fp, buf, sizeof(buf)) != EOF) {
for (opt = option ; p = (u_char *)opt -> optname ; opt++)
for (opt = option ; (p = (u_char *)opt -> optname) != NULL ; opt++)
if (!cmpstr(p, buf)) break;
if (p) {
p = buf; while (*p++) ;
@ -404,9 +404,8 @@ void read_runcmd()
}
static set_defstr(d, s)
char **d, *s;
static void
set_defstr(char** d, char* s)
{
if (*d == NULL && s) {
*d = malloc(strlen(s) + 1);
@ -414,12 +413,17 @@ char **d, *s;
strcpy(*d, s);
}
}
static set_defint(d, s)
int *d, s;
static void
set_defint(int* d, int s)
{
if (*d < 0) *d = s;
}
void set_default()
void
set_default(void)
{
set_defstr(&debug_file, DebugOutFile);
set_defstr(&error_file, ErrorOutFile);
@ -447,26 +451,27 @@ void set_default()
}
void parse_arg(argc, argv)
int argc;
char **argv;
void
parse_arg(int argc, char** argv)
{
int c;
int errflg = 0;
char *p;
size_t ret;
extern char *optarg, *strrchr();
extern int optind;
p = (p = strrchr(argv[0], '/')) ? p + 1 : argv[0];
strcpy(program_name, p);
strcpy(runcmd_file, RunCmdFile);
strlcpy(program_name, p, sizeof(program_name));
strlcpy(runcmd_file, RunCmdFile, sizeof(runcmd_file));
while ((c = getopt(argc, argv, "f:")) != EOF) {
switch (c) {
case 'f':
strcpy(runcmd_file, optarg);
ret = strlcpy(runcmd_file, optarg, sizeof(runcmd_file));
if (ret > sizeof(runcmd_file))
errflg++;
break;
case '?':
@ -484,7 +489,7 @@ char **argv;
void
preload_dict()
preload_dict(void)
{
StrList *p;
char filename[PathNameLen];
@ -511,7 +516,8 @@ preload_dict()
free(work_base);
}
preopen_dict()
void
preopen_dict(void)
{
StrList *p;
char filename[PathNameLen];
@ -531,9 +537,9 @@ preopen_dict()
if (make_full_path(filename))
warning_out("too long filename \"%s\"", p -> str1);
else if (dict = (DICT *)opendict(filename, p -> str2)) {
else if ((dict = (DICT *)opendict(filename, p -> str2)) != NULL) {
logging_out("open dictionary \"%s\"", filename);
if (!(dictl = (DICTL *)malloc(sizeof *dictl))) {
if ((dictl = (DICTL *)malloc(sizeof *dictl)) == NULL) {
closedict((DictFile *)dict);
warning_out("can't open dictionary \"%s\"", filename);
continue;
@ -548,10 +554,8 @@ preopen_dict()
}
static str_match(s, d)
char *s;
char *d;
static int
str_match(char* s, char* d)
{
while (*d) {
if (*s == '*') {
@ -571,10 +575,8 @@ char *d;
}
check_user(user, host)
char *user;
char *host;
int
check_user(char* user, char* host)
{
StrList *p;

View file

@ -31,47 +31,51 @@
* $SonyRCSfile: funckey.c,v $
* $SonyRevision: 1.3 $
* $SonyDate: 1997/01/23 11:20:53 $
*
* $Id: funckey.c,v 1.3 2004/07/04 08:38:33 hiroo Exp $
*/
#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, NULL
{ "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[];
@ -108,13 +112,14 @@ int comstrvalue[KEY_OTHER] = {
KEY_OTHER
};
mk_cvtkey(term)
char *term;
void
mk_cvtkey(char* term)
{
register char *p;
char line[MAXLINE], rstr[16], *getkey2();
FILE *fd, *fopen();
char cvtkey_file[LONGLENGTH], *strchr();
char *p;
char line[MAXLINE], rstr[16];
FILE *fd;
char cvtkey_file[LONGLENGTH];
struct cvtkey *ckeyp;
struct wcvtkey *wckeyp;
@ -153,11 +158,10 @@ char *term;
}
char *
getkey2(istr, ostr)
char *istr, *ostr;
getkey2(char* istr, char* ostr)
{
register char *p;
register int i;
char *p;
int i;
while (*istr == ' ' || *istr == '\t')
istr++;
@ -178,16 +182,19 @@ char *istr, *ostr;
return(NULL);
}
clear_ukeys ()
void
clear_ukeys (void)
{
Unumber = 0;
}
set_func (word)
struct wordent word[];
void
set_func (struct wordent word[])
{
register int i, num;
register wchar16_t *p, *s;
int i, num;
wchar16_t *p, *s;
struct wcvtkey *ckeyp;
if (Unumber >= UKEYNUM)
@ -222,10 +229,11 @@ struct wordent word[];
}
}
eval_keys (s, p)
wchar16_t *s, *p;
wchar16_t
eval_keys (wchar16_t* s, wchar16_t* p)
{
register wchar16_t c, i;
wchar16_t c, i;
if (wslen (s) > SEQLEN)
return (-1);
@ -247,22 +255,26 @@ wchar16_t *s, *p;
return (i);
}
clear_key ()
void
clear_key (void)
{
clear_commkeys ();
clear_etckeys ();
clear_ukeys ();
}
clear_commkeys ()
void
clear_commkeys (void)
{
comnumber = 0;
}
eval_key (s)
wchar16_t *s;
int
eval_key (wchar16_t* s)
{
register wchar16_t c;
wchar16_t c;
c = *s;
@ -282,15 +294,18 @@ wchar16_t *s;
return (-1);
}
clear_etckeys ()
void
clear_etckeys (void)
{
u_etckeys = 0;
}
set_etckeys (word)
struct wordent word[];
int
set_etckeys (struct wordent word[])
{
register int i;
int i;
if (u_etckeys >= ETCKEYS)
return (1);
@ -315,15 +330,13 @@ struct wordent word[];
}
parse_command (s, count)
register wchar16_t *s;
register int *count;
wchar16_t
parse_command (wchar16_t* s, int* count)
{
extern wchar16_t pars_seq[];
extern int pars_n;
register int i, j;
register wchar16_t c;
int i, j;
wchar16_t c;
c = *s;
for (i = 0; i < comnumber ; i ++) {

211
sj3/sj3.c
View file

@ -44,6 +44,9 @@
#if defined(__NetBSD__)
#define LACKOF_SETLOCALE
#endif
#if defined(__FreeBSD__)
#include <sys/ioctl_compat.h>
#endif
#include <curses.h>
#endif
@ -55,13 +58,12 @@
#include <netdb.h>
#endif
#include <locale.h>
#include "sj3.h"
#ifndef _PATH_UTMP
#define _PATH_UTMP "/etc/utmp"
#endif
int fail ();
#ifdef SVR4
#define killpg(pid, sig) kill(-(pid),(sig))
@ -125,8 +127,6 @@ struct ttysize Ttysize;
#endif
int master;
int slave;
int exitprocess ();
int onwinch ();
#ifdef SYSV_TERMIOS
struct termios b;
@ -153,11 +153,9 @@ int Pid_shell;
int current_locale;
int done();
main (argc, argv)
int argc;
char **argv;
int
main (int argc, char** argv)
{
init (argv);
get_ttymode ();
@ -174,7 +172,8 @@ char **argv;
done ();
}
makecore ()
void
makecore (void)
{
chdir ("/tmp");
setgid (getgid ());
@ -183,11 +182,10 @@ makecore ()
}
init (argv)
char **argv;
void
init (char** argv)
{
char *cp, *strrchr ();
char *cp;
(void) signal (SIGTERM, (void (*)())done);
(void) signal (SIGWINCH, SIG_IGN);
@ -216,11 +214,11 @@ char **argv;
}
init_env()
void
init_env(void)
{
register char *uname, *hp, *tname;
register int i;
char *uname, *hp, *tname;
int i;
struct passwd *pwd, *getpwnam(), *getpwuid();
char *getlogin(), *getenv();
@ -263,16 +261,13 @@ init_env()
}
parsearg (argc, argv)
register int argc;
register char **argv;
void
parsearg (int argc, char** argv)
{
register int ap;
register char c;
register int sp;
register char **shella;
char *getenv();
int ap;
char c;
int sp;
char **shella;
shella = shellargs;
ap = 1;
@ -346,8 +341,8 @@ register char **argv;
}
usage()
void
usage(void)
{
aprintf ("Usage: %s [-option ...]\n\r", progname);
aprintf ("\t-option\n\r");
@ -367,8 +362,8 @@ usage()
}
sjinit ()
void
sjinit (void)
{
getfixtty ();
setshellname ();
@ -380,11 +375,11 @@ sjinit ()
}
setshellname ()
void
setshellname (void)
{
register char *s;
char *namep, *strrchr (), *getenv();
char *s;
char *namep;
if (shellprog[0] == '\0') {
s = getenv ("SHELL");
@ -412,8 +407,8 @@ setshellname ()
}
getfixtty ()
void
getfixtty (void)
{
getmaster ();
fixtty ();
@ -421,8 +416,8 @@ getfixtty ()
}
get_ttymode ()
void
get_ttymode (void)
{
#ifdef SYSV_TERMIOS
ioctl (0, TCGETS, (char *)&b);
@ -453,8 +448,8 @@ get_ttymode ()
}
getmaster ()
void
getmaster (void)
{
#ifdef SVR4
struct stat stb;
@ -520,11 +515,16 @@ getmaster ()
#endif
}
set_jmode (mode)
register int mode;
void
#ifdef __sony_news
set_jmode (int mode)
#else
set_jmode (void)
#endif
{
#ifdef __sony_news
register int term_mode;
int term_mode;
term_mode = mode & KM_KANJI;
if (term_mode == KM_JIS) {
@ -583,8 +583,8 @@ register int mode;
}
fixtty ()
void
fixtty (void)
{
#ifdef SYSV_TERMIOS
struct termios sbuf;
@ -640,17 +640,19 @@ fixtty ()
#include <grp.h>
#endif
setdev ()
void
setdev (void)
{
char *cp, *ttyname ();
char *cp;
#ifdef BSD43
struct group *ttygrp;
#endif
register Conversion *cv;
Conversion *cv;
cv = current_conversion;
if (cp = ttyname (2))
if ((cp = ttyname (2)) != NULL)
strcpy (tty_name, cp);
else
*tty_name = '\0';
@ -659,7 +661,7 @@ setdev ()
slave_name[strlen ("/dev/")] = 't';
#endif
#ifdef BSD43
if (ttygrp = getgrnam ("tty"))
if ((ttygrp = getgrnam ("tty")) != NULL)
chown(slave_name, getuid(), ttygrp->gr_gid);
else
chown(slave_name, getuid(), getgid());
@ -673,12 +675,12 @@ setdev ()
#endif
#ifdef SYSV_TERMIOS
if (ioctl(0, TIOCGWINSZ, &Ttysize) == 0) {
if (ioctl(0, TIOCGWINSZ, &Ttysize) == 0)
#else
if (ioctl(0, TIOCGSIZE, &Ttysize) == 0) {
if (ioctl(0, TIOCGSIZE, &Ttysize) == 0)
#endif
{
if (!status_line)
--Ttysize.ts_lines;
if (Ttysize.ts_lines < 1) {
@ -730,10 +732,10 @@ setdev ()
}
static char shellbuf[128];
forkshell ()
void
forkshell (void)
{
#ifdef SVR4
struct sigaction action;
@ -767,15 +769,16 @@ forkshell ()
#endif
}
sj3_setenv (ename, eval, buf)
char *ename, *eval, *buf;
void
sj3_setenv (char* ename, char* eval, char* buf)
{
register char *cp, *dp;
register char **ep = environ;
char *cp, *dp;
char **ep = environ;
while (dp = *ep++) {
while ((dp = *ep++) != NULL) {
for (cp = ename; *cp == *dp && *cp; cp++, dp++)
continue;
if (*cp == 0 && (*dp == '=' || *dp == 0)) {
@ -787,8 +790,8 @@ sj3_setenv (ename, eval, buf)
}
shellprocess ()
void
shellprocess (void)
{
int t, f;
#ifdef SYSV_TERMIOS
@ -830,12 +833,11 @@ shellprocess ()
#endif /* SYSV_UTMP */
#else /* SYSV_TERMIOS */
struct utmp Utmp;
register char *p;
char *p;
/*
* Remove warning.
* Patched by Hidekazu Kuroki(hidekazu@cs.titech.ac.jp) 1996/8/10
*/
char *ttyname (), *strrchr ();
#define SCPYN(a, b) strncpy(a, b, sizeof(a))
if ((p = ttyname (0)) == NULL)
@ -905,8 +907,8 @@ shellprocess ()
}
getslave ()
void
getslave (void)
{
#ifdef SVR4
grantpt(master);
@ -956,9 +958,8 @@ getslave ()
}
execcmd (cmd, ap)
char *cmd, **ap;
void
execcmd (char* cmd, char** ap)
{
int c;
char *getenv ();
@ -967,7 +968,7 @@ char *cmd, **ap;
path = getenv ("PATH");
cp = fullcmd;
while (c = *path++) {
while ((c = *path++) != 0) {
if (c == ':') {
*cp++ = '/';
*cp = '\0';
@ -995,16 +996,16 @@ char *cmd, **ap;
}
fail ()
void
fail (void)
{
(void) kill (0, SIGTERM);
done ();
}
done ()
void
done (void)
{
(void) signal (SIGWINCH, SIG_IGN);
@ -1013,7 +1014,9 @@ done ()
done2 ();
}
done2 ()
void
done2 (void)
{
chown (slave_name, 0, 0);
chmod (slave_name, 0666);
@ -1037,15 +1040,17 @@ done2 ()
done3 ();
}
done3 ()
void
done3 (void)
{
aprintf ("\r\nexit %s.\r\n", progname);
exit (0);
}
exitprocess ()
void
exitprocess (void)
{
#ifdef SVR4
siginfo_t info;
@ -1056,14 +1061,13 @@ exitprocess ()
return;
if (info.si_code == CLD_STOPPED)
#else
union wait status;
int pid;
int pid, status;
/*
* Remove warning.
* Patched by Hidekazu Kuroki(hidekazu@cs.titech.ac.jp) 1996/8/10
*/
pid = wait3 ((int *)&status, (WNOHANG|WUNTRACED), 0);
pid = wait3 (&status, (WNOHANG|WUNTRACED), 0);
if (WIFSTOPPED (status))
#endif
suspend();
@ -1072,8 +1076,8 @@ exitprocess ()
}
suspend ()
void
suspend (void)
{
#ifdef SIGTYPE_VOID
void (*old_sigtstp) ();
@ -1155,7 +1159,8 @@ cont:
}
#ifdef SVR4
clearutmpentry()
void
clearutmpentry(void)
{
struct utmpx *up;
#ifdef SVR4
@ -1195,7 +1200,8 @@ clearutmpentry()
}
#else /* SVR4 */
#ifdef SYSV_UTMP
clearutmpentry ()
void
clearutmpentry (void)
{
struct utmp Utmp;
@ -1214,7 +1220,8 @@ clearutmpentry ()
endutent();
}
#else /* SYSV_UTMP */
clearutmpentry ()
void
clearutmpentry (void)
{
int f;
struct utmp Utmp;
@ -1234,20 +1241,21 @@ clearutmpentry ()
#endif /* SVR4 */
onwinch ()
void
onwinch (void)
{
int ttypgrp;
register Conversion *cv;
Conversion *cv;
cv = current_conversion;
(void) signal (SIGWINCH, SIG_IGN);
#ifdef SYSV_TERMIOS
if (ioctl (0, TIOCGWINSZ, &Ttysize) == 0) {
if (ioctl (0, TIOCGWINSZ, &Ttysize) == 0)
#else /* SYSV_TERMIOS */
if (ioctl (0, TIOCGSIZE, &Ttysize) == 0) {
if (ioctl (0, TIOCGSIZE, &Ttysize) == 0)
#endif /* SYSV_TERMIOS */
{
if (!status_line) {
clear_guide_line ();
--Ttysize.ts_lines;
@ -1280,7 +1288,9 @@ onwinch ()
(void) signal (SIGWINCH, (void (*)())onwinch);
}
SetRegion ()
void
SetRegion (void)
{
set_tty_size ();
@ -1288,7 +1298,9 @@ SetRegion ()
RegionSet (1, Ttysize.ts_lines);
}
set_tty_size ()
void
set_tty_size (void)
{
#ifdef SYSV_TERMIOS
@ -1298,11 +1310,12 @@ set_tty_size ()
#endif /* SYSV_TERMIOS */
}
setsjserv(hname)
char *hname;
void
setsjserv(char* hname)
{
register char *p;
register int i;
char *p;
int i;
char *sbuf;
if (hname == NULL || *hname == '\0')
@ -1324,9 +1337,9 @@ char *hname;
cur_serv = serv_list[0];
}
char *
chmyhname(hname)
char *hname;
chmyhname(char* hname)
{
if (hname != NULL) {
if (strcmp(my_hname, hname) == 0 ||

88
sj3/sj3.h Normal file
View file

@ -0,0 +1,88 @@
/*
* Copyright (c) 2004 Hiroo Ono <hiroo+sj3 at oikumene.gcd.org>
*
* 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.
*
*/
/*
* $Id: sj3.h,v 1.1 2004/07/02 18:31:25 hiroo Exp $
*/
#ifndef _SJ3_H_
#define _SJ3_H_ 1
/* funckey.c */
void mk_cvtkey(char *term);
char *getkey2(char *istr, char *ostr);
void clear_ukeys(void);
void set_func(struct wordent word[]);
wchar16_t eval_keys(wchar16_t *s, wchar16_t *p);
void clear_key(void);
void clear_commkeys(void);
int eval_key(wchar16_t *s);
void clear_etckeys(void);
int set_etckeys(struct wordent word[]);
wchar16_t parse_command(wchar16_t *s, int *count);
/* sj3.c */
int main(int argc, char **argv);
void makecore(void);
void init(char **argv);
void init_env(void);
void parsearg(int argc, char **argv);
void usage(void);
void sjinit(void);
void setshellname(void);
void getfixtty(void);
void get_ttymode(void);
void getmaster(void);
#ifdef __sony_news
void set_jmode(int mode);
#else
void set_jmode(void);
#endif
void fixtty(void);
void setdev(void);
void forkshell(void);
void sj3_setenv(char *ename, char *eval, char *buf);
void shellprocess(void);
void getslave(void);
void execcmd(char *cmd, char **ap);
void fail(void);
void done(void);
void done2(void);
void done3(void);
void exitprocess(void);
void suspend(void);
void clearutmpentry(void);
void onwinch(void);
void SetRegion(void);
void set_tty_size(void);
void setsjserv(char *hname);
char *chmyhname(char *hname);
#endif /* _SJ3_H_ */

View file

@ -31,31 +31,31 @@
* $SonyRCSfile: sj3dic.c,v $
* $SonyRevision: 1.2 $
* $SonyDate: 1996/02/15 02:22:58 $
*
* $Id$
*/
#include "sj_sysvdef.h"
#include <stdio.h>
#ifdef SVR4
#include <stdlib.h>
#include <string.h>
#else
#include <strings.h>
#endif
#include <sys/types.h>
#include <ctype.h>
#include <pwd.h>
#include <locale.h>
#include <unistd.h>
#include "sjtool.h"
#include "sj3lib.h"
#include "sj3dic.h"
char *getlogin(), *getenv();
struct passwd *getpwnam(), *getpwuid();
static _open_error();
static _close_error();
void make_dicname();
void setsjserv();
static void _open_error(int err);
static void _close_error(int err);
static void init_env(void);
static void make_dicname(void);
static int parsearg(int argc, char* argv[]);
static void usage(int ret);
#ifdef __sony_news
extern int _sys_code;
@ -71,14 +71,14 @@ 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
{ "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];
@ -92,9 +92,9 @@ int verbose_flag = 0;
int init_flag = 0;
int force_flag = 0;
main(argc, argv)
int argc;
char **argv;
int
main(int argc, char** argv)
{
int err;
int mode;
@ -109,7 +109,10 @@ char **argv;
getsjrc();
make_dicname();
if (err = sj3_open(serv_name, user_name, prog_name)) _open_error(err);
/* XXX: is this progname intentional? or old variable left? */
/* if (err = sj3_open(serv_name, user_name, prog_name)) */
if (err = sj3_open(serv_name, user_name))
_open_error(err);
switch (mode) {
case EXEC_TEXT:
@ -126,7 +129,8 @@ char **argv;
if (err = sj3_close()) _close_error(err);
}
init_env()
static void
init_env(void)
{
char *un, *hp, *tn;
struct passwd *pwd;
@ -159,8 +163,8 @@ init_env()
strcpy(term_name, tn);
}
usage(ret)
int ret;
static void
usage(int ret)
{
fprintf(stderr,
"Usage: %s -{text|dict} [-H host_name] [file_name]\n",
@ -168,9 +172,8 @@ int ret;
exit(ret);
}
parsearg(argc, argv)
int argc;
char *argv[];
static int
parsearg(int argc, char* argv[])
{
int errflg = 0;
int i, j;
@ -240,8 +243,8 @@ char *argv[];
return mode;
}
void
make_dicname()
static void
make_dicname(void)
{
if (dict_name[0] != '\0') return;
@ -251,8 +254,7 @@ make_dicname()
}
void
setdicname(dictname)
char *dictname;
setdicname(char* dictname)
{
if (dict_name[0] != '\0') return;
if (dictname == NULL) return;
@ -260,8 +262,7 @@ char *dictname;
}
void
setsjserv(hostname)
char *hostname;
setsjserv(char* hostname)
{
if (serv_name[0] != '\0') return;
if (hostname == NULL) return;
@ -274,9 +275,8 @@ struct errlist {
int flg;
};
static _error_and(err, list)
int err;
struct errlist *list;
static void
_error_and(int err, struct errlist* list)
{
int flag = 0;
@ -291,41 +291,41 @@ struct errlist *list;
if (flag) exit(1);
}
static _open_error(err)
int err;
static void
_open_error(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
{ 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 void
_close_error(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
{ 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);

42
sj3dic/sj3dic.h Normal file
View file

@ -0,0 +1,42 @@
/*
* Copyright (c) 2004 Hiroo Ono <hiroo+sj3 at oikumene.gcd.org>
*
* 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.
*
*/
/*
* $Id: sj3dic.h,v 1.1 2004/07/03 02:26:56 hiroo Exp $
*/
#ifndef _SJ3DIC_H_
#define _SJ3DIC_H_ 1
/* sj3dic.c */
void setdicname(char *dictname);
void setsjserv(char *hostname);
#endif /* _SJ3DIC_H_ */

View file

@ -31,17 +31,20 @@
* $SonyRCSfile: level1.c,v $
* $SonyRevision: 1.4 $
* $SonyDate: 1995/04/17 10:36:08 $
*
* $Id: level1.c,v 1.2 2004/07/20 15:55:43 hiroo Exp $
*/
#include "sj_sysvdef.h"
#include <stdio.h>
#include <netdb.h>
#include <pwd.h>
#include <string.h>
#include <sys/un.h>
#include <sys/types.h>
#include <sys/param.h>
#include <unistd.h>
#include <netinet/in.h>
#ifdef TLI
#include <fcntl.h>
@ -58,16 +61,14 @@
#include "sj3cmd.h"
#include "sj3err.h"
#include "sj3lib.h"
#include "sj3lowlib.h"
#ifdef SVR4
#define signal sigset
#endif
char *getlogin();
#ifndef lint
static char rcsid_sony[] = "$SonyId: level1.c,v 1.4 1995/04/17 10:36:08 notanaka Exp $ SONY;";
static char rcsid_patch[] = "$Id: level1.c,v 1.2 2004/07/20 15:55:43 hiroo Exp $";
#endif
int sj3_error_number;
@ -103,10 +104,11 @@ static int ReadErrorFlag = FALSE;
} \
}
static put_flush()
static int
put_flush(void)
{
register int i, j;
register u_char *p;
int i, j;
u_char *p;
for (i = putpos, p = putbuf ; i > 0 ; i -= j, p += j) {
#ifdef TLI
@ -127,27 +129,31 @@ static put_flush()
return 0;
}
static put_byte(c)
register int c;
static void
put_byte(int c)
{
putbuf[putpos++] = c;
}
static put_word(c)
register int c;
static void
put_word(int c)
{
put_byte(c >> 8);
put_byte(c & 0xff);
}
static put_int(c)
register int c;
static void
put_int(int c)
{
put_byte(c >> (8 * 3));
put_byte(c >> (8 * 2));
put_byte(c >> (8 * 1));
put_byte(c);
}
static put_cmd(cmd)
register int cmd;
static void
put_cmd(int cmd)
{
ReadErrorFlag = FALSE;
putpos = getlen = 0;
@ -156,20 +162,21 @@ register int cmd;
#define put_string put_ndata
static u_char *put_ndata(p, n)
register u_char *p;
register int n;
static u_char*
put_ndata(u_char* p, int n)
{
while (n-- > 0) put_byte(p ? *p++ : 0);
return p;
}
static put_over(buflen, n, func1, str1, len1, func2, str2, len2,
func3, str3, len3, func4, str4, len4)
int buflen, n;
u_char *(*func1)(), *(*func2)(), *(*func3)(), *(*func4)();
u_char *str1, *str2, *str3, *str4;
int len1, len2, len3, len4;
static int
put_over(
int buflen,
int n,
u_char* (*func1)(), u_char* str1, int len1,
u_char* (*func2)(), u_char* str2, int len2,
u_char* (*func3)(), u_char* str3, int len3,
u_char* (*func4)(), u_char* str4, int len4)
{
#define ARGNUM 4
u_char *(*func[ARGNUM])();
@ -201,7 +208,8 @@ int len1, len2, len3, len4;
return 0;
}
static get_buffer()
static int
get_buffer(void)
{
if (ReadErrorFlag) return ERROR;
getpos = getlen = 0;
@ -221,7 +229,8 @@ static get_buffer()
return getlen;
}
static get_byte()
static u_char
get_byte(void)
{
if ((getpos >= getlen) && (get_buffer() == ERROR)) {
ReadErrorFlag = TRUE;
@ -229,28 +238,33 @@ static get_byte()
}
return(getbuf[getpos++] & 0xff);
}
static get_word()
static int
get_word(void)
{
register int i;
int i;
i = get_byte();
return ((i << 8) | get_byte());
}
static get_int()
static int
get_int(void)
{
register int i0;
register int i1;
register int i2;
int i0;
int i1;
int i2;
i0 = get_byte();
i1 = get_byte();
i2 = get_byte();
return ((i0 << (8*3)) | (i1 << (8*2)) | (i2 << (8*1)) | get_byte());
}
static u_char *get_string(p)
register u_char *p;
static u_char*
get_string(u_char* p)
{
register int c;
int c;
do {
*p++ = c = get_byte();
@ -258,11 +272,11 @@ register u_char *p;
return p;
}
static get_nstring(p, n)
register u_char *p;
register int n;
static int
get_nstring(u_char* p, int n)
{
register int c;
int c;
c = get_byte();
while (c) {
@ -272,24 +286,29 @@ register int n;
if (n > 0) *p++ = 0;
return n;
}
static u_char *get_ndata(p, n)
register u_char *p;
register int n;
static u_char*
get_ndata(u_char* p, int n)
{
while (n-- > 0) *p++ = get_byte();
return p;
}
static skip_string()
static void
skip_string(void)
{
while (get_byte()) ;
}
static skip_ndata(n)
register int n;
static void
skip_ndata(int n)
{
while (n-- > 0) get_byte();
}
#ifndef TLI
static open_unix()
static int
open_unix(void)
{
int fd, len;
struct sockaddr_un sunix;
@ -316,19 +335,19 @@ static open_unix()
}
#endif
sj3_set_timeout(timeout)
int timeout;
{
void
sj3_set_timeout(int timeout)
{
sj3_timeout = timeout;
}
}
static void
connect_timeout()
{
}
connect_timeout(void)
{
}
static open_inet(host)
char *host;
static int
open_inet(char* host)
{
#ifdef TLI
int val;
@ -339,7 +358,6 @@ char *host;
struct nd_addrlist *addrs;
void *handlep;
char host_name[BUFSIZ], proto_name[BUFSIZ], *port_name, *tmp_addr;
extern char *strchr();
extern void *setnetpath();
extern struct netconfig *getnetpath();
#else
@ -469,12 +487,12 @@ char *host;
}
int sj3_make_connection(client, serv, user, prog)
SJ3_CLIENT_ENV *client;
char *serv;
char *user;
char *prog;
int
sj3_make_connection(
SJ3_CLIENT_ENV* client,
char* serv,
char* user,
char* prog)
{
char host[MAXHOSTNAMELEN];
int tmp;
@ -484,8 +502,9 @@ char *prog;
client -> fd = -1;
if (!serv || *serv == '\0' || !strcmp(serv, af_unix_str)) {
if (!serv || *serv == '\0' || !strcmp(serv, af_unix_str))
#ifdef TLI
{
serv = LocalHost;
strcpy(host, af_unix_str);
} else {
@ -494,6 +513,7 @@ char *prog;
if ((server_fd = open_inet(serv)) == ERROR) return ERROR;
#else
{
if ((server_fd = open_unix()) == ERROR) return ERROR;
strcpy(host, af_unix_str);
}
@ -568,8 +588,9 @@ char *prog;
return ReadErrorFlag ? ERROR : 0;
}
int sj3_erase_connection(client)
SJ3_CLIENT_ENV *client;
int
sj3_erase_connection(SJ3_CLIENT_ENV* client)
{
client_init(client);
@ -588,11 +609,10 @@ SJ3_CLIENT_ENV *client;
}
long sj3_open_dictionary(client, dictname, password)
SJ3_CLIENT_ENV *client;
char *dictname;
char *password;
long
sj3_open_dictionary(
SJ3_CLIENT_ENV* client,
char* dictname, char* password)
{
int res;
int dictlen, passlen;
@ -619,9 +639,9 @@ char *password;
res = get_int();
return ReadErrorFlag ? ERROR : res;
}
int sj3_close_dictionary(client, dicid)
SJ3_CLIENT_ENV *client;
long dicid;
int
sj3_close_dictionary(SJ3_CLIENT_ENV* client, long dicid)
{
client_init(client);
@ -634,11 +654,10 @@ long dicid;
}
int sj3_open_study_file(client, stdyname, password)
SJ3_CLIENT_ENV *client;
char *stdyname;
char *password;
int
sj3_open_study_file(
SJ3_CLIENT_ENV* client,
char* stdyname, char* password)
{
int stdylen, passlen;
int datalen, buflen;
@ -663,8 +682,9 @@ char *password;
if (sj3_error_number = get_int()) return ERROR;
return ReadErrorFlag ? ERROR : 0;
}
int sj3_close_study_file(client)
SJ3_CLIENT_ENV *client;
int
sj3_close_study_file(SJ3_CLIENT_ENV* client)
{
client_init(client);
@ -676,9 +696,8 @@ SJ3_CLIENT_ENV *client;
}
int sj3_get_id_size(client)
SJ3_CLIENT_ENV *client;
int
sj3_get_id_size(SJ3_CLIENT_ENV* client)
{
client_init(client);
@ -691,9 +710,8 @@ SJ3_CLIENT_ENV *client;
}
int sj3_lock_server(client)
SJ3_CLIENT_ENV *client;
int
sj3_lock_server(SJ3_CLIENT_ENV* client)
{
client_init(client);
@ -703,8 +721,9 @@ SJ3_CLIENT_ENV *client;
if (sj3_error_number = get_int()) return ERROR;
return ReadErrorFlag ? ERROR : 0;
}
int sj3_unlock_server(client)
SJ3_CLIENT_ENV *client;
int
sj3_unlock_server(SJ3_CLIENT_ENV *client)
{
client_init(client);
@ -716,15 +735,15 @@ SJ3_CLIENT_ENV *client;
}
int sj3_ikkatu_henkan(client, src, dst, dstsiz, mb_flag)
SJ3_CLIENT_ENV *client;
u_char *src;
register u_char *dst;
register int dstsiz;
int mb_flag;
int
sj3_ikkatu_henkan(
SJ3_CLIENT_ENV* client,
u_char* src,
u_char* dst,
int dstsiz,
int mb_flag)
{
register int c;
int c;
u_char *top;
int result;
int len;
@ -793,13 +812,13 @@ error2:
}
int sj3_bunsetu_henkan(client, yomi, len, kanji, mb_flag)
SJ3_CLIENT_ENV *client;
u_char *yomi;
int len;
u_char *kanji;
int mb_flag;
int
sj3_bunsetu_henkan(
SJ3_CLIENT_ENV* client,
u_char* yomi,
int len,
u_char* kanji,
int mb_flag)
{
int result;
int buflen;
@ -828,11 +847,13 @@ int mb_flag;
get_string( get_ndata(kanji, cliptr -> stdy_size) );
return ReadErrorFlag ? ERROR : result;
}
int sj3_bunsetu_jikouho(client, kanji, mode, mb_flag)
SJ3_CLIENT_ENV *client;
u_char *kanji;
int mode;
int mb_flag;
int
sj3_bunsetu_jikouho(
SJ3_CLIENT_ENV* client,
u_char* kanji,
int mode,
int mb_flag)
{
int result;
@ -851,11 +872,11 @@ int mb_flag;
get_string( get_ndata(kanji, cliptr -> stdy_size) );
return ReadErrorFlag ? ERROR : result;
}
int sj3_bunsetu_maekouho(client, kanji, mode, mb_flag)
SJ3_CLIENT_ENV *client;
u_char *kanji;
int mode;
int mb_flag;
int
sj3_bunsetu_maekouho(
SJ3_CLIENT_ENV* client,
u_char* kanji, int mode, int mb_flag)
{
int result;
@ -876,12 +897,12 @@ int mb_flag;
}
int sj3_bunsetu_kouhosuu(client, yomi, len, mb_flag)
SJ3_CLIENT_ENV *client;
u_char *yomi;
int len;
int mb_flag;
int
sj3_bunsetu_kouhosuu(
SJ3_CLIENT_ENV* client,
u_char* yomi,
int len,
int mb_flag)
{
int result;
int buflen;
@ -909,12 +930,14 @@ int mb_flag;
result = get_int();
return ReadErrorFlag ? ERROR : result;
}
int sj3_bunsetu_zenkouho(client, yomi, len, douon, mb_flag)
SJ3_CLIENT_ENV *client;
u_char *yomi;
int len;
SJ3_DOUON *douon;
int mb_flag;
int
sj3_bunsetu_zenkouho(
SJ3_CLIENT_ENV* client,
u_char* yomi,
int len,
SJ3_DOUON* douon,
int mb_flag)
{
int cnt = 0;
int buflen;
@ -951,10 +974,8 @@ int mb_flag;
}
int sj3_tango_gakusyuu(client, stdy)
SJ3_CLIENT_ENV *client;
SJ3_STUDYREC *stdy;
int
sj3_tango_gakusyuu(SJ3_CLIENT_ENV* client, SJ3_STUDYREC* stdy)
{
int buflen;
@ -975,12 +996,14 @@ SJ3_STUDYREC *stdy;
if (sj3_error_number = get_int()) return ERROR;
return ReadErrorFlag ? ERROR : 0;
}
int sj3_bunsetu_gakusyuu(client, yomi1, yomi2, stdy, mb_flag)
SJ3_CLIENT_ENV *client;
u_char *yomi1;
u_char *yomi2;
SJ3_STUDYREC *stdy;
int mb_flag;
int
sj3_bunsetu_gakusyuu(
SJ3_CLIENT_ENV* client,
u_char* yomi1,
u_char* yomi2,
SJ3_STUDYREC* stdy,
int mb_flag)
{
int yomilen1, yomilen2;
int datalen, buflen;
@ -1012,14 +1035,14 @@ int mb_flag;
}
int sj3_tango_touroku(client, dicid, yomi, kanji, code, mb_flag)
SJ3_CLIENT_ENV *client;
long dicid;
u_char *yomi;
u_char *kanji;
int code;
int mb_flag;
int
sj3_tango_touroku(
SJ3_CLIENT_ENV* client,
long dicid,
u_char* yomi,
u_char* kanji,
int code,
int mb_flag)
{
int yomilen, kanjilen;
int datalen, buflen;
@ -1049,13 +1072,15 @@ int mb_flag;
if (sj3_error_number = get_int()) return ERROR;
return ReadErrorFlag ? ERROR : 0;
}
int sj3_tango_sakujo(client, dicid, yomi, kanji, code, mb_flag)
SJ3_CLIENT_ENV *client;
long dicid;
u_char *yomi;
u_char *kanji;
int code;
int mb_flag;
int
sj3_tango_sakujo(
SJ3_CLIENT_ENV* client,
long dicid,
u_char* yomi,
u_char* kanji,
int code,
int mb_flag)
{
int yomilen, kanjilen;
int datalen, buflen;
@ -1087,14 +1112,14 @@ int mb_flag;
}
int sj3_tango_syutoku(client, dicid, buf, mb_flag)
SJ3_CLIENT_ENV *client;
int dicid;
u_char *buf;
int mb_flag;
int
sj3_tango_syutoku(
SJ3_CLIENT_ENV* client,
int dicid,
u_char* buf,
int mb_flag)
{
register u_char *p;
u_char *p;
client_init(client);
@ -1112,13 +1137,15 @@ int mb_flag;
*p = get_int();
return ReadErrorFlag ? ERROR : 0;
}
int sj3_tango_jikouho(client, dicid, buf, mb_flag)
SJ3_CLIENT_ENV *client;
int dicid;
u_char *buf;
int mb_flag;
int
sj3_tango_jikouho(
SJ3_CLIENT_ENV* client,
int dicid,
u_char* buf,
int mb_flag)
{
register u_char *p;
u_char *p;
client_init(client);
@ -1136,13 +1163,15 @@ int mb_flag;
*p = get_int();
return ReadErrorFlag ? ERROR : 0;
}
int sj3_tango_maekouho(client, dicid, buf, mb_flag)
SJ3_CLIENT_ENV *client;
int dicid;
u_char *buf;
int mb_flag;
int
sj3_tango_maekouho(
SJ3_CLIENT_ENV* client,
int dicid,
u_char* buf,
int mb_flag)
{
register u_char *p;
u_char *p;
client_init(client);
@ -1162,13 +1191,13 @@ int mb_flag;
}
int sj3_make_dict_file(client, path, idxlen, seglen, segnum)
SJ3_CLIENT_ENV *client;
char *path;
int idxlen;
int seglen;
int segnum;
int
sj3_make_dict_file(
SJ3_CLIENT_ENV* client,
char* path,
int idxlen,
int seglen,
int segnum)
{
int pathlen;
int buflen, datalen;
@ -1197,13 +1226,13 @@ int segnum;
}
int sj3_make_study_file(client, path, stynum, clstep, cllen)
SJ3_CLIENT_ENV *client;
char *path;
int stynum;
int clstep;
int cllen;
int
sj3_make_study_file(
SJ3_CLIENT_ENV* client,
char* path,
int stynum,
int clstep,
int cllen)
{
int pathlen;
int buflen, datalen;
@ -1232,10 +1261,8 @@ int cllen;
}
int sj3_make_directory(client, path)
SJ3_CLIENT_ENV *client;
char *path;
int
sj3_make_directory(SJ3_CLIENT_ENV* client, char* path)
{
int pathlen;
int buflen;
@ -1260,11 +1287,8 @@ char *path;
}
int sj3_access(client, path, mode)
SJ3_CLIENT_ENV *client;
char *path;
int mode;
int
sj3_access(SJ3_CLIENT_ENV* client, char* path, int mode)
{
int result;
int pathlen;
@ -1292,11 +1316,8 @@ int mode;
}
int sj3_who(client, ret, num)
SJ3_CLIENT_ENV *client;
SJ3_WHO_STRUCT *ret;
int num;
int
sj3_who(SJ3_CLIENT_ENV* client, SJ3_WHO_STRUCT* ret, int num)
{
int i, j;
@ -1331,9 +1352,8 @@ int num;
}
int sj3_quit(client)
SJ3_CLIENT_ENV *client;
int
sj3_quit(SJ3_CLIENT_ENV* client)
{
client_init(client);
@ -1343,8 +1363,9 @@ SJ3_CLIENT_ENV *client;
if (sj3_error_number = get_int()) return ERROR;
return ReadErrorFlag ? ERROR : 0;
}
int sj3_kill(client)
SJ3_CLIENT_ENV *client;
int
sj3_kill(SJ3_CLIENT_ENV* client)
{
client_init(client);
@ -1356,11 +1377,8 @@ SJ3_CLIENT_ENV *client;
}
int sj3_version(client, dst, dstsiz)
SJ3_CLIENT_ENV *client;
char *dst;
int dstsiz;
int
sj3_version(SJ3_CLIENT_ENV* client, char* dst, int dstsiz)
{
int c;

View file

@ -31,28 +31,28 @@
* $SonyRCSfile: sj.c,v $
* $SonyRevision: 1.2 $
* $SonyDate: 1994/12/09 11:27:09 $
*
* $Id$
*/
#include <stdio.h>
#include <ctype.h>
#include <locale.h>
#include <pwd.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/file.h>
#include <ctype.h>
#include <unistd.h>
#include "sj_const.h"
#include "Const.h"
#include "sj3err.h"
#include "sj3lib.h"
#include "sj3lowlib.h"
#include "sj_hinsi.h"
extern int sj3_error_number;
extern int sj3_str_sjistoeuc(), sj3_str_euctosjis(), sj3_sjistoeuclen();
#ifdef __sony_news
extern int _sys_code;
#else
@ -79,12 +79,10 @@ static u_char buf1[YomiBufSize];
static u_char buf2[YomiBufSize];
static u_char kbuf[KanjiBufSize];
char *getlogin(), *getenv();
long sj3_open_dictionary();
#ifndef __sony_news
static int
set_sys_code()
set_sys_code(void)
{
char *loc;
@ -97,11 +95,11 @@ set_sys_code()
#endif
static make_dirs(path)
char *path;
static int
make_dirs(char* path)
{
char tmp[PathNameLen];
register char *p;
char *p;
int i;
for (p = path ; *p ; p++) {
@ -118,10 +116,8 @@ char *path;
}
sj3_open(host, user)
char *host;
char *user;
int
sj3_open(char* host, char* user)
{
char tmp[PathNameLen];
char *p;
@ -195,19 +191,17 @@ server_dead:
return SJ3_SERVER_DEAD;
}
sj3_open_with_list(host, user, dicts_num, dicts, error_num, error_index)
char *host;
char *user;
int dicts_num;
char **dicts;
int *error_num;
int **error_index;
int
sj3_open_with_list(
char* host, char* user, int dicts_num,
char** dicts, int* error_num, int** error_index)
{
char tmp[PathNameLen];
char *p;
int err = SJ3_NORMAL_END;
int i, err_id_num = 0;
long *dict_idx;
long *dict_idx = NULL;
if (client.fd != -1) return SJ3_ALREADY_CONNECTED;
@ -304,7 +298,10 @@ server_dead:
mdicid = udicid = 0;
return SJ3_SERVER_DEAD;
}
sj3_close()
int
sj3_close(void)
{
int err = SJ3_NORMAL_END;
int i;
@ -368,12 +365,8 @@ server_dead:
}
sj3_getkan(yomi, bun, knj, knjsiz)
u_char *yomi;
SJ3_BUNSETU *bun;
u_char *knj;
int knjsiz;
int
sj3_getkan(u_char* yomi, SJ3_BUNSETU* bun, u_char* knj, int knjsiz)
{
u_char *src;
int buncnt = 0;
@ -424,11 +417,10 @@ int knjsiz;
return buncnt;
}
sj3_getkan_euc(yomi, bun, knj, knjsiz)
u_char *yomi;
SJ3_BUNSETU *bun;
u_char *knj;
int knjsiz;
int
sj3_getkan_euc(u_char* yomi, SJ3_BUNSETU* bun, u_char* knj, int knjsiz)
{
u_char *src, *yp, *kp, *khp;
int buncnt = 0, i;
@ -523,11 +515,9 @@ int knjsiz;
return buncnt;
}
sj3_getkan_mb(yomi, bun, knj, knjsiz)
u_char *yomi;
SJ3_BUNSETU *bun;
u_char *knj;
int knjsiz;
int
sj3_getkan_mb(u_char* yomi, SJ3_BUNSETU* bun, u_char* knj, int knjsiz)
{
#ifndef __sony_news
if (_sys_code == SYS_NOTDEF)
@ -540,9 +530,8 @@ int knjsiz;
}
sj3_douoncnt(yomi)
u_char *yomi;
int
sj3_douoncnt(u_char* yomi)
{
int i;
@ -560,8 +549,10 @@ u_char *yomi;
return i;
}
sj3_douoncnt_euc(yomi)
u_char *yomi;
int
sj3_douoncnt_euc(u_char* yomi)
{
int i, l, flag;
u_char *yp;
@ -591,8 +582,9 @@ u_char *yomi;
return i;
}
sj3_douoncnt_mb(yomi)
u_char *yomi;
int
sj3_douoncnt_mb(u_char* yomi)
{
#ifndef __sony_news
if (_sys_code == SYS_NOTDEF)
@ -605,10 +597,8 @@ u_char *yomi;
}
sj3_getdouon(yomi, dou)
u_char *yomi;
SJ3_DOUON *dou;
int
sj3_getdouon(u_char* yomi, SJ3_DOUON* dou)
{
int i;
@ -625,9 +615,10 @@ SJ3_DOUON *dou;
return i;
}
sj3_getdouon_euc(yomi, dou)
u_char *yomi;
SJ3_DOUON *dou;
int
sj3_getdouon_euc(u_char* yomi, SJ3_DOUON* dou)
{
int i, j, l;
@ -665,9 +656,10 @@ SJ3_DOUON *dou;
}
return i;
}
sj3_getdouon_mb(yomi, dou)
u_char *yomi;
SJ3_DOUON *dou;
int
sj3_getdouon_mb(u_char* yomi, SJ3_DOUON* dou)
{
#ifndef __sony_news
if (_sys_code == SYS_NOTDEF)
@ -679,8 +671,9 @@ SJ3_DOUON *dou;
return sj3_getdouon(yomi, dou);
}
sj3_gakusyuu(dcid)
SJ3_STUDYREC *dcid;
int
sj3_gakusyuu(SJ3_STUDYREC* dcid)
{
if (sj3_tango_gakusyuu(&client, dcid) == ERROR) {
if (client.fd < 0) {
@ -692,10 +685,9 @@ SJ3_STUDYREC *dcid;
return 0;
}
sj3_gakusyuu2(yomi1, yomi2, dcid)
u_char *yomi1;
u_char *yomi2;
SJ3_STUDYREC *dcid;
int
sj3_gakusyuu2(u_char* yomi1, u_char* yomi2, SJ3_STUDYREC* dcid)
{
if (sj3_bunsetu_gakusyuu(&client, yomi1, yomi2, dcid, MBCODE_SJIS) == ERROR) {
if (client.fd < 0) {
@ -706,10 +698,10 @@ SJ3_STUDYREC *dcid;
}
return 0;
}
sj3_gakusyuu2_euc(yomi1, yomi2, dcid)
u_char *yomi1;
u_char *yomi2;
SJ3_STUDYREC *dcid;
int
sj3_gakusyuu2_euc(u_char* yomi1, u_char* yomi2, SJ3_STUDYREC* dcid)
{
int l, flag;
u_char *y1p, *y2p;
@ -738,10 +730,10 @@ SJ3_STUDYREC *dcid;
}
return 0;
}
sj3_gakusyuu2_mb(yomi1, yomi2, dcid)
u_char *yomi1;
u_char *yomi2;
SJ3_STUDYREC *dcid;
int
sj3_gakusyuu2_mb(u_char* yomi1, u_char* yomi2, SJ3_STUDYREC* dcid)
{
#ifndef __sony_news
if (_sys_code == SYS_NOTDEF)
@ -753,10 +745,9 @@ SJ3_STUDYREC *dcid;
return sj3_gakusyuu2(yomi1, yomi2, dcid);
}
sj3_touroku(yomi, kanji, code)
u_char *yomi;
u_char *kanji;
int code;
int
sj3_touroku(u_char* yomi, u_char* kanji, int code)
{
if (sj3_tango_touroku(&client, udicid, yomi, kanji, code, MBCODE_SJIS)) {
if (client.fd < 0) {
@ -780,10 +771,10 @@ int code;
return 0;
}
sj3_touroku_euc(yomi, kanji, code)
u_char *yomi;
u_char *kanji;
int code;
int
sj3_touroku_euc(u_char* yomi, u_char* kanji, int code)
{
int l, flag;
u_char *yp;
@ -825,10 +816,10 @@ int code;
return 0;
}
sj3_touroku_mb(yomi, kanji, code)
u_char *yomi;
u_char *kanji;
int code;
int
sj3_touroku_mb(u_char* yomi, u_char* kanji, int code)
{
#ifndef __sony_news
if (_sys_code == SYS_NOTDEF)
@ -840,10 +831,9 @@ int code;
return sj3_touroku(yomi, kanji, code);
}
sj3_syoukyo(yomi, kanji, code)
u_char *yomi;
u_char *kanji;
int code;
int
sj3_syoukyo(u_char* yomi, u_char* kanji, int code)
{
if (sj3_tango_sakujo(&client, udicid, yomi, kanji, code, MBCODE_SJIS)) {
if (client.fd < 0) {
@ -863,10 +853,10 @@ int code;
}
return 0;
}
sj3_syoukyo_euc(yomi, kanji, code)
u_char *yomi;
u_char *kanji;
int code;
int
sj3_syoukyo_euc(u_char* yomi, u_char* kanji, int code)
{
int l, flag;
u_char *yp;
@ -904,10 +894,10 @@ int code;
}
return 0;
}
sj3_syoukyo_mb(yomi, kanji, code)
u_char *yomi;
u_char *kanji;
int code;
int
sj3_syoukyo_mb(u_char* yomi, u_char* kanji, int code)
{
#ifndef __sony_news
if (_sys_code == SYS_NOTDEF)
@ -919,8 +909,9 @@ int code;
return sj3_syoukyo(yomi, kanji, code);
}
sj3_getdict(buf)
u_char *buf;
int
sj3_getdict(u_char* buf)
{
if (sj3_tango_syutoku(&client, udicid, buf, MBCODE_SJIS)) {
if (client.fd < 0) {
@ -931,8 +922,10 @@ u_char *buf;
}
return 0;
}
sj3_getdict_euc(buf)
u_char *buf;
int
sj3_getdict_euc(u_char* buf)
{
int l, ll, slen;
@ -969,8 +962,10 @@ u_char *buf;
}
return 0;
}
sj3_getdict_mb(buf)
u_char *buf;
int
sj3_getdict_mb(u_char* buf)
{
#ifndef __sony_news
if (_sys_code == SYS_NOTDEF)
@ -982,8 +977,8 @@ u_char *buf;
return sj3_getdict(buf);
}
sj3_nextdict(buf)
u_char *buf;
int
sj3_nextdict(u_char* buf)
{
if (sj3_tango_jikouho(&client, udicid, buf, MBCODE_SJIS)) {
if (client.fd < 0) {
@ -994,8 +989,10 @@ u_char *buf;
}
return 0;
}
sj3_nextdict_euc(buf)
u_char *buf;
int
sj3_nextdict_euc(u_char* buf)
{
int l, ll, slen;
@ -1032,8 +1029,10 @@ u_char *buf;
}
return 0;
}
sj3_nextdict_mb(buf)
u_char *buf;
int
sj3_nextdict_mb(u_char* buf)
{
#ifndef __sony_news
if (_sys_code == SYS_NOTDEF)
@ -1045,8 +1044,8 @@ u_char *buf;
return sj3_nextdict(buf);
}
sj3_prevdict(buf)
u_char *buf;
int
sj3_prevdict(u_char* buf)
{
if (sj3_tango_maekouho(&client, udicid, buf, MBCODE_SJIS)) {
if (client.fd < 0) {
@ -1057,8 +1056,10 @@ u_char *buf;
}
return 0;
}
sj3_prevdict_euc(buf)
u_char *buf;
int
sj3_prevdict_euc(u_char* buf)
{
int l, ll, slen;
@ -1095,8 +1096,10 @@ u_char *buf;
}
return 0;
}
sj3_prevdict_mb(buf)
u_char *buf;
int
sj3_prevdict_mb(u_char* buf)
{
#ifndef __sony_news
if (_sys_code == SYS_NOTDEF)
@ -1108,7 +1111,8 @@ u_char *buf;
return sj3_prevdict(buf);
}
sj3_lockserv()
int
sj3_lockserv(void)
{
if (sj3_lock_server(&client) == ERROR) {
if (client.fd < 0) {
@ -1119,7 +1123,10 @@ sj3_lockserv()
}
return 0;
}
sj3_unlockserv()
int
sj3_unlockserv(void)
{
if (sj3_unlock_server(&client)) {
if (client.fd < 0) {

View file

@ -31,11 +31,14 @@
* $SonyRCSfile: sj3lib.h,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:03:57 $
*
* $Id$
*/
#ifndef _SJ3LIB_H_
#define _SJ3LIB_H_ 1
#include <sys/types.h>
#define SJ3_NORMAL_END 0
#define SJ3_SERVER_DEAD (1 << 0)
@ -150,3 +153,103 @@ typedef struct douon {
#define SJ3_H_RAVERB 98
#define SJ3_H_WAVERB 99
#define SJ3_H_SINGLE 189
/* moved from include/sj3lowlib.h for function prototypes.
* $SonyRCSfile: sj3lowlib.h,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:59 $
*/
typedef struct sj3_client_env {
int fd;
int serv_dead_flg;
int stdy_size;
short svr_version;
short cli_version;
char default_char[2];
} SJ3_CLIENT_ENV;
#ifndef SJ3_NAME_LENGTH
# define SJ3_NAME_LENGTH 128
#endif
typedef struct sj3_who_struct {
int fd;
char hostname[SJ3_NAME_LENGTH];
char username[SJ3_NAME_LENGTH];
char progname[SJ3_NAME_LENGTH];
} SJ3_WHO_STRUCT;
#define MBCODE_SJIS 1
#define MBCODE_EUC 2
/* level1.c */
void sj3_set_timeout(int timeout);
int sj3_make_connection(SJ3_CLIENT_ENV *client, char *serv, char *user, char *prog);
int sj3_erase_connection(SJ3_CLIENT_ENV *client);
long sj3_open_dictionary(SJ3_CLIENT_ENV *client, char *dictname, char *password);
int sj3_close_dictionary(SJ3_CLIENT_ENV *client, long dicid);
int sj3_open_study_file(SJ3_CLIENT_ENV *client, char *stdyname, char *password);
int sj3_close_study_file(SJ3_CLIENT_ENV *client);
int sj3_get_id_size(SJ3_CLIENT_ENV *client);
int sj3_lock_server(SJ3_CLIENT_ENV *client);
int sj3_unlock_server(SJ3_CLIENT_ENV *client);
int sj3_ikkatu_henkan(SJ3_CLIENT_ENV *client, u_char *src, u_char *dst, int dstsiz, int mb_flag);
int sj3_bunsetu_henkan(SJ3_CLIENT_ENV *client, u_char *yomi, int len, u_char *kanji, int mb_flag);
int sj3_bunsetu_jikouho(SJ3_CLIENT_ENV *client, u_char *kanji, int mode, int mb_flag);
int sj3_bunsetu_maekouho(SJ3_CLIENT_ENV *client, u_char *kanji, int mode, int mb_flag);
int sj3_bunsetu_kouhosuu(SJ3_CLIENT_ENV *client, u_char *yomi, int len, int mb_flag);
int sj3_bunsetu_zenkouho(SJ3_CLIENT_ENV *client, u_char *yomi, int len, SJ3_DOUON *douon, int mb_flag);
int sj3_tango_gakusyuu(SJ3_CLIENT_ENV *client, SJ3_STUDYREC *stdy);
int sj3_bunsetu_gakusyuu(SJ3_CLIENT_ENV *client, u_char *yomi1, u_char *yomi2, SJ3_STUDYREC *stdy, int mb_flag);
int sj3_tango_touroku(SJ3_CLIENT_ENV *client, long dicid, u_char *yomi, u_char *kanji, int code, int mb_flag);
int sj3_tango_sakujo(SJ3_CLIENT_ENV *client, long dicid, u_char *yomi, u_char *kanji, int code, int mb_flag);
int sj3_tango_syutoku(SJ3_CLIENT_ENV *client, int dicid, u_char *buf, int mb_flag);
int sj3_tango_jikouho(SJ3_CLIENT_ENV *client, int dicid, u_char *buf, int mb_flag);
int sj3_tango_maekouho(SJ3_CLIENT_ENV *client, int dicid, u_char *buf, int mb_flag);
int sj3_make_dict_file(SJ3_CLIENT_ENV *client, char *path, int idxlen, int seglen, int segnum);
int sj3_make_study_file(SJ3_CLIENT_ENV *client, char *path, int stynum, int clstep, int cllen);
int sj3_make_directory(SJ3_CLIENT_ENV *client, char *path);
int sj3_access(SJ3_CLIENT_ENV *client, char *path, int mode);
int sj3_who(SJ3_CLIENT_ENV *client, SJ3_WHO_STRUCT *ret, int num);
int sj3_quit(SJ3_CLIENT_ENV *client);
int sj3_kill(SJ3_CLIENT_ENV *client);
int sj3_version(SJ3_CLIENT_ENV *client, char *dst, int dstsiz);
/* sj.c */
int sj3_open(char *host, char *user);
int sj3_open_with_list(char *host, char *user, int dicts_num, char **dicts, int *error_num, int **error_index);
int sj3_close(void);
int sj3_getkan(u_char *yomi, SJ3_BUNSETU *bun, u_char *knj, int knjsiz);
int sj3_getkan_euc(u_char *yomi, SJ3_BUNSETU *bun, u_char *knj, int knjsiz);
int sj3_getkan_mb(u_char *yomi, SJ3_BUNSETU *bun, u_char *knj, int knjsiz);
int sj3_douoncnt(u_char *yomi);
int sj3_douoncnt_euc(u_char *yomi);
int sj3_douoncnt_mb(u_char *yomi);
int sj3_getdouon(u_char *yomi, SJ3_DOUON *dou);
int sj3_getdouon_euc(u_char *yomi, SJ3_DOUON *dou);
int sj3_getdouon_mb(u_char *yomi, SJ3_DOUON *dou);
int sj3_gakusyuu(SJ3_STUDYREC *dcid);
int sj3_gakusyuu2(u_char *yomi1, u_char *yomi2, SJ3_STUDYREC *dcid);
int sj3_gakusyuu2_euc(u_char *yomi1, u_char *yomi2, SJ3_STUDYREC *dcid);
int sj3_gakusyuu2_mb(u_char *yomi1, u_char *yomi2, SJ3_STUDYREC *dcid);
int sj3_touroku(u_char *yomi, u_char *kanji, int code);
int sj3_touroku_euc(u_char *yomi, u_char *kanji, int code);
int sj3_touroku_mb(u_char *yomi, u_char *kanji, int code);
int sj3_syoukyo(u_char *yomi, u_char *kanji, int code);
int sj3_syoukyo_euc(u_char *yomi, u_char *kanji, int code);
int sj3_syoukyo_mb(u_char *yomi, u_char *kanji, int code);
int sj3_getdict(u_char *buf);
int sj3_getdict_euc(u_char *buf);
int sj3_getdict_mb(u_char *buf);
int sj3_nextdict(u_char *buf);
int sj3_nextdict_euc(u_char *buf);
int sj3_nextdict_mb(u_char *buf);
int sj3_prevdict(u_char *buf);
int sj3_prevdict_euc(u_char *buf);
int sj3_prevdict_mb(u_char *buf);
int sj3_lockserv(void);
int sj3_unlockserv(void);
#endif /* _SJ3LIB_H_ */

View file

@ -31,6 +31,8 @@
* $SonyRCSfile: sj3stat.c,v $
* $SonyRevision: 1.2 $
* $SonyDate: 1997/01/23 11:09:41 $
*
* $Id$
*/
#include <stdio.h>
@ -39,11 +41,9 @@
#include "Const.h"
#include "sj3err.h"
#include "sj3lib.h"
#include "sj3lowlib.h"
int main (argc, argv)
int argc;
char **argv;
int
main (int argc, char** argv)
{
SJ3_CLIENT_ENV clnt;
SJ3_WHO_STRUCT who[64];
@ -87,7 +87,7 @@ int main (argc, argv)
for (p = ver; *p; p++) {
while (*p) putc(*p++, stdout);
fprintf (stdout, "%, ");
fprintf (stdout, "%%, ");
}
fprintf (stdout, "%d users.\n", n);