/*------------------------------------------------------------------------ -- Name: die -- -- Description: -- Cleanup resources and exit. -- -- Parameters: -- (IN) exit_code - The exit code to use. -- -- Returns: -- None. -- ------------------------------------------------------------------------*/ static void die(int exit_code) { eb_finalize_book(&book); eb_finalize_library(); eb_finalize_hookset(&hookset); exit(exit_code); } /* die */
void uim_eb_close (void) { eb_finalize_library(); }
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); }
int main(int argc, char *argv[]) { EB_Error_Code error_code; EB_BookList bl; int book_count; char *name, *title; int i; /* コマンド行引数をチェック。*/ if (argc != 2) { fprintf(stderr, "Usage: %s book-path remote-access-identifier\n", argv[0]); exit(1); } /* EB ライブラリと `bl' を初期化。*/ eb_initialize_library(); eb_initialize_booklist(&bl); /* EBNET サーバを `bl' に結び付ける。*/ error_code = eb_bind_booklist(&bl, argv[1]); if (error_code != EB_SUCCESS) { fprintf(stderr, "%s: failed to bind the EBNET server, %s: %s\n", argv[0], eb_error_message(error_code), argv[1]); goto die; } /* サーバ上の書籍、appendix の個数を取得。*/ error_code = eb_booklist_book_count(&bl, &book_count); if (error_code != EB_SUCCESS) { fprintf(stderr, "%s: failed to get the number of books, %s\n", argv[0], eb_error_message(error_code)); goto die; } for (i = 0; i < book_count; i++) { /* 書籍、appendix の名称を取得。*/ error_code = eb_booklist_book_name(&bl, i, &name); if (error_code != EB_SUCCESS) { fprintf(stderr, "%s: failed to get book name #%d, %s\n", argv[0], i, eb_error_message(error_code)); goto die; } /* 書籍、appendix の題名を取得。*/ error_code = eb_booklist_book_name(&bl, i, &title); if (error_code != EB_SUCCESS) { fprintf(stderr, "%s: failed to get book title #%d, %s\n", argv[0], i, eb_error_message(error_code)); goto die; } printf("%-20s %s\n", name, title); } /* `bl' と EB ライブラリの利用を終了。*/ eb_finalize_booklist(&bl); eb_finalize_library(); exit(0); /* エラー発生で終了するときの処理。*/ die: eb_finalize_booklist(&bl); eb_finalize_library(); exit(1); }
int main(int argc, char *argv[]) { EB_Error_Code error_code; EB_Appendix app; EB_Subbook_Code subbook_list[EB_MAX_SUBBOOKS]; int subbook_count; int subbook_index; int alt_start; char text[EB_MAX_ALTERNATION_TEXT_LENGTH + 1]; int i; /* コマンド行引数をチェック。*/ if (argc != 3) { fprintf(stderr, "Usage: %s appendix-path subbook-index\n", argv[0]); exit(1); } /* EB ライブラリと `app' を初期化。*/ eb_initialize_library(); eb_initialize_appendix(&app); /* appendix を `app' に結び付ける。*/ error_code = eb_bind_appendix(&app, argv[1]); if (error_code != EB_SUCCESS) { fprintf(stderr, "%s: failed to bind the app, %s: %s\n", argv[0], eb_error_message(error_code), argv[1]); goto die; } /* 副本の一覧を取得。*/ error_code = eb_appendix_subbook_list(&app, subbook_list, &subbook_count); if (error_code != EB_SUCCESS) { fprintf(stderr, "%s: failed to get the subbook list, %s\n", argv[0], eb_error_message(error_code)); goto die; } /* 副本のインデックスを取得。*/ subbook_index = atoi(argv[2]); /*「現在の副本 (current subbook)」を設定。*/ if (eb_set_appendix_subbook(&app, subbook_list[subbook_index]) < 0) { fprintf(stderr, "%s: failed to set the current subbook, %s\n", argv[0], eb_error_message(error_code)); goto die; } /* 外字の開始位置を取得。*/ error_code = eb_narrow_alt_start(&app, &alt_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 = alt_start; for (;;) { /* 外字の代替文字列を取得。*/ error_code = eb_narrow_alt_character_text(&app, i, text); 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("%04x: %s\n", i, text); /* 外字の文字番号を一つ進める。*/ error_code = eb_forward_narrow_alt_character(&app, 1, &i); if (error_code != EB_SUCCESS) break; } /* appendix と EB ライブラリの利用を終了。*/ eb_finalize_appendix(&app); eb_finalize_library(); exit(0); /* エラー発生で終了するときの処理。*/ die: eb_finalize_appendix(&app); eb_finalize_library(); exit(1); }
int main(int argc, char *argv[]) { EB_Error_Code error_code; char out_path[PATH_MAX + 1]; char book_path[PATH_MAX + 1]; char subbook_name_list[EB_MAX_SUBBOOKS][EB_MAX_DIRECTORY_NAME_LENGTH + 1]; int subbook_name_count = 0; int ch; invoked_name = argv[0]; strcpy(out_path, DEFAULT_OUTPUT_DIRECTORY); /* * Initialize locale data. */ #ifdef ENABLE_NLS #ifdef HAVE_SETLOCALE setlocale(LC_ALL, ""); #endif bindtextdomain(TEXT_DOMAIN_NAME, LOCALEDIR); textdomain(TEXT_DOMAIN_NAME); #endif /* * Initialize `book'. */ error_code = eb_initialize_library(); if (error_code != EB_SUCCESS) { fprintf(stderr, "%s: %s\n", invoked_name, eb_error_message(error_code)); goto die; } /* * Parse command line options. */ for (;;) { ch = getopt_long(argc, argv, short_options, long_options, NULL); if (ch == -1) break; switch (ch) { case 'h': /* * Option `-h'. Display help message, then exit. */ output_help(); exit(0); case 'o': /* * Option `-o'. Output files under DIRECOTRY. * The length of the file name * "<out_path>/catalogs.bak;1" * must not exceed PATH_MAX. */ if (PATH_MAX < strlen(optarg)) { fprintf(stderr, _("%s: too long output directory path\n"), invoked_name); exit(1); } strcpy(out_path, optarg); canonicalize_path(out_path); if (PATH_MAX < strlen(out_path) + (1 + EB_MAX_DIRECTORY_NAME_LENGTH + 6)) { fprintf(stderr, _("%s: too long output directory path\n"), invoked_name); goto die; } break; case 'S': /* * Option `-S'. Specify target subbooks. */ if (parse_subbook_name_argument(invoked_name, optarg, subbook_name_list, &subbook_name_count) < 0) exit(1); break; case 'v': /* * Option `-v'. Display version number, then exit. */ output_version(program_name, program_version); exit(0); default: output_try_help(invoked_name); goto die; } } /* * Check the number of rest arguments. */ if (1 < argc - optind) { fprintf(stderr, _("%s: too many arguments\n"), invoked_name); output_try_help(invoked_name); goto die; } /* * Set a book path. */ if (argc == optind) strcpy(book_path, DEFAULT_BOOK_DIRECTORY); else strcpy(book_path, argv[optind]); if (is_ebnet_url(book_path)) { fprintf(stderr, "%s: %s\n", invoked_name, eb_error_message(EB_ERR_EBNET_UNSUPPORTED)); goto die; } canonicalize_path(book_path); if (PATH_MAX < strlen(book_path) + (1 + EB_MAX_DIRECTORY_NAME_LENGTH + 6)) { fprintf(stderr, _("%s: too long book directory path\n"), invoked_name); goto die; } /* * Set signals. */ #ifdef SIGHUP signal(SIGHUP, trap); #endif signal(SIGINT, trap); #ifdef SIGQUIT signal(SIGQUIT, trap); #endif #ifdef SIGTERM signal(SIGTERM, trap); #endif /* * Refile a catalog. */ if (refile_book(out_path, book_path, subbook_name_list, subbook_name_count) < 0) goto die; eb_finalize_library(); return 0; /* * A critical error occurs... */ die: eb_finalize_library(); exit(1); }