");
} else if (!strcmp(tag, "RUBY")) {
*dst++ = '(';
} else if (!strcmp(tag, "HL")) {
dst = conv_hyperlink(dst, &p, itemno, genjump);
} else if (!strcmp(tag, "CMT")) {
byte *q;
/*
* まで読み捨てる
*/
if ((q = strstr(p, "")) != NULL)
p = q + 6;
} else {
/*
* 上記以外のタグは読み捨てる
* ただし未知のタグはログに記録
*/
if (strcmp(tag, "SO") &&
strcmp(tag, "SC") &&
strcmp(tag, "OBJ") &&
strcmp(tag, "DSR") &&
strncmp(tag, "FONT ", 5)) {
write_log("本文に未知のタグがあります\n");
write_log(" TAG: %s>\n", tag);
write_log(" KEY: %s\n", srchkey);
write_log(" LINE: %s\n", srctop);
}
}
} else if (*p & 0x80) {
/*
* 2バイト漢字
*/
*dst++ = *p++;
*dst++ = *p++;
} else if (gset == 5 && *p >= 'A') {
/*
* G5セットでは通常文字もSmall Capitalにする
*/
dst = addstr(dst, gstr(gset, *p++));
} else {
/*
* 通常の1バイト文字
*/
*dst++ = *p++;
}
}
*dst = '\0';
return OK;
}
/*
* 見出し文字列のタグ除去、外字変換を行う
*/
int
conv_title(byte *dst, byte *src)
{
byte *p;
static byte cdot[9] = "";
if (!*cdot) {
/*
* 最初の1回だけcdotの準備
*/
strcpy(cdot, gstr(99, 0xa5));
}
p = src;
while (*p) {
if (*p == 0xa5) {
/*
* 1バイト中点
* cdot(外字セットG99の0xa5)に変換する
*/
dst = addstr(dst, cdot);
p++;
} else if (*p == '#' && p[3] == '#') {
/*
* #nn#: 外字またはエスケープ表記
* (見出しの外字はすべてG99セット)
*/
dst = addstr(dst, gstr(99, hexval(p+1)));
p += 4;
} else if (*p == '<') {
/*
* タグはすべて読み捨てる
* 〜, 〜,
* 〜, 〜がある
*/
p = skipch(p, '>');
} else {
*dst++ = *p++;
}
}
*dst = '\0';
return OK;
}
/*
* 用例本体のタグ除去、外字変換を行う
*/
int
conv_example(byte *dst, byte *src)
{
int gset;
byte *p, tag[MAX_WORD];
gset = -1;
p = src;
while (*p) {
if (*p == 0xa5) {
/*
* 用例中の1バイト中点は
* 2バイト中点に変換する
*/
dst = addstr(dst, "・");
p++;
} else if (*p == '#' && p[3] == '#') {
/*
* #nn#: 外字またはエスケープ表記
*/
dst = addstr(dst, gstr(gset, hexval(p+1)));
p += 4;
} else if (*p == '<') {
/*
* 外字以外のタグはすべて読み捨てる
*/
p = getupto(p+1, tag, '>') + 1;
if (*tag == 'G') {
if (tag[1] == '9')
gset = 99;
else
gset = tag[1] - '0';
}
} else {
*dst++ = *p++;
}
}
*dst = '\0';
return OK;
}
/*
* 項目内ジャンプデータファイルを生成する
*/
int
generate_quickjump_file(void)
{
int newidiom, pscount, idcount, lines;
long lpos, base, pc, prevpc;
byte *p;
byte itemno[MAX_WORD], key[MAX_WORD];
byte name[MAX_WORD], tmp[MAX_WORD];
byte linebuf[MAX_LINE], buf[MAX_LINE];
FILE *mainfp, *qjfp;
LBLTBL *lp;
message("項目内ジャンプデータを生成しています...");
write_log("\n");
if ((mainfp = dic_open(dic_path, MAIN_FILE)) == NULL ||
(qjfp = qj_newfile(QJD_FILE)) == NULL) {
return ERR;
}
base = dic_filesize() / 100L;
prevpc = -1;
pscount = 0;
idcount = 0;
lines = 0;
newidiom = TRUE;
*buf = '\0';
while (dic_getline(mainfp, linebuf) != NULL) {
lp = get_label(linebuf);
p = skipch(linebuf, '=');
switch (lp->id) {
case LBL_RA: /* 項目開始 */
if (pscount + idcount >= qj_items && lines >= qj_lines) {
/*
* 品詞/成句がqj_items以上、項目行数がqj_lines以上なら
* 項目内ジャンプのためのリンクデータを生成する
*/
fprintf(qjfp, "%ld|%s|%s|%s\n", lpos, itemno, key, buf);
}
pscount = 0;
idcount = 0;
lines = 0;
newidiom = TRUE;
*buf = '\0';
lpos = dic_linepos();
pc = lpos / base;
if (pc > prevpc) {
printf("\r項目内ジャンプデータを生成しています... %ld%%", pc);
fflush(stdout);
prevpc = pc;
}
break;
case LBL_RN: /* 項目番号 */
strcpy(itemno, p);
break;
case LBL_EN: /* 項目見出し */
p = skipch(p, '|');
strcpy(key, p);
lines++;
break;
case LBL_DR: /* 派生形 */
strcat(buf, "派生形|");
lines++;
break;
case LBL_PS: /* 品詞 */
conv_html(tmp, p, itemno, "", FALSE);
strcat(buf, tmp);
strcat(buf, "|");
pscount++;
newidiom = TRUE; /* 品詞の異なる成句は別に数える */
lines++;
break;
case LBL_ID: /* 成句 */
if (newidiom) {
strcat(buf, "成句|");
idcount++;
newidiom = FALSE;
}
lines++;
break;
case LBL_OT1: /* 類語 */
case LBL_OT2: /* 語法 */
case LBL_OT3: /* 活用 */
case LBL_OT4: /* 発音 */
case LBL_OT5: /* 地域的異形 */
p += 2; /* "【"をスキップ */
getuptow(p, name, "】");
strcat(buf, name);
strcat(buf, "|");
lines++;
break;
default:
if (lp->disp)
lines++;
break;
}
}
if (pscount + idcount >= qj_items && lines >= qj_lines)
fprintf(qjfp, "%ld|%s|%s|%s\n", lpos, itemno, key, buf);
dic_close(mainfp);
qj_close(qjfp);
printf("\r項目内ジャンプデータを生成しています... ");
message("終了しました\n");
return OK;
}
/*
* 文字列から空白と"#nn#"を取り除く(成句キー比較用)
*/
byte *
hl_canonical(byte *dst, byte *src)
{
byte *p, *q;
p = src;
q = dst;
while (*p) {
if (*p == ' ') {
p++;
continue;
}
if (*p == '#') {
p += 4;
continue;
}
if (*p & 0x80)
*q++ = *p++;
*q++ = *p++;
}
*q = '\0';
return dst;
}
/*
* ハイパーリンクデータを1項目分読み込む
*/
byte *
hl_getentry(FILE *fp)
{
byte *p, *s, **pp;
HLDATA *hp;
byte tmp[MAX_DLINE];
static int status = ST_START;
static byte itemno[MAX_WORD], buf[MAX_DLINE], sbuf[MAX_LINE];
if (status == ST_END)
return NULL;
if (status == ST_START) {
if (fgets(buf, MAX_DLINE, fp) == NULL)
return NULL;
status = ST_CONT;
}
hp = hldata;
s = sbuf;
p = skipsp(buf);
p = getupto(p, itemno, '|') + 1;
do {
hp->itemno = itemno; /* 項目番号 */
p = getupto(p, hp->tag, '|') + 1; /* HLnnnnnn */
p = getupto(p, tmp, ':') + 1; /* 行頭ラベル */
hp->id = get_label(tmp)->id;
p = getupto(p, tmp, ':') + 1; /* 品詞 */
hp->ps = NULL;
for (pp = pslist; *pp; pp++) {
if (!strcmp(tmp, *pp)) {
hp->ps = *pp;
break;
}
}
p = getupto(p, tmp, ':') + 1; /* 語意番号 */
hp->tr = *tmp? atoi(tmp): -1;
p = getupto(p, tmp, ':') + 1; /* 語意サブ番号 */
hp->trsub = *tmp? atoi(tmp): -1;
p = getupto(p, tmp, '|') + 1; /* 派生形または成句 */
if (*tmp) {
hp->str = s;
s = addstr(s, tmp);
*s++ = '\0';
hp->cstr = s;
hl_canonical(s, tmp);
s = endstr(s);
s++;
} else {
hp->str = NULL;
hp->cstr = NULL;
}
hp->done = FALSE;
hp++;
if (fgets(buf, MAX_DLINE, fp) == NULL) {
status = ST_END;
break;
}
status = ST_CONT;
p = skipsp(buf);
p = getupto(p, tmp, '|') + 1;
} while (!strcmp(itemno, tmp));
hp->id = LBL_ERROR;
return itemno;
}
/*
* 条件を満たすアンカータグを生成する
*/
void
hl_generate_anchor(byte *buf, int id, byte *ps, int tr, int trsub, byte *str)
{
byte *p, cstr[MAX_WORD];
HLDATA *hp;
p = buf;
for (hp = hldata; hp->id != LBL_ERROR; hp++) {
if (hp->done)
continue;
if (hp->id != id)
continue;
if (hp->ps && (ps == NULL || strstr(ps, hp->ps) == NULL))
continue;
if (hp->tr != -1 && (tr == -1 || hp->tr != tr))
continue;
if (hp->trsub != -1 && (trsub == -1 || hp->trsub != trsub))
continue;
if (hp->str) {
if (str == NULL)
continue;
if (id == LBL_KEYID) {
hl_canonical(cstr, str);
if (strcmp(cstr, hp->cstr))
continue;
} else {
if (strcmp(str, hp->str))
continue;
}
}
p = endstr(p);
sprintf(p, "\n", hp->tag);
hp->done = TRUE;
}
}
/*
* 生成されなかったハイパーリンクアンカーをログに書く
*/
void
hl_warn_undone(void)
{
int first;
HLDATA *hp;
LBLTBL *lp;
byte tr[10], trsub[10];
first = TRUE;
for (hp = hldata; hp->id != LBL_ERROR; hp++) {
if (hp->done)
continue;
for (lp = labeltbl; lp->id != hp->id; lp++)
;
if (hp->tr < 0)
*tr = '\0';
else
sprintf(tr, "%d", hp->tr);
if (hp->trsub < 0)
*trsub = '\0';
else
sprintf(trsub, "%d", hp->trsub);
if (first) {
write_log("飛び先不明のため項目末尾にハイパーリンクのアンカーを生成しました\n");
first = FALSE;
}
write_log(" 項目番号=%s, リンク=\"%s:%s:%s:%s:%s\"\n",
hp->itemno, lp->label, hp->ps? hp->ps: "",
tr, trsub, hp->str? hp->str: "");
}
}
/*
* 残りのハイパーリンクアンカーを吐き出す
*/
int
hl_flush_anchor(FILE *fp, int *needbrp)
{
int n;
HLDATA *hp;
n = 0;
for (hp = hldata; hp->id != LBL_ERROR; hp++) {
if (hp->done)
continue;
if (*needbrp) {
fprintf(fp, "
\n");
*needbrp = FALSE;
}
fprintf(fp, "\n", hp->tag);
hp->done = TRUE;
n++;
}
return n;
}
/*
* 字下げタグ文字列を作る
*/
byte *
indentstr(int indent)
{
static byte buf[32];
sprintf(buf, "Ἁ%02x;", indent+1);
return buf;
}
/*
* 変換処理本体
*/
int
do_convert(void)
{
int n, hn, cnt;
int qjno, newidiom, derived, needbr;
int capital, figcap, figno, tlcap, tlno;
int ot1cap, ot1no, ot2cap, ot2no, ot3cap, ot3no;
int first, have_title, have_variant, have_pron, have_sound;
int hlno_pass1, hlno_pass2, have_anchor, cur_tr, cur_trsub;
int imgfd, sndfd;
long lpos, dpos, dlen, qjpos, base, pc, prevpc, sndfiles;
byte *p, *q, *qjp, *space, *indent, *hlitemno, *cur_ps;
byte *snd_file, *fig_ext, *snd_ext;
byte linebuf[MAX_LINE], htmlbuf[MAX_LINE];
byte qjbuf[MAX_DLINE], psbuf[MAX_DLINE];
byte itemno[MAX_WORD], drbuf[MAX_WORD];
byte title[MAX_WORD], variant[MAX_WORD], srchkey[MAX_WORD];
byte pron[MAX_WORD], key[MAX_WORD], soundref[MAX_WORD];
byte filename[MAX_WORD], tmp[MAX_WORD], snddir[4];
byte pron_ref[MAX_WORD], jump_ref[MAX_WORD];
byte arrow_ref[MAX_WORD], ret_ref[MAX_WORD];
FILE *fp, *mainfp, *enfp, *trfp, *qjfp, *hlfp;
FILE *m1fp, *m2fp, *m3fp, *m4fp, *m5fp, *plfp, *plafp;
LENT en, tr, *enp, *trp;
LBLTBL *lp;
static byte holdbuf[MAX_HOLD];
message("本文データをHTMLに変換しています...");
write_log("\n");
if (macintosh) {
fig_ext = ".pict";
snd_ext = ".aifc";
snd_file = MAC_SND_FILE;
} else {
fig_ext = ".bmp";
snd_ext = ".ra";
snd_file = WIN_SND_FILE;
}
if ((mainfp = dic_open(dic_path, MAIN_FILE)) == NULL ||
(enfp = lst_open(dic_path, EN_FILE)) == NULL ||
(trfp = lst_open(dic_path, TR_FILE)) == NULL ||
do_quickjump && (qjfp = qj_open(QJD_FILE)) == NULL ||
(hlfp = hl_open(HLD_FILE)) == NULL ||
do_figure && (imgfd = dat_open(data_path, IMG_FILE)) < 0 ||
do_sound && (sndfd = dat_open(data_path, snd_file)) < 0 ||
(fp = html_newfile(base_path, HTML_FILE)) == NULL ||
do_figure && (m1fp = menu_newfile(base_path, MENU1_FILE, "図版")) == NULL ||
(m2fp = menu_newfile(base_path, MENU2_FILE, "作品名")) == NULL ||
(m3fp = menu_newfile(base_path, MENU3_FILE, "類語")) == NULL ||
(m4fp = menu_newfile(base_path, MENU4_FILE, "語法")) == NULL ||
(m5fp = menu_newfile(base_path, MENU5_FILE, "活用・発音・地域的異形")) == NULL) {
return ERR;
}
base = dic_filesize() / 100L;
prevpc = -1;
enp = lst_getentry(enfp, &en);
trp = lst_getentry(trfp, &tr);
if (do_quickjump)
qjpos = qj_getline(qjfp, qjbuf);
first = TRUE;
needbr = FALSE;
*holdbuf = '\0';
sndfiles = 0L;
plfp = NULL;
figcap = tlcap = ot1cap = ot2cap = ot3cap = ' ';
figno = tlno = ot1no = ot2no = ot3no = 0;
hlno_pass1 = next_hlno() - 1;
reset_hlno();
hlitemno = hl_getentry(hlfp);
if (do_sound)
buildstr(pron_ref, pron_sym);
if (do_quickjump) {
if (do_quickjump == QJ_INDIRECT)
buildstr(jump_ref, jump_sym);
buildstr(arrow_ref, arrow_sym);
}
buildstr(ret_ref, ret_sym);
while (dic_getline(mainfp, linebuf) != NULL) {
lp = get_label(linebuf);
p = skipch(linebuf, '=');
switch (lp->id) {
case LBL_RA: /* 項目開始 */
lpos = dic_linepos();
have_title = FALSE;
have_variant = FALSE;
have_pron = FALSE;
have_sound = FALSE;
if (do_quickjump) {
if (qjpos >= 0L && qjpos < lpos)
qjpos = qj_getline(qjfp, qjbuf);
if (qjpos == lpos) {
qjp = skipch(qjbuf, '|'); /* ファイル位置をスキップ */
qjp = skipch(qjp, '|'); /* 項目番号をスキップ */
qjp = skipch(qjp, '|'); /* キーワードをスキップ */
qjno = 0;
newidiom = TRUE;
} else {
qjp = NULL;
}
}
have_anchor = FALSE;
cur_ps = NULL;
cur_tr = cur_trsub = -1;
pc = lpos / base;
if (pc > prevpc) {
printf("\r本文データをHTMLに変換しています... %ld%%", pc);
fflush(stdout);
prevpc = pc;
}
break;
case LBL_RN: /* 項目番号 */
strcpy(tmp, itemno);
strcpy(itemno, p);
if (hlitemno != NULL) {
n = atoi(itemno);
hn = atoi(hlitemno);
cnt = 0;
while (hn < n) {
hl_warn_undone();
cnt += hl_flush_anchor(fp, &needbr);
hlitemno = hl_getentry(hlfp);
if (hlitemno == NULL)
break;
hn = atoi(hlitemno);
}
if (cnt > 0) {
fprintf(fp, "%s%s",
indentstr(1), tmp, ret_ref);
needbr = TRUE;
}
have_anchor = (hlitemno && hn == n);
} else {
have_anchor = FALSE;
}
break;
case LBL_EN: /* 項目見出し */
case LBL_DR: /* 派生形 */
p = getupto(p, tmp, '|');
strcpy(srchkey, p+1);
conv_title(title, tmp);
have_title = TRUE;
if (lp->id == LBL_EN)
derived = 0;
else
derived++;
for (q = srchkey; *q; q++) {
if (isalpha(*q))
break;
}
if (!*q)
capital = '@';
else if (islower(*q))
capital = toupper(*q);
else
capital = *q;
if (have_anchor && lp->id == LBL_DR) {
hl_generate_anchor(holdbuf,
LBL_DR, NULL, -1, -1, srchkey);
}
break;
case LBL_ENV: /* 異表記 */
if (!have_title)
goto output;
conv_html(variant, p, itemno, "", TRUE);
have_variant = TRUE;
break;
case LBL_PR: /* 発音 */
conv_html(pron, p, itemno, "", TRUE);
have_pron = TRUE;
break;
case LBL_SND: /* 音声 */
if (!do_sound)
break;
sscanf(p, "%lx,%lx", &dpos, &dlen);
if (dlen == 0L)
break;
if (sndfiles % 1000L == 0L) {
sprintf(snddir, "%03ld", sndfiles / 1000);
sprintf(tmp, "%s%s", sound_path_slash, snddir);
if (generate_sound)
mkdir(tmp);
}
if (macintosh && generate_sound && (sndfiles % 10000L == 0L)) {
if (plfp != NULL)
pl_close(plfp, sndfiles - 9999L, sndfiles);
sprintf(tmp, "pl_%s.xml", snddir);
if ((plfp = pl_newfile(base_path, tmp)) == NULL)
return ERR;
if (sndfiles == 0L) {
if ((plafp = pl_newfile(base_path, "pl_all.xml")) == NULL)
return ERR;
}
}
filename[0] = snddir[0];
filename[1] = snddir[1];
filename[2] = snddir[2];
filename[3] = '/';
getupto(p, filename+4, ',');
strcpy(tmp, filename);
strcat(filename, snd_ext);
if (generate_sound) {
if (dat_splitfile(sound_path, filename, sndfd, dpos, dlen) == ERR)
return ERR;
if (macintosh) {
if (pl_putentry(plfp, sound_path_slash,
SND_DIR, snddir, dpos, sndfiles+1) == ERR ||
pl_putentry(plafp, sound_path_slash,
SND_DIR, snddir, dpos, sndfiles+1) == ERR) {
return ERR;
}
}
}
sprintf(soundref, "%s",
SND_DIR, tmp, pron_ref);
sndfiles++;
have_sound = TRUE;
break;
case LBL_IMG: /* 図版 */
if (have_anchor) {
hl_generate_anchor(holdbuf,
LBL_IMG, cur_ps, cur_tr, cur_trsub, NULL);
}
if (!do_figure)
break;
sscanf(p, "%lx,%lx", &dpos, &dlen);
getupto(p, filename, ',');
strcpy(tmp, filename);
strcat(tmp, fig_ext);
if (dat_splitfile(figure_path, tmp, imgfd, dpos, dlen) == ERR)
break;
strcat(filename, use_jpeg? ".jpg": ".bmp");
if (capital != figcap) {
if (figcap != ' ')
fprintf(m1fp, "\n");
fprintf(m1fp, "%s
\n\n", han2zen[capital]);
figcap = capital;
}
fprintf(m1fp, "%s
\n",
HTML_FILE, figno, title);
sprintf(endstr(holdbuf),
"",
figno++, FIG_DIR, filename, title);
goto output;
case LBL_OT1: /* 類語 */
case LBL_OT2: /* 語法 */
case LBL_OT3: /* 活用 */
case LBL_OT4: /* 発音 */
case LBL_OT5: /* 地域的異形 */
/*
* 類語などのメニューを作る
*/
if (!strncmp(p, "【類語】", 8)) {
if (capital != ot1cap) {
if (ot1cap != ' ')
fprintf(m3fp, "
\n");
fprintf(m3fp, "%s
\n\n", han2zen[capital]);
ot1cap = capital;
}
fprintf(m3fp, "【類語】%s
\n",
HTML_FILE, ot1no, title);
sprintf(endstr(holdbuf), "\n", ot1no++);
} else if (!strncmp(p, "【語法】", 8)) {
if (capital != ot2cap) {
if (ot2cap != ' ')
fprintf(m4fp, "
\n");
fprintf(m4fp, "%s
\n\n", han2zen[capital]);
ot2cap = capital;
}
fprintf(m4fp, "【語法】%s
\n",
HTML_FILE, ot2no, title);
sprintf(endstr(holdbuf), "\n", ot2no++);
} else {
if (capital != ot3cap) {
if (ot3cap != ' ')
fprintf(m5fp, "
\n");
fprintf(m5fp, "%s
\n\n", han2zen[capital]);
ot3cap = capital;
}
getuptow(p, tmp, "】");
fprintf(m5fp, "%s】%s
\n",
HTML_FILE, ot3no, tmp, title);
sprintf(endstr(holdbuf), "\n", ot3no++);
}
if (have_anchor) {
hl_generate_anchor(holdbuf,
lp->id, cur_ps, cur_tr, cur_trsub, NULL);
}
goto output;
case LBL_TL: /* 文献タイトル */
case LBL_TLSUB: /* 文献タイトルサブ項目 */
/*
* "◇"や"[音楽]"を読み飛ばして、
* そこに作品名があれば作品名メニューを作る
*/
q = p;
if (!strncmp(q, "◇", 2))
q += 2;
if (*q == '[') {
q = getupto(q, tmp, ']') + 1;
strcat(tmp, "]");
}
if (have_anchor) {
hl_generate_anchor(holdbuf,
lp->id, cur_ps, cur_tr, cur_trsub, *tmp? tmp: NULL);
}
if (!*q)
goto output;
if (capital != tlcap) {
if (tlcap != ' ')
fprintf(m2fp, "
\n");
fprintf(m2fp, "%s
\n\n", han2zen[capital]);
tlcap = capital;
}
conv_html(tmp, q, itemno, "", FALSE);
fprintf(m2fp, "%s
\n",
HTML_FILE, tlno, tmp);
sprintf(endstr(holdbuf), "\n", tlno++);
goto output;
case LBL_KEYID: /* 成句キー */
if (have_anchor) {
strcpy(tmp, p);
removetag(tmp);
hl_generate_anchor(holdbuf,
LBL_KEYID, cur_ps, cur_tr, cur_trsub, tmp);
}
/*
* 複合検索インデックスを作る
*/
if (!do_complexed_index)
break;
conv_html(tmp, p, itemno, "", TRUE);
q = endstr(holdbuf);
if (q - holdbuf > MAX_HOLD - HOLD_MARGIN)
write_log("出力保持バッファがもうすぐ一杯です\n");
while ((p = getidxword(p, key)) != NULL) {
sprintf(q, "%s\n",
tmp, key);
q = endstr(q);
}
*q = '\0';
break;
case LBL_PS: /* 品詞 */
strcpy(psbuf, p);
cur_ps = removetag(psbuf);
cur_tr = cur_trsub = -1;
if (have_anchor) {
hl_generate_anchor(holdbuf,
LBL_PS, cur_ps, cur_tr, cur_trsub, NULL);
}
goto output;
case LBL_TR: /* 語意 */
cur_tr = lp->tr;
cur_trsub = -1;
if (have_anchor) {
hl_generate_anchor(holdbuf,
LBL_TR, cur_ps, cur_tr, cur_trsub, NULL);
}
goto output;
case LBL_TRSUB: /* 語意サブ項目 */
cur_tr = lp->tr;
cur_trsub = lp->trsub;
if (have_anchor) {
hl_generate_anchor(holdbuf,
LBL_TRSUB, cur_ps, cur_tr, cur_trsub, NULL);
}
goto output;
case LBL_MN: /* 意味 */
cur_tr = 1;
cur_trsub = -1;
if (have_anchor) {
hl_generate_anchor(holdbuf,
LBL_TR, cur_ps, cur_tr, cur_trsub, NULL);
}
goto output;
case LBL_KEYEX: /* 用例キー */
if (have_anchor) {
hl_generate_anchor(holdbuf,
LBL_KEYEX, cur_ps, cur_tr, cur_trsub, NULL);
}
goto output;
case LBL_SRC: /* 語源 */
if (have_anchor) {
hl_generate_anchor(holdbuf,
LBL_SRC, cur_ps, cur_tr, cur_trsub, NULL);
}
goto output;
case LBL_J2E: /* 日本語から借用 */
if (!strcmp(p, "END"))
break;
goto output;
default:
output:
if (!lp->disp)
break;
if (!*p)
break;
if (have_title) {
have_title = FALSE;
if (first)
first = FALSE;
else
fprintf(fp, "\n
\n");
if (*holdbuf) {
fprintf(fp, "%s", holdbuf);
*holdbuf = '\0';
}
if (derived)
sprintf(drbuf, "DR%02d", derived);
else
*drbuf = '\0';
fprintf(fp, "%s\n", itemno, drbuf, title);
while (enp && enp->dpos <= lpos) {
tozen(key, enp->fkey);
fprintf(fp,
"%s\n",
title, key);
fprintf(fp,
"%s\n",
title, key);
enp = lst_getentry(enfp, &en);
}
while (trp && trp->dpos <= lpos) {
fprintf(fp,
"%s\n",
title, trp->fkey);
fprintf(fp,
"%s\n",
title, trp->fkey);
trp = lst_getentry(trfp, &tr);
}
fprintf(fp, "\n");
space = "";
if (have_pron) {
have_pron = FALSE;
fprintf(fp, "%s%s", space, pron);
space = " ";
}
if (have_variant) {
have_variant = FALSE;
fprintf(fp, "%s%s", space, variant);
space = " ";
}
if (have_sound) {
have_sound = FALSE;
fprintf(fp, "%s%s", space, soundref);
space = " ";
}
if (do_quickret && qjp && derived) {
fprintf(fp, "%s%s",
space, itemno, ret_ref);
space = " ";
}
if (do_quickjump == QJ_INDIRECT && qjp && !derived) {
fprintf(fp, "%s%s",
space, itemno, jump_ref);
space = " ";
} else if (do_quickjump && qjp && !derived) {
int no = 0;
int dr = 1;
if (do_quickjump == QJ_NEXTLINE) {
fprintf(fp, "
\n%s", indentstr(1));
space = "";
}
while (*qjp && *qjp != '\n') {
if (do_quickjump == QJ_NEXTNLINE) {
fprintf(fp, "
\n%s", indentstr(1));
space = "";
}
qjp = getupto(qjp, tmp, '|') + 1;
if (strcmp(tmp, "派生形")) {
fprintf(fp, "%s%s%s",
space, itemno, no++, arrow_ref, tmp);
} else if (*qjp && *qjp != '\n') {
qjp = getupto(qjp, tmp, '|') + 1;
fprintf(fp, "%s%s%s",
space, itemno, dr++, arrow_ref, tmp);
}
space = " ";
}
}
if (!*space) {
/*
*
title
では
* titleのあと改行してくれないので
* スペースを1つ入れる
*/
fprintf(fp, " ");
}
needbr = TRUE;
}
if (needbr && lp->id != LBL_ID) {
fprintf(fp, "
\n");
needbr = FALSE;
}
if (*holdbuf && lp->id != LBL_ID && lp->id != LBL_TL) {
fprintf(fp, "%s", holdbuf);
*holdbuf = '\0';
}
if (do_quickjump &&
qjp && *qjp &&
(lp->id == LBL_PS ||
lp->id == LBL_OT1 ||
lp->id == LBL_OT2 ||
lp->id == LBL_OT3 ||
lp->id == LBL_OT4 ||
lp->id == LBL_OT5 ||
lp->id == LBL_ID && newidiom)) {
fprintf(fp, "\n", itemno, qjno++);
}
switch (lp->id) {
case LBL_EX: /* 用例 */
case LBL_NB: /* 註 */
case LBL_NBP: /* 表現註 */
case LBL_NBSUB: /* 註サブ項目 */
case LBL_NBPSUB: /* 表現註サブ項目 */
case LBL_NSBUS: /* NBSUBの誤記???(and) */
indent = indentstr(2);
break;
default:
indent = indentstr(1);
break;
}
switch (lp->id) {
case LBL_PS: /* 品詞 */
conv_html(htmlbuf, p, itemno, srchkey, TRUE);
fprintf(fp, "%s━%s", indent, htmlbuf);
if (do_quickret && qjp && !derived)
fprintf(fp, "%s", itemno, ret_ref);
newidiom = TRUE;
break;
case LBL_TRSUB: /* 語意サブ項目 */
if (!strncmp(p, "【", 2))
p = skipwch(p, "】");
conv_html(htmlbuf, p, itemno, srchkey, TRUE);
fprintf(fp, "%s%s", indent, htmlbuf);
break;
case LBL_ID: /* 成句 */
if (newidiom) {
if (needbr) {
fprintf(fp, "
\n");
needbr = FALSE;
}
fprintf(fp, "%s<成句>", indent);
if (do_quickret && qjp)
fprintf(fp, "%s", itemno, ret_ref);
newidiom = FALSE;
}
conv_html(htmlbuf, p, itemno, srchkey, TRUE);
fprintf(fp, "\n
\n\n");
if (*holdbuf) {
fprintf(fp, "%s", holdbuf);
*holdbuf = '\0';
}
fprintf(fp, "%s%s", indent, htmlbuf);
break;
case LBL_EX : /* 用例 */
if (!do_complexed_index) {
conv_html(htmlbuf, p, itemno, srchkey, TRUE);
fprintf(fp, "%s%s", indent, htmlbuf);
break;
}
/*
* " "があればその直前まで、
* なければ全体をクロス条件検索に登録
* 同時に複合検索にも登録される
*/
if ((q = strstr(p, " ")) != NULL) {
*q = '\0';
/*
* 用例本体にあるタグはすべて捨てる
* そうしないとEBStudioが検索用の単語を
* クロス条件検索ではなく前方一致検索
* インデックスのほうに登録してしまうため
* (2004/12/11現在のEBStudioの制約)
*/
conv_example(htmlbuf, p);
conv_html(tmp, q+6, itemno, srchkey, TRUE);
*q = ' ';
fprintf(fp, "%s%s %s",
indent, htmlbuf, tmp);
} else {
conv_html(htmlbuf, p, itemno, srchkey, TRUE);
fprintf(fp, "%s%s", indent, htmlbuf);
}
break;
case LBL_OT1: /* 類語 */
case LBL_OT2: /* 語法 */
case LBL_OT3: /* 活用 */
case LBL_OT4: /* 発音 */
case LBL_OT5: /* 地域的異形 */
fprintf(fp, "%s", indent);
if (!strncmp(p, "【", 2)) {
p = getuptow(p+2, tmp, "】") + 2;
fprintf(fp, "<%s>", tmp);
if (do_quickret && qjp)
fprintf(fp, "%s", itemno, ret_ref);
}
if (*p) {
conv_html(htmlbuf, p, itemno, srchkey, TRUE);
fprintf(fp, "
\n%s%s", indent, htmlbuf);
}
break;
case LBL_TL: /* 文献タイトル */
if (!strncmp(p, "◇", 2)) {
fprintf(fp, "%s◆作品名", indent);
p += 2;
if (!*p)
break;
fprintf(fp, "
\n");
}
if (*holdbuf) {
fprintf(fp, "%s", holdbuf);
*holdbuf = '\0';
}
conv_html(htmlbuf, p, itemno, srchkey, TRUE);
fprintf(fp, "%s%s", indent, htmlbuf);
break;
case LBL_IMG:
break;
default:
conv_html(htmlbuf, p, itemno, srchkey, TRUE);
fprintf(fp, "%s%s", indent, htmlbuf);
break;
}
needbr = TRUE;
break;
}
}
do {
hl_warn_undone();
cnt += hl_flush_anchor(fp, &needbr);
} while (hl_getentry(hlfp) != NULL);
if (cnt > 0) {
fprintf(fp, "%s%s", indentstr(1), itemno, ret_ref);
needbr = TRUE;
}
fprintf(fp, "\n
\n");
if (do_quickjump == QJ_INDIRECT) {
rewind(qjfp);
indent = indentstr(1);
while (qj_getline(qjfp, qjbuf) != -1L) {
int no = 0;
int dr = 1;
fprintf(fp, "ἃ\nἂ\n");
qjp = skipch(qjbuf, '|');
qjp = getupto(qjp, itemno, '|') + 1;
qjp = getupto(qjp, key, '|') + 1;
fprintf(fp, "%s\n
\n", itemno, key);
needbr = FALSE;
while (*qjp && *qjp != '\n') {
if (needbr) {
fprintf(fp, "
\n");
needbr = FALSE;
}
qjp = getupto(qjp, tmp, '|') + 1;
if (strcmp(tmp, "派生形")) {
fprintf(fp, "%s%s%s",
indent, itemno, no++, arrow_ref, tmp);
} else if (*qjp && *qjp != '\n') {
qjp = getupto(qjp, tmp, '|') + 1;
fprintf(fp, "%s%s%s",
indent, itemno, dr++, arrow_ref, tmp);
}
needbr = TRUE;
}
fprintf(fp, "\n
\n");
}
}
dic_close(mainfp);
lst_close(enfp);
lst_close(trfp);
if (do_quickjump)
qj_close(qjfp);
hl_close(hlfp);
if (do_figure)
dat_close(imgfd);
if (do_sound)
dat_close(sndfd);
html_close(fp);
if (do_figure)
menu_close(m1fp);
menu_close(m2fp);
menu_close(m3fp);
menu_close(m4fp);
menu_close(m5fp);
if (do_sound && generate_sound && macintosh) {
pl_close(plfp, sndfiles - (sndfiles % 10000L) + 1L, sndfiles);
pl_close(plafp, 1L, sndfiles);
}
printf("\r本文データをHTMLに変換しています... ");
message("終了しました\n");
hlno_pass2 = next_hlno() - 1;
if (hlno_pass2 != hlno_pass1) {
message("ハイパーリンクタグの個数が生成時(%d)と参照時(%d)で異なっています\n",
hlno_pass1, hlno_pass2);
return ERR;
}
return OK;
}
/*
* 著作権表示ファイルを生成する
*/
int
generate_copyright_file(void)
{
int c, lastc, holdsp;
byte *p, buf[MAX_PATH];
FILE *ifp, *ofp;
sprintf(buf, "%s%s", dic_path, README_FILE);
if ((ifp = fopen(buf, "rb")) == NULL) {
message("ファイル %s がオープンできません\n", buf);
return ERR;
}
sprintf(buf, "%s%s", base_path, COPR_FILE);
if ((ofp = fopen(buf, "w")) == NULL) {
message("著作権表示ファイル %s が新規作成できません\n", buf);
return ERR;
}
message("著作権表示ファイルを生成しています... ");
fprintf(ofp, "\n");
fprintf(ofp, "\n");
fprintf(ofp, "著作権表示\n");
fprintf(ofp, "\n");
fprintf(ofp, "\n");
fprintf(ofp, "\n");
lastc = '\0';
holdsp = FALSE;
while ((c = getc(ifp)) != EOF && c != 0x1a) {
if (c == '\r') {
fprintf(ofp, "
\n");
} else if (c == '\n') {
if (lastc != '\r')
fprintf(ofp, "
\n");
} else if (c == ' ') {
if (holdsp) {
fprintf(ofp, " ");
holdsp = FALSE;
} else {
holdsp = TRUE;
}
} else {
if (holdsp) {
putc(' ', ofp);
holdsp = FALSE;
}
putc(c, ofp);
}
lastc = c;
}
fprintf(ofp, "
\n");
fprintf(ofp, "\n");
fprintf(ofp, "\n");
fclose(ifp);
fclose(ofp);
message("終了しました\n");
return OK;
}
/*
* 複合検索定義ファイルを生成する
*/
int
generate_complex_file(void)
{
byte buf[MAX_PATH];
FILE *fp;
sprintf(buf, "%s%s", base_path, CMPL_FILE);
if ((fp = fopen(buf, "w")) == NULL) {
message("複合検索定義ファイル %s が新規作成できません\n", buf);
return ERR;
}
message("複合検索定義ファイルを生成しています... ");
fprintf(fp, "\n");
fprintf(fp, "\n");
fprintf(fp, "\n");
fprintf(fp, " \n");
fprintf(fp, " \n");
fprintf(fp, " \n");
fprintf(fp, " \n");
fprintf(fp, " \n");
fprintf(fp, " \n");
fprintf(fp, " \n");
fprintf(fp, "\n");
fclose(fp);
message("終了しました\n");
return OK;
}
/*
* EBStudio定義ファイルsrd.ebsを生成する
*/
int
generate_ebs_file(void)
{
byte buf[MAX_PATH];
FILE *fp;
sprintf(buf, "%s%s", base_path, EBS_FILE);
if ((fp = fopen(buf, "w")) == NULL) {
message("EBStudio定義ファイル %s が新規作成できません\n", buf);
return ERR;
}
message("EBSファイルを生成しています... ");
fprintf(fp, "InPath=%s\n", base_path);
fprintf(fp, "OutPath=%s\n", out_path);
fprintf(fp, "IndexFile=\n");
fprintf(fp, "Copyright=\n");
fprintf(fp, "GaijiFile=$(BASE)\\%s\n", GFONT_FILE);
fprintf(fp, "GaijiMapFile=$(BASE)\\%s\n", GMAP_FILE);
fprintf(fp, "EBType=0\n");
fprintf(fp, "WordSearchHyoki=1\n");
fprintf(fp, "WordSearchKana=0\n");
fprintf(fp, "EndWordSearchHyoki=1\n");
fprintf(fp, "EndWordSearchKana=0\n");
fprintf(fp, "KeywordSearch=%d\n", do_complexed_index);
fprintf(fp, "ComplexSearch=%d\n", do_complexed_index);
fprintf(fp, "topMenu=0\n");
fprintf(fp, "singleLine=1\n");
fprintf(fp, "kanaSep1=【\n");
fprintf(fp, "kanaSep2=】\n");
fprintf(fp, "hyokiSep=0\n");
fprintf(fp, "makeFig=%d\n", (do_figure || do_sound)? 1: 0);
fprintf(fp, "inlineImg=0\n");
fprintf(fp, "paraHdr=0\n");
fprintf(fp, "ruby=1\n");
fprintf(fp, "paraBr=0\n");
fprintf(fp, "subTitle=1\n");
fprintf(fp, "dfnStyle=0\n");
fprintf(fp, "srchUnit=1\n");
fprintf(fp, "linkChar=0\n");
fprintf(fp, "arrowCode=222A\n");
fprintf(fp, "eijiPronon=1\n");
fprintf(fp, "eijiPartOfSpeech=1\n");
fprintf(fp, "eijiBreak=1\n");
fprintf(fp, "eijiKana=0\n");
fprintf(fp, "leftMargin=0\n");
fprintf(fp, "indent=0\n");
fprintf(fp, "tableWidth=480\n");
fprintf(fp, "StopWord=\n");
fprintf(fp, "delBlank=1\n");
fprintf(fp, "delSym=1\n");
fprintf(fp, "delChars=\n");
fprintf(fp, "refAuto=0\n");
fprintf(fp, "titleWord=1\n");
fprintf(fp, "autoWord=0\n");
fprintf(fp, "autoEWord=0\n");
fprintf(fp, "HTagIndex=0\n");
fprintf(fp, "DTTagIndex=1\n");
fprintf(fp, "dispKeyInSelList=0\n");
fprintf(fp, "titleOrder=0\n");
fprintf(fp, "omitHeader=0\n");
fprintf(fp, "addKana=1\n");
fprintf(fp, "autoKana=0\n");
fprintf(fp, "withHeader=0\n");
fprintf(fp, "optMono=0\n");
fprintf(fp, "Size=220000;390000;100;229000000;82000;3300000;100;2600;106500;10100;3100\n");
fprintf(fp, "Book=ランダムハウス英語辞典;SRD;英和辞典;$(BASE)\\%s;", COPR_FILE);
if (do_complexed_index) {
fprintf(fp, "$(BASE)\\%s;", CMPL_FILE);
} else {
fprintf(fp, "_;");
}
fprintf(fp, "GAI16H00;GAI16F00;_;_;_;_;_;_;\n");
fprintf(fp, "Source=$(BASE)\\%s;本文;_;HTML;\n", HTML_FILE);
if (do_figure)
fprintf(fp, "Source=$(BASE)\\%s;図版;_;HTML;\n", MENU1_FILE);
fprintf(fp, "Source=$(BASE)\\%s;作品名;_;HTML;\n", MENU2_FILE);
fprintf(fp, "Source=$(BASE)\\%s;類語;_;HTML;\n", MENU3_FILE);
fprintf(fp, "Source=$(BASE)\\%s;語法;_;HTML;\n", MENU4_FILE);
fprintf(fp, "Source=$(BASE)\\%s;活用他;_;HTML;\n", MENU5_FILE);
fclose(fp);
message("終了しました\n");
return OK;
}
/*
* 設定ファイルを読み込む
*/
int
parse_ini_file(void)
{
int n, lineno, ret;
byte *p;
byte key[MAX_WORD], val[MAX_PATH], buf[BUFSIZ];
FILE *fp;
if ((fp = fopen(INI_FILE, "r")) == NULL) {
message("設定ファイル %s がオープンできません\n", INI_FILE);
return ERR;
}
ret = OK;
lineno = 0;
while (fgets((char *)buf, BUFSIZ, fp) != NULL) {
lineno++;
p = skipsp(buf);
if (*p == '#' || *p == '\r' || *p == '\n')
continue;
p = getuptos(p, key, " \t=#");
p = skipch(p, '=');
p = skipsp(p);
p = getuptos(p, val, "\t#");
n = atoi(val);
if (!strcmp(key, "BASEPATH")) {
if (p[-1] != '/' && p[-1] != '\\')
strcat(val, "\\");
base_path = strdup(val);
} else if (!strcmp(key, "OUTPATH")) {
if (p[-1] != '/' && p[-1] != '\\')
strcat(val, "\\");
out_path = strdup(val);
} else if (!strcmp(key, "DICPATH")) {
if (p[-1] != '/' && p[-1] != '\\')
strcat(val, "\\");
dic_path = strdup(val);
} else if (!strcmp(key, "DATAPATH")) {
if (p[-1] != '/' && p[-1] != '\\')
strcat(val, "\\");
data_path = strdup(val);
} else if (!strcmp(key, "SORTCMD"))
sort_cmd = strdup(val);
else if (!strcmp(key, "MACINTOSH"))
macintosh = n;
else if (!strcmp(key, "FIGURE"))
do_figure = n;
else if (!strcmp(key, "JPEG"))
use_jpeg = n;
else if (!strcmp(key, "SOUND"))
do_sound = n;
else if (!strcmp(key, "GENSOUND"))
generate_sound = n;
else if (!strcmp(key, "COMPLEX"))
do_complexed_index = n;
else if (!strcmp(key, "QUICKJUMP"))
do_quickjump = n;
else if (!strcmp(key, "QJITEMS"))
qj_items = n;
else if (!strcmp(key, "QJLINES"))
qj_lines = n;
else if (!strcmp(key, "QUICKRET"))
do_quickret = n;
else if (!strcmp(key, "ITALIC"))
use_italic = n;
else if (!strcmp(key, "PRONSYM"))
pron_sym = strdup(val);
else if (!strcmp(key, "JUMPSYM"))
jump_sym = strdup(val);
else if (!strcmp(key, "ARROWSYM"))
arrow_sym = strdup(val);
else if (!strcmp(key, "RETSYM"))
ret_sym = strdup(val);
else {
message("設定ファイルに不正な行があります(%d行め)\n", lineno);
ret = ERR;
}
}
fclose(fp);
message("変換設定は以下のとおりです\n");
message(" BASEPATH = %s\n", base_path);
message(" OUTPATH = %s\n", out_path);
message(" DICPATH = %s\n", dic_path);
message(" DATAPATH = %s\n", data_path);
message(" SORTCMD = %s\n", sort_cmd);
message(" MACINTOSH = %d\n", macintosh);
message(" FIGURE = %d\n", do_figure);
message(" JPEG = %d\n", use_jpeg);
message(" SOUND = %d\n", do_sound);
message(" GENSOUND = %d\n", generate_sound);
message(" COMPLEX = %d\n", do_complexed_index);
message(" QUICKJUMP = %d\n", do_quickjump);
message(" QJITEMS = %d\n", qj_items);
message(" QJLINES = %d\n", qj_lines);
message(" QUICKRET = %d\n", do_quickret);
message(" ITALIC = %d\n", use_italic);
message(" PRONSYM = %s\n", pron_sym);
message(" JUMPSYM = %s\n", jump_sym);
message(" ARROWSYM = %s\n", arrow_sym);
message(" RETSYM = %s\n", ret_sym);
return ret;
}
/*
* ファイル出力先ディレクトリを作る
*/
int
work_directory(void)
{
int i;
char *p, path[MAX_PATH], subpath[MAX_PATH];
struct stat st;
if (*base_path &&
strcmp(base_path, "\\") &&
strcmp(base_path + 1, ":\\")) {
strcpy(path, base_path);
p = &path[strlen(path) - 1];
if (*p == '/' || *p == '\\')
*p = '\0';
if (stat(path, &st) < 0) {
if (mkdir(path) < 0) {
message("基準ディレクトリ %s が作れません\n", path);
return ERR;
}
message("基準ディレクトリ %s を新規作成しました\n", path);
} else if ((st.st_mode & S_IFMT) != S_IFDIR) {
message("基準ディレクトリ %s と同名のファイルがあります\n", path);
return ERR;
}
}
if (do_figure) {
sprintf(path, "%s%s", base_path, FIG_DIR);
if (stat(path, &st) < 0) {
if (mkdir(path) < 0) {
message("図版データディレクトリ %s が作れません\n", path);
return ERR;
}
message("図版データディレクトリ %s を新規作成しました\n", path);
} else if ((st.st_mode & S_IFMT) != S_IFDIR) {
message("図版データディレクトリ %s と同名のファイルがあります\n", path);
return ERR;
}
strcat(path, "\\");
figure_path = strdup(path);
}
if (do_sound && generate_sound) {
sprintf(path, "%s%s", base_path, SND_DIR);
if (stat(path, &st) < 0) {
if (mkdir(path) < 0) {
message("音声データディレクトリ %s が作れません\n", path);
return ERR;
}
message("音声データディレクトリ %s を新規作成しました\n", path);
} else if ((st.st_mode & S_IFMT) != S_IFDIR) {
message("音声データディレクトリ %s と同名のファイルがあります\n", path);
return ERR;
}
strcat(path, "\\");
sound_path = strdup(path);
sound_path_slash = strdup(sound_path);
for (p = sound_path_slash; *p; p++) {
if (*p == '\\')
*p = '/';
}
}
if (*out_path &&
strcmp(out_path, "\\") &&
strcmp(out_path + 1, ":\\")) {
strcpy(path, out_path);
p = &path[strlen(path) - 1];
if (*p == '/' || *p == '\\')
*p = '\0';
if (stat(path, &st) < 0) {
if (mkdir(path) < 0) {
message("出力先ディレクトリ %s が作れません\n", path);
return ERR;
}
message("出力先ディレクトリ %s を新規作成しました\n", path);
} else if ((st.st_mode & S_IFMT) != S_IFDIR) {
message("出力先ディレクトリ %s と同名のファイルがあります\n", path);
return ERR;
}
}
return OK;
}
/*
* 利用可能なソートコマンドを設定する
*/
int
set_sort_command(void)
{
char **p;
struct stat st;
static char *sort_cmd_cand[] = {
"",
"C:\\Windows\\System32\\sort.exe",
"C:\\WinNT\\System32\\sort.exe",
"C:\\Windows\\command\\sort.exe",
NULL
};
if (sort_cmd && *sort_cmd)
sort_cmd_cand[0] = sort_cmd;
for (p = sort_cmd_cand; *p; p++) {
if (stat(*p, &st) == 0) {
sort_cmd = *p;
return OK;
}
}
message("ソートコマンドが見つかりません\n");
return ERR;
}
/*
* 初期化
*/
int
init(char *cmd_path)
{
char *p, path[MAX_PATH];
strcpy(path, cmd_path);
p = &path[strlen(path) - 1];
while (p > path && *p != '\\')
p--;
*p = '\0';
if (!strcmp(path + 1, ":"))
strcat(path, "\\");
if (chdir(path) < 0) {
printf("作業ディレクトリ %s への移動に失敗しました\n", path);
return ERR;
}
time(&start_time);
write_log("開始時刻: %s", ctime(&start_time));
message("作業ディレクトリ %s に移動しました\n", path);
return OK;
}
/*
* 終了処理
*/
void
term(int status)
{
time_t t;
if (status == OK)
message("変換処理が終了しました\n");
else
message("変換処理に失敗しました\n");
time(&stop_time);
t = stop_time - start_time;
write_log("終了時刻: %s", ctime(&stop_time));
message("経過時間: %d:%02d\n", (int)(t / 60), (int)(t % 60));
if (status == OK) {
if (do_figure) {
if (use_jpeg)
message("※ %s にある図版データをJPEG形式に変換してください\n",
figure_path);
else if (macintosh)
message("※ %s にある図版データをBMP形式に変換してください\n",
figure_path);
}
if (do_sound && generate_sound)
message("※ %s にある音声データを無圧縮WAV形式に変換してください\n",
sound_path);
message("※ ");
if (do_figure && use_jpeg || do_sound && generate_sound)
message("その後 ");
message("%s%s を入力としてEBStudioを実行してください\n",
base_path, EBS_FILE);
}
write_log("\n");
exit(status == ERR? 1: 0);
}
/*
* メイン
*/
int
main(int ac, char **av)
{
if (init(av[0]) == ERR)
term(ERR);
if (parse_ini_file() == ERR)
term(ERR);
if (work_directory() == ERR)
term(ERR);
if (set_sort_command() == ERR)
term(ERR);
if (init_gaiji() == ERR)
term(ERR);
if (do_quickjump) {
if (generate_quickjump_file() == ERR)
term(ERR);
}
if (generate_hyperlink_file() == ERR)
term(ERR);
if (do_convert() == ERR)
term(ERR);
if (generate_copyright_file() == ERR)
term(ERR);
if (do_complexed_index) {
if (generate_complex_file() == ERR)
term(ERR);
}
if (generate_ebs_file() == ERR)
term(ERR);
term(OK);
}