Пример #1
0
EB_Error_Code QEb::setSubbook(EB_Subbook_Code code)
{
    EB_Error_Code ecode = eb_set_subbook(&book, code);
    if (ecode != EB_SUCCESS)
        dispError("eb_set_subbook", ecode);
    return ecode;
}
Пример #2
0
char *
uim_eb_search_text (uim_eb *ueb, const char *key, const char *enc)
{
  char *text;
  int i;
  char *str = NULL;
  iconv_t cd;

  /* FIXME! check return value */

  cd = (iconv_t)uim_iconv->create("EUC-JP", enc);
  text = uim_iconv->convert(cd, key);
  uim_iconv->release(cd);

  if (!text)
	  return NULL;

  for (i = 0; i < ueb->subCount; i++) {
    EB_Hit hits[MAX_HITS];
    int hitCount;
    int j;

    /* specify subbook */
    if (eb_set_subbook(&ueb->book, ueb->subCodes[i]) != EB_SUCCESS) {
      uim_notify_fatal(N_("eb: eb_set_subbook() failed")); continue;
    }

    eb_search_word(&ueb->book, text);
    eb_hit_list(&ueb->book, MAX_HITS, hits, &hitCount);
    for (j = 0; j < hitCount; j++) {
      /*EB_Position headp = hits[j].heading;*/
      EB_Position textp = hits[j].text;

      go_text_eb(ueb, textp, &str, enc);
      uim_eb_strappend(&str, "\n", sizeof("\n"));
    }
  }

  free(text);

  return str;
}
Пример #3
0
Файл: font.c Проект: jokester/eb
int
main(int argc, char *argv[])
{
    EB_Error_Code error_code;
    EB_Book book;
    EB_Subbook_Code subbook_list[EB_MAX_SUBBOOKS];
    int subbook_count;
    int subbook_index;
    int font_start;
    unsigned char bitmap[EB_SIZE_NARROW_FONT_16];
    int i, j;

    /* コマンド行引数をチェック。*/
    if (argc != 3) {
        fprintf(stderr, "Usage: %s book-path subbook-index\n",
            argv[0]);
        exit(1);
    }

    /* EB ライブラリと `book' を初期化。*/
    eb_initialize_library();
    eb_initialize_book(&book);

    /* 書籍を `book' に結び付ける。*/
    error_code = eb_bind(&book, argv[1]);
    if (error_code != EB_SUCCESS) {
        fprintf(stderr, "%s: failed to bind the book, %s: %s\n",
            argv[0], eb_error_message(error_code), argv[1]);
        goto die;
    }

    /* 副本の一覧を取得。*/
    error_code = eb_subbook_list(&book, subbook_list, &subbook_count);
    if (error_code != EB_SUCCESS) {
        fprintf(stderr, "%s: failed to get the subbbook list, %s\n",
            argv[0], eb_error_message(error_code));
        goto die;
    }

    /* 副本のインデックスを取得。*/
    subbook_index = atoi(argv[2]);

    /*「現在の副本 (current subbook)」を設定。*/
    error_code = eb_set_subbook(&book, subbook_list[subbook_index]);
    if (error_code != EB_SUCCESS) {
        fprintf(stderr, "%s: failed to set the current subbook, %s\n",
            argv[0], eb_error_message(error_code));
        goto die;
    }

    /*「現在の外字の大きさ」を設定。*/
    if (eb_set_font(&book, EB_FONT_16) < 0) {
        fprintf(stderr, "%s: failed to set the font size, %s\n",
            argv[0], eb_error_message(error_code));
        goto die;
    }

    /* 外字の開始位置を取得。*/
    error_code = eb_narrow_font_start(&book, &font_start);
    if (error_code != EB_SUCCESS) {
        fprintf(stderr, "%s: failed to get font information, %s\n",
            argv[0], eb_error_message(error_code));
        goto die;
    }

    i = font_start;
    for (;;) {
        /* 外字のビットマップデータを取得。*/
	error_code = eb_narrow_font_character_bitmap(&book, i,
	    (char *)bitmap);
	if (error_code != EB_SUCCESS) {
            fprintf(stderr, "%s: failed to get font data, %s\n",
                argv[0], eb_error_message(error_code));
            goto die;
        }

	/* ビットマップをアスキーアートにして出力。*/
	printf("code point=%04x\n", i);
	for (j = 0; j < 16; j++) {
	    fputc((bitmap[j] & 0x80) ? '*' : ' ', stdout);
	    fputc((bitmap[j] & 0x40) ? '*' : ' ', stdout);
	    fputc((bitmap[j] & 0x20) ? '*' : ' ', stdout);
	    fputc((bitmap[j] & 0x10) ? '*' : ' ', stdout);
	    fputc((bitmap[j] & 0x08) ? '*' : ' ', stdout);
	    fputc((bitmap[j] & 0x04) ? '*' : ' ', stdout);
	    fputc((bitmap[j] & 0x02) ? '*' : ' ', stdout);
	    fputc((bitmap[j] & 0x01) ? '*' : ' ', stdout);
	    fputc('\n', stdout);
	}
	fputs("--------\n", stdout);

        /* 外字の文字番号を一つ進める。*/
	error_code = eb_forward_narrow_font_character(&book, 1, &i);
	if (error_code != EB_SUCCESS)
	    break;
    }
        
    /* 書籍と EB ライブラリの利用を終了。*/
    eb_finalize_book(&book);
    eb_finalize_library();
    exit(0);

    /* エラー発生で終了するときの処理。*/
  die:
    eb_finalize_book(&book);
    eb_finalize_library();
    exit(1);
}
Пример #4
0
/*------------------------------------------------------------------------
-- Name: init
--
-- Description:
--   Initialize EB Lib, set hooks, open the desired subbook.
--
-- Parameters:
--   None.
--
-- Returns:
--   None.
--
------------------------------------------------------------------------*/
static void init(void)
{
    EB_Error_Code error_code;
    EB_Subbook_Code subbook_list[EB_MAX_SUBBOOKS];
    FILE *out_file = NULL;
    int subbook_count;

    /* Blank the output file */
    out_file = fopen(out_path, "w");

    if(out_file == NULL)
    {
        fprintf(stderr, "Error: Could not open output file, \"%s\"\n", out_path);
        die(1);
    }

    fclose(out_file);

    /* Init EB Lib */
    eb_initialize_library();
    eb_initialize_book(&book);
    eb_initialize_hookset(&hookset);

    /* Set hooks */
    eb_set_hook(&hookset, &hook_narrow_font);
    eb_set_hook(&hookset, &hook_wide_font);

    if(set_emphasis_hook)
    {
        eb_set_hook(&hookset, &hook_begin_emphasis);
        eb_set_hook(&hookset, &hook_end_emphasis);
    }

    if(set_keyword_hook)
    {
        eb_set_hook(&hookset, &hook_begin_keyword);
        eb_set_hook(&hookset, &hook_end_keyword);
    }

    if(set_reference_hook)
    {
        eb_set_hook(&hookset, &hook_begin_reference);
        eb_set_hook(&hookset, &hook_end_reference);
    }

    if(set_subscript_hook)
    {
        eb_set_hook(&hookset, &hook_begin_subscript);
        eb_set_hook(&hookset, &hook_end_subscript);
    }

    if(set_superscript_hook)
    {
        eb_set_hook(&hookset, &hook_begin_superscript);
        eb_set_hook(&hookset, &hook_end_superscript);
    }

    /* Open the EPWING book */
    error_code = eb_bind(&book, book_path);

    if(error_code != EB_SUCCESS)
    {
        fprintf(stderr, "Error: Failed to bind the book, %s: %s\n", eb_error_message(error_code), book_path);
        die(1);
    }

    /* Get the subbook list */
    error_code = eb_subbook_list(&book, subbook_list, &subbook_count);

    if(error_code != EB_SUCCESS)
    {
        fprintf(stderr, "Error: Failed to get the subbbook list, %s\n", eb_error_message(error_code));
        die(1);
    }

    /* Get the subbook */
    error_code = eb_set_subbook(&book, subbook_list[subbook_index]);

    if(error_code != EB_SUCCESS)
    {
        fprintf(stderr, "Error: Failed to set the current subbook, %s\n", eb_error_message(error_code));
        die(1);
    }

    /* Get the subbook directory (the name only, not the full path) */
    error_code = eb_subbook_directory(&book, subbook_directory);

    if(error_code != EB_SUCCESS)
    {
        fprintf(stderr, "Error: Failed to get the subbook directory: %s\n", eb_error_message(error_code));
        die(1);
    }

    /* Set the font */
    if (eb_set_font(&book, EB_FONT_16) < 0)
    {
        fprintf(stderr, "Error: Failed to set the font size: %s\n", eb_error_message(error_code));
        die(1);
    }

} /* init */