Author: iratqq
Date: Sun Feb 17 20:13:09 2008
New Revision: 5188
Modified:
trunk/uim/sj3.c
Log:
* uim/sj3.c
(uim_sj3_error): Add human readable message.
(uim_sj3_open_error): Reconstruct.
(uim_sj3_close_error): Ditto.
(uim_sj3_touroku_syoukyo_error): Ditto.
(uim_sj3_make_error_pair):
- New function. Add calling uim_notify_fatal().
(uim_sj3_select_error): Use uim_sj3_make_error_pair().
(uim_sj3_getkan): Add message to uim_sj3_make_error().
(uim_sj3_douoncnt): Ditto.
(uim_sj3_getdouon): Ditto.
(uim_sj3_touroku): Ditto.
(uim_sj3_syoukyo): Ditto.
Modified: trunk/uim/sj3.c
==============================================================================
--- trunk/uim/sj3.c (original)
+++ trunk/uim/sj3.c Sun Feb 17 20:13:09 2008
@@ -41,33 +41,46 @@
#include "uim-scm.h"
#include "uim-scm-abbrev.h"
#include "uim-helper.h"
+#include "uim-notify.h"
+#include "gettext.h"
#include "plugin.h"
static int uim_sj3_is_open = 0;
struct uim_sj3_error {
int errno;
- char *error;
+ char *error_sym;
+ char *error_str;
};
static uim_lisp
-uim_sj3_make_error(char *error)
+uim_sj3_make_error_pair(char *sym, char *str)
{
- return CONS(MAKE_SYM("error"), MAKE_SYM(error));
+ char error_str[BUFSIZ];
+
+ snprintf(error_str, sizeof(error_str), "In uim-sj3, %s", str);
+ uim_notify_fatal(error_str);
+ return MAKE_SYM(sym);
+}
+
+static uim_lisp
+uim_sj3_make_error(char *sym, char *str)
+{
+ return CONS(MAKE_SYM("error"), uim_sj3_make_error_pair(sym, str));
}
-#define uim_sj3_server_down_error()
uim_sj3_make_error("*SJ3-SERVER-DOWN-ERROR*")
-#define uim_sj3_undefined_error() uim_sj3_make_error("*SJ3-UNDEFINED-ERROR*")
-#define uim_sj3_internal_error()
uim_sj3_make_error("*SJ3-UIM-INTERNAL-ERROR*")
+#define uim_sj3_server_down_error() uim_sj3_make_error("*SJ3-SERVER-DOWN-ERROR*" ,
"Serverdown.")
+#define uim_sj3_undefined_error()
uim_sj3_make_error("*SJ3-UNDEFINED-ERROR*" , "Undefined error.")
+#define uim_sj3_internal_error()
uim_sj3_make_error("*SJ3-UIM-INTERNAL-ERROR*", "Internal error.")
static uim_lisp
uim_sj3_select_error(int errno, const struct uim_sj3_error *error)
{
uim_lisp ret_ = uim_scm_null();
- while (error->error != NULL) {
+ while (error->error_sym != NULL) {
if (errno & error->errno)
- ret_ = CONS(MAKE_SYM(error->error), ret_);
+ ret_ = CONS(uim_sj3_make_error_pair(error->error_sym,
error->error_str), ret_);
error++;
}
@@ -80,17 +93,17 @@
const static struct uim_sj3_error uim_sj3_open_error[] = {
- { SJ3_NORMAL_END, "*SJ3-NORMAL-END*" },
- { SJ3_SERVER_DEAD, "*SJ3-SERVER-DEAD*" },
- { SJ3_CONNECT_ERROR, "*SJ3-CONNECT-ERROR*" },
- { SJ3_ALREADY_CONNECTED, "*SJ3-ALREADY-CONNECTED*" },
- { SJ3_CANNOT_OPEN_MDICT, "*SJ3-CANNOT-OPEN-MDICT*" },
- { SJ3_CANNOT_OPEN_UDICT, "*SJ3-CANNOT-OPEN-UDICT*" },
- { SJ3_CANNOT_OPEN_STUDY, "*SJ3-CANNOT-OPEN-STUDY*" },
- { SJ3_CANNOT_MAKE_UDIR, "*SJ3-CANNOT-MAKE-UDIR*" },
- { SJ3_CANNOT_MAKE_UDICT, "*SJ3-CANNOT-MAKE-UDICT*" },
- { SJ3_CANNOT_MAKE_STUDY, "*SJ3-CANNOT-MAKE-STUDY*" },
- { -1, NULL }
+ { SJ3_NORMAL_END, "*SJ3-NORMAL-END*" , "Normal end." },
+ { SJ3_SERVER_DEAD, "*SJ3-SERVER-DEAD*" , "Server is
dead." },
+ { SJ3_CONNECT_ERROR, "*SJ3-CONNECT-ERROR*" , "Connect
failed." },
+ { SJ3_ALREADY_CONNECTED, "*SJ3-ALREADY-CONNECTED*", "Already
connected." },
+ { SJ3_CANNOT_OPEN_MDICT, "*SJ3-CANNOT-OPEN-MDICT*", "Cannot open
main dictionary file." },
+ { SJ3_CANNOT_OPEN_UDICT, "*SJ3-CANNOT-OPEN-UDICT*", "Cannot open
user dictionary file." },
+ { SJ3_CANNOT_OPEN_STUDY, "*SJ3-CANNOT-OPEN-STUDY*", "Cannot open
study file." },
+ { SJ3_CANNOT_MAKE_UDIR, "*SJ3-CANNOT-MAKE-UDIR*", "Cannot make
user dictionary directory." },
+ { SJ3_CANNOT_MAKE_UDICT, "*SJ3-CANNOT-MAKE-UDICT*", "Cannot make
user dictionary file." },
+ { SJ3_CANNOT_MAKE_STUDY, "*SJ3-CANNOT-MAKE-STUDY*", "Cannot make
study file." },
+ { -1, NULL, NULL }
};
static uim_lisp
@@ -160,17 +173,17 @@
const static struct uim_sj3_error uim_sj3_close_error[] = {
- { SJ3_NORMAL_END, "*SJ3-NORMAL-END*" },
- { SJ3_SERVER_DEAD, "*SJ3-SERVER-DEAD*" },
- { SJ3_DISCONNECT_ERROR, "*SJ3-DISCONNECT-ERROR*" },
- { SJ3_NOT_CONNECTED, "*SJ3-NOT-CONNECTED*" },
- { SJ3_NOT_OPENED_MDICT, "*SJ3-NOT-OPENED-MDICT*" },
- { SJ3_NOT_OPENED_UDICT, "*SJ3-NOT-OPENED-UDICT*" },
- { SJ3_NOT_OPENED_STUDY, "*SJ3-NOT-OPENED-STUDY*" },
- { SJ3_CLOSE_MDICT_ERROR, "*SJ3-CLOSE-MDICT-ERROR*" },
- { SJ3_CLOSE_UDICT_ERROR, "*SJ3-CLOSE-UDICT-ERROR*" },
- { SJ3_CLOSE_STUDY_ERROR, "*SJ3-CLOSE-STUDY-ERROR*" },
- { 0, NULL }
+ { SJ3_NORMAL_END, "*SJ3-NORMAL-END*" , "Normal end." },
+ { SJ3_SERVER_DEAD, "*SJ3-SERVER-DEAD*" , "Server is
dead." },
+ { SJ3_DISCONNECT_ERROR, "*SJ3-DISCONNECT-ERROR*" , "Server is
disconnected." },
+ { SJ3_NOT_CONNECTED, "*SJ3-NOT-CONNECTED*" , "Server is not
connected." },
+ { SJ3_NOT_OPENED_MDICT, "*SJ3-NOT-OPENED-MDICT*" , "Main dictionary
file is not opened." },
+ { SJ3_NOT_OPENED_UDICT, "*SJ3-NOT-OPENED-UDICT*" , "User dictionary
file is not opened." },
+ { SJ3_NOT_OPENED_STUDY, "*SJ3-NOT-OPENED-STUDY*" , "Study file is
not opened." },
+ { SJ3_CLOSE_MDICT_ERROR, "*SJ3-CLOSE-MDICT-ERROR*", "Main dictionary
file cannot clese." },
+ { SJ3_CLOSE_UDICT_ERROR, "*SJ3-CLOSE-UDICT-ERROR*", "User dictionary
file cannot clese." },
+ { SJ3_CLOSE_STUDY_ERROR, "*SJ3-CLOSE-STUDY-ERROR*", "Study file
cannot clese." },
+ { 0, NULL, NULL }
};
static uim_lisp
@@ -202,7 +215,7 @@
uim_lisp ret_ = uim_scm_f();
if (255 < strlen(yomi))
- return uim_sj3_make_error("*SJ3-YOMI-STRING-TOO-LONG*");
+ return uim_sj3_make_error("*SJ3-YOMI-STRING-TOO-LONG*", "Yomi
string is too long.");
bunsetu_cnt = sj3_getkan_euc((unsigned char *)yomi, bun, (unsigned
char *)kanji, sizeof(kanji));
@@ -210,7 +223,7 @@
return uim_sj3_server_down_error();
if (bun[bunsetu_cnt - 1].destlen == 0) /* too large? */
- return uim_sj3_make_error("*SJ3-TOO-SHORT-BUFFER-SIZE*");
+ return uim_sj3_make_error("*SJ3-TOO-SHORT-BUFFER-SIZE*", "Too
short buffer size.");
if (bunsetu_cnt == 0)
return MAKE_STR("");
@@ -247,7 +260,7 @@
int ret;
if (63 < strlen(yomi))
- return uim_sj3_make_error("*SJ3-YOMI-STRING-TOO-LONG*");
+ return uim_sj3_make_error("*SJ3-YOMI-STRING-TOO-LONG*", "Yomi
string is too long.");
ret = sj3_douoncnt_euc((unsigned char *)yomi);
if (ret == -1)
@@ -266,7 +279,7 @@
uim_lisp ret_ = uim_scm_f();
if (255 < strlen(yomi))
- return uim_sj3_make_error("*SJ3-YOMI-STRING-TOO-LONG*");
+ return uim_sj3_make_error("*SJ3-YOMI-STRING-TOO-LONG*", "Yomi
string is too long.");
douon_cnt = sj3_getdouon_euc((unsigned char *)yomi, douon);
if (douon_cnt == -1)
@@ -361,18 +374,19 @@
};
const static struct uim_sj3_error uim_sj3_touroku_syoukyo_error[] = {
- { SJ3_DICT_ERROR, "*SJ3-DICT-ERROR*" },
- { SJ3_DICT_LOCKED, "*SJ3-DICT-LOCKED*" },
- { SJ3_BAD_YOMI_STR, "*SJ3-BAD-YOMI-STR*" },
- { SJ3_BAD_KANJI_STR, "*SJ3-BAD-KANJI-STR*" },
- { SJ3_BAD_HINSI_CODE, "*SJ3-BAD-HINSI-CODE*" },
- { SJ3_WORD_EXIST, "*SJ3-WORD-EXIST*" },
- { SJ3_DOUON_FULL, "*SJ3-DOUON-FULL*" },
- { SJ3_DICT_FULL, "*SJ3-DICT-FULL*" },
- { SJ3_INDEX_FULL, "*SJ3-INDEX-FULL*" },
- { SJ3_TOUROKU_FAILED, "*SJ3-TOUROKU-FAILED*" },
- { SJ3_WORD_NOT_EXIST, "*SJ3-WORD-NOT-EXIST*" },
- { SJ3_SYOUKYO_FAILED, "*SJ3-SYOUKYO-FAILED*" }
+ { SJ3_DICT_ERROR, "*SJ3-DICT-ERROR*" , "Dictionary error." },
+ { SJ3_DICT_LOCKED, "*SJ3-DICT-LOCKED*" , "Dictionary is
locked." },
+ { SJ3_BAD_YOMI_STR, "*SJ3-BAD-YOMI-STR*" , "Invalid yomi string."},
+ { SJ3_BAD_KANJI_STR, "*SJ3-BAD-KANJI-STR*" , "Invalid kanji
string." },
+ { SJ3_BAD_HINSI_CODE, "*SJ3-BAD-HINSI-CODE*", "Invalid hinsi code." },
+ { SJ3_WORD_EXIST, "*SJ3-WORD-EXIST*" , "Word exist." },
+ { SJ3_DOUON_FULL, "*SJ3-DOUON-FULL*" , "Douon is full." },
+ { SJ3_DICT_FULL, "*SJ3-DICT-FULL*" , "Dictionary is full." },
+ { SJ3_INDEX_FULL, "*SJ3-INDEX-FULL*" , "Index is full." },
+ { SJ3_TOUROKU_FAILED, "*SJ3-TOUROKU-FAILED*", "Touroku failed." },
+ { SJ3_WORD_NOT_EXIST, "*SJ3-WORD-NOT-EXIST*", "Word does not exist." },
+ { SJ3_SYOUKYO_FAILED, "*SJ3-SYOUKYO-FAILED*", "Syoukyo is failed." },
+ { 0, NULL, NULL }
};
static uim_lisp
@@ -385,7 +399,7 @@
int ret;
if (31 < strlen(yomi) || 31 < strlen(kanji))
- return uim_sj3_make_error("*SJ3-KANJI-STRING-TOO-LONG*");
+ return uim_sj3_make_error("*SJ3-KANJI-STRING-TOO-LONG*", "Kanji
string is too long.");
while (1) {
if (uim_sj3_hinsi[i].name == NULL)
@@ -416,7 +430,7 @@
int ret;
if (31 < strlen(yomi) || 31 < strlen(kanji))
- return uim_sj3_make_error("*SJ3-KANJI-STRING-TOO-LONG*");
+ return uim_sj3_make_error("*SJ3-KANJI-STRING-TOO-LONG*", "Kanji
string is too long.");
while (1) {
if (uim_sj3_hinsi[i].name == NULL)