/* */ /* WNN7 CLIENT LIBRARY--SOFTWARE LICENSE TERMS AND CONDITIONS Wnn7 Client Library : (C) Copyright OMRON Corporation. 1995,1998,2000,2001 all rights reserved. (C) Copyright OMRON Software Co., Ltd. 1995,1998,2000,2001 all rights reserved. Wnn Software : (C) Copyright Kyoto University Research Institute for Mathematical Sciences 1987, 1988, 1989, 1990, 1991, 1992, 1993 (C) Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1993 (C) Copyright ASCTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992, 1993 Preamble These Wnn7 Client Library--Software License Terms and Conditions (the "License Agreement") shall state the conditions under which you are permitted to copy, distribute or modify the software which can be used to create Wnn7 Client Library (the "Wnn7 Client Library"). The License Agreement can be freely copied and distributed verbatim, however, you shall NOT add, delete or change anything on the License Agreement. OMRON Corporation and OMRON Software Co., Ltd. (collectively referred to as "OMRON") jointly developed the Wnn7 Software (development code name is FI-Wnn), based on the Wnn Software. Starting from November, 1st, 1998, OMRON publishes the source code of the Wnn7 Client Library, and OMRON permits anyone to copy, distribute or change the Wnn7 Client Library under the License Agreement. Wnn7 Client Library is based on the original version of Wnn developed by Kyoto University Research Institute for Mathematical Sciences (KURIMS), OMRON Corporation and ASTEC Inc. Article 1. Definition. "Source Code" means the embodiment of the computer code, readable and understandable by a programmer of ordinary skills. It includes related source code level system documentation, comments and procedural code. "Object File" means a file, in substantially binary form, which is directly executable by a computer after linking applicable files. "Library" means a file, composed of several Object Files, which is directly executable by a computer after linking applicable files. "Software" means a set of Source Code including information on its use. "Wnn7 Client Library" the computer program, originally supplied by OMRON, which can be used to create Wnn7 Client Library. "Executable Module" means a file, created after linking Object Files or Library, which is directly executable by a computer. "User" means anyone who uses the Wnn7 Client Library under the License Agreement. Article 2. Copyright 2.1 OMRON Corporation and OMRON Software Co., Ltd. jointly own the Wnn7 Client Library, including, without limitation, its copyright. 2.2 Following words followed by the above copyright notices appear in all supporting documentation of software based on Wnn7 Client Library: This software is based on the original version of Wnn7 Client Library developed by OMRON Corporation and OMRON Software Co., Ltd. and also based on the original version of Wnn developed by Kyoto University Research Institute for Mathematical Sciences (KURIMS), OMRON Corporation and ASTEC Inc. Article 3. Grant 3.1 A User is permitted to make and distribute verbatim copies of the Wnn7 Client Library, including verbatim of copies of the License Agreement, under the License Agreement. 3.2 A User is permitted to modify the Wnn7 Client Library to create Software ("Modified Software") under the License Agreement. A User is also permitted to make or distribute copies of Modified Software, including verbatim copies of the License Agreement with the following information. Upon modifying the Wnn7 Client Library, a User MUST insert comments--stating the name of the User, the reason for the modifications, the date of the modifications, additional terms and conditions on the part of the modifications if there is any, and potential risks of using the Modified Software if they are known--right after the end of the License Agreement (or the last comment, if comments are inserted already). 3.3 A User is permitted to create Library or Executable Modules by modifying the Wnn7 Client Library in whole or in part under the License Agreement. A User is also permitted to make or distribute copies of Library or Executable Modules with verbatim copies of the License Agreement under the License Agreement. Upon modifying the Wnn7 Client Library for creating Library or Executable Modules, except for porting a computer, a User MUST add a text file to a package of the Wnn7 Client Library, providing information on the name of the User, the reason for the modifications, the date of the modifications, additional terms and conditions on the part of the modifications if there is any, and potential risks associated with using the modified Wnn7 Client Library, Library or Executable Modules if they are known. 3.4 A User is permitted to incorporate the Wnn7 Client Library in whole or in part into another Software, although its license terms and conditions may be different from the License Agreement, if such incorporation or use associated with the incorporation does NOT violate the License Agreement. Article 4. Warranty THE WNN7 CLIENT LIBRARY IS PROVIDED BY OMRON ON AN "AS IS" BAISIS. OMRON EXPRESSLY DISLCIAMS ANY AND ALL WRRANTIES, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, IN CONNECTION WITH THE WNN7 CLIENT LIBRARY OR THE USE OR OTHER DEALING IN THE WNN7 CLIENT LIBRARY. IN NO EVENT SHALL OMRON BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND WHATSOEVER IN CONNECTION WITH THE WNN7 CLIENT LIBRARY OR THE USE OR OTHER DEALING IN THE WNN7 CLIENT LIBRARY. *************************************************************************** Wnn7 Client Library : (C) Copyright OMRON Corporation. 1995,1998,2001 all rights reserved. (C) Copyright OMRON Software Co., Ltd. 1995,1998,2001 all rights reserved. Wnn Software : (C) Copyright Kyoto University Research Institute for Mathematical Sciences 1987, 1988, 1989, 1990, 1991, 1992, 1993 (C) Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1993 (C) Copyright ASCTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992, 1993 *************************************************************************** Comments on Modifications: */ /* * New FI-Wnn function call for both of server and library * Binary FI dictionary common routine */ #if defined(JSERVER) || defined(JS) #ifdef WRITE_CHECK #define BDIC_WRITE_CHECK #endif #endif /* defined(JSERVER) || defined(JS) */ #ifdef UX386 #include #else #include #endif #ifndef JS #include #include #include "commonhd.h" #include "jslib.h" #include "jh.h" #endif #include "jdata.h" #include "wnn_os.h" #include "wnn_string.h" #include "fi_jdata.h" #ifdef JS static #else extern #endif /* JS */ int output_header_fi_jt(FILE *ofpter, struct FI_JT *jt1), output_header_fi_hjt(FILE *ofpter, struct FI_HJT *hjt1); #ifndef JS extern int getint(), getnstr(), input_file_uniq(), create_file_header(); extern void new_pwd(); extern # ifdef BDIC_WRITE_CHECK int # else void #endif /* BDIC_WRITE_CHECK */ putint(), put_n_str(), output_file_uniq(), put_n_EU_str(), putnull(); #endif /* Not JS */ #ifndef JS /*:::DOC_START * * Function Name: input_header_fi_jt * Description : FI関係辞書のヘッダ部を読み込む * Parameter : * ifpter : (In) ファイルポインタ * jt1 : (Out) FI関係辞書へのポインタ * * Return value : 0==SUCCESS, -1==ERROR * * Revision history: * *:::DOC_END */ int input_header_fi_jt(ifpter, jt1) FILE *ifpter; struct FI_JT *jt1; { int i; if( getint(&jt1->syurui , ifpter) == -1 || getint(&jt1->maxcomment, ifpter) == -1 || getnstr(ifpter, WNN_PASSWD_LEN, jt1->hpasswd) == -1 || getnstr(ifpter, 1, &jt1->maxjisho) == -1) return(-1); /* 接続定義Wnn辞書 f_uniq 配列の読み込み */ if(jt1->maxjisho) { if((jt1->jisho_uniq = (struct wnn_file_uniq *) malloc(jt1->maxjisho * sizeof(struct wnn_file_uniq))) == NULL) return(-1); for(i = 0; i < jt1->maxjisho; i++) { if(input_file_uniq(&((jt1->jisho_uniq)[i]), ifpter) == -1) return(-1); } } return(0); } /* End of input_header_fi_jt */ /*:::DOC_START * * Function Name: input_header_fi_hjt * Description : FI関係頻度のヘッダ部を読み込む * Parameter : * ifpter : (In) ファイルポインタ * jt1 : (Out) FI関係頻度へのポインタ * * Return value : 0==SUCCESS, -1==ERROR * * Revision history: * *:::DOC_END */ int input_header_fi_hjt(ifpter, hjt1) FILE *ifpter; struct FI_HJT *hjt1; { if( input_file_uniq(&hjt1->fi_dic_uniq, ifpter) == -1 || getint(&hjt1->maxcomment, ifpter) == -1 || getnstr(ifpter, 1, &hjt1->maxjisho) == -1) return(-1); return(0); } /* End of input_header_fi_hjt */ #endif /* Not JS */ /*:::DOC_START * * Function Name: output_header_fi_jt * Description : FI関係辞書のヘッダ部を書き込む * Parameter : * ofpter : (Out) ファイルポインタ * jt1 : (In) FI関係辞書へのポインタ * * Return value : 0==SUCCESS, -1==ERROR * * Revision history: * *:::DOC_END */ #ifdef JS static #endif int output_header_fi_jt(ofpter, jt1) FILE *ofpter; struct FI_JT *jt1; { int i; #ifdef BDIC_WRITE_CHECK if ((putint(ofpter, jt1->syurui) == -1) || (putint(ofpter, jt1->maxcomment) == -1) || (put_n_str(ofpter, jt1->hpasswd, WNN_PASSWD_LEN) == -1) || (put_n_str(ofpter, &jt1->maxjisho, 1) == -1)) return(-1); /* 接続定義Wnn辞書 f_uniq 配列の書き込み */ for(i = 0; i < jt1->maxjisho; i++) { if(output_file_uniq(&((jt1->jisho_uniq)[i]), ofpter) == -1) return(-1); } #else /* BDIC_WRITE_CHECK */ putint(ofpter, jt1->syurui); putint(ofpter, jt1->maxcomment); put_n_str(ofpter, jt1->hpasswd, WNN_PASSWD_LEN); put_n_str(ofpter, &jt1->maxjisho, 1); /* 接続定義Wnn辞書 f_uniq 配列の書き込み */ for(i = 0; i < jt1->maxjisho; i++) output_file_uniq(&((jt1->jisho_uniq)[i]), ofpter); #endif /* BDIC_WRITE_CHECK */ return(0); } /* End of output_header_fi_jt */ /*:::DOC_START * * Function Name: output_header_fi_hjt * Description : FI関係頻度のヘッダ部を書き込む * Parameter : * ofpter : (Out) ファイルポインタ * hjt1 : (In) FI関係頻度へのポインタ * * Return value : 0==SUCCESS, -1==ERROR * * Revision history: * *:::DOC_END */ #ifdef JS static #endif int output_header_fi_hjt(ofpter, hjt1) FILE *ofpter; struct FI_HJT *hjt1; { #ifdef BDIC_WRITE_CHECK if ((output_file_uniq(&hjt1->fi_dic_uniq, ofpter) == -1) || (putint(ofpter, hjt1->maxcomment) == -1) || (put_n_str(ofpter, &hjt1->maxjisho, 1) == -1)) return(-1); #else /* BDIC_WRITE_CHECK */ output_file_uniq(&hjt1->fi_dic_uniq, ofpter); putint(ofpter, hjt1->maxcomment); put_n_str(ofpter, &hjt1->maxjisho, 1); #endif /* BDIC_WRITE_CHECK */ return(0); } /* End of output_header_fi_hjt */ /*:::DOC_START * * Function Name: create_fi_index_table * Description : FIインデックステーブルを作成する * Parameter : * fp : (Out) ファイルポインタ * njisho : (In) 対応FI関係辞書の接続定義Wnn辞書数 * primary : (In) 接続定義Wnn辞書の primary index table 数の * 配列へのポインタ * * Return value : 0==SUCCESS, -1==ERROR * * Revision history: * *:::DOC_END */ static int create_fi_index_table(fp, njisho, primary) FILE *fp; unsigned char njisho; int *primary; { int i; for(i = 0; i < njisho; i++) { #ifdef BDIC_WRITE_CHECK if((putint(fp, primary[i]) == -1) || (putnull(fp, primary[i]) == -1) || (putint(fp, 0) == -1)) return(-1); #else /* BDIC_WRITE_CHECK */ putint(fp, primary[i]); putnull(fp, primary[i]); putint(fp, 0); #endif /* BDIC_WRITE_CHECK */ } return(0); } /* End of create_fi_index_table */ /*:::DOC_START * * Function Name: create_fi_hindo_file * Description : FI関係頻度を作成するサブルーチン関数 * Parameter : * funiq : (In) 対応FI関係辞書の file uniq orig * fn : (In) FI関係頻度ファイル名 * comm : (In) FI関係頻度コメント * passwd : (In) FI関係頻度パスワード * njisho : (In) 対応FI関係辞書の接続定義Wnn辞書数 * primary : (In) 接続定義Wnn辞書 primary index table 数の * 配列へのポインタ * * Return value : 0==SUCCESS, -1==ERROR * * Revision history: * *:::DOC_END */ #ifdef JS static #endif int create_fi_hindo_file(funiq, fn, comm, passwd, njisho, primary) struct wnn_file_uniq *funiq; char *fn; w_char *comm; char *passwd; /* Not encoded */ unsigned char njisho; int *primary; { FILE *fp; struct FI_HJT hjt; char epasswd[WNN_PASSWD_LEN]; w_char tmp[1]; tmp[0] = 0; if(comm == NULL) comm = tmp; memcpy(&(hjt.fi_dic_uniq), funiq, WNN_F_UNIQ_LEN); hjt.maxcomment = wnn_Strlen(comm); hjt.maxjisho = njisho; if((fp = fopen(fn, "w+")) == NULL){ return(-1); } if(passwd){ new_pwd(passwd, epasswd); } else{ memset(epasswd, 0, WNN_PASSWD_LEN); } if(create_file_header(fp, WNN_FT_FI_HINDO_FILE, epasswd) == -1) { fclose(fp); return(-1); } #ifdef BDIC_WRITE_CHECK if ((output_header_fi_hjt(fp, &hjt) == -1) || (put_n_EU_str(fp, comm, hjt.maxcomment) == -1) || (create_fi_index_table(fp, njisho, primary) == -1)) { fclose(fp); return(-1); } #else /* BDIC_WRITE_CHECK */ output_header_fi_hjt(fp, &hjt); put_n_EU_str(fp, comm, hjt.maxcomment); create_fi_index_table(fp, njisho, primary); #endif /* BDIC_WRITE_CHECK */ #ifdef BSD42 fchmod(fileno(fp), 0644); fclose(fp); #else /* SYSV */ fclose(fp); chmod(fn, 0644); #endif /* BSD42 */ return(0); } /*:::DOC_START * * Function Name: create_null_fi_dic * Description : FI関係辞書を作成するサブルーチン関数 * Parameter : * fn : (In) FI関係辞書ファイル名 * comm : (In) FI関係辞書コメント * passwd : (In) FI関係辞書パスワード * hpasswd : (In) FI関係頻度パスワード * which : (In) FI関係辞書タイプ(WNN_FI_USER_DICT) * njisho : (In) 接続定義Wnn辞書数 * duniq : (In) 接続定義Wnn辞書 file uniq orig の配列への * ポインタ * primary : (In) 接続定義Wnn辞書 primary index table 数の * 配列へのポインタ * */ #ifdef JS static #endif int create_null_fi_dic(fn, comm, passwd, hpasswd, which, njisho, duniq, primary) char *fn; w_char *comm; char *passwd, *hpasswd; /* not encoded passwd */ int which; unsigned char njisho; struct wnn_file_uniq *duniq; int *primary; { FILE *fp; struct FI_JT jt; char epasswd[WNN_PASSWD_LEN]; extern void new_pwd(); if(hpasswd){ new_pwd(hpasswd, jt.hpasswd); } else{ memset(jt.hpasswd, 0, WNN_PASSWD_LEN); } jt.syurui = which; if(comm) jt.maxcomment = wnn_Strlen(comm); else jt.maxcomment = 0; jt.maxjisho = njisho; jt.jisho_uniq = duniq; if((fp = fopen(fn, "w+")) == NULL){ return(-1); } if(passwd){ new_pwd(passwd, epasswd); } else{ memset(epasswd, 0, WNN_PASSWD_LEN); } if(create_file_header(fp, WNN_FT_FI_DICT_FILE, epasswd) == -1) { fclose(fp); return(-1); } #ifdef BDIC_WRITE_CHECK if ((output_header_fi_jt(fp, &jt) == -1) || (put_n_EU_str(fp, comm, jt.maxcomment) == -1) || (create_fi_index_table(fp, njisho, primary) == -1)) { fclose(fp); return(-1); } #else /* BDIC_WRITE_CHECK */ output_header_fi_jt(fp, &jt); put_n_EU_str(fp, comm, jt.maxcomment); create_fi_index_table(fp, njisho, primary); #endif /* BDIC_WRITE_CHECK */ #ifdef BSD42 fchmod(fileno(fp), 0644); fclose(fp); #else /* SYSV */ fclose(fp); chmod(fn, 0644); #endif /* BSD42 */ return(0); } /* End of create_null_fi_dic */