Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ henkanowari(3X) — HP-UX 7.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

open_kana_kan(3X)

J_UD_open(3X)

HENKAN(3X)

NAME

Henkan, JiKouho, Kakutei, HenkanOwari, SetUserDict − KANA to KANJI conversion routines

SYNOPSIS

#include <jlib.h>

Bun *Henkan (ed, string, len, buf, size, mode)
int ed;
unsigned char *string, *buf;
int len, size, mode;

int JiKouho (ed, pb, nb)
int ed;
Bun *pb;
int nb;

int Kakutei (ed, pb, nb, nk)
int ed;
Bun *pb;
int nb, nk;

int HenkanOwari (ed, pb)
int ed;
Bun *pb;

int SetUserDict (ed, dp, mode)
int ed;
UserDict dp;
int mode;

DESCRIPTION

Ed is an environment descriptor obtained from a open_kana_kan call. 

Henkan performs KANA to KANJI conversion for string. String is an array of characters terminated by a null character.  Len is the length of the first BUNSETSU in bytes.  If a positive value is assigned to len, henkan takes its value as the length of the first BUNSETSU.  Otherwise, it is ignored.  Henkan puts the resultant string (an array of characters terminated by a null character) into buf and returns a pointer to the Bun structure.  Size is the size of buf in bytes.  Mode is a flag having one of the following values:

JIDOU enable automatic KANA to KANJI conversion. 

IKKATSU disable automatic KANA to KANJI conversion (default). 

where default is the value used when neither value is specified. 

The Bun structure declared in the <jlib.h> header file includes the following fields:

int nbunsetsu; /* number of BUNSETSU */
int nvalid; /* number of BUNSETSU with validity */
Bunsetsu **bunsetsu; /* BUNSETSU table */

where nvalid is effective when mode is JIDOU. 

The Bunsetsu structure includes the following fields:

unsigned char *yomi; /* YOMI (an array of characters terminated by a null character)*/
Kouho kouho; /* KOUHO associated with YOMI */
Kouhogun *kouhogun; /* a pointer to Kouhogun structure */

where the Kouho structure includes the following field:

unsigned char *hyouki; /* HYOUKI (an array of characters terminated by a null character) */

and kouhogun is set to a NULL pointer by henkan. 

JiKouho is used to get all KOUHOs for any BUNSETSU in the given sentence associated with pb. Pb is a pointer to a Bun structure obtained from a Henkan call.  Nb is an index for the BUNSETSU table in the Bun structure.  JiKouho sets a pointer to the Kouhogun structure in the Bun structure.  The structure declared in the <jlib.h> header file includes the following fields:

int nkouho; /* number of KOUHO */
Kouho **kouho; /* KOUHO table */

The KOUHO before the last one and the last one are spelled by HIRAGANA and KATAKANA respectively. 

Henkan and JiKouho allocate space themselves.  After HenkanOwari is performed, this space is made available for further allocation.  The argument to HenkanOwari is a pointer to a Bun structure obtained from a Henkan call. 

Kakutei is used to update HINDO information after Kakutei is performed.  The KOUHO appears with higher priority in further conversion.  Pb is a pointer to a Bun structure.  Nb is an index for the BUNSETSU table in the Bun structure and Nk is an index for the KOUHO table in the Kouhogun structure. 

SetUserDict is used to enable or disable consulting of a user dictionary in addition to a system dictionary during the KANA to KANJI conversion.  The last enabled dictionary is consulted first.  Dp is a dictionary pointer returned by J_UD_open. Mode specifies the action to be taken, and must be one of the following:

UDoff disable consulting of a user dictionary

UDon enable user dictionary consulting (default)

where default indicates which value is used when neither value is specified. 

DIAGNOSTICS

Henkan returns a NULL pointer upon conversion failure.  jlib_errno is set to indicate the error:

[JNOSPC] Not enough space to return the result. 

[JNOBUF] No more space to put the resultant string into buf. 

[JBADSIZ] Size is equal to or less than 0. 

[JINVAL] String is too long. 

[JNOTRESPOND] A server does not respond. 

[JBADED] Ed is not a valid environment descriptor. 

JiKouho returns 0  upon successful completion. Otherwise, -1 is returned and jlib_errno is set to indicate the error:

[JNOSPC] Not enough space in memory to return the result. 

[JINVAL] Nb is invalid. 

[JNOTRESPOND] A server does not respond. 

[JBADED] Ed is not a valid environment descriptor. 

Kakutei returns 0 upon successful completion. Otherwise, -1 is returned and jlib_errno is set to indicate the error:

[JNOTRESPOND] A server does not respond. 

[JINVAL] Nb or nk is invalid. 

[JBADED] Ed is not a valid environment descriptor. 

HenkanOwari returns 0 upon successful completion. Otherwise, -1 is returned and jlib_errno is set to indicate the error. 

[JNOTRESPOND] A server does not respond. 

[JBADED] Ed is not a valid environment descriptor. 

SetUserDict returns 0 upon successful completion. Otherwise, -1 is returned and jlib_errno is set to indicate the error:

[JBADED] Ed is not a valid environment descriptor. 

[JUDBADDP] Dp is not a valid dictionary pointer. 

[JNOTRESPOND] A server does not respond. 

EXAMPLES

The following example shows typical use for the above routines. After KANA to KANJI conversion is performed, one of the following actions is taken for each BUNSETSU:

• If the BUNSETSU matchs what you want, Kakutei is invoked. 

• Otherwise, JiKouho is invoked to get all KOUHOs, and Kakutei is invoked for the KOUHO matching what you want. 

HenkanOwari is invoked with the return value of the previous Henkan call. 

for (;;) {/* top level */
/* get sentences */

/* conversion (KANA to KANJI) */
if ((p = Henkan (ed, string, 0, buf, BUFSIZ, IKKATSU)) == NULL)
error();
 /* accept result or not */
n = p->nbunsetsu;/* number of BUNSETSU */
/* for each BUNSETSU */
for (i = 0; i < n; i++) {
cp = p->bunsetsu[i];
if ( /* acceptable */ )
Kakutei (ed, p, i, 0);/* accept */
else {
/* get alternatives */
if (JiKouho (ed, p, i) == -1)
error();
/* select one of them */
/* assume it to be k-th entry */
Kakutei (ed, p, i, k-1);
}
} /*  end of for (i = 0; i < n; i++)  */
 HenkanOwari (ed, p);
 } /*  end of for (;;)  */

SEE ALSO

open_kana_kan(3X), J_UD_open(3X)

Hewlett-Packard Company  —  HP-UX Release 7.0: Sept 1989

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026