Import sj3-patches-20040916

Signed-off-by: Masanori Ogino <mogino@acm.org>
This commit is contained in:
Masanori Ogino 2023-11-27 11:34:52 +09:00
commit a76f53bc03
78 changed files with 3433 additions and 3852 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (c) 1997 Sony Corporation * 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 * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the

View file

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

115
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_ */

224
include/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_ */

124
include/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_ */

88
include/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_ */

42
include/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

@ -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 $ * $SonyRCSfile: sj_const.h,v $
* $SonyRevision: 1.1 $ * $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:01:01 $ * $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" #include "sj_euc.h"
@ -50,11 +50,10 @@
#define UNDER 4 #define UNDER 4
#ifndef FALSE
#define FALSE 0 #define FALSE 0
#define TRUE -1 #define TRUE -1
#endif /* FALSE */
@ -196,4 +195,4 @@
#define NumWordBuf ((NumKetaLength+3)/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 sstrncpy Jsstrncpy
#define memset Jmemset
#define mvmemd Jmvmemd #define mvmemd Jmvmemd

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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

View file

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

View file

@ -31,36 +31,31 @@
* $SonyRCSfile: mkkouho.c,v $ * $SonyRCSfile: mkkouho.c,v $
* $SonyRevision: 1.1 $ * $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:04 $ * $SonyDate: 1994/06/03 08:02:04 $
*
* $Id$
*/ */
#include "sj_euc.h" #include "sj_euc.h"
#include "sj_kcnv.h" #include "sj_kcnv.h"
#include "sj_hinsi.h" #include "sj_hinsi.h"
#include "sj_suuji.h" #include "sj_suuji.h"
#include "sj_dict.h" #include "sj_dict.h"
#include "kanakan.h"
static void getkhtbl(CLREC* clrec);
Uchar *skipkstr(); static void cl_kanji(JREC* jrec, CLREC* clrec);
Void setkouho(), setwdnum(), get_askknj(); static u_char* makekan(u_char* s, u_char* d, int flg);
Int seldict(), codesize(); static int diffknj(JREC* jrec, u_char* ptr, int num);
static void cl_numcmn(JREC* jrec, CLREC* clrec);
void
Static Void getkhtbl(), cl_kanji(); mkkouho(void)
Static Int diffknj();
Static Void cl_numcmn();
Static Uchar *makekan();
Void mkkouho()
{ {
CLREC *clrec; CLREC *clrec;
Int keeplen; int keeplen;
khcount = nkhcount = 0; khcount = nkhcount = 0;
@ -79,19 +74,15 @@ Void mkkouho()
} }
static void
Static Void getkhtbl(clrec) getkhtbl(CLREC* clrec)
CLREC *clrec;
{ {
JREC *jrec; JREC *jrec;
jrec = clrec -> jnode; jrec = clrec -> jnode;
switch (jrec -> class) { switch (jrec -> class) {
case C_DICT: case C_DICT:
cl_kanji(jrec, clrec); cl_kanji(jrec, clrec);
break; break;
@ -114,20 +105,17 @@ CLREC *clrec;
case C_MINASI: case C_MINASI:
case C_WAKACHI: case C_WAKACHI:
setkouho(clrec, (TypeDicOfs)0, 0); setkouho(clrec, (TypeDicOfs)0, 0);
break; break;
} }
} }
static void
Static Void cl_kanji(jrec, clrec) cl_kanji(JREC* jrec, CLREC* clrec)
JREC *jrec;
CLREC *clrec;
{ {
Uchar *ptr; u_char *ptr;
Int kcount = khcount; int kcount = khcount;
if (seldict(jrec -> dicid)) { if (seldict(jrec -> dicid)) {
@ -156,21 +144,15 @@ CLREC *clrec;
} }
u_char*
Uchar *makekan_none(s, d, flg) makekan_none(u_char* s, u_char* d, int flg)
Uchar *s;
Uchar *d;
Int flg;
{ {
return d; return d;
} }
u_char*
Uchar *makekan_1byte(s, d, flg) makekan_1byte(u_char* s, u_char* d, int flg)
Uchar *s;
Uchar *d;
Int flg;
{ {
if ((*s & KanjiModeMask) == ZenHiraAssyuku) if ((*s & KanjiModeMask) == ZenHiraAssyuku)
*d++ = 0x10 | (*s & KnjAssyukuMask); *d++ = 0x10 | (*s & KnjAssyukuMask);
@ -182,22 +164,16 @@ Int flg;
} }
u_char*
Uchar *makekan_knj(s, d, flg) makekan_knj(u_char* s, u_char* d, int flg)
Uchar *s;
Uchar *d;
Int flg;
{ {
return makekan(askknj[*s & KnjAssyukuMask], d, flg); return makekan(askknj[*s & KnjAssyukuMask], d, flg);
} }
u_char*
Uchar *makekan_ofs(s, d, flg) makekan_ofs(u_char* s, u_char* d, int flg)
Uchar *s;
Uchar *d;
Int flg;
{ {
return makekan(dicbuf + ((*s & KanjiCodeMask) << 8) + *(s + 1), return makekan(dicbuf + ((*s & KanjiCodeMask) << 8) + *(s + 1),
@ -205,14 +181,10 @@ Int flg;
} }
u_char*
Uchar *makekan_norm(s, d, flg) makekan_norm(u_char* s, u_char* d, int flg)
Uchar *s;
Uchar *d;
Int flg;
{ {
Reg1 Int i, csize; u_char c;
Reg1 Uchar c;
if (*s != 0) { if (*s != 0) {
c = s[1]; c = s[1];
@ -229,13 +201,10 @@ Int flg;
} }
u_char*
Uchar *makekan_ascii(s, d, flg) makekan_ascii(u_char* s, u_char* d, int flg)
Uchar *s;
Uchar *d;
Int flg;
{ {
Reg1 Uchar c; u_char c;
c = s[1]; c = s[1];
if (c & 0x80) if (c & 0x80)
@ -248,13 +217,10 @@ Int flg;
} }
static u_char*
Static Uchar *makekan(s, d, flg) makekan(u_char* s, u_char* d, int flg)
Uchar *s;
Uchar *d;
Int flg;
{ {
Reg1 Int csize; int csize;
for ( ; ; ) { for ( ; ; ) {
csize = codesize(*s); csize = codesize(*s);
@ -314,26 +280,19 @@ Int flg;
} }
#define PEND 2 #define PEND 2
#define QEND 1 #define QEND 1
Static Int sameknj(p, plen, q, qlen) static int
Reg1 Uchar *p; sameknj(u_char* p, int plen, u_char* q, int qlen)
Uchar plen;
Reg2 Uchar *q;
Uchar qlen;
{ {
Int i; int i;
Int j; int j;
Int endf = 0; int endf = 0;
Int brkf; int brkf;
extern Int euc_codesize();
do { do {
if ((i = euc_codesize(*p)) != euc_codesize(*q)) return FALSE; if ((i = euc_codesize(*p)) != euc_codesize(*q)) return FALSE;
brkf = 0; brkf = 0;
for (j = 0; j < i; j++) { for (j = 0; j < i; j++) {
if (p[j] != q[j] ) { if (p[j] != q[j] ) {
@ -343,37 +302,30 @@ Uchar qlen;
} }
if (brkf) break; if (brkf) break;
if (p[i] == KanjiStrEnd) endf += PEND; if (p[i] == KanjiStrEnd) endf += PEND;
if (q[i] == KanjiStrEnd) endf += QEND; if (q[i] == KanjiStrEnd) endf += QEND;
p += i; p += i;
q += i; q += i;
} while (!endf); } while (!endf);
switch (endf) { switch (endf) {
case (PEND | QEND): case (PEND | QEND):
if (plen == qlen) return TRUE; if (plen == qlen) return TRUE;
break; break;
case PEND: case PEND:
i = plen; i = plen;
plen = qlen; plen = qlen;
qlen = i; qlen = i;
p = q; p = q;
case QEND: case QEND:
if (p[euc_codesize(*p)] != KanjiStrEnd) break; if (p[euc_codesize(*p)] != KanjiStrEnd) break;
if ((*p & KanjiModeMask) != 0x10 ) break; if ((*p & KanjiModeMask) != 0x10 ) break;
if (qlen != plen - (*p & KanjiCodeMask) - 1) break; if (qlen != plen - (*p & KanjiCodeMask) - 1) break;
return TRUE; return TRUE;
default: default:
if (q[euc_codesize(*q)] != KanjiStrEnd) break; if (q[euc_codesize(*q)] != KanjiStrEnd) break;
if (p[euc_codesize(*p)] != KanjiStrEnd) break; if (p[euc_codesize(*p)] != KanjiStrEnd) break;
@ -390,72 +342,52 @@ Uchar qlen;
#undef QEND #undef QEND
static int
Static Int diffknj(jrec, ptr, num) diffknj(JREC* jrec, u_char* ptr, int num)
JREC *jrec;
Uchar *ptr;
Int num;
{ {
KHREC *kptr; KHREC *kptr;
JREC *jptr; JREC *jptr;
Int i; int i;
Uchar kbuf1[MaxWdKanjiLen]; u_char kbuf1[MaxWdKanjiLen];
Uchar kbuf2[MaxWdKanjiLen]; u_char kbuf2[MaxWdKanjiLen];
if (jrec -> hinsi == TANKANJI) return TRUE; if (jrec -> hinsi == TANKANJI) return TRUE;
makekan(ptr, kbuf1, TRUE); makekan(ptr, kbuf1, TRUE);
for (i = 0, kptr = kouhotbl ; i < num ; i++, kptr++) { for (i = 0, kptr = kouhotbl ; i < num ; i++, kptr++) {
if ((jptr = kptr -> clrec -> jnode) == jrec) if ((jptr = kptr -> clrec -> jnode) == jrec)
return FALSE; return FALSE;
if (jptr -> hinsi == TANKANJI) continue; if (jptr -> hinsi == TANKANJI) continue;
if (jptr -> class != jrec -> class) continue; if (jptr -> class != jrec -> class) continue;
if (jptr -> dicid != jrec -> dicid) continue; if (jptr -> dicid != jrec -> dicid) continue;
if (jptr -> jseg != jrec -> jseg) continue; if (jptr -> jseg != jrec -> jseg) continue;
if (jptr -> sttofs != jrec -> sttofs) continue; if (jptr -> sttofs != jrec -> sttofs) continue;
if (jptr -> stbofs != jrec -> stbofs) continue; if (jptr -> stbofs != jrec -> stbofs) continue;
makekan(dicbuf + kptr -> offs, kbuf2, TRUE); makekan(dicbuf + kptr -> offs, kbuf2, TRUE);
if (sameknj(kbuf1, jrec -> jlen, kbuf2, jptr -> jlen)) if (sameknj(kbuf1, jrec -> jlen, kbuf2, jptr -> jlen))
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
static int
chrck_numtbl(u_short flg, u_short cond)
Static Int chrck_numtbl(flg, cond)
Ushort flg;
Ushort cond;
{ {
Ushort must; u_short must;
if (cond = SelNumCond(cond)) { if ((cond = SelNumCond(cond)) != 0) {
if (must = (cond & SelNumMust)) { if ((must = (cond & SelNumMust)) != 0) {
if ((flg & must) != must) return FALSE; if ((flg & must) != must) return FALSE;
cond &= ~must; cond &= ~must;
} }
@ -466,13 +398,12 @@ Ushort cond;
} }
int
Int sel_sjmode(jrec) sel_sjmode(JREC* jrec)
JREC *jrec;
{ {
Ushort i; u_short i;
Ushort TFar *p; u_short *p;
Ushort TFar *q; u_short *q;
switch (jrec -> class) { switch (jrec -> class) {
case C_N_ARABIA: case C_N_ARABIA:
@ -504,15 +435,13 @@ JREC *jrec;
} }
static void
Static Void cl_numcmn(jrec, clrec) cl_numcmn(JREC* jrec, CLREC* clrec)
JREC *jrec;
CLREC *clrec;
{ {
Uchar *p; u_char *p;
Int i; int i;
Ushort j; u_short j;
Ushort TFar *tbl; u_short *tbl;
p = cnvstart; p = cnvstart;
@ -556,7 +485,7 @@ CLREC *clrec;
if (!chrck_numtbl(jrec -> flags, j)) continue; 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 $ * $SonyRCSfile: mknumber.c,v $
* $SonyRevision: 1.1 $ * $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:02:05 $ * $SonyDate: 1994/06/03 08:02:05 $
*
* $Id$
*/ */
#include <sys/types.h>
#include "sj_kcnv.h" #include "sj_kcnv.h"
#include "sj_yomi.h" #include "sj_yomi.h"
#include "sj_suuji.h" #include "sj_suuji.h"
#include "kanakan.h"
static int
Void setwdnum(); word2char(u_short wd, u_char* tbl, int keta, int flg)
Int setucnum();
Static Int word2char(wd, tbl, keta, flg)
Ushort wd;
Uchar TFar *tbl;
Int keta;
Int flg;
{ {
Int mask; int mask;
Int num; int num;
Uchar TFar *src; u_char* src;
for (mask = 0x1000 ; mask ; mask >>= 4) { for (mask = 0x1000 ; mask ; mask >>= 4) {
@ -90,16 +82,13 @@ Int flg;
} }
static void
Static Void words2num(wd, tbl, flgc) words2num(u_short* wd, u_char* tbl, int flgc)
Ushort *wd;
Uchar TFar *tbl;
Int flgc;
{ {
Int i; int i;
Int keta; int keta;
Int flg; int flg;
Uchar *kp = kanjitmp; u_char *kp = kanjitmp;
if (flgc) { if (flgc) {
keta = NumKetaLength - 1; keta = NumKetaLength - 1;
@ -124,149 +113,122 @@ Int flgc;
} }
void
Void num_type00(s1, s2, jrec) num_type00(u_char* s1, u_char* s2, JREC* jrec)
Uchar *s1;
Uchar *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); words2num(num, Num1tbl, FALSE);
} }
void
Void num_type01(s1, s2, jrec) num_type01(u_char* s1, u_char* s2, JREC* jrec)
Uchar *s1;
Uchar *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); words2num(num, Num1tbl, FALSE);
} }
void
Void num_type02(s1, s2, jrec) num_type02(u_char* s1, u_char* s2, JREC* jrec)
Uchar *s1;
Uchar *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); words2num(num, Num1tbl, TRUE);
} }
void
Void num_type03(s1, s2, jrec) num_type03(u_char* s1, u_char* s2, JREC* jrec)
Uchar *s1;
Uchar *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); words2num(num, Num2tbl, FALSE);
} }
void
Void num_type04(s1, s2, jrec) num_type04(u_char* s1, u_char* s2, JREC* jrec)
Uchar *s1;
Uchar *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); words2num(num, Num2tbl, FALSE);
} }
void
Void num_type05(s1, s2, jrec) num_type05(u_char* s1, u_char* s2, JREC* jrec)
Uchar *s1;
Uchar *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); words2num(num, Num2tbl, TRUE);
} }
void
Void num_type06(s1, s2, jrec) num_type06(u_char* s1, u_char* s2, JREC* jrec)
Uchar *s1;
Uchar *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); words2num(num, Num3tbl, FALSE);
} }
void
Void num_type07(s1, s2, jrec) num_type07(u_char* s1, u_char* s2, JREC* jrec)
Uchar *s1;
Uchar *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); words2num(num, Num3tbl, FALSE);
} }
static void
Static Void kan_num(wd, tbl1, tbl2) kan_num(u_short* wd, u_char* tbl1, u_char* tbl2)
Ushort *wd;
Uchar TFar *tbl1;
Uchar TFar *tbl2;
{ {
Int ii; int ii;
Ushort tmp; u_short tmp;
Int mask; int mask;
Int num; int num;
Int flg; int flg;
Uchar TFar *kurai1; u_char* kurai1;
Uchar TFar *kurai2; u_char* kurai2;
Uchar TFar *src; u_char* src;
Uchar *keep = kanjitmp; u_char* keep = kanjitmp;
kurai2 = Num6tbl - 2; kurai2 = Num6tbl - 2;
@ -325,45 +287,36 @@ Uchar TFar *tbl2;
} }
void
Void num_type08(s1, s2, jrec) num_type08(u_char* s1, u_char* s2, JREC* jrec)
Uchar *s1;
Uchar *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); kan_num(num, Num2tbl, Num4tbl);
} }
void
Void num_type09(s1, s2, jrec) num_type09(u_char* s1, u_char* s2, JREC* jrec)
Uchar *s1;
Uchar *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); kan_num(num, Num3tbl, Num5tbl);
} }
void
Void num_type10(s1, s2, jrec) num_type10(u_char* s1, u_char* s2, JREC* jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
{ {
Int i; int i;
for (i = jrec -> numlen ; i > 0 ; i--) { for (i = jrec -> numlen ; i > 0 ; i--) {
@ -379,14 +332,11 @@ JREC *jrec;
} }
void
Void num_type11(s1, s2, jrec) num_type11(u_char* s1, u_char* s2, JREC* jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
{ {
Int i; int i;
Int j; int j;
i = j = jrec -> numlen; i = j = jrec -> numlen;
@ -412,14 +362,11 @@ JREC *jrec;
} }
void
Void num_type12(s1, s2, jrec) num_type12(u_char* s1, u_char* s2, JREC* jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
{ {
Int i; int i;
Int j; int j;
for (i = jrec -> numlen ; i > 0 ; i--) { for (i = jrec -> numlen ; i > 0 ; i--) {
@ -433,26 +380,23 @@ JREC *jrec;
} }
static void
Static Void num_kurai(p, len, tbl) num_kurai(u_char* p, int len, u_char* tbl)
Uchar *p;
Int len;
Uchar TFar *tbl;
{ {
Int i; int i;
Int j; int j;
Uchar tmp; u_char tmp;
for (i = 0 ; i < len ; i++) { for (i = 0 ; i < len ; i++) {
tmp = *p++; tmp = *p++;
*kanjitmp++ = tbl[j = ((tmp & 0x0f) - _Num0) * 2]; *kanjitmp++ = tbl[j = ((tmp & 0x0f) - _Num0) * 2];
*kanjitmp++ = tbl[j + 1]; *kanjitmp++ = tbl[j + 1];
if (j = ((tmp >> 4) & 3)) { if ((j = ((tmp >> 4) & 3)) != 0) {
*kanjitmp++ = Num4tbl[j = (3 - j) * 2]; *kanjitmp++ = Num4tbl[j = (3 - j) * 2];
*kanjitmp++ = Num4tbl[j + 1]; *kanjitmp++ = Num4tbl[j + 1];
} }
if (j = ((tmp >> 6) & 3)) { if ((j = ((tmp >> 6) & 3)) != 0) {
*kanjitmp++ = Num6tbl[j = (3 - j) * 2]; *kanjitmp++ = Num6tbl[j = (3 - j) * 2];
*kanjitmp++ = Num6tbl[j + 1]; *kanjitmp++ = Num6tbl[j + 1];
} }
@ -460,34 +404,28 @@ Uchar TFar *tbl;
} }
void
Void num_type13(s1, s2, jrec) num_type13(u_char* s1, u_char* s2, JREC* jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
{ {
Uchar num[NumKetaLength]; u_char num[NumKetaLength];
Int len; int len;
len = setucnum(s1, (Int)jrec -> numlen, num); len = setucnum(s1, (int)jrec -> numlen, num);
num_kurai(num, len, Num1tbl); num_kurai(num, len, Num1tbl);
} }
void
Void num_type14(s1, s2, jrec) num_type14(u_char* s1, u_char* s2, JREC* jrec)
Uchar *s1;
Uchar *s2;
JREC *jrec;
{ {
Uchar num[NumKetaLength]; u_char num[NumKetaLength];
Int len; int len;
len = setucnum(s1, (Int)jrec -> numlen, num); len = setucnum(s1, (int)jrec -> numlen, num);
num_kurai(num, len, Num2tbl); num_kurai(num, len, Num2tbl);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -31,47 +31,51 @@
* $SonyRCSfile: funckey.c,v $ * $SonyRCSfile: funckey.c,v $
* $SonyRevision: 1.3 $ * $SonyRevision: 1.3 $
* $SonyDate: 1997/01/23 11:20:53 $ * $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 "wchar16.h"
#include "sj2.h" #include "sj2.h"
#include "key.h" #include "key.h"
#include "Paths.h" #include "Paths.h"
#include "sj3.h"
struct cvtkey { struct cvtkey {
char *key_word; char *key_word;
char key_seq[SEQLEN]; char key_seq[SEQLEN];
} cvtkeytbl[] = { } cvtkeytbl[] = {
"F1", "", { "F1", "" },
"F2", "", { "F2", "" },
"F3", "", { "F3", "" },
"F4", "", { "F4", "" },
"F5", "", { "F5", "" },
"F6", "", { "F6", "" },
"F7", "", { "F7", "" },
"F8", "", { "F8", "" },
"F9", "", { "F9", "" },
"F10", "", { "F10", "" },
"F11", "", { "F11", "" },
"F12", "", { "F12", "" },
"F13", "", { "F13", "" },
"F14", "", { "F14", "" },
"F15", "", { "F15", "" },
"F16", "", { "F16", "" },
"F17", "", { "F17", "" },
"F18", "", { "F18", "" },
"F19", "", { "F19", "" },
"F20", "", { "F20", "" },
"Select", "", { "Select", "" },
"Kanji", "", { "Kanji", "" },
"Cancel", "", { "Cancel", "" },
"Execute", "", { "Execute", "" },
"Up", "", { "Up", "" },
"Down", "", { "Down", "" },
"Right", "", { "Right", "" },
"Left", "", { "Left", "" },
NULL, NULL { NULL, "" }
}; };
extern struct wcvtkey wcvtkeytbl[]; extern struct wcvtkey wcvtkeytbl[];
@ -108,13 +112,14 @@ int comstrvalue[KEY_OTHER] = {
KEY_OTHER KEY_OTHER
}; };
mk_cvtkey(term)
char *term; void
mk_cvtkey(char* term)
{ {
register char *p; char *p;
char line[MAXLINE], rstr[16], *getkey2(); char line[MAXLINE], rstr[16];
FILE *fd, *fopen(); FILE *fd;
char cvtkey_file[LONGLENGTH], *strchr(); char cvtkey_file[LONGLENGTH];
struct cvtkey *ckeyp; struct cvtkey *ckeyp;
struct wcvtkey *wckeyp; struct wcvtkey *wckeyp;
@ -153,11 +158,10 @@ char *term;
} }
char * char *
getkey2(istr, ostr) getkey2(char* istr, char* ostr)
char *istr, *ostr;
{ {
register char *p; char *p;
register int i; int i;
while (*istr == ' ' || *istr == '\t') while (*istr == ' ' || *istr == '\t')
istr++; istr++;
@ -178,16 +182,19 @@ char *istr, *ostr;
return(NULL); return(NULL);
} }
clear_ukeys ()
void
clear_ukeys (void)
{ {
Unumber = 0; Unumber = 0;
} }
set_func (word)
struct wordent word[]; void
set_func (struct wordent word[])
{ {
register int i, num; int i, num;
register wchar16_t *p, *s; wchar16_t *p, *s;
struct wcvtkey *ckeyp; struct wcvtkey *ckeyp;
if (Unumber >= UKEYNUM) 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) if (wslen (s) > SEQLEN)
return (-1); return (-1);
@ -247,22 +255,26 @@ wchar16_t *s, *p;
return (i); return (i);
} }
clear_key ()
void
clear_key (void)
{ {
clear_commkeys (); clear_commkeys ();
clear_etckeys (); clear_etckeys ();
clear_ukeys (); clear_ukeys ();
} }
clear_commkeys ()
void
clear_commkeys (void)
{ {
comnumber = 0; comnumber = 0;
} }
eval_key (s) int
wchar16_t *s; eval_key (wchar16_t* s)
{ {
register wchar16_t c; wchar16_t c;
c = *s; c = *s;
@ -282,15 +294,18 @@ wchar16_t *s;
return (-1); return (-1);
} }
clear_etckeys ()
void
clear_etckeys (void)
{ {
u_etckeys = 0; u_etckeys = 0;
} }
set_etckeys (word)
struct wordent word[]; int
set_etckeys (struct wordent word[])
{ {
register int i; int i;
if (u_etckeys >= ETCKEYS) if (u_etckeys >= ETCKEYS)
return (1); return (1);
@ -315,15 +330,13 @@ struct wordent word[];
} }
wchar16_t
parse_command (s, count) parse_command (wchar16_t* s, int* count)
register wchar16_t *s;
register int *count;
{ {
extern wchar16_t pars_seq[]; extern wchar16_t pars_seq[];
extern int pars_n; extern int pars_n;
register int i, j; int i, j;
register wchar16_t c; wchar16_t c;
c = *s; c = *s;
for (i = 0; i < comnumber ; i ++) { for (i = 0; i < comnumber ; i ++) {

217
sj3/sj3.c
View file

@ -44,9 +44,18 @@
#if defined(__NetBSD__) #if defined(__NetBSD__)
#define LACKOF_SETLOCALE #define LACKOF_SETLOCALE
#endif #endif
#if defined(__FreeBSD__)
#include <sys/ioctl_compat.h>
#endif
#include <curses.h> #include <curses.h>
#endif #endif
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
#include "select.h" #include "select.h"
#include "common.h" #include "common.h"
#ifdef SVR4 #ifdef SVR4
@ -55,13 +64,12 @@
#include <netdb.h> #include <netdb.h>
#endif #endif
#include <locale.h> #include <locale.h>
#include "sj3.h"
#ifndef _PATH_UTMP #ifndef _PATH_UTMP
#define _PATH_UTMP "/etc/utmp" #define _PATH_UTMP "/etc/utmp"
#endif #endif
int fail ();
#ifdef SVR4 #ifdef SVR4
#define killpg(pid, sig) kill(-(pid),(sig)) #define killpg(pid, sig) kill(-(pid),(sig))
@ -125,8 +133,6 @@ struct ttysize Ttysize;
#endif #endif
int master; int master;
int slave; int slave;
int exitprocess ();
int onwinch ();
#ifdef SYSV_TERMIOS #ifdef SYSV_TERMIOS
struct termios b; struct termios b;
@ -153,11 +159,9 @@ int Pid_shell;
int current_locale; int current_locale;
int done();
main (argc, argv) int
int argc; main (int argc, char** argv)
char **argv;
{ {
init (argv); init (argv);
get_ttymode (); get_ttymode ();
@ -174,7 +178,8 @@ char **argv;
done (); done ();
} }
makecore () void
makecore (void)
{ {
chdir ("/tmp"); chdir ("/tmp");
setgid (getgid ()); setgid (getgid ());
@ -183,11 +188,10 @@ makecore ()
} }
void
init (argv) init (char** argv)
char **argv;
{ {
char *cp, *strrchr (); char *cp;
(void) signal (SIGTERM, (void (*)())done); (void) signal (SIGTERM, (void (*)())done);
(void) signal (SIGWINCH, SIG_IGN); (void) signal (SIGWINCH, SIG_IGN);
@ -216,11 +220,11 @@ char **argv;
} }
void
init_env() init_env(void)
{ {
register char *uname, *hp, *tname; char *uname, *hp, *tname;
register int i; int i;
struct passwd *pwd, *getpwnam(), *getpwuid(); struct passwd *pwd, *getpwnam(), *getpwuid();
char *getlogin(), *getenv(); char *getlogin(), *getenv();
@ -263,16 +267,13 @@ init_env()
} }
void
parsearg (argc, argv) parsearg (int argc, char** argv)
register int argc;
register char **argv;
{ {
register int ap; int ap;
register char c; char c;
register int sp; int sp;
register char **shella; char **shella;
char *getenv();
shella = shellargs; shella = shellargs;
ap = 1; ap = 1;
@ -346,8 +347,8 @@ register char **argv;
} }
void
usage() usage(void)
{ {
aprintf ("Usage: %s [-option ...]\n\r", progname); aprintf ("Usage: %s [-option ...]\n\r", progname);
aprintf ("\t-option\n\r"); aprintf ("\t-option\n\r");
@ -367,8 +368,8 @@ usage()
} }
void
sjinit () sjinit (void)
{ {
getfixtty (); getfixtty ();
setshellname (); setshellname ();
@ -380,11 +381,11 @@ sjinit ()
} }
void
setshellname () setshellname (void)
{ {
register char *s; char *s;
char *namep, *strrchr (), *getenv(); char *namep;
if (shellprog[0] == '\0') { if (shellprog[0] == '\0') {
s = getenv ("SHELL"); s = getenv ("SHELL");
@ -412,8 +413,8 @@ setshellname ()
} }
void
getfixtty () getfixtty (void)
{ {
getmaster (); getmaster ();
fixtty (); fixtty ();
@ -421,8 +422,8 @@ getfixtty ()
} }
void
get_ttymode () get_ttymode (void)
{ {
#ifdef SYSV_TERMIOS #ifdef SYSV_TERMIOS
ioctl (0, TCGETS, (char *)&b); ioctl (0, TCGETS, (char *)&b);
@ -453,8 +454,8 @@ get_ttymode ()
} }
void
getmaster () getmaster (void)
{ {
#ifdef SVR4 #ifdef SVR4
struct stat stb; struct stat stb;
@ -520,11 +521,16 @@ getmaster ()
#endif #endif
} }
set_jmode (mode)
register int mode; void
#ifdef __sony_news
set_jmode (int mode)
#else
set_jmode (void)
#endif
{ {
#ifdef __sony_news #ifdef __sony_news
register int term_mode; int term_mode;
term_mode = mode & KM_KANJI; term_mode = mode & KM_KANJI;
if (term_mode == KM_JIS) { if (term_mode == KM_JIS) {
@ -583,8 +589,8 @@ register int mode;
} }
void
fixtty () fixtty (void)
{ {
#ifdef SYSV_TERMIOS #ifdef SYSV_TERMIOS
struct termios sbuf; struct termios sbuf;
@ -640,17 +646,19 @@ fixtty ()
#include <grp.h> #include <grp.h>
#endif #endif
setdev ()
void
setdev (void)
{ {
char *cp, *ttyname (); char *cp;
#ifdef BSD43 #ifdef BSD43
struct group *ttygrp; struct group *ttygrp;
#endif #endif
register Conversion *cv; Conversion *cv;
cv = current_conversion; cv = current_conversion;
if (cp = ttyname (2)) if ((cp = ttyname (2)) != NULL)
strcpy (tty_name, cp); strcpy (tty_name, cp);
else else
*tty_name = '\0'; *tty_name = '\0';
@ -659,7 +667,7 @@ setdev ()
slave_name[strlen ("/dev/")] = 't'; slave_name[strlen ("/dev/")] = 't';
#endif #endif
#ifdef BSD43 #ifdef BSD43
if (ttygrp = getgrnam ("tty")) if ((ttygrp = getgrnam ("tty")) != NULL)
chown(slave_name, getuid(), ttygrp->gr_gid); chown(slave_name, getuid(), ttygrp->gr_gid);
else else
chown(slave_name, getuid(), getgid()); chown(slave_name, getuid(), getgid());
@ -673,12 +681,12 @@ setdev ()
#endif #endif
#ifdef SYSV_TERMIOS #ifdef SYSV_TERMIOS
if (ioctl(0, TIOCGWINSZ, &Ttysize) == 0) { if (ioctl(0, TIOCGWINSZ, &Ttysize) == 0)
#else #else
if (ioctl(0, TIOCGSIZE, &Ttysize) == 0) { if (ioctl(0, TIOCGSIZE, &Ttysize) == 0)
#endif #endif
{
if (!status_line) if (!status_line)
--Ttysize.ts_lines; --Ttysize.ts_lines;
if (Ttysize.ts_lines < 1) { if (Ttysize.ts_lines < 1) {
@ -730,10 +738,10 @@ setdev ()
} }
static char shellbuf[128]; static char shellbuf[128];
forkshell () void
forkshell (void)
{ {
#ifdef SVR4 #ifdef SVR4
struct sigaction action; struct sigaction action;
@ -767,15 +775,16 @@ forkshell ()
#endif #endif
} }
sj3_setenv (ename, eval, buf)
char *ename, *eval, *buf; void
sj3_setenv (char* ename, char* eval, char* buf)
{ {
register char *cp, *dp; char *cp, *dp;
register char **ep = environ; char **ep = environ;
while (dp = *ep++) { while ((dp = *ep++) != NULL) {
for (cp = ename; *cp == *dp && *cp; cp++, dp++) for (cp = ename; *cp == *dp && *cp; cp++, dp++)
continue; continue;
if (*cp == 0 && (*dp == '=' || *dp == 0)) { if (*cp == 0 && (*dp == '=' || *dp == 0)) {
@ -787,8 +796,8 @@ sj3_setenv (ename, eval, buf)
} }
void
shellprocess () shellprocess (void)
{ {
int t, f; int t, f;
#ifdef SYSV_TERMIOS #ifdef SYSV_TERMIOS
@ -830,12 +839,11 @@ shellprocess ()
#endif /* SYSV_UTMP */ #endif /* SYSV_UTMP */
#else /* SYSV_TERMIOS */ #else /* SYSV_TERMIOS */
struct utmp Utmp; struct utmp Utmp;
register char *p; char *p;
/* /*
* Remove warning. * Remove warning.
* Patched by Hidekazu Kuroki(hidekazu@cs.titech.ac.jp) 1996/8/10 * Patched by Hidekazu Kuroki(hidekazu@cs.titech.ac.jp) 1996/8/10
*/ */
char *ttyname (), *strrchr ();
#define SCPYN(a, b) strncpy(a, b, sizeof(a)) #define SCPYN(a, b) strncpy(a, b, sizeof(a))
if ((p = ttyname (0)) == NULL) if ((p = ttyname (0)) == NULL)
@ -905,8 +913,8 @@ shellprocess ()
} }
void
getslave () getslave (void)
{ {
#ifdef SVR4 #ifdef SVR4
grantpt(master); grantpt(master);
@ -956,9 +964,8 @@ getslave ()
} }
void
execcmd (cmd, ap) execcmd (char* cmd, char** ap)
char *cmd, **ap;
{ {
int c; int c;
char *getenv (); char *getenv ();
@ -967,7 +974,7 @@ char *cmd, **ap;
path = getenv ("PATH"); path = getenv ("PATH");
cp = fullcmd; cp = fullcmd;
while (c = *path++) { while ((c = *path++) != 0) {
if (c == ':') { if (c == ':') {
*cp++ = '/'; *cp++ = '/';
*cp = '\0'; *cp = '\0';
@ -995,16 +1002,16 @@ char *cmd, **ap;
} }
void
fail () fail (void)
{ {
(void) kill (0, SIGTERM); (void) kill (0, SIGTERM);
done (); done ();
} }
void
done () done (void)
{ {
(void) signal (SIGWINCH, SIG_IGN); (void) signal (SIGWINCH, SIG_IGN);
@ -1013,7 +1020,9 @@ done ()
done2 (); done2 ();
} }
done2 ()
void
done2 (void)
{ {
chown (slave_name, 0, 0); chown (slave_name, 0, 0);
chmod (slave_name, 0666); chmod (slave_name, 0666);
@ -1037,15 +1046,17 @@ done2 ()
done3 (); done3 ();
} }
done3 ()
void
done3 (void)
{ {
aprintf ("\r\nexit %s.\r\n", progname); aprintf ("\r\nexit %s.\r\n", progname);
exit (0); exit (0);
} }
void
exitprocess () exitprocess (void)
{ {
#ifdef SVR4 #ifdef SVR4
siginfo_t info; siginfo_t info;
@ -1056,14 +1067,13 @@ exitprocess ()
return; return;
if (info.si_code == CLD_STOPPED) if (info.si_code == CLD_STOPPED)
#else #else
union wait status; int pid, status;
int pid;
/* /*
* Remove warning. * Remove warning.
* Patched by Hidekazu Kuroki(hidekazu@cs.titech.ac.jp) 1996/8/10 * 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)) if (WIFSTOPPED (status))
#endif #endif
suspend(); suspend();
@ -1072,8 +1082,8 @@ exitprocess ()
} }
void
suspend () suspend (void)
{ {
#ifdef SIGTYPE_VOID #ifdef SIGTYPE_VOID
void (*old_sigtstp) (); void (*old_sigtstp) ();
@ -1155,7 +1165,8 @@ cont:
} }
#ifdef SVR4 #ifdef SVR4
clearutmpentry() void
clearutmpentry(void)
{ {
struct utmpx *up; struct utmpx *up;
#ifdef SVR4 #ifdef SVR4
@ -1195,7 +1206,8 @@ clearutmpentry()
} }
#else /* SVR4 */ #else /* SVR4 */
#ifdef SYSV_UTMP #ifdef SYSV_UTMP
clearutmpentry () void
clearutmpentry (void)
{ {
struct utmp Utmp; struct utmp Utmp;
@ -1214,7 +1226,8 @@ clearutmpentry ()
endutent(); endutent();
} }
#else /* SYSV_UTMP */ #else /* SYSV_UTMP */
clearutmpentry () void
clearutmpentry (void)
{ {
int f; int f;
struct utmp Utmp; struct utmp Utmp;
@ -1234,20 +1247,21 @@ clearutmpentry ()
#endif /* SVR4 */ #endif /* SVR4 */
void
onwinch () onwinch (void)
{ {
int ttypgrp; int ttypgrp;
register Conversion *cv; Conversion *cv;
cv = current_conversion; cv = current_conversion;
(void) signal (SIGWINCH, SIG_IGN); (void) signal (SIGWINCH, SIG_IGN);
#ifdef SYSV_TERMIOS #ifdef SYSV_TERMIOS
if (ioctl (0, TIOCGWINSZ, &Ttysize) == 0) { if (ioctl (0, TIOCGWINSZ, &Ttysize) == 0)
#else /* SYSV_TERMIOS */ #else /* SYSV_TERMIOS */
if (ioctl (0, TIOCGSIZE, &Ttysize) == 0) { if (ioctl (0, TIOCGSIZE, &Ttysize) == 0)
#endif /* SYSV_TERMIOS */ #endif /* SYSV_TERMIOS */
{
if (!status_line) { if (!status_line) {
clear_guide_line (); clear_guide_line ();
--Ttysize.ts_lines; --Ttysize.ts_lines;
@ -1280,7 +1294,9 @@ onwinch ()
(void) signal (SIGWINCH, (void (*)())onwinch); (void) signal (SIGWINCH, (void (*)())onwinch);
} }
SetRegion ()
void
SetRegion (void)
{ {
set_tty_size (); set_tty_size ();
@ -1288,7 +1304,9 @@ SetRegion ()
RegionSet (1, Ttysize.ts_lines); RegionSet (1, Ttysize.ts_lines);
} }
set_tty_size ()
void
set_tty_size (void)
{ {
#ifdef SYSV_TERMIOS #ifdef SYSV_TERMIOS
@ -1298,11 +1316,12 @@ set_tty_size ()
#endif /* SYSV_TERMIOS */ #endif /* SYSV_TERMIOS */
} }
setsjserv(hname)
char *hname; void
setsjserv(char* hname)
{ {
register char *p; char *p;
register int i; int i;
char *sbuf; char *sbuf;
if (hname == NULL || *hname == '\0') if (hname == NULL || *hname == '\0')
@ -1324,9 +1343,9 @@ char *hname;
cur_serv = serv_list[0]; cur_serv = serv_list[0];
} }
char * char *
chmyhname(hname) chmyhname(char* hname)
char *hname;
{ {
if (hname != NULL) { if (hname != NULL) {
if (strcmp(my_hname, hname) == 0 || if (strcmp(my_hname, hname) == 0 ||

View file

@ -53,6 +53,10 @@
#include <curses.h> #include <curses.h>
#endif #endif
#if defined(__FreeBSD__)
#include <sys/ioctl_compat.h>
#endif
#include <errno.h> #include <errno.h>
#include <sys/file.h> #include <sys/file.h>
#include "sj2.h" #include "sj2.h"

View file

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

View file

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

View file

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

View file

@ -31,11 +31,14 @@
* $SonyRCSfile: sj3lib.h,v $ * $SonyRCSfile: sj3lib.h,v $
* $SonyRevision: 1.1 $ * $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:03:57 $ * $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_NORMAL_END 0
#define SJ3_SERVER_DEAD (1 << 0) #define SJ3_SERVER_DEAD (1 << 0)
@ -150,3 +153,103 @@ typedef struct douon {
#define SJ3_H_RAVERB 98 #define SJ3_H_RAVERB 98
#define SJ3_H_WAVERB 99 #define SJ3_H_WAVERB 99
#define SJ3_H_SINGLE 189 #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 $ * $SonyRCSfile: sj3stat.c,v $
* $SonyRevision: 1.2 $ * $SonyRevision: 1.2 $
* $SonyDate: 1997/01/23 11:09:41 $ * $SonyDate: 1997/01/23 11:09:41 $
*
* $Id$
*/ */
#include <stdio.h> #include <stdio.h>
@ -39,11 +41,9 @@
#include "Const.h" #include "Const.h"
#include "sj3err.h" #include "sj3err.h"
#include "sj3lib.h" #include "sj3lib.h"
#include "sj3lowlib.h"
int main (argc, argv) int
int argc; main (int argc, char** argv)
char **argv;
{ {
SJ3_CLIENT_ENV clnt; SJ3_CLIENT_ENV clnt;
SJ3_WHO_STRUCT who[64]; SJ3_WHO_STRUCT who[64];
@ -87,7 +87,7 @@ int main (argc, argv)
for (p = ver; *p; p++) { for (p = ver; *p; p++) {
while (*p) putc(*p++, stdout); while (*p) putc(*p++, stdout);
fprintf (stdout, "%, "); fprintf (stdout, "%%, ");
} }
fprintf (stdout, "%d users.\n", n); fprintf (stdout, "%d users.\n", n);