commit 5497a76516340fd01241a465d3a9e17d788a4cc3 Author: Alex Yatskov Date: Fri Oct 28 20:02:30 2016 -0700 Initial commit diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..99a23db --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Motoyuki Kasahara diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..46b46ec --- /dev/null +++ b/COPYING @@ -0,0 +1,23 @@ +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the name of the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..a201280 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,582 @@ +2010-03-08 Motoyuki Kasahara + + * Version 4.4.3. + + * configure.ac (AC_INIT): Set version to 4.4.3. + * eb/ebnet.c (ebnet_open): Use _atoi64() or atol(), when atoll() + is not available. + * configure.ac (LIBEB_VERSION_INFO): + EB Library verison 4.2.2 sets LIBEB_VERSION_INFO to 15:0:2, + but it is wrong. To avoid the confusion, I decide to update + LIBEB_VERSION_INFO to 16:0:0. + +2010-01-16 Motoyuki Kasahara + + * Version 4.4.2. + + * eb/readtext.c (eb_read_text_internal): In the escape sequence + 0x1c and 0x1d sections, separate EBXA-C codes from others. + +2010-01-03 Motoyuki Kasahara + + * configure.ac (AC_INIT): Set version to 4.4.2. + * configure.ac (LIBEB_VERSION_INFO): Set LIBEB_VERSION_INFO to 15:0:2. + + * ebzip/speedup.c (ebzip_set_zip_speedup): + Add missing ebzip_close() and ebzip_finalize() calls for zio. + * ebzip/ebzip.c (main): Don't call(1) just after unzip_book(). + * ebzip/copyfile.c (ebzip_copy_file): Don't copy a file in + case of test mode. + + * ebzip/unlinkfile.c: New file. + * ebzip/Makefile.am (ebzip_SOURCES): Add unlinkfile.c + * ebzip/zipfile.c (ebzip_zip_file): Don't call unlink() directly + for an input file. Call unlink_files_add() instead. + * ebzip/unzipfile.c (ebzip_unzip_file): Likewise. + * ebzip/copyfile.c (ebzip_copy_file): Likewise. + +2009-05-02 Motoyuki Kasahara + + * eb/text.h (EB_HOOK_BEGIN_UNICODE, EB_HOOK_END_UNICODE, + EB_HOOK_BEGIN_EBXAC_GAIJI, EB_HOOK_END_EBXAC_GAIJI, + EB_HOOK_EBXAC_GAIJI): Added. + * eb/defs.h (EB_NUMBER_OF_HOOKS): Defined as 54. + * eb/defs.h (EB_Text_Context_Struct): Add `ebxac_gaiji_flag'. + * eb/readtext.c (eb_read_text_internal): Also recognize escape + sequences 0x0b, 0x0c, 0x1c and 0x1d. + +2009-03-14 Motoyuki Kasahara + + * Version 4.4.1. + + * configure.ac (AC_INIT): Set version to 4.4.1. + * configure.ac (LIBEB_VERSION_INFO): Set LIBEB_VERSION_INFO to 14:0:1. + + * eb/binary.c (eb_set_binary_mono_graphic, eb_set_binary_gray_graphic, + eb_set_binary_wave, eb_set_binary_color_graphic): Apply large + file support patch by Kazuhiro Ito. + +2009-02-28 Motoyuki Kasahara + + * Version 4.4. + + * configure.ac (AC_CHECK_FUNCS): Also checks atoll() and _atoi64(). + * eb/ebnet.c (ebnet_open, ebnet_lseek, ebnet_read): + Support large files. + * eb/multiplex.c (EBNet_Socket_Entry_Struct, ebnet_get_file_size): + Likewise. + * eb/ebnet.h: Likewise. + +2009-01-29 Motoyuki Kasahara + + * Version 4.4. + + * eb/zio.c (zio_open_ebzip): Always set zio->code to ZIO_EBZIP1, + regardless of ebzip-mode value in an EBZIP header. + + * ebzip/zipfile.c (ebzip_zip_file_internal): Improve compression + progress messages. Don't output a message with the same percent + as the previous. + * ebzip/unzipfile.c (ebzip_unzip_file_internal): Also improve + uncompression messages. + + * ebzip/zipbook.c (ebzip_zip_book_eb, ebzip_zip_book_epwing): + Output an error message when make_missing_directory() fails. + * ebzip/unzipbook.c (ebzip_unzip_book_eb, ebzip_unzip_book_epwing): + Ditto. + * ebzip/copyfile.c (ebzip_copy_files_in_directory): Ditto. + +2009-01-23 Motoyuki Kasahara + + * INSTALL: Describe `--enable-largefile' option of configure. + + * eb/subbook.c (eb_set_subbook): If eb_set_subbook_eb() or + eb_set_subbook_epwing() returns -1, also this function returns -1. + + * ebzip/zipbook.c (ebzip_zip_book_eb, ebzip_zip_book_epwing): + Output a warning mesage when eb_load_all_subbooks() fails. + * ebzip/unzipbook.c (ebzip_unzip_book_eb, + ebzip_unzip_book_epwing): Ditto. + * ebzip/zipinfobook.c (ebzip_zipinfo_book_eb, + ebzip_zipinfo_book_epwing): Ditto. + + * ebzip/zipfile.c (ebzip_zip_file_internal): Don't output + strerror(errno) in an error message when zio_open(), zio_lseek() or + zio_read() fails, since errno may be 0. + * ebzip/unzipfile.c (ebzip_unzip_file_internal): Likewise. + * ebzip/sppedup.c (ebzip_zipinfo_file_internal): Likewise. + +2009-01-08 Motoyuki Kasahara + + * configure.ac (AC_INIT): Set version to 4.4. + * configure.ac (EB_VERSION_MINOR): Set EB_VERSION_MINOR to 4. + * configure.ac (LIBEB_VERSION_INFO): Set LIBEB_VERSION_INFO to 13:0:0. + + * configure.ac (eb_SYS_LARGEFILE): Added. + * m4/largefile.m4: New file. It defines macros to check + large file support. + + * m4/libtool.m4, m4/m4/ltdl.m4, m4/ltoptions.m4, m4/ltsugar.m4, + m4/ltversion.m4, m4/lt~obsolete.m4, ltmain.sh, config.guess, + config.sub: Import from libtool-2.2.6. + + * depcomp, missing, compile, install-sh: Import from Autoconf-1.63. + * po-eb/Makefile.in, po-ebutils/Makefile.in (datarootdir): + Set `datarootdir' macro. + + * m4/eb.m4 (AC_C_CONST, AC_C_PROTOTYPES, AC_HEADER_TIME): + Don't call those obsolete macros any longer. + + * po-ep/Makefile.in, po-ebutils/Makefile.in (datarootdir): Defined. + +2009-01-07 Motoyuki Kasahara + + * eb/build-post.h.in (off_t_is_large): New macro. + * eb/zio.c (off_t_is_large): Likewise. + + * ebzip/zipinfofile.c, ebzip/sebxa.c, ebzip/zipfile.c, + ebzip/speedup.c, ebzip/unzipfile.c, ebzip/copyfile.c: + Support large files (over 2GB). + + * eb/narwfont.c, eb/zio.c, eb/subbook.c, eb/readtext.c, eb/binary.c, + eb/appsub.c, eb/multi.c, eb/search.c: Likewise. + +2008-12-25 Motoyuki Kasahara + + * Version 4.3.3. + + * configure.ac (AC_INIT): Set version to 4.3.4. + + * m4/gettext.m4 (eb_GNU_GETTEXT): Fix a bug of iconv() and + iconv_open() checks. Don't add '-liconv' to LIBS at all times. + +2008-09-29 Motoyuki Kasahara + + * Version 4.3.3. + + * configure.ac (AC_INIT): Set version to 4.3.3. + * configure.ac (LIBEB_VERSION_INFO): Set it to 12:7:0. + * ltmain.sh, m4/libtool.m4, config.guess, config.sub: Import from + libtool-1.5.26. + +2008-09-17 Motoyuki Kasahara + + * eb/Makefile.am (libeb_la_LDFLAGS): Add `-no-undefined' option + Add $(ZLIBLIBS) and $(INTLLIBS) arguments. + * ebzip/Makefile.am (ebzip_LDADD): Exchange the order of + $(LIBEBUTILS) and $(LIBEB). + +2008-02-04 Motoyuki Kasahara + + * ebzip/zipinfofile.c (ebzip_zipinfo_file_internal): Don't close + `in_file' directly. On Windows, it raises an exception. + +2008-01-28 Motoyuki Kasahara + + * Version 4.3.2. + + * configure.ac (LIBEB_VERSION_INFO): Set it to 12:6:0. + In EB Library version 4.3.1, LIBEB_VERSION_INFO is set to 12:4:1, + but it is incorrect. It would be 12:5:0. + + * po-ebutils/ja.po: Add a missing space to a msgstr corresponding + to the msgid "image-menu ". + +2008-01-14 Motoyuki Kasahara + + * Version 4.3.1. + + * ltmain.sh, config.sub, config.guess: Imported from libtool-1.5.24. + +2007-02-13 Motoyuki Kasahara + + * ltmain.sh, config.sub, config.guess: Imported from libtool-1.5.22. + + * eb/multiplex.c (ebnet_set_book_name): Fix a buffer overrun bug. + * eb/binary.c (eb_set_binary_mpeg): Fix a bug that it doesn't + compose a movie file name correctly. + * eb/book.c (misleaded_book_table): Add Panasonic KX-EBP2 accessories. + +2006-08-31 Motoyuki Kasahara + + * Version 4.3. + + * configure.ac (LIBEB_VERSION_INFO): Set it to 12:4:0. + * configure.ac (AC_INIT): Set version to 4.3.0. + * configure.ac (EB_VERSION_MINOR): Set it to 3. + + * eb/subbook.c (eb_load_subbook_indexes): Support for image menu, + contributed by Kazuhiro Ito. + * eb/readtext.c (eb_read_text_internal): Ditto. + * eb/readtext.c (EB_MAX_ARGV): Change the value from 6 to 7. + * eb/text.h (EB_HOOK_BEGIN_IMAGE_PAGE, EB_HOOK_END_IMAGE_PAGE, + EB_HOOK_BEGIN_CLICKABLE_AREA, EB_HOOK_END_CLICKABLE_AREA): + Add the four hooks. + * eb/menu.c (eb_have_image_menu, eb_image_menu): New functions. + * eb/defs.h (EB_NUMBER_OF_HOOKS): Change the value from 45 to 49. + * eb/defs.h (EB_Subbook_Struct): Add the member `image_menu'. + * ebinfo/ebinfo.c (output_information): Also display "image-menu". + +2006-06-20 Motoyuki Kasahara + + * Makefile.am (EXTRA_DIST): Add `ChangeLog.2'. + + * ebappendix/ebappendix.in: Use `File::Basename' module. + * ebappendix/ebappendix.in: Specify `my' modifier to local variables. + * ebappendix/ebappendix.in: Use reference (\$var, \@array and \%hash) + instead of alias (*name). + + * ebzip/ebunzip.c (ebzip_unzip_book_eb): Fix a bug that `ebunzip + --test' rewrites START files. + + * eb/zio.c (zio_unzip_slice_sebxa): Fix a bug in the uncompression + algorithm. + +2006-06-16 Motoyuki Kasahara + + * eb/subbook.c (eb_set_subbook_epwing): Fix a bug that EB + cannot initialize a book if a subbook has stream data only + and the subbook shares `data' sub-directory with another + subbook. + + * libebutils/strlist.c, libebutils/strlist.h: New file. + * libebutils/Makefile.am (libebutils_a_SOURCES): Add strlist.c. + * libebutils/Makefile.am (dist_noinst_HEADERS): Add strlist.h. + * ebzip/zipbook.c (ebzip_zip_book_eb, ebzip_zip_book_epwing): + Use `String_List' to avoid compressing a file twice. + * ebzip/unzipbook.c (ebzip_unzip_book_eb, ebzip_unzip_book_epwing): + Ditto. + +2006-05-15 Motoyuki Kasahara + + * ebappendix/ebappendix.in: Fix a bug that ebappendix creates + an appendix in EB style even when it reads `catalogs.app'. + +2005-11-26 Motoyuki Kasahara + + * Version 4.2.2. + + * ltmain.sh, config.sub, config.guess, depcomp, install-sh: + Imported from libtool-1.5.20 and Automake-1.9.6. + + * m4/lcmessage.m4, m4/gettext.m4, m4/sockaddrin6.m4, m4/in6addr.m4, + m4/sockinttypes.m4, configure.ac: Substitute AC_TRY_COMPILE, + AC_TRY_LINK and AC_TRY_RUN with AC_COMPILE_IFELSE, AC_LINK_IFELSE + and AC_RUN_IFELSE. + +2005-11-21 Motoyuki Kasahara + + * m4/gettext.m4: Check for existance of libintl and libiconv even + when `--with-gettext-libraries' or `--with-iconv-libraries' option + is not specified. + * m4/gettext.m4: Do not perform AC_TRY_RUN to check for gettext(). + We perform AC_TRY_LINK instead. On Debian Linux, the test program + doesn't succeed though gettext() is available. The test program + called setlocale(LC_ALL, "en_US") but it didn't change the locale + to `en' or `en_US' since "en_US" is not acceptable locale name on + that environment. + * gttest.po, gttest.mo: Deleted. + * Makefile.am (EXTRA_DIST): Likewise. + +2005-11-20 Motoyuki Kasahara + + * eb/binary.c (eb_set_binary_wave): Fix a bug that it set wrong + wave data size to `context'. + * eb/binary.c (eb_set_binary_wave): Fix a bug that it generated + wrong RIFF header when the CD-ROM book provided fmt block of the + wave data. + + * eb/multiplex.c (ebnet_get_addresses): Retry getnameinfo() + without the NI_WITHSCOPEID flag if getnameinfo() with that flag + doesn't succeed. + +2005-10-25 Motoyuki Kasahara + + * eb.conf.in (EBCONF_ENABLE_NLS): Fix a bug that Makefile filled + an incorrect value. + * Makefile.am (eb.conf): Likewise. + + * eb/book.c (eb_load_catalog_epwing): When EPWING version is 1, + the function never read an extra information block. + +2005-09-16 Motoyuki Kasahara + + * eb/book.c (eb_load_catalog_epwing): Fix a bug that it sometimes + raises an error when the catalog file doesn't have extra information + block. + +2005-09-08 Motoyuki Kasahara + + * eb/search.c (eb_and_hit_lists): Fix a bug that it outputs + a wrong debug mesasge at the end of the function. + +2005-08-14 Motoyuki Kasahara + + * Version 4.2.1. + + * eb/book.c (eb_load_catalog_epwing): Fix a bug that EB Library + sets wrong graphic and sound file names if target subbook contains + graphic and/or sound data in a text file. + + * eb/book.c (eb_load_catalog_epwing): Correct a debug message + that shows EB_ERR_FAIL_READ_CAT error. + +2005-05-29 Motoyuki Kasahara + + * Version 4.2. + + * eb/book.c (eb_load_catalog_epwing): Fix a bug that EB Library + sets wrong graphic and sound file names if target subbook has + HONMON2 only. + + * eb/binary.c (eb_set_binary_wave): Fix a bug that the function + appends "fmt " to the wave data mistakenly. + +2005-04-18 Motoyuki Kasahara + + * ltmain.sh, config.guess, config.sub, install-sh, m4/libtool.m4: + Import from libtool 1.5.18. + +2005-04-10 Motoyuki Kasahara + + * eb/build-post.h.in (EB_TEXT_TEXT): Renamed to EB_TEXT_MAIN_TEXT. + * eb/ebinfo.c: Support `Cross Search'. + + * eb/multiplex.c (ebnet_create_new_connection): Set stream socket + to non-blocking I/O mode. + +2005-03-20 Motoyuki Kasahara + + * eb/binary.c (eb_read_binary_mono_graphic, + eb_read_binary_gray_graphic): Fix the 2nd argument to zio_lseek(). + `line_length * -2' must be `(off_t)line_length * -2' since + `line_length' is `size_t' which is usually unsigned integral type. + +2005-02-05 Motoyuki Kasahara + + * eb/multi.c (eb_initialize_multi_searches, + eb_finalize_multi_searches): Remove the internal functions. + + * eb/defs.h (EB_Subbook_Struct): Add the member `cross'. + * eb/defs.h (EB_MAX_CROSS_ENTRIES): Defined. + * eb/build-post.h.in (EB_SEARCH_CROSS): Defined. + * eb/Makefile.am (libeb_la_SOURCES): Add `cross.c'. + * eb/cross.c: New file. + * eb/search.c (eb_initialize_searches, eb_hit_list): Support for + cross search. + * eb/subbook.c (eb_load_subbook_indexes): Ditto. + + * eb/filename.c (eb_compose_movie_path_name): New function. + + * configure.ac (AC_CONFIG_SUBDIRS): Remove `zlib'. + * Makefile.am (SUBDIRS): Remove $(ZLIB_SUBDIR). + +2005-01-29 Motoyuki Kasahara + + * ebrefile/ebrefile.c (copy_file, refile_book): `ebrefile' + preserves an original catalog file in an output directory as + "catalogs.old" and then it overwrites the original catalog file. + +2004-12-05 Motoyuki Kasahara + + * Version 4.1.3. + + * po-eb/Makefile.in, po-ebutils/Makefile.in (mkinstalldirs): + Defined as `$(install_sh) -d'. + * po-eb/Makefile.in, po-ebutils/Makefile.in (install_sh): + Defined as `@install_sh@'. + + * configure.ac (LIBEB_VERSION_INFO): Set it to 9:1:0. + * configure.ac (AC_INIT): Set version to 4.1.3. + +2004-11-28 Motoyuki Kasahara + + * Version 4.1.2. + + * ebzip/ebzip.c (main): Also recognize `\' as a path separator when + DOS_FILE_PATH is defined. + + * po-eb/Makefile.in, po-ebutils/Makefile.in (mkinstalldirs): + Defined as `$(SHELL) $(top_srcdir)/mkinstalldirs'. + It was defined as `$(mkdir_p)', but it causes cycric reference + on FreeBSD-5.3-RELEASE. + + * eb/readtext.c (eb_seek_text): Accept position whose offset is + greater than or equal to EB_SIZE_PAGE. + * eb/binary.c (eb_set_binary_mono_graphic, eb_set_binary_gray_graphic, + eb_set_binary_wave, eb_set_binary_color_graphic, eb_set_binary_mpeg): + Don't accept position whose offset is less than 0. + +2004-11-22 Motoyuki Kasahara + + * eb/search.c (eb_hit_list_word, eb_hit_list_keyword, + eb_hit_list_multi): Fix a historical bug that EB Library cannot + find matched entries in particular books. + + * eb/eb.c (eb_initialize_library): In debug mode, EB Library + displays its version number. + + * eb/searh.c (eb_presearch_word, eb_hit_list_word, + eb_hit_list_keyword, eb_hit_list_multi): The debug messages also + outputs index page number. + +2004-10-24 Motoyuki Kasahara + + * Version 4.1.1. + + * libebutils/getopt.c: Fix a bug in getopt_long(). + It may abort when it outputs the message "option `--xxx' requires + an argument". + + * eb/readtext.c (eb_write_text_byte2): Fix a bug that the function + writes incorrect data on the text buffer. + +2004-07-03 Motoyuki Kasahara + + * Version 4.1. + + * doc/Makefile.am (uninstall-hook): Defined. + * doc/Makefile.am: Fix bugs that `make all' fails when $(srcdir) + != `.'. + +2004-06-23 Motoyuki Kasahara + + * doc/Makefile.am (pkgdoc_DATA): Do not use meta characters to + specify splitted HTML files. Use `install-data-hook' instead. + +2004-05-27 Motoyuki Kasahara + + * README-ja, INSTALL-ja: Removed. + * README, INSTALL: These documents are now written in Japanese. + + * doc-ja: Directory removed. + * doc: The documents under the directory are now written in Japanese + and with HTML format. + + * Makefile.am (SUBDIRS): Delete `doc-ja'. + * configure.ac (AC_CONFIG_FILES): Ditto. + + * configure.ac (AC_ARG_WITH): Add `--with-pkgdocdir' option. + + * move-if-change: Rewrite it from scratch. + +2004-05-22 Motoyuki Kasahara + + * EB Library now adopts BSD License. + + * ebzip/zipfile.c (ebzip_zip_file_internal), + ebzip/zipbook.c (ebzip_zip_book_eb, ebzip_zip_book_epwing): + Support for partial compression. + * ebzip/speedup.c: New file. + * ebzip/Makefile.am (ebzip_SOURCES): Add `ebzip/speedup.c'. + * po-ebutils/Makefile.in (POTFILES): Ditto. + +2004-05-16 Motoyuki Kasahara + + * ebzip/sebxa.c (fix_sebxa_start): Renamed to rewrite_sebxa_start(). + * ebzip/sebxa.c (fix_sebxa_start): Fix a bug that ebzip outputs + `completed' message even when quiet flag is enabled. + +2004-05-09 Motoyuki Kasahara + + * ebzip/zipfile.c (ebzip_zip_file_internal): Output compression + result even when input is an empty file. + +2004-05-08 Motoyuki Kasahara + + * configure.ac (AC_CHECK_HEADERS): Delete `utime.h' and `sys/utime.h'. + Add `mbstring.h' instead. + * ebzip/ebzip.h (EBZIP_OVERWRITE_QUERY): Renamed to + EBZIP_OVERWRITE_CONFIRM. + + * ebzip/ebzip.c: Add `--overwrite' (-w) option. + + * ebzip/zipfile.c (ebzip_zip_file_internal): Don't abort when ebzip + fails to delete an original file. Delete an original file even when + ebzip outputs "already exists, skip the file" message. + ebzip/unzipfile.c (ebzip_unzip_file_internal): Ditto. + ebzip/copyfile.c (ebzip_copy_file): Ditto. + +2004-05-07 Motoyuki Kasahara + + * Use Automake-1.8.4 and Libtool-1.5.6. + + * configure.ac (AC_TYPE_SIGNAL, AC_STRUCT_UTIMBUF): Removed. + * configure.ac (AC_CHECK_FUNCS): Remove dup2() and utime(). + * m4/herrno.m4, m4/utimbuf,m4, m4/voidpointer.m4: Removed. + +2004-04-29 Motoyuki Kasahara + + * eb/bitmap.c (eb_bitmap_to_png): New function. + * eb/bitmap.c (eb_bitmap_to_xbm, eb_bitmap_to_xpm, eb_bitmap_to_gif, + eb_bitmap_to_bmp, eb_bitmap_to_png): They return EB_Error_Code. + * ebfont/ebfont.c: `ebfont' supports PNG format images. + + * eb/zio.c: Enlarge cache buffer, contributed by Takashi NEMOTO. + + * eb/setword.c (eb_convert_euc_jp): Fix argument order. + + * configure.ac (AC_INIT): Set version to 4.1. + * configure.ac (EB_VERSION_MINOR): Set minor version to 1. + * configure.ac (LIBEB_VERSION_INFO): Set version to 9:0:0. + + * configure.ac (AC_C_CONST, AC_C_PROTOTYPES, AC_C_VOID_POINTER, + AC_HEADER_STDC, AC_HEADER_STAT, AC_HEADER_TIME, AC_HEADER_DIRENT, + AC_FUNC_VPRINTF, AC_TYPE_OFF_T, AC_TYPE_SIZE_T): Removed. + * configure.ac (AC_CHECK_HEADERS): Remove checks for fcntl.h, + limits.h, memory.h, stdlib.h and unistd.h. + * eb/Makefile.am + * configure.ac (AC_CHECK_FUNCS): Remove checks for getcwd(), memcpy(), + memmove() and strchr(). + * configure.ac (AC_REPLACE_FUNCS): Remove checks for memset() and + strerror(). + + * eb/appendix.c, eb/appendix.h, eb/appsub.c, eb/bcd.c, eb/binary.c, + eb/binary.h, eb/bitmap.c, eb/book.c, eb/booklist.c, eb/booklist.h, + eb/build-post.h.in, eb/build-pre.h, eb/copyright.c, eb/defs.h, + eb/eb.c, eb/eb.h, eb/ebnet.c, eb/ebnet.h, eb/endword.c, eb/error.c, + eb/error.h, eb/exactword.c, eb/filename.c, eb/font.c, eb/font.h, + eb/getaddrinfo.c, eb/getaddrinfo.h, eb/hook.c, eb/jacode.c, + eb/keyword.c, eb/linebuf.c, eb/linebuf.h, eb/lock.c, eb/log.c, + eb/makeproto, eb/match.c, eb/menu.c, eb/multi.c, eb/multiplex.c, + eb/narwalt.c, eb/narwfont.c, eb/readtext.c, eb/search.c, eb/setword.c, + eb/stopcode.c, eb/strcasecmp.c, eb/subbook.c, eb/text.c, eb/text.h, + eb/urlparts.c, eb/urlparts.h, eb/word.c, eb/zio.c, eb/zio.h, + ebfont/ebfont.c, ebinfo/ebinfo.c, ebrefile/ebrefile.c, + ebstopcode/ebstopcode.c, ebzip/copyfile.c, ebzip/ebzip.c, + ebzip/ebzip.h, ebzip/ebzip1.c, ebzip/sebxa.c, ebzip/unzipbook.c, + ebzip/unzipfile.c, ebzip/zipbook.c, ebzip/zipfile.c, + ebzip/zipinfobook.c, ebzip/zipinfofile.c, libebutils/ebutils.c, + libebutils/ebutils.h.in, libebutils/getopt.c, libebutils/getopt.h, + libebutils/getumask.c, libebutils/getumask.h, libebutils/makedir.c, + libebutils/makedir.h, libebutils/puts_eucjp.c, libebutils/samefile.c, + libebutils/samefile.h, libebutils/strcasecmp.c, libebutils/yesno.c, + libebutils/yesno.h, samples/appendix.c, samples/booklist.c, + samples/disctype.c, samples/font.c, samples/initexit.c, + samples/subbook.c, samples/text.c, samples/word.c: + EB Library now assumes POSIX.1-1990 systems and requires ANSI C89 + compiler. + +2004-03-20 Motoyuki Kasahara + + * Version 4.0.1. + + * ebzip/zipfile.c, ebzip/unzipfile.c, ebzip/copyfile.c, ebzip/sebxa.c: + Output progress messages to stderr, not stdout. + + * ebzip/zipbook.c (ebzip_zip_book, ebzip_zip_book_eb, + ebzip_zip_book_epwing): Abort if ebzip_zip_file() fails. + * ebzip/unzipbook.c (ebzip_unzip_book, ebzip_unzip_book_eb, + ebzip_unzip_book_epwing): Abort if ebzip_unzip_file() or + ebzip_unzip_start_file() fails. + +2004-02-29 Motoyuki Kasahara + + * ebzip/zipinfobook.c (ebzip_zipinfo_book_epwing): Also display + movie files. + +2004-01-30 Motoyuki Kasahara + + * eb/build-pre.h, eb/defs.h, ebzip/ebzip.h (EB_P): Fix typo in + the definition of EB_P. + * eb/zio.h (ZIO_P): Likewise. diff --git a/ChangeLog.0 b/ChangeLog.0 new file mode 100644 index 0000000..f411bec --- /dev/null +++ b/ChangeLog.0 @@ -0,0 +1,1464 @@ +1999-12-03 Motoyuki Kasahara + + * Version 2.3.6. + + * eb/subbook.c (eb_initialize_indexes): Fix a bug that search + method parameters aren't set correctly. + + * eb/font.c (eb_initialize_eb_fonts): If the number of characters + in a font is 0, ignore the font entry. This fix is for "Nihongo + Goi Taikei" (EPWING, Iwanami Shoten). + * eb/font.c (eb_initialize_epwing_fonts): Likewise. + +1999-11-03 Motoyuki Kasahara + + * Version 2.3.5. + +1999-10-23 Motoyuki Kasahara + + * Version 2.3.4. + + * eb/epwunzip.c (eb_epwunzip_slice): Fix a bug that an + application dumps core when the compression ratio of a target + page is over 100%. + + * eb/appendix.h: Add missing `}' for extern "C". + +1999-10-03 Motoyuki Kasahara + + * ebrefile/ebrefile.in: When the `--version' option is specified, + don't put an empty line followed by the Copyright string. + * ebappendix/ebappendix.in: Likewise. + + * ebinfo/ebinfo.c (output_information): Add `S-EBXA' to the + string `EB/EBG/EBXA/...'. + +1999-09-04 Motoyuki Kasahara + + * Version 2.3.3. + +1999-06-20 Motoyuki Kasahara + + * Version 2.3.2. + + * Use libtool-1.3.2. + + * eb/text.c (eb_read_internal): Skip text within `1ff0H - 1ff1H', + `1ff2H - 1ff3H', ... `1ffeH - 1ffHH', not `1ff1H - 1ff2H', + `1ff3H - 1ff4H' ... `1ffdH - 1ffeH'. + +1999-04-29 Motoyuki Kasahara + + * Version 2.3. + +1999-04-24 Motoyuki Kasahara + + * Version 2.3beta2. + + * eb/subbook.c (eb_initialize_subbook): Don't access the removed + `length' member in the `EB_Search' structure. + * eb/text.c (eb_text): Likewise. Don't tell text from menu. + * eb/text.c (CONTENT_MENU): Removed. + +1999-04-17 Motoyuki Kasahara + + * eb/eb.c (eb_initialize_catalog): Change the character code + parameter of `EB Kagakugijutu Yougo Daijiten (YRRS-048)' + to JIS X 0208. + +1999-04-11 Motoyuki Kasahara + + * eb/zio.c (eb_zopen): Remove and append `.' to a filename + and try to open the file, when failed to open the file. + +1999-03-28 Motoyuki Kasahara + + * Version 2.3beta1. + + * ebinfo/ebinfo.c (output_information): Recognize the book + written in EB_CHARCODE_JISX0208_GB2312. + + * eb/text.c (eb_read_internal): Case to `unsigned char' when + assign an integral value to `*workbuf'. + + * eb/defs.h (EB_Search): Add the member `length'. + * eb/subbook.c (eb_initialize_subbook): Record not only start + pages of search methods but their index length. + * eb/text.c (CONTENT_MENU): Defined. + * eb/text.c (eb_text): Check for the content type, text or menu. + * eb/text.c (eb_read_internal): If the content type is menu, + text is fed to the application until the library meets `0x1f03'. + + * eb/eb.c (eb_initialize_catalog): Tell EB_CHARCODE_ISO8859_1 + from others, not EB_CHARCODE_JISX0208 from others. + * eb/font.c (eb_initialize_eb_fonts, + eb_initialize_epwing_fonts): Likewise. + * eb/narwalt.c(eb_narrow_alt_character_text, + eb_forward_narrow_alt_character, + eb_backward_narrow_alt_character): Likewise. + * eb/narwfont.c (eb_narrow_font_character_bitmap, + eb_forward_narrow_font_character, + eb_backward_narrow_font_character): Likewise. + * eb/widealt.c(eb_wide_alt_character_text, + eb_forward_wide_alt_character, + eb_backward_wide_alt_character): Likewise. + * eb/widefont.c (eb_wide_font_character_bitmap, + eb_forward_wide_font_character, + eb_backward_wide_font_character): Likewise. + + * eb/text.c (eb_read_internal): Recognize GB 2312 character in + EBXA-C. + * eb/text.h (EB_HOOK_GB2312): Add the hook. + * eb/text.h (EB_NUM_HOOKS): Increment. + + * eb/defs.h (EB_CHARCODE_JISX0208_GB2312): Defined. + * eb/language.c:eb_initialize_languages): Recognize EBXA-C disc. + +1999-03-07 Motoyuki Kasahara + + * Version 2.3beta0. + + * eb/ebrefile.in: Find catalog file in the same order as + ebzip does. + + * eb/zio.c (eb_zopen2): Defined. + * eb/zio.c (eb_zclose): Dispose memory for huffman nodes. + + * ebzip/ebzip.c (zip_book, unzip_book, zipinfo_book): Support + CD-ROM book compressed with EPWING compression format. + * ebzip/ebzip.c (zip_book, unzip_book, zipinfo_book): Support + CD-ROM book compressed with EPWING compression format. + * ebzip/ebzip.c (zip_file, unzip_file): Argument formats are + changed. `in_filename' are changed to `in_filename_list'. + * ebzip/ebzip.c (zipinfo_file): Argument format is changed. + `ebz_filename' and `orig_filename' are unified to `filename_list'. + * ebzip/ebzip.c (zip_file, unzip_file, zipinfo_file): Use + eb_zopen2(), eb_zlseek(), eb_zread() and eb_zclose() for input + files. + + * ebzip/ebzip.c (fix_filename, zip_file, unzip_file, zipinfo_file): + `eb_canonicalize_filename()' are called at `fix_filename()', not + elsewhere. + +1999-02-27 Motoyuki Kasahara + + * eb/zio.c (eb_read_all): Return the number of read bytes so far + when it receives an EOF. + +1999-02-26 Motoyuki Kasahara + + * eb/internal.h (EB_HUFFMAN_NODE_INTERMEDIATE, EB_HUFFMAN_NODE_LEAF8, + EB_HUFFMAN_NODE_LEAF16, EB_HUFFMAN_NODE_EOF): Defined. + +1999-02-25 Motoyuki Kasahara + + * eb/unzip1.c: Renamed to `ebunzip1.c'. + * eb/ebunzip1.c (eb_unzip_mode1): Renamed to `eb_ebunzip1_slice'. + + * ebzip/zip1.c: Renamed to `ebzip1.c'. + * ebzip/ebzip1.c (zip_mode1): Renamed to `ebzip1_slice'. + + * eb/def.h (EB_SIZE_ZIP_HEADER): Renamed to `EB_SIZE_EBZIP_HEADER'. + * eb/def.h (EB_SIZE_ZIP_MARGIN): Renamed to `EB_SIZE_EBZIP_MARGIN'. + * eb/def.h (EB_SIZE_ZIP_LEVEL): Renamed to `EB_SIZE_EBZIP_LEVEL'. + * eb/def.h (EB_ZIP_MODE1): Renamed to `EB_ZIP_EBZIP1'. + * eb/def.h (EB_ZIP_EPWING): Defined. + * eb/defs.h (EB_Huffman_Node): Defined. + * eb/defs.h (EB_Zip): Add some members for EPWING compression: + `index_location', `index_length', `frequencies_location', + `frequencies_length', `huffman_nodes' and `huffman_root'. + + * eb/zio.c (eb_zopen): Split this function into `eb_zopen()' and + `eb_zopen_ebzipped()'. + * eb/zio.c (eb_zopen): Split this function into `eb_zread()' and + `eb_zread_ebzipped()'. + * eb/zio.c (eb_zopen_epwzipped, eb_zread_epwzipped): Defined. + * eb/zio.c (eb_fix_ebzip_filename): Removed. The procedures in + this function are moved into `eb_open_ebzipped'. + +1999-02-20 Motoyuki Kasahara + + * Version 2.2.1. + + * eb/jpcode.c: Renamed to `eb/jacode.c'. + + * configure.in (AC_CYGWIN, AC_MINGW32, AC_EXEEXT, AC_OBJEXT): + Added. + * configure.in: Add AM_CONDITIONAL(EXEEXT, ...) + * ebzip/Makefile.am: add `if..else..endif' statement which + branches off according with `EXEEXT'. + + * Makefile.am: add `if..else..endif' statement which branches + off according with `ENABLE_SAMPLES'. + * Makefile.am (EXTRA_DIST): Delete files under the `samples' + and `samples-ja' directories. + * Makefile.am (SUBDIRS): Add `$(SAMPLES_SUBDIR)'. + * samples/disctype.c, samples/subbook.c, samples/word.c: + Import Japanese comments in `samples-ja/*.c' and renamed + to `*.c.in'. + * samples/Makefile.am (disctype.c, subbook.c, word.c): They + are generated from `*.c.in' files. + * samples-ja/configure.in, samples-ja/Makefile.am + samples-ja/disctype.c, samples/subbook.c, samples/word.c: + Removed. + * doc/Makefile.am (disctype.c.texi, subbook.c.texi): Generated + from `$(samplesdir)/disctype.c.in' and `$(samplesdir)/subbook.c.in'. + * doc-ja/Makefile.am (disctype.c.texi, subbook.c.texi): Likewise. + * doc-ja/Makefile.am (samplesdir): Changed to `$(srcdir)/../samples', + from `$(srcdir)/../samples-ja'. + +1999-02-11 Motoyuki Kasahara + + * ebinfo/ebinfo.c (main): Don't include . + * ebfont/ebfont.c (main): Likewise. + * ebfont/ebzip.c (main): Likewise. + + * lib/fakelog.c (set_fakelog_level): Takes a facility with + `FAKELOG_' prefix as an argument. + * lib/fakelog.h, lib/fakelog.c: Move facility macros definitions + (`FAKELOG_QUIET', `FAKELOG_EMERG' ...) from `lib/fakelog.c' to + `lib/fakelog.h'. + * lib/fakelog.c: include `syslog.h' only when `HAVE_SYSLOG_H' + is defined (for DOS and Windows). + * lib/fakelog.c (fakelog): call syslog() only when HAVE_SYSLOG + is defined (for DOS and Windows). + * configure.in (AC_CHECK_FUNCS): Add `syslog'. + * configure.in (AC_CHECK_HEADERS): Add `syslog.h'. + +1999-01-28 Motoyuki Kasahara + + * ebzip/ebzip.c (zip_book, unzip_book, zipinfo_book): + Fix eb_canonicalize_filename() calls in the `DOS_FILE_PATH' + blocks. Undefined variables were used. + +1999-01-15 Motoyuki Kasahara + + * Version 2.2. + + * eb/text.c (eb_initialize_hookset): Set hook functions + of `EB_HOOK_STOPCODE', `EB_HOOK_NARROW_JISX0208', + `EB_HOOK_NARROW_FONT' and `EB_HOOK_WIDE_FONT' + + * eb/hookset.c (eb_hook_stopcode_dummy, eb_hook_stopcode_mixed): + Now, simply call `eb_hook_stopcode'. + * eb/hookset.c (eb_hook_stopcode_mixed): Rename to + `eb_hook_stopcode'. The old version of `eb_hook_stopcode' + has overwritten. + + * eb/hookset.c (eb_hook_narrow_character_text, + eb_hook_wide_character_text, eb_hook_empty): Add three builtin + hooks. + +1999-01-10 Motoyuki Kasahara + + * eb/text.c (default_hookset, default_hookset_initialized): + Add these static variables. + * eb/text.c (eb_text, eb_heading): Initialize `default_hookset' + if it has not been initialized yet. + * eb/text.c (eb_read_internal): Use `default_hookset' when + `hookset' is `NULL'. + + * doc/Makefile.am (info_TEXINFOS): Add `eb.texi'. + * doc/Makefile.am (eb_ja_TEXINFOS): Define this macro. + * doc/Makefile.am (MOSTLYCLEANFILES): Rename to `CLEANFILES'. + * doc/Makefile.am (CLEANFILES): Add `disctype.c.texi' and + `subbook.c.texi'. + * doc/Makefile.am (EXTRA_DIST): Add `stamp-eb'. + * doc/Makefile.am (eb-ver.texi, stamp-eb): Add these targets. + + * doc-ja/Makefile.am (info_TEXINFOS): Add `eb-ja.texi'. + * doc-ja/Makefile.am (eb_ja_TEXINFOS): Define this macro. + * doc-ja/Makefile.am (MOSTLYCLEANFILES): Rename to `CLEANFILES'. + * doc-ja/Makefile.am (CLEANFILES): Add `disctype.c.texi' and + `subbook.c.texi'. + * doc-ja/Makefile.am (EXTRA_DIST): Add `stamp-eb'. + * doc-ja/Makefile.am (eb-ver.texi, stamp-eb): Add these targets. + + * Makefile.am (EXTRA_DIST): add files under the `samples' and + `samples-ja' directories. + +1998-12-12 Motoyuki Kasahara + + * Version 2.1.2. + + * ebzip/ebzip.c (zip_file, unzip_file, copy_file): Check + whether SIGHUP, SIGTERM and SIGQUIT are defined or not. + + * config.guess, config.sub, ltconfig, ltmain.sh: Use libtool + version 1.2c, taken via anonymous CVS. This version supports + FreeBSD-ELF. + + * configure.in (LIBEB_VERSION_INFO): Set it to `1:2:0'. + (The previous version was `1:1:1', but this is incorrect.) + +1998-11-13 Motoyuki Kasahara + + * Version 2.1.1. + + * eb/text.c (eb_read_internal): Update `pagebufp' and `pagerest' + before go to `at_end'. + +1998-11-09 Motoyuki Kasahara + + * eb/eb.c (eb_initialize_catalog): If the target book is a + CD-ROM of SONY DataDiscMan (DD-DR1), modify `char_code' to + JIS X 0208. + + * eb/appendix.c (eb_initialize_appendix_catalog): Raise an error + if the target appendix has no subbook. + * eb/eb.c (eb_initialize_catalog): Raise an error if the target + book has no subbook. + +1998-11-08 Motoyuki Kasahara + + * ebinfo/ebinfo.c (output_information): Output `copyright' + instead of `copyright-notice'. + +1998-11-06 Motoyuki Kasahara + + * INSTALL-ja, README-ja: Add these files. + * Makefile.am (EXTRA_DIST): Add this macro. + + * configure.in (LIBEB_VERSION_INFO): Set it to `1:1:1'. + + * eb/appsub.c (eb_initialize_all_appendix_subbooks): Examine + whether the appendix is bound or not. + * eb/subbook.c (eb_initialize_all_subbooks): Examine whether + the book is bound or not. + +1998-10-31 Motoyuki Kasahara + + * doc-ja/texinfo.tex: Use Japanized 1998-10-27 version. + * doc/texinfo.tex: Use 1998-10-27 version. + * doc-ja/Makefile.am (EXTRA_DIST): Add texinfo-ja.tex. + +1998-10-28 Motoyuki Kasahara + + * eb/font.c (eb_initialize_epwing_fonts): Close a font file + immediately and set `font_count' to 0 when an error occurs. + +1998-10-19 Motoyuki Kasahara + + * libebutils/samefile.c (is_same_file): If `DOS_FILE_PATH' + is defined, compare fields other than `st_dev' and `st_ino'. + +1998-10-08 Motoyuki Kasahara + + * eb/ebzip.c (main): Ignore case of the command name + when DOS_FILE_PATH is defined. + * eb/ebzip.c (main, zip_book, unzip_book, zipinfo_book): + Call eb_canonicalize_filename() after fix_filename(), when + DOS_FILE_PATH is defined. + * eb/ebzip.c (main): Recognize the command name `ebunzip.exe' + and `ebzipinfo.exe' when DOS_FILE_PATH is defined. + + * eb/ebzip.c (info_book): Rename it to `zipinfo_book'. + * eb/ebzip.c (info_file): Rename it to `zipinfo_file'. + +1998-10-02 Motoyuki Kasahara + + * Version 2.1. + + * eb/subbook.c (eb_initialize_indexes): Recognize an index + with the identifer 0x02 as copyright notice. + +1998-09-23 Motoyuki Kasahara + + * ebzip/ebzip.c: Add missing O_BINARY modifier to an argument + to read(). + +1998-09-17 Motoyuki Kasahara + + * eb/text.c (eb_read_internal): `0x1f53' is an escape sequence + for END-OF-SOUND, not END-OF-PICTURE. + +1998-08-21 Motoyuki Kasahara + + * ebrefile/ebrefile.in: Copy reserved area 1 (described in JIS + X 4081) in an original CATALOG(S) to a new CATALOG(S). + + * configure.in (LIBZ_INCLUDED): Rename it to `INCLUDED_FOR_LIBZ'. + * configure.in (LIBZ_DEPENDED): Rename it to `DEPENDENCIES_FOR_LIBZ'. + * configure.in (LIBZ_LDADDED): Rename it to `LDADD_FOR_LIBZ'. + +1998-08-15 Motoyuki Kasahara + + * Version 2.1beta2. + + * eb/defs.h (EB_VERSION_MINOR): Set to `1'. + (NDTPD 2.1beta0 and beta1 set wrong miner version.) + +1998-08-14 Motoyuki Kasahara + + * libebutils/getopt_long.pl (getopt_long): Set option name to '' + for a return value of a non-option argument when RETURN_IN_ORDER + mode. + +1998-08-02 Motoyuki Kasahara + + * ebzip/Makefile.am (TEXINFO_TEX): Deleted. + +1998-07-19 Motoyuki Kasahara + + * ebappendix/Makefile.am (EXTRA_DIST, ebappendix): Move + `getopt_long.in' to the `libebutils' directory. + * libebutils/Makefile.am (EXTRA_DIST): Add `getopt_long.in'. + + * eb/zio.c (eb_zread): Decrease size of `tmp_buffer'. + * eb/unzip1.c (eb_unzip_mode1): Set `avail_out' to just + `out_byte_length'. Don't add margin. + + * ebrefile/ebrefile.in, ebrefile/Makefile.am, ebrefile/getopt_long.pl: + Add these files. + * Makefile.am (SUBDIRS): Add `ebrefile'. + * configure.in (AC_OUTPUT): Add `ebrefile/Makefile'. + + * eb/ebzip.c (info_file): Output size of original files. + * eb/defs.h (EB_MAX_ZIP_LEVEL): Set to `3' (it was `2'). + +1998-07-16 Motoyuki Kasahara + + * Version 2.1beta1. + + * libebutils/samefile.c (is_same_file): Fix an expression of + inode comparion. + * ebzip/ebzip.c (main): Don't change `filename_suffix' regardless + of action mode. + * ebzip/ebzip.c (list_book): Rename to `info_book'. + * ebzip/ebzip.c (list_file): Rename to `info_file'. + * ebzip/ebzip.c (fix_output_directory): Delete the function. + * ebzip/ebzip.c (fix_output_filename): Rename to `fix_filename' + and change its interface. + + * ebzip/ebzip.c (zip_file, unzip_file): Output status messages + with more precise output byte-counts during compression/uncompression. + +1998-07-16 Motoyuki Kasahara + + * zlib/Makefile.am (EXTRA_DIST): List minimum files; `*.c' and + `*.h' sources required to build the library, and documents. + + * Import zlib-1.1.3 sources. + + * acinclude.m4 (AX_HAVE_STRUCT_UTIMBUF): Fix a message. + + * ebinfo/Makefile.am, ebfont/Makefile.am (INCLUDES): Delete + `-I$(zincludedir)'. + + * ebzip/ebzip.c (compress_book, uncompress_book): Correctly + generate filenames of HONMON files. + + * ebzip/ebzip.c (output_help): Fix miss-spelling. + +1998-07-12 Motoyuki Kasahara + + * Version 2.1beta0. + + * ebappendix/ebappendix.in: Fix option parser. + + * ebfont/ebfont.c (make_subbook_size_fonts): Omit intermedate + directories for image-names. + + * configure.in (AC_ARG_WITH): Add `--with-zlib'. + +1998-07-10 Motoyuki Kasahara + + * doc/Makefile.am (ebinfo-ver.texi, stamp-ebinfo, ebzip-ver.texi, + stamp-ebzip): Define these rules. + * doc-ja/Makefile.am (ebinfo-ver.texi, stamp-ebinfo, ebzip-ver.texi, + stamp-ebzip): Liksewise. + + * doc/Makefile.am (ebinfo_TEXINFOS, ebzip_TEXINFO): Define + these macros. + * doc-ja/Makefile.am (ebinfo_ja_TEXINFOS, ebzip_ja_TEXINFO): + Likewise. + + * doc/Makefile.am (MOSTLYCLEANFILES): Add vti.tmp. + * doc-ja/Makefile.am (MOSTLYCLEANFILES): Likewise. + + * doc/ebzip.texi: Add this file. + * doc/ebzip-ja.texi: Likewise. + * doc/Makefile.am (info_TEXINFOS): Add `ebzip.texi'. + * doc/Makefile.am (info_TEXINFOS): Likewise. + +1998-07-05 Motoyuki Kasahara + + * Makefile.am (JA_DOC_SUBDIR): Define this variable according to + `ENABLE_JA_DOC' conditinal flag. + * Makefile.am (SUBDIRS): Add `doc' and `$(JA_DOC_SUBDIR)'. + * configure.in (AC_ARG_ENABLE): Add `--with-ja-doc'. + * configure.in (AM_CONDITIONAL): Add `ENABLE_JA_DOC'. + * configure.in (AC_OUTPUT): Add `doc/Makefile' and `doc-ja/Makefile'. + + * ebinfo/Makefile.am (info_TEXINFOS, TEXINFO_TEX): Delete these + macros. + * ebinfo/ebinfo.texi: Move to `doc/ebinfo.texi'. + * doc-ja/Makefile.am: Add this file. + * doc-ja/ebinfo-ja.texi: Add this file. + * doc/Makefile.am: Likewise. + +1998-06-28 Motoyuki Kasahara + + * ebfont/ebfont.c (short_options): Define this variable and passed + to getopt_long(). + * ebinfo/ebinfo.c (longopts): Likewise. + + * ebfont/ebfont.c (longopts): Rename to `long_options'. + * ebinfo/ebinfo.c (longopts): Likewise. + +1998-06-27 Motoyuki Kasahara + + * eb/appendix.c (eb_clear_appendix), eb/eb.c (eb_clear): Call + `eb_zclear'. + * eb/appendix.c, eb/eb.c: Use `eb_read_all' instead of `read'. + * eb/appsub.c, eb/font.c, eb/keyword.c, eb/language.c, eb/message.c, + eb/multi.c, eb/narwalt.c, eb/narwfont.c, eb/search.c, eb/subbook.c, + eb/text.c, eb/widealt.c, eb/widefont.c: Use `eb_zopn', `eb_zclose', + `eb_zlseek' and `eb_zread' instead of `open', `close', `lseek' and + `read'. + + * eb/internal.h: Add declarations of the functions defined in + `unzip.c' and `zio.c'. + * eb/defs.h (EB_Appendix_Subbook, EB_Font, EB_Subbook): Add + the member `zip'. + * eb/defs.h (EB_Zip_Code, EB_Zip): Define these types. + * eb/defs.h (EB_ZIP_NONE, EB_ZIP_MODE1, EB_SIZE_ZIP_HEADER, + EB_SIZE_ZIP_MARGIN, EB_MAX_ZIP_LEVEL): Define these macros. + * eb/Makefile.am (libeb_la_SOURCES): Add `zio.c' and `unzip1.c'. + * eb/zio.c, eb/unzip1.c: Add the file. + + * Makefile.am (ZLIB_SUBDIR): Define this variable according to + `WITH_ZLIB' conditinal flag. + * Makefile.am (SUBDIRS): Add `$(ZLIB_SUBDIR)'. + * configure.in (AC_ARG_WITH): Add `--with-zlib-includes' + and `--with-zlib-libraries'. + * configure.in (AM_CONDITIONAL): Add `WITH_ZLIB'. + * configure.in (AC_CONFIG_SUBDIRS): Set as `zlib'. + + * Use libtool-1.2a. + + * eb/Makefile.am (install-data-hook): Insert $(DESTDIR) to + filenames. + + * configure.in (AC_TYPE_SIGNAL): Add this macro. + * configure.in (AC_DEFINE): Define RETSIGTYPE_VOID. + * acconfig.h: Add RETSIGTYPE_VOID. + +1998-06-23 Motoyuki Kasahara + + * ebfont/ebfont.c (main): Call output_try_help() when + an argument to `-f' or `-i' is invalid value. + +1998-06-21 Motoyuki Kasahara + + * ebfont/Makefile.am (INCLUDES): Add `-I$(zincludedir)'. + + * ebfont/Makefile.am (ebfont_LDADD): Add $(LIBZ) + * ebinfo/Makefile.am (ebinfo_LDADD): Likewise. + + * ebfont/Makefile.am (LIBZ): Set this macro. + * ebinfo/Makefile.am (LIBZ): Likewise. + + * configure.in (LIBEB_VERSION_INFO): Set to `1:1:0'. + * configure.in (AC_CONFIG_SUBDIRS): Add `zlib'. + * configure.in (AC_ARG_WITH): Add the `--with-zlib-includes' + and `--with-zlib-libraries' options. + * configure.in (AM_CONDITIONAL): Add `WITH_ZLIB'. + * configure.in (AC_SUBST): Substitute `zincludedir' and + `zlibdir'. + + * Import zlib-1.12 sources. + +1998-06-18 Motoyuki Kasahara + + * configure.in (AC_PREREQ): Set to `2.12'. + +1998-06-14 Motoyuki Kasahara + + * configure.in (AC_CHECK_FUNCS): Add `utime'. + * configure.in (AC_CHECK_HEADERS): Add `utime.h'. + + * ebappendix/ebappendix.in: Rename the option name `--filename-case' + to `--case'. + +1998-06-13 Motoyuki Kasahara + + * ebfont/ebfont.c: Include `getumask.h'. + * ebfont/ebfont.c (get_umask): Move the function to + `libebutils/getumask.c'. + * libebutils/getumask.c, libebutils/getumask.h: Add these files. + * libebutils/Makefile.am (libebutils_a_SOURCES): Add `getumask.c' + and `getumask.h'. + + * ebfont/ebfont.c (main): Check the length of an argument + to the option `-o', canonicalize the argument as an absolute + path, and then check the length of the canonicalized path + again. + +1998-06-11 Motoyuki Kasahara + + * Version 2.0.1. + + * eb/defs.h: Add `EB_SUFFIX_DOT' for an alias name to + `EB_SUFFIX_PERIOD'. + + * eb/eb.c (eb_initialize_catalog): Ignore font filenames + which beginning with a character 0x80...0xff. + * eb/filename.c (eb_catalog_filename_internal): Fix a gug; + add a suffix to a filename correctly. + +1998-06-09 Motoyuki Kasahara + + * Version 2.0. + + * eb/filename.c (eb_canonicalize_filename): Rename + `EB_ERR_TOO_LONG_FNAME' to `EB_ERR_TOO_LONG_FILENAME'. + +1998-06-07 Motoyuki Kasahara + + * ebappendix/ebappendix.in: Rename argument to the `--suffix' + (`-s') option; from `period' to `dot'. + + * ebfont/ebfont.c (longopts): Add the `--subbook' (`-S') option. + * ebfont/ebfont.c (main, help): Add the `--subbook' (`-S') option. + * ebfont/ebfont.c (make_book_fonts): Change an arugment list. + Add `subname_list' and `subname_count' arguments. + * ebfont/ebfont.c (make_fonts): Rename to `make_book_fonts'. + +1998-06-06 Motoyuki Kasahara + + * ebfont/ebfont.c (DEFAULT_FONT_HEIGHT, DEFAULT_IMAGE_FORMAT): + Define these macros as strings; "16" and "xbm". + * ebfont/ebfont.c (main): Call `parse_font_argument' with + `DEFAULT_FONT_HEIGHT' when `-f' option is not speicified. + * ebfont/ebfont.c (main): Call `parse_image_argument' with + `DEFAULT_IMAGE_HEIGHT' when `-i' option is not speicified. + +1998-06-05 Motoyuki Kasahara + + * ebfont/ebfont.c (parse_font_argument): Use `strcmp' to + check an argument instead of `strncmp'. + + * ebfont/ebfont.c: Define `DEFAULT_BOOK_DIRECTORY' and use + it rather than ".". + * ebfont/ebinfo.c: Define `DEFAULT_BOOK_DIRECTORY' and use + it rather than ".". + +1998-06-01 Motoyuki Kasahara + + * ebappendix/ebappendix.in: Use `if expr {die "..."}' intead + of `die "..." if expr' when `$!' is used in "...". + * ebappendix/ebappendix.in: Add two argument tyes `version' + and `both' to the option `-s'. + + * ebappendix/ebappendix.in (@long_options): + Rename `--check-only'(`-n') to `--test'(`-t'). + Rename `-N'(`--no-catalog') to `-n'(`--no-catalog'). + +1998-05-30 Motoyuki Kasahara + + * eb/Makefile.am (libeb_la_SOURCES): Add `unzip.c' and + `unzip-mode1.c'. + * eb/unzip.c, eb/unzip-mode1.c: Add these files. + * ebzip/Makefile.am, ebzip/zip-mode1.c, ebzip/ebzip.c: + Add these files. + * Makefile.am (SUBDIRS): Add `ebzip'. + * configure.in (AC_OUTPUT): Add `ebzip/Makefile'. + + * eb/defs.h: include `time.h' and/or `sys/time.h' according + with `TIME_WITH_SYS_TIME' and `HAVE_SYS_TIME_H'. + * configure.in: Add `AC_HEADER_TIME'. + * eb/eb.c (eb_bind): Assume that the suffix `.ebz' may be + inserted to the filename. + * eb/defs.h (EB_Appendix_Subbook, EB_Font, EB_Subbook): Add + the member `unzip'. + * eb/defs.h (EB_Zip): Define the type. + +1998-05-23 Motoyuki Kasahara + + * eb/defs.h (EB_Appendix_Subbook): + Rename `appfile' to `sub_file'. + Rename `charcode' to `char_code'. + Rename `narwstart' to `narw_start'. + Rename `widestart' to `wide_start'. + Rename `narwend' to `narw_end'. + Rename `wideend' to `wide_end'. + Rename `narwpage' to `narw_page'. + Rename `widepage' to `wide_page'. + * eb/defs.h (EB_Appendix): + Rename `pathlen' to `path_length'. + Rename `disccode' to `disc_code'. + Rename `casecode' to `case_code'. + Rename `suffixcode' to `suffix_code'. + Rename `subcount' to `sub_count'. + Rename `subcurrent' to `sub_current'. + Rename `narwcache' to `narw_cache'. + Rename `widecache' to `wide_cache'. + * eb/defs.h (EB_Font): + Rename `fontfile' to `font_file'. + * eb/defs.h (EB_Language): + Rename `msgcount' to `msg_count'. + * eb/defs.h (EB_Search): + Rename `entrycount' to `entry_count'. + * eb/defs.h (EB_Subbook): + Rename `startfile' to `sub_file'. + Rename `multicount' to `multi_count'. + Rename `fontcount' to `font_count'. + Rename `narwcurrent' to `narw_current'. + Rename `widecurrent' to `wide_current'. + * eb/defs.h (EB_Book): + Rename `disccode' to `disc_code'. + Rename `charcode' to `char_code'. + Rename `pathlen' to `path_length'. + Rename `casecode' to `case_code'. + Rename `suffixcode' to `suffix_code'. + Rename `subcount' to `sub_count'. + Rename `subcurrent' to `sub_current'. + Rename `langcount' to `lang_count'. + Rename `langcurrent' to `lang_current'. + +1998-04-29 Motoyuki Kasahara + + * Version 2.0beta1. + + * Use automake 1.3. + + * eb/appendix.h, eb/eb.h, eb/error.h, eb/font.h, eb/internal.h, + eb/language.h, eb/text.h (EB_P): Examine whether the `__cplusplus' + macro is defined or not. + + * ebappendix/getopt_long.pl: Don't use the expression like as + `($ver, $var, $var) = (0..2)'. Perl5.004_01 doesn't accept + such an expression. + + * ebappendix/ebappendix.in: Rename an option name; + `--filename-cases' to `--filename-case'. + + * texinfo.tex: Move to the sub-directory `ebinfo'. + * ebinfo/Makefile.am: Delete `TEXINFO_TEX'. + (automake-1.2 and 1.3 seems to ignore TEXINFO_TEX.) + +1998-04-14 Motoyuki Kasahara + + * ebappendix/Makefile.am (ebappendix): Concat the header part + of `ebappendix.in', `getopt_long.pl' and the body part of + `ebappendix.in' in that order to generate `ebappendix'. + +1998-04-11 Motoyuki Kasahara + + * eb/setword.c (eb_fix_word_jis): Return with the return value + EB_WORD_OTHER when a word contains kana and kanji, or contains + alphabet and kanji. + + * eb/defs.h (EB_WORD_KANJI): Rename to `EB_WORD_OTHER'. + + * eb/filename.c (eb_catalog_filename_internal): Find a catalog + file with EB_SUFFIX_VERSION style filename. + * eb/defs.h (EB_SUFFIX_VERSION): Add this cpp macro. + +1998-04-05 Motoyuki Kasahara + + * eb/setword.c (eb_fix_word_jis): Don't reject spaces. + * eb/subbook.c (eb_initialize_indexes): Initialize `search.space' + when inex style information is available. + + * eb/text.h (EB_HOOK_JISX0208): Split to `EB_HOOK_NARROW_JISX0208' + and `EB_HOOK_WIDE_JISX0208'. + + * eb/text.h (EB_HOOK_NULL): Modify its value to -1. + +1998-04-04 Motoyuki Kasahara + + * eb/font.h, eb/bitmap.c (eb_convert_bitmap_xbm, + eb_convert_bitmap_xpm, eb_convert_bitmap_gif): Rename to + `eb_bitmap_to_xbm', `eb_bitmap_to_xpm', `eb_bitmap_to_gif'. + + * eb/defs.h (EB_CHARACTER_ISO8859_1 and EB_CHARACTER_JISX0208): + Rename to `EB_CHARCODE_ISO8859_1' and `EB_CHARCODE_JISX0208'. + +1998-04-01 Motoyuki Kasahara + + * eb/eb.c (eb_initialize_catalog): Fix the character-code of + the earliest edition of `Shin Eiwa Waei Chujiten'. + +1998-03-30 Motoyuki Kasahara + + * eb/text.c (eb_read_internal): Don't use auto stop-code decision + mechanism. This mechanism cannot guess a stop-code collectly. + + * eb/appendix.c (eb_clear_appendix): Call `eb_unset_appendix_subbook' + at first, and then dispose memories asigned to `appendix->subbooks'. + +1998-03-25 Motoyuki Kasahara + + * Version 2.0beta0. + + * Use GNU libtool-1.2. + +1998-03-21 Motoyuki Kasahara + + * eb/text.c (eb_text_internal): Detect text stopcode automatically. + + * narwfont.c (eb_forward_narrow_character): Rename to + `eb_forward_narrow_font_character'. + * widefont.c (eb_forward_wide_character): Rename to + `eb_forward_wide_font_character'. + + * widealt.c (eb_have_wide_alternation, + eb_wide_alternation_start, + eb_wide_alternation_end, + eb_wide_character_text, + eb_wide_character_text_jis, + eb_wide_character_text_latin, + eb_next_wide_appendix_character, + eb_previous_wide_appendix_character): Rename to + `eb_have_wide_alt', + `eb_wide_alt_start', + `eb_wide_alt_end', + `eb_wide_alt_character', + `eb_wide_alt_character_jis, + `eb_wide_alt_character_latin, + `eb_forward_wide_alt_character', and + `eb_backward_wide_alt_character'. + * narwalt.c (eb_have_narrow_alternation, + eb_narrow_alternation_start, + eb_narrow_alternation_end, + eb_narrow_character_text, + eb_narrow_character_text_jis, + eb_narrow_character_text_latin, + eb_next_narrow_appendix_character, + eb_previous_narrow_appendix_character): Rename to + `eb_have_narrow_alt', + `eb_narrow_alt_start', + `eb_narrow_alt_end', + `eb_narrow_alt_character', + `eb_narrow_alt_character_jis, + `eb_narrow_alt_character_latin, + `eb_forward_narrow_alt_character', and + `eb_backward_narrow_alt_character'. + * appendix.c (eb_initialize_alternation_cache), appsub.c, + (eb_initialize_appendix_subbook): Rename + `eb_initialize_alternation_cache' to `eb_initialize_alt_cache'. + + * eb/search.c (eb_hit_list): Add the function. + * eb/search.c (eb_next_word, eb_next_endword): Delete these + functions. + * eb/search.c (eb_search_endword, eb_search_endword): Change + interfaces. + * eb/search.c (eb_presearch, eb_next_word_internal): + Change interfaces and rename to `eb_search_word_internal' + and `eb_hit_list_internal'. + + * eb/text.c (eb_next_text_internal): Change interface and rename + to `eb_read_internal'. + * eb/text.c (eb_text, eb_heading): Change interfaces. + These functions can be invoked repeatedly in order to get suceesive + text. + * eb/io.c (eb_read), eb/text.c: Rename `eb_read' to `eb_rawtext' + and move it to `eb/text.c'. + * eb/text.c (eb_next_text, eb_next_heading): Delete these functions. + * eb/io.c (eb_seek): Change interface. + This function is used before getting text or heading. + + * eb/setword.c (eb_fix_word_jis): Support SS2. + +1998-03-08 Motoyuki Kasahara + + * eb/narwalt.c (eb_forward_narrow_appendix_character): + Rename to `eb_forward_narrow_alternation_character'. + * eb/widealt.c (eb_forward_wide_appendix_character): + Rename to `eb_forward_wide_alternation_character'. + + * eb/narwfont.c (eb_forward_narrow_character): + Rename to `eb_forward_narrow_font_character'. + * eb/widefont.c (eb_forward_wide_character): + Rename to `eb_forward_wide_font_character'. + +1998-03-08 KSK + + * eb/filename.c (eb_canonicalize_filename): Add DOS version + of this function. + +1998-02-20 Motoyuki Kasahara + + * ebinfo/ebinfo.c (output_information): Add 2nd argument + `multiflag'. Call `output_multi_information' when `multiflag' + is non-zero. + * ebinfo/ebinfo.c (output_multi_information): Add this function. + * ebinfo/ebinfo.c (option longopts, main, outout_help): + Add the `-m' and `--multi-search' options. + +1998-02-15 Motoyuki Kasahara + + * eb/subbook.c (eb_subbook2): Add this function. + * eb/appsub.c (eb_appendix_subbook2): Add this function. + + * eb/subbook.c (eb_initialize_subbook): Get the location of + the index page from the member `page_index' in `EB_Subbook'. + * eb/eb.c (eb_initialize_catalog): Get an index page location + from the `CATALOGS' file. + * eb/internal.c (eb_uint3): Add this macro. + + * eb/multi.c (eb_initialize_multi_search, eb_multi_search_count, + eb_multi_search_list, eb_multi_entry_count, eb_multi_entry_list, + eb_multi_entry_label, eb_multi_entry_have_exactword_search, + eb_multi_entry_have_word_search, eb_multi_entry_have_endword_search, + eb_multi_entry_have_keyword_search): Add these functions. + * eb/subbook.c (eb_initialize_subbook): Call + eb_initialize_multi_search(). + * eb/error.h, eb/error.c (messages): Add new error codes + `EB_ERR_NO_SUCH_MULTI_ID' and `EB_ERR_NO_SUCH_ENTRY_ID'. + * eb/error.h: Increase EB_NUM_ERRORS. + + * eb/setword.c (eb_set_word, eb_set_endword): Fully revised. + * eb/setword.c (eb_convert_katakana_jis, eb_convert_lower_latin, + eb_convert_lower_jis, eb_delete_marks_jis, eb_convert_long_vowels_jis, + eb_delete_long_vowels_jis, eb_convert_double_consonants_jis, + eb_convert_contracted_sounds_jis, eb_convert_small_vowels_jis, + eb_convert_voiced_consonants_jis, eb_convert_p_sounds_jis, + eb_delete_spaces_jis): Add these functions. + * eb/setword.c (eb_fix_word_jis): Don't delete spaces in a + word. + * ebinfo/ebinfo.c (output_multi_information): Add this function. + +1998-02-11 Motoyuki Kasahara + + * eb/appendix.h, eb/defs.h, eb/eb.h, eb/error.h, + eb/font.h, eb/internal.h, eb/language.h, eb/text.h: + Define the cpp macro `EB_P' used at function declarations. + + * eb/Makefile.am (install-data-hook): Add this target. + + * eb/appendix.h, eb/eb.h, eb/font.h, eb/internal.h, eb/language.h, + eb/text.h: Regenerate function declarations. + + * eb/text.h (EB_UINT_FUNC): Rename to `EB_UINT_FUNCTION'. + + * eb/defs.h, eb/types.h: Merge these files and put into + `eb/defs.h'. `eb/types.h' is deleted. + + * eb/havesearch.c (eb_have_word_search, eb_have_endword_search, + eb_have_exactword_search): Move to `eb/search.c'. + * eb/havesearch.c (eb_have_keyword_search): Move to `eb/keyword.c'. + * eb/havesearch.c (eb_have_multi_search): Move to `eb/multi.c'. + * eb/havesearch.c (eb_have_grpahic_search): Move to `eb/graphic.c'. + * eb/havesearch.c (eb_have_menu): Move to `eb/menu.c'. + * eb/havesearch.c (eb_have_copyright): Move to `eb/copyright.c'. + * eb/search.c (eb_menu): Move to `eb/menu.c'. + * eb/search.c (eb_copyright): Move to `eb/copyright.c'. + + * eb/io.c (eb_seek, eb_read): Move to `eb/text.c'. + * eb/io.h: Move definitions of eb_seek() and eb_read() to + `eb/text.h' + * eb/io.c: Rename to `eb/uint.c'. + * eb/io.h: Move definitions of eb_uint1(), eb_uint2(), eb_uint4(), + eb_bcd2(), eb_bcd4() and eb_bcd6() to `text.h' and `internal.h'. + * eb/io.h: Delete this file. + +1998-01-26 Motoyuki Kasahara + + * eb/text.c (eb_text_internal, eb_text, eb_heading): + Unified the `page' and `offset' static variables, and + to `location'. In `eb_text_internal', `page' and `offset' + were not updated correctly. + +1998-01-19 Motoyuki Kasahara + + * eb/setword.c (eb_fix_word_latin): Don't ignore spaces in + a word. + + * eb/search.c (eb_search_exactword, eb_search_word, + eb_search_endword): Don't canonicalize a word if the book + is EPWING and if `page' is `EB_INDEX_WORD_ASIS'. + (temporary solution) + +1998-01-11 Motoyuki Kasahara + + * eb/Makefile.am (libeb_la_LDFLAGS): Use `@LIBEB_VERSION_INFO@' + as an argument to the `-version-info' option of libtool. + * configure.in: Add the `LIBEB_VERSION_INFO' variable and + substitute it by `AC_SUBST'. + +1998-01-10 Motoyuki Kasahara + + * eb/subbook.c (eb_initialize_subbook, eb_initialize_indexes): + Initialize `EB_Search' type members in `EB_Subbook' data at + `eb_initialize_indexes'. + + * eb/io.c (eb_seek, eb_tell, eb_read), eb/text.c (eb_heading, + eb_next_heading, eb_text, eb_next_text): Return with the error + code `EB_ERR_NO_START' when the subbook lacks a start file. + * eb/error.c, eb/error.h: Add `EB_ERR_NO_START' to the error + code list. + + * eb/narwalt.c (eb_previous_narrow_appendix_character): + Set `eb_error' to `EB_ERR_NO_CUR_APPSUB', not `EB_ERR_NO_CUR_SUB' + when the current subbook is not selected. + + * eb/io.c (eb_seek): Set `eb_error' when lseek() is failed. + + * eb/language.c (eb_initialize_languages): Close the LANGUAGE + file upon return. + + * ebappendix/getopt_long.pl (getopt_initialize), + ebappendix/ebappendix.in (long_options): + Modify option-list format of `getopt_long'. + FLAGS must be `no-argument' or `required-argument'. + +1998-01-04 Motoyuki Kasahara + + * eb/subbook.c (eb_initialize_indexes), eb/search.c + (eb_search_exactword, eb_search_word, eb_search_endword, eb_menu, + eb_copyright), havesearch.c (eb_have_word_search, + eb_have_endword_search, eb_have_keyword_search, eb_have_multi_search, + eb_have_graphic_search, eb_have_menu, eb_have_copyright): + Adapt to new `EB_Subbook' structure. + * eb/types.h (EB_Subbook): Delete the `indexes' member, and add + `word_alpha', `word_asis', `word_kana', `endword_alpha', + `endword_asis', `endword_kana', `keyword', `menu', `graphic', + `copyright', `multi' and `multicount' members. + Delete the `EB_Index_Code' type; + * eb/defs.h: Delete `EB_INDEX_WORD_KANA', `EB_INDEX_WORD_ASIS', + `EB_INDEX_WORD_ALPHA', `EB_INDEX_ENDWORD_KANA', + `EB_INDEX_ENDWORD_ASIS', `EB_INDEX_ENDWORD_ALPHA', + `EB_INDEX_KEYWORD', `EB_INDEX_MENU', `EB_INDEX_GRAPHIC' and + `EB_INDEX_MULTI'. + +1998-01-03 Motoyuki Kasahara + + * eb/havesearch.c: Rename `eb_have_menu_search' to `eb_have_menu'. + * eb/search.c: Rename `eb_search_menu' to `eb_menu'. + +1998-01-01 Motoyuki Kasahara + + * eb/match.c (eb_match_word, eb_match_exactword): + Don't ignore all spaces in a search pattern, but in the tail of + the pattern. + + * eb/narwalt.c: Rename `eb_narrow_character_text_ltn' to + `eb_narrow_character_text_latin'. + * eb/narwfont.c: Rename `eb_narrow_character_bitmap_ltn' + to `eb_narrow_character_charavter_latin'. + * eb/setword.c Rename `eb_fix_word_ltn, eb_reverse_word_ltn' + to `eb_fix_word_latin' and `eb_reverse_word_ltn'. + * eb/widealt.c: Rename `eb_wide_character_text_ltn' to + `eb_wide_character_text_latin'. + * eb/widefont.c: Rename `eb_wide_character_bitmap_ltn' + to `eb_wide_character_charavter_latin'. + + * eb/defs.h: Define `EB_INDEX_STYLE_CONVERT', `EB_INDEX_STYLE_ASIS' + and `EB_INDEX_STYLE_DELETE'. + * eb/types.h: Define the `EB_Search', `EB_Multi_Entry', + `EB_Index_Style_Code', `EB_Multi_Search_Code' and + `EB_Multi_Entry_Code' types. + * eb/types.h (EB_Subbook): Add the `index_page' member. + * eb/tyes.h (EB_Subbook): Add the `multicout' and `multi' members. + * eb/defs.h: Define `EB_MAX_MULTI_SEARCHES` and + `EB_MAX_MULTI_ENTRIES' macros. + +1997-12-31 Motoyuki Kasahara + + * ebinfo/ebinfo.texi: Add this file. + * ebinfo/Makefile.am: Define `info_TEXINFOS' as `ebinfo.texi'. + + * ebinfo/ebinfo.c (main), ebfont/ebfont.c (main): + Call `set_fakelog_name', `set_fakelog_mode' and `set_fakelog_level'. + * ebinfo/ebinfo.c: Include `fakelog.h'. + + * ebappendix/ebappendix.in: Delete the `--no-catalogs' option. + * ebappendix/ebappendix.in, ebfont/ebfont.c (main, output_help, + longopts): Add the `--verbose' option. + + * Makefile.am: Define `appendixdir' and `appendix_DATA'. + + * ebappendix/ebappendix.in, ebfont/ebfont.c (main, make_fonts, + make_subbook_fonts, make_subbook_size_fonts, + make_subbook_size_image_fonts, save_image_file), ebinfo/ebinfo.c + (main, output_information): Unify style of error messages. + + * configure.in: ebappendix/Makfile.am, ebappendix/ebappendix.in: + Set and substitute `MAILING_ADDRESS'. + + * ebappendix/ebappendix.in, ebfont/ebfont.c (output_help, + output_version), ebinfo/ebinfo.c (output_help, output_version): + Change version and help messages; output to standard rather than + standard error, add copyright and license into version message, + and add mailing address information into help message. + +1997-12-27 Motoyuki Kasahara + + * eb/appendix.c, eb/appsub.c, eb/eb.c, eb/font.c, eb/language.c, + eb/message.c, eb/subbook.c, ebfont/ebfont.c: + Define O_BINARY if not defined. + Specify `O_BINARY' at the 2nd argument of `open'. + +1997-12-21 Motoyuki Kasahara + + * eb/setword.c (eb_set_word, eb_set_endword): + Don't call `eb_canonicalize_word_jis' when the current subbook + doesn't have a KANA index table. + The current subbook must have been set to call the functions. + + * Delete the `doc/' subdirectory. + +1997-12-06 Motoyuki Kasahara + + * eb/appendix.c: Move functions related to subbook to the new + file `appsub.c'. + * eb/Makefile.am (libeb_la_SOURCES): Add `eb/appsub.c'. + + * ebinfo/Makefile.am (ebinfo_LDADD, ebinfo_DEPENDENCIES), + ebfont/Makefile.am (ebfont_LDADD, ebfont_DEPENDENCIES): + Link `../eb/libeb.la' instead of `../eb/libeb.a'. + * eb/Makefile.am: Rename `lib_LIBRARIES' to `lib_LTLIBRARIES'. + Rename `libeb_a_SOURCES' to `libeb_la_SOURCES'. + Define `libeb_la_LDFLAGS'. + * configure.in: Define `AM_PROG_LIBTOOL'. + * Get 4 files from the libtool-1.0 distribution; + `config.guess', `config.sub', `ltconfig' and `ltmain.sh'. + +1997-11-30 Motoyuki Kasahara + + * eb/error.h: + Rename `EB_ERR_TOO_LONG_FNAME' to `EB_ERR_TOO_LONG_FILENAME'. + Rename `EB_ERR_TOO_LONG_FILENAME' to `EB_ERR_TOO_EMPTY_FILENAME'. + + * eb/eb.h, eb/filename.c: + Rename `EB_FSUFFIX_NONE' to `EB_SUFFIX_NONE'. + Rename `EB_FSUFFIX_DOT' to `EB_SUFFIX_DOT'. + Rename `EB_FSUFFIX_BOTH' to `EB_SUFFIX_BOTH'. + Rename `EB_FCASE_UPPER' to `EB_CASE_UPPER'. + Rename `EB_FCASE_LOWER' to `EB_CASE_LOWER'. + Rename `EB_SIZE_EP_CATALOG' to `EB_EPWING_EB_SIZE_EPWING_CATALOG'. + Rename `EB_MAXLEN_EP_TILE' to `EB_EPWING_EB_MAXLEN_EPWING_TITLE'. + Rename `EB_FNAME_START' to `EB_FILENAME_START'. + Rename `EB_FNAME_SOUND' to `EB_FILENAME_SOUND'. + Rename `EB_FNAME_CATALOG' to `EB_FILENAME_CATALOG'. + Rename `EB_FNAME_LANGUAGE' to `EB_FILENAME_LANGUAGE'. + Rename `EB_FNAME_VTOC' to `EB_FILENAME_VTOC'. + Rename `EB_FNAME_WELCOME' to `EB_FILENAME_WELCOME'. + Rename `EB_FNAME_CATALOGS' to `EB_FILENAME_CATALOGS'. + Rename `EB_FNAME_HONMON' to `EB_FILENAME_HONMON'. + Rename `EB_FNAME_APPENDIX' to `EB_FILENAME_APPENDIX'. + Rename `EB_FNAME_FUROKU' to `EB_FILENAME_FUROKU'. + Rename `EB_CHAR_ISO8859_1' to `EB_CHARACTER_ISO8859_1'. + Rename `EB_CHAR_JISX0208' to `EB_CHARACTER_JISX0208'. + + * Delete the `utils/' sub-directory. + * utils/lib/fakelog.c, utils/lib/fakelog.h, utils/lib/getopt.c, + utils/lib/getopt.h, utils/lib/getopt1.c, utils/lib/makedir.c, + utils/lib/makedir.h, utils/lib/memset.c, utils/lib/strcasecmp.c, + utils/lib/strerror.c: Move these files to the `libebutils/' + sub-directory. + * utils/src/ebappendix.in: Move this file to the `ebappendix' sub- + directory. + * utils/src/ebinfo.c: Move this file to the `ebinfo/' sub-directory. + * utils/src/ebfont.c: Move this file to the `ebfont/' sub-directory. + * ebappendix/Makefile.am, ebinfo/Makefile.am, ebfont/Makefile.am: + Add these files. + * Makefile.am (SUBDIR): Define as `eb libebutils ebappendix ebfont + ebinfo'. + +1997-11-23 Motoyuki Kasahara + + * Version 1.0.4. + + * ebappendix/ggetopt.pl: Rename to `ebappendix/getopt_long.pl'. + + * eb/ebinfo.c (output_information): Display whether a target book + has a copyright notice or not. + + * eb/subbook.c (eb_initialize_indexes): Record an index of + multi search. eb_have_search() returns with a valid return + code, but multi search has not implemented yet. + + * eb/search.c, eb/eb.h: Add the `eb_copyright' function. + * eb/havesearch.c, eb/eb.h: Add the `eb_have_copyright' function. + + * eb/defs.h: Define `EB_INDEX_COPYRIGHT'. + + * Makefile.am: Generate dependency rules again. + + * eb/subbook.c (eb_initialize_subbook): Call `eb_initialize_fonts' + instead of `eb_initialize_eb_fonts' and `eb_initialize_epwing_fonts'. + + * eb/font.c, eb/font.h: Add the `eb_initialize_fonts' function. + + * eb/ebinfo.c (output_information), eb/ebfont.c (main): Call + `eb_bind', and then call `eb_initialize'. + * eb/eb.c (eb_bind): Call `eb_clear' rather than `eb_initialize'. + + * eb/language.c, eb/message.c: Move the functions `eb_message_count', + `eb_message_list', `eb_have_message' and `eb_message' in + `eb/language.c' to `eb/message.c'. + * eb/eb.c, eb/message.c: Move `eb_initialize_messages' in `eb/eb.c' + to `eb/message.c'. + * eb/eb.c, eb/language.c: Move `eb_initialize_language' in `eb/eb.c' + to `eb/language.c', and rename it to `eb_initialize_languages'. + * eb/eb.c, eb/font.c: Move `eb_initialize_eb_fonts' and + `eb_initialize_epwing_fonts' in `eb/eb.c' to `eb/font.c'. + * eb/eb.c, eb/subbook.c: Move `eb_initialize_subbook', + `eb_initialize_all_subbooks', and `eb_initialize_indexes' + in `eb/eb.c' to `eb/subbook.c'. + + * eb/appendix.c, eb/font.c, eb/eb.c, eb/language.c, eb/subbook.c: + Don't include `ctype.h'. + + * Add `eb/internal.h' and `eb/message.c'. + + * eb/util.c, eb/eb.c: Delete `eb/util.c'. + Move `eb_is_bound' `eb_path' and `eb_disc_type' in `eb/util.c' to + `eb/eb.c'. + * eb/init.c: Rename to `eb/eb.c'. + +1997-11-03 Motoyuki Kasahara + + * eb/text.h, text.c (eb_text_internal): Delete the hook + `EB_HOOK_UNKNOWN_SEQUENCE'. + + * eb/text.c (eb_text_internal): Skip data between a pair of + extended control sequences, as described in JIS X 4081. + +1997-10-19 Motoyuki Kasahara + + * Version 1.0.3. + + * utils/src/ebfont.c (make_subbook_fonts): Don't exit if a subbook + lacks the specified font. + + * utils/src/ebappendix.in: Add `-s' (and `--suffix') options. + +1997-10-18 Motoyuki Kasahara + + * configure.in: Use `AC_MSG_WARN' rather than `echo'. + + * eb/match.c (eb_match_word, eb_match_exactword): Ignore spaces + in a search pattern. This modicication is for the Oxford Concise + Dictionary. + + * eb/setword.c (eb_fix_word_ltn): Ignore spaces in a search + word. + + * utils/src/ebfont.c (make_fonts): Split into the five functions; + `make_fonts', `make_subbook_fonts', `make_subbook_size_fonts' + `make_subbook_size_image_fonts', and `save_image_file'. + +1997-10-10 Motoyuki Kasahara + + * utils/src/Makefile.am (ebappendix): Use `$(srcdir)/ebappendix.in' + rather than `ebappendix.in'. + Use `$(srcdir)/ggetopt.pl', not `ggetopt.pl'. + + * utils/src/Makefile.am (INCLUDES): + Use the `-I$(top_srcdir)' option, not `-I$(top_srcdir)/eb'. + + * eb/bitmap.h: Define macros; `EB_SIZE_NARROW_FONT_16_XBM', + `EB_SIZE_NARROW_FONT_16_XPM', `EB_SIZE_NARROW_FONT_16_GIF', + `EB_SIZE_NARROW_FONT_24_XBM', `EB_SIZE_NARROW_FONT_24_XPM', + `EB_SIZE_NARROW_FONT_24_GIF', `EB_SIZE_NARROW_FONT_30_XBM', + `EB_SIZE_NARROW_FONT_30_XPM', `EB_SIZE_NARROW_FONT_30_GIF', + `EB_SIZE_NARROW_FONT_48_XBM', `EB_SIZE_NARROW_FONT_48_XPM', + `EB_SIZE_NARROW_FONT_48_GIF'. + * eb/bitmap.c, eb/bitmap.h: Delete `eb_save_bitmap_xbm', + `eb_save_bitmap_xpm', `eb_save_bitmap_gif', `eb_write_bitmap_xbm', + `eb_write_bitmap_xpm', and `eb_write_bitmap_gif'. + * eb/bitmap.c, eb/bitmap.h: Add `eb_narrow_font_xbm_size', + `eb_narrow_font_xpm_size', `eb_narrow_font_gif_size', + `eb_wide_font_xbm_size', `eb_wide_font_xpm_size', + `eb_wide_font_gif_size', `eb_convert_bitmap_xbm', + `eb_convert_bitmap_xpm' and `eb_convert_bitmap_gif'. + + * eb/error.h, eb/error.c: Delete three error codes; + `EB_ERR_BAD_SIZE_BITMAP', `EB_ERR_FAIL_OPEN_BITMAP', and + `EB_ERR_FAIL_WRITE_BITMAP'. + +1997-10-05 Motoyuki Kasahara + + * eb/error.h: Define EB_MAXLEN_ERROR_MESSAGE. + + * utils/src/ebfont.c (make_fonts): Use `eb_forward_narrow_character' + and `eb_forward_wide_character'. + Don't calculate character number by itself. + * eb/widealt.c: Add `eb_forward_wide_appendix_character' and + `eb_backward_wide_appendix_character'. + * eb/narwalt.c: Add `eb_forward_narrow_appendix_character' and + `eb_backward_narrow_appendix_character'. + * eb/widefont.c: Add `eb_forward_wide_character' and + `eb_backward_wide_character'. + * eb/narwfont.c: Add `eb_forward_narrow_character' and + `eb_backward_narrow_character'. + + * eb/font.c (eb_font): Set `eb_errno' when no current book + is set. + * eb/font.c (eb_font_list): Return -1 when an error occurs. + +1997-09-27 Motoyuki Kasahara + + * Version 1.0.2. + + * utils/src/ebfont.c (make_fonts): Fix error messages. + Append some information to the error message. + +1997-09-25 Motoyuki Kasahara + + * utils/lib/memset.c: Add this file. + + * configure.in (AC_REPLACE_FUNCS): Add `memset'. + + * eb/narwalt.c, eb/widealt.c: Define `SEEK_SET', `SEEK_CUR' and + `SEEK_END' if undefined. + + * eb/bitmap.c, eb/bitmap.h: Adapt to EB library. + Insert the `eb_' prefix to function names. + Set `eb_error' instead of syslog message when an error occurs. + * utils/lib/bitmap.h, utils/lib/bitmap.c: Move to the `eb/' + sub-directory. + + * eb/error.h, eb/error.c: Add the following error codes; + `EB_ERR_BAD_SIZE_BITMAP', `EB_ERR_FAIL_OPEN_BITMAP', and + `EB_ERR_FAIL_WRITE_BITMAP'. + + * lib/fakelog.c (fakelog): Fix a mistake in `%m' expansion. + Took `strcat' for `strcpy'. + +1997-09-18 Motoyuki Kasahara + + * lib/logpid.c (log_pid_file): Output the warning message + which tells pid file already exists only when the file is + regular file. + +1997-09-13 Motoyuki Kasahara + + * utils/src/version.h.in, utils/src/version.h: Delete these files + because `config.h' also defines $(VERSION). + +1997-09-06 Motoyuki Kasahara + + * Version 1.0.1. + + * eb/text.c (eb_text_internal): Fix the control sequence + processes. + The display control sequences `1f1a'...`1f1f' and `1fe0' take + an arguemnt only when the book is EPWING. + + * utils/src/ebappendix.in: Fix the calculation way of + $wide_len and $narrow_len. + +1997-09-03 Motoyuki Kasahara + + * eb/init.c (eb_initialize_catalog): Scan all eight filename + slots in the `catalogs' file even when an empty filename is + found. (for EPWING `Readers eiwa jiten', kenkyusha) + +1997-08-30 Motoyuki Kasahara + + * Use original version of automake-1.2. + + * doc/texinfo.tex: Delete this file. + + * eb/defs.h, eb/setword.c, eb/search.c, eb/init.c, havesearch.c: + Rename `EB_INDEX_WORD_ALPHA' to `EB_INDEX_WORD_ASIS', and + add `EB_INDEX_WORD_ALPHA' again. + Rename `EB_INDEX_ENDWORD_ALPHA' to `EB_INDEX_ENDWORD_ASIS', + and add `EB_INDEX_ENDWORD_ALPHA' again. + (for EPWING `Readers eiwa jiten', kenkyusha) + +1997-08-24 Motoyuki Kasahara + + * lib/bitmap.c, lib/bitmap.h: Add `write_bitmap_xbm', + `write_bitmap_xpm', and `write_bitmap_gif'. + + * eb/text.c (eb_text_internal): Fix a bug which causes + segmentation violation when `EB_HOOK_NARROW' is not defined. + + * eb/text.c (eb_text_internal): Parse control sequences described + in JIS X 4081-1996. + + * eb/defs.h, eb/search.c (eb_search_exact_word, eb_search_word, + eb_search_endword), eb/setword.c (eb_fix_word_jis): + Define the new word type `EB_WORD_KANJI'. + +1997-08-19 Motoyuki Kasahara + + * configure.in: Delete `AC_PROG_MAKE_SET'. + It is defined by `AM_INIT_AUTOMAKE'. + + * utils/src/Makefile.am (ebappendix): Generate `ebappendix.tmp' + from `ebappendix.in', and then copy `ebappendix.tmp' to `ebappendix'. + * utils/src/Makefile.am (CLEANFILES): Add `ebappendix.tmp'. + +1997-08-09 Motoyuki Kasahara + + * utils/src/ebappendix.in: Don't output a blank page in the + tail of the alternation text data. + +1997-08-05 Motoyuki Kasahara + + * Version 1.0. + + * doc/texinfo.tex: Get the file from texinfo-3.11. + +1997-07-19 Motoyuki Kasahara + + * Version 1.0beta2. + + * eb/init.c (eb_bind), eb/appendix.c (eb_bind_appendix): Get + disc and filename types before trying to open a language file + and a catalog file. + + * eb/io.c (eb_uint1, eb_uint2, eb_uint4), eb/io.h (eb_uint1, + eb_uint2, eb_uint4): Fix casts. + eb/io.c (eb_bcd2, eb_bcd4, eb_bcd6): Fix functions because + they returns an incorrect value. + + * eb/text.c (eb_text_internal): Call a hook function of + `EB_HOOK_END_REFERENCE', not `EB_HOOK_END_KEYWORD'. + + * eb/init.c, eb/language.c, eb/eb.h (eb_init_language): Split + into `eb_init_language' and `eb_init_messages'. + +1997-07-06 Motoyuki Kasahara + + * Use automake-1.2. + + * utils/src/ebinfo.c (output_information): Output title and + directory name of a subbook even when eb_set_subbook() to the + subbook is failed. + + * eb/error.c (messages): Modify error messages. + +1997-06-25 Motoyuki Kasahara + + * lib/getopt.c, lib/getopt1.c, lib/getopt.h: Get these files + from glibc-2.0.4. + +1997-06-18 Motoyuki Kasahara + + * Version 1.0beta1. + + * lib/fakelog.c, lib/fakelog.h: Don't include `varargs.h' for + ANSI C compilers even when `STDC_HEADERS' is undefined. + + * utils/src/ebfont.c: Add the missing `HAVE_STRCASECMP' check. + +1997-06-08 Motoyuki Kasahara + + * utils/src/ebappendix.in: Add a character code field with 2 + bytes in the beginning of an appendix file -- the format of + appendix data files is changed. + * eb/appendix.c (eb_initialize_appendix_subbook): Get a character + code from appendix data when initializing subbook. + + * eb/types.h (EB_Appendix_Subbook): Add the `charcode' member. + + * eb/narwalt.c (eb_narrow_character_text), eb/widealt.c + (eb_wide_character_text): Fix bugs in alternation text proceessing. + Character code of appendix data was examined by a wrong way. + +1997-06-07 Motoyuki Kasahara + + * configure.in: Add `AC_HEADER_STAT'. + + * lib/makedir.c, eb/filename.c: Use `S_ISDIR' instead of `S_IFDIR'. + Define `S_ISREG' and `S_ISDIR' if they aren't defined in . + Redefine `S_ISREG' and `S_ISDIR' if they are broken. diff --git a/ChangeLog.1 b/ChangeLog.1 new file mode 100644 index 0000000..9d33b12 --- /dev/null +++ b/ChangeLog.1 @@ -0,0 +1,2222 @@ +2001-06-03 Motoyuki Kasahara + + * Version 3.0. + + * configure.ac (AM_INIT_AUTOMAKE): Set version to 3.0. + + * eb/error.h (EB_ERR_FAIL_OPEN_LANG, EB_ERR_FAIL_READ_LANG, + EB_ERR_FAIL_SEEK_LANG, EB_ERR_UNEXP_LANG, EB_ERR_NO_LANG, + EB_ERR_NO_MSG, EB_ERR_NO_CUR_LANG, EB_ERR_NO_SUCH_LANG, + EB_ERR_NO_SUCH_MSG): Removed. + * eb/error.c (error_messages): Ditto. + + * eb/book.c (eb_initialize_language): Not to return a value. + +2001-05-19 Motoyuki Kasahara + + * eb/book.c: Function declaration of eb_initialize_catalog() is + duplicated. Fixed. + * eb/book.c: + * eb/language.c, eb/message.c: Removed. + All functions in the files except for eb_initialize_languages() + are removed. + eb_initialize_languages() is renamed to eb_initialize_languages() + and it is now placed in eb/book.c. + * eb/defs.h (EB_MAX_LANGUAGE_NAME_LENGTH, EB_MAX_MESSAGE_LENGTH, + EB_MAX_LANGUAGES, EB_MAX_MESSAGES): Deleted. + * eb/defs.h (EB_Language_Code, EB_Message_Code, EB_Language_Struct): + Removed. + * eb/defs.h (EB_Book_Struct): Delete `language_file_name', + `language_zio', `language_count', `languages', `language_current', + and `messages' from the structure. + * eb/zipbook.c (eb_zip_book_eb): Find LANGUAGE file by itself. + * eb/unzipbook.c (eb_unzip_book_eb): Ditto. + * eb/zipinfobook.c (eb_zipinfo_book_eb): Ditto. + +2001-05-11 Motoyuki Kasahara + + * Version 3.0beta1. + + * configure.ac (AM_INIT_AUTOMAKE): Set version to 3.0beta1. + + * eb/Makefile, libebutils/Makefile, ebfont/Makefile, ebinfo/Makefile, + ebrefile/Makefile, ebzip/Makefile: Delete dependencies between *.c + and *.o. + +2001-05-09 Motoyuki Kasahara + + * m4/eb3.m4 (eb_LIB_EB3): Avoid other AC_TRY_LINK and CK_TRY_RUN + checks linking libeb.* to test program. + +2001-05-08 Motoyuki Kasahara + + * Makefile.am (ACLOCAL_AMFLAGS): Set the variable to `-I m4', not + `-I $(srcdir)/m4'. + +2001-05-02 Motoyuki Kasahara + + * ebzip/zipbook.c (ebzip_zip_book_epwing): Fix a bug that ebzip + doesn't compress gaiji files. + + * eb/narwfont.c (eb_initialize_narrow_font): Canonicalize font file + name before fix. + * eb/filename.c (eb_canonicalize_font_file_name): New function. + + * po-ebutils/Makefile.in (POTFILES): Updated. + Delete ebzip/filename.c and add ebrefile/ebrefile.c. + + * ebrefile/Makefile.am: Revised. Now ebrefile is written in C. + * ebrefile/ebrefile.c: New file. + * ebrefile/ebrefile.in: Deleted. + +2001-04-28 Motoyuki Kasahara + + * ebzip/filename.c, eb/filename.c: fix_path_name_suffix() is + renamed to eb_fix_path_name_suffix() and its definition is moved + from ebzip/filename.c to eb/filename.c. + * ebzip/filename.c: Removed. + * ebzip/Makefile.am (ebzip_SOURCES): Delete `filename.c'. + + * ebfont/Makefile.am (ebfont_LDADD): Fix the order of library to + be linked. + * ebinfo/Makefile.am (ebinfo_LDADD): Ditto. + * ebzip/Makefile.am (ebzip_LDADD): Ditto. + +2001-04-24 Motoyuki Kasahara + + * eb/setword.c (eb_fix_word): Fix word if the given word is for + keyword search or multi-search without candidates. Reported by + Kenichi Suto. + +2001-04-23 Motoyuki Kasahara + + * configure.in: Renamed to `configure.ac'. + +2001-04-13 Motoyuki Kasahara + + * eb/narwfont.c (eb_initialize_narrow_font): Fix a bug in reopen + a font file, reported by HASEGAWA Masafumi. + +2001-04-12 Motoyuki Kasahara + + * eb/subbook.c (eb_initialize_indexes): Fix calcuration of end + page number of an index. + + * m4/gettext.m4 (eb_GNU_GETTEXT): Ignore arguments. + * configure.in (eb_GNU_GETTEXT): Don't pass arguments to the macro. + + * eb/po: Move the directory to po-eb. + * po-eb/Makefile.in (top_builddir, subdir): Updated. + * po: Move the directory to po-ebutils. + * po-ebutils/Makefile.in (subdir): Updated. + + * configure.in (AC_OUTPUT): Delete `po/Makefile' and `eb/po/Makefile', + and add `po-eb/Makefile' and `po-ebutils/Makefile' instead. + * Makefile.am (SUBDIRS): Delete `po' and add `po-eb' and `po-ebutils' + instead. + * eb/Makefile.am (SUBDIRS): Deleted. + +2001-04-10 Motoyuki Kasahara + + * Version 3.0beta0. + + * ebzip/Makefile.am (noinst_HEADERS): Add `ebzip.h'. + + * gttest.po: Add header. + +2001-04-08 Motoyuki Kasahara + + * eb/defs.h (EB_Search_Struct): Add `index_id'. + * eb/subbook.c (eb_initialize_indexies): Also set index ID. + * eb/multi.c (eb_initialize_multi_search): Likewise. + * eb/setword.c (eb_fix_word): Copy `canonicalized_word' to `word' + if as-is or alphabet search. Don't modify `word' otherwise. + Don't modify `word' nor `canonicalized_word' if keyword or + candidate search. + * eb/setword.c (eb_set_multiword): Pass entry's search information + to `eb_fix_word', not to pass method's search information. + + * configure.in (AC_ARG_ENABLE): Use `[[' and `]]' in a help string. + + * Makefile.am (SUBDIRS): Delete `intl'. + * configure.in (AC_OUTPUT): Delete `intl/Makefile'. + * m4/gettext.m4 (AM_GNU_GETTEXT_HACKED): Renamed to `eb_GNU_GETTEXT', + and revised to support GNU gettext 0.10.36. Now, we inspect not only + libintl but also libiconv. Instead, we never use included libintl + sources. + + * configure.in (AM_INIT_AUTOMAKE): Set version to `3.0beta0'. + +2001-04-07 Motoyuki Kasahara + + * ebzip/zipbook.c (zip_book.c): Change type of the argument + `subbook_name_list'. + * ebzip/unzipbook.c (unzip_book.c): Ditto. + * ebzip/zipinfobook.c (zipinfo_book.c): Ditto. + +2001-04-06 Motoyuki Kasahara + + * eb/internal.h.in (EB_TEXT_OPTINAL_TEXT): Defined. + * eb/defs.h.in (EB_Search_Struct): add `end_page'. Rename + `index_page' to `start_page'. + * eb/subbook.c (eb_initialize_indexes): Also initialize and set + end pages of search methods. + * eb/text.c (eb_read_text): Set text mode to EB_TEXT_OPTINAL_TEXT + if the current position points to menu or copyright text. + +2001-04-05 Motoyuki Kasahara + + * po/Makefile.in (POTFILES): Add `ebzip/copyfile.c', + `ebzip/filename.c', `ebzip/unzipbook.c', `ebzip/unzipfile.c', + `ebzip/zipbook.c', `ebzip/zipfile.c', `ebzip/zipinfobook.c', + `ebzip/zipinfofile.c'. Delete `ebzip/ebzip1.c'. + + * eb/text.h (EB_HOOK_BEGIN_BITMAP, EB_HOOK_END_BITMAP): Renamed to + EB_HOOK_BEGIN_MONO_GRAPHIC and EB_HOOK_END_MONO_GRAPHIC. + * eb/text.h (EB_HOOK_BEGIN_BMP, EB_HOOK_END_BMP): Renamed to + EB_HOOK_BEGIN_COLOR_BMP and EB_HOOK_END_COLOR_BMP. + * eb/text.h (EB_HOOK_BEGIN_JPEG, EB_HOOK_END_JPEG): + EB_HOOK_BEGIN_COLOR_JPEG and EB_HOOK_END_COLOR_JPEG. + * eb/text.h (EB_HOOK_BEGIN_IN_JPEG, EB_HOOK_END_IN_JPEG): + EB_HOOK_BEGIN_IN_COLOR_JPEG and EB_HOOK_END_IN_COLOR_JPEG. + * eb/text.h (EB_HOOK_BEGIN_GRAY_GRAPHIC, EB_HOOK_END_GRAY_GRAPHIC): + Defined. + + * eb/internal.h.in (EB_BINARY_MONO_GRAPHIC, EB_BINARY_COLOR_GRAPHIC, + EB_BINARY_WAVE, EB_BINARY_MPEG, EB_BINARY_GRAY_GRAPHIC, + EB_BINARY_INVALID): Defined. + * eb/ebconfig.h (EB_Binary_Code): Defined. + * eb/defs.h (EB_SIZE_BINARY_CACHE_BUFFER): Change the value to 128. + * eb/defs.h (EB_Binary_Context_Struct): Add `code' and `width'. + * eb/binary.c (eb_set_binary_mono_graphic, eb_set_binary_gray_graphic, + eb_read_binary_mono_graphic): New functions. + +2001-03-25 Motoyuki Kasahara + + * eb/libintl_r.c, eb/libintl_r.h: Removed. + * eb/Makefile.am (libeb_la_SOURCES): Remove `libintl_r.c'. + * eb/Makefile.am (pkginclude_HEADERS): Remove `libintl_r.h'. + + * eb/error.h (EB_MAX_ERROR_MESSAGE_LENGTH): Deleted. + * eb/error.c (eb_error_message_r): Deleted. + +2001-03-20 Motoyuki Kasahara + + * m4/gettext.m4 (AM_GNU_GETTEXT_HACKED): Quote $INCLUDED_GETTEXT + and $ENABLE_NLS. + +2001-03-18 Motoyuki Kasahara + + * ebzip/zio.c (zio_reopen): Return -1 if `zio' context cannot be + re-used. + + * eb/book.c (eb_initialize_book): `book->language_zio' was not + initialized. Fixed. + + * eb/defs.h (EB_Font_Struct): Fix the length of the array `file_name'. + + * eb/narwfont.c (eb_initialize_narrow_font): Fix a bug that it cannot + open a font file correctly. + + * eb/zio.c (eb_reopen): Check strictly whehter the zio context is + ready to reopen. + + * eb/zio.h (ZIO_REOPEN, ZIO_EBZIP1, ZIO_EPWING, ZIO_EPWING6, + ZIO_SEBXA): Renumbered. + + * ebfont/ebfont.c: Don't include . + * ebinfo/ebinfo.c: Ditto. + * ebfont/ebfont.c (main): Don't call set_fakelog_name(), + set_fakelog_mode() nor set_fakelog_level(). + * ebinfo/ebinfo.c (main): Ditto. + + * libebutils/ebutils.c (output_try_help): Add the argument + `invoked_name'. + * libebutils/ebutils.c (output_version): Add the arguments + `program_name' and `program_version'. + * libebutils/ebutils.c (parse_subbook_name_argument): Add the + argument `invoked_name'. + * libebutils/ebutils.c: Delete definition of `program_name', + `program_version' and `invoked_name'. + * ebfont/ebfont.c: Define `program_name', `program_version' and + `invoked_name'. + * ebinfo/ebinfo.c: Ditto. + * ebfont/ebfont. (main): Don't initialize `program_name'. + * ebinfo/ebinfo.c (main): Ditto. + + * ebfont/ebfont.c (subbook_list, subbook_count): + Changed to `static' variables. + * ebfont/ebfont.c (font_list, fount_count): Ditto. + * ebfont/ebfont.c (image_list, image_count): Ditto. + + * ebfont/ebfont.c (parse_image_argument): The order of arguments + is changed. + * ebfont/ebfont.c (parse_font_argument): Ditto. + + * libebtuils/ebutils.c (find_subbook): Fix a bug. The function + returns invalid error code if an error has occured. + + * ebzip/copyfile.c: Include "eb.h", "error.h" and "internal.h". + + * ebzip/copyfile.c (copy_file): Don't `stat' the input file. + + * ebzip/copyfile.c (copy_files_in_directory): Don't output an error + message if input directory doesn't exists. + * ebzip/copyfile.c (copy_files_in_directory): Output an error message + if failed to open the input directory. + * ebzip/copyfile.c (copy_files_in_directory): Skip a file entry + if it is not regular file. + + * ebzip/ebzip.c: Add `-s' and `--skip-content' options. + * ebzip/ebzip.c (ebzip_skip_flag_font, ebzip_skip_flag_graphic, + ebzip_skip_flag_movie, ebzip_skip_flag_sound): New variables. + * ebzip/ebzip.h (EBZIP_DEFAULT_SKIP_FONT, EBZIP_DEFAULT_SKIP_GRAPHIC, + EBZIP_DEFAULT_SKIP_MOVIE, EBZIP_DEFAULT_SKIP_SOUND): New cpp macros. + * ebzip/ebzip.c (parse_skip_content_argument): New function. + + * ebzip/ebzip.h (EBZIP_SUFFIX_NONE, EBZIP_SUFFIX_EBZ, + EBZIP_SUFFIX_ORG): New cpp macros. + + * ebzip/filename.c (compose_unfixed_path_name): Renamed to + fix_path_name_suffix() and revised. + * ebzip/filename.c (compose_unfixed_path_name2, + compose_unfixed_path_name3, compose_fixed_path_name, + compose_fixed_path_name2, compose_fixed_path_name3): Deleted. + + * ebzip/zipbook.c (ebzip_zipbook): In order to compose a file name, + use eb_find_file_name(), eb_compose_file_name(), + eb_compose_file_name2(), eb_compose_file_name3() and + fix_path_name_suffix(). + * ebzip/unzipbook.c (ebzip_unzip_book): Ditto. + * ebzip/zipinfobook.c (ebzip_zipinfo_book): Ditto. + + * ebzip/zipbook.c (ebzip_zip_book): Support movie files. + * ebzip/unzipbook.c (ebzip_unzip_book): Ditto. + +2001-03-12 Motoyuki Kasahara + + * configure.in (AC_PROG_CC, AC_AIX, AC_MINIX, AC_PROG_LIBTOOL): + Check AC_PROG_CC, (AC_AIX + AC_MINIX) and AC_PROG_LIBTOOL in that + order. + + * eb/filename.c (eb_fix_file_name, eb_fix_file_name2, + eb_fix_file_name3): Removed. + * eb/filename.c (eb_find_file_name, eb_find_file_name2, + eb_find_file_name3): Added. + * eb/filename.c (eb_compose_path_name, eb_compose_path_name2, + eb_compose_path_name3): Revised. + * eb/internal.h.in (EB_FILE_NAME_START, EB_FILE_NAME_SOUND, + EB_FILE_NAME_CATALOG, EB_FILE_NAME_LANGUAGE, EB_FILE_NAME_VTOC, + EB_FILE_NAME_WELCOME, EB_FILE_NAME_CATALOGS, EB_FILE_NAME_HONMON, + EB_FILE_NAME_HONMON2, EB_FILE_NAME_HONMONG, EB_FILE_NAME_HONMONS, + EB_FILE_NAME_APPENDIX, EB_FILE_NAME_FUROKU): Deleted. + * eb/internal.h.in (EB_SUFFIX_NONE, EB_SUFFIX_EBZ, EB_SUFFIX_ORG): + Deleted. + + * eb/appendix.c (eb_initialize_appendix_catalog): + Use eb_find_file_name() to find a file to open. + * eb/appsub.c (eb_set_appendix_subbook_eb): Ditto. + * eb/appsub.c (eb_set_appendix_subbook_epwing): Ditto. + * eb/binary.c (eb_set_binary_mpeg): Ditto. + * eb/book.c (eb_initialize_catalog): Ditto. + * eb/language.c (eb_initialize_languages, eb_set_language): Ditto. + * eb/message.c (eb_initialize_messages): Ditto. + * eb/narwfont.c (eb_initialize_narrow_font): Ditto. + * eb/subbook.c (eb_set_subbook_eb, eb_set_subbook_epwing): Ditto. + + * eb/defs.h (EB_Font_Struct): Delete unused member `available'. + * eb/defs.h (EB_Book_Struct): Add the member `language_file_name'. + * eb/defs.h (EB_Book_Struct): Add `language_file_name' and + `language_zio'. + +2001-02-26 Motoyuki Kasahara + + * eb/appsub.c (eb_initialize_appendix_subbook, + eb_set_appendix_subbook): fix `data' sub-dirtory name in + eb_set_appendix_subbook(), reported by HASEGAWA Masafumi. + +2001-02-25 Motoyuki Kasahara + + * m4/eb3.m4 (AC_ARG_WITH): Fix typo. + + * m4/utimbuf.m4: Rename variable prefix from `ax_cv' to `ac_cv'. + +2001-02-20 Motoyuki Kasahara + + * check gettext() in libintl , and then in libc. + +2001-02-19 Motoyuki Kasahara + + * ebzip/filename.c (compose_unfixed_path_name2): Enclose "%s/%s" + with F_(). + +2001-02-18 Motoyuki Kasahara + + * ebzip/filename.c (compose_out_path_name, compose_out_path_name2, + compose_out_path_name3): Rename prefix from `compose_out_' to + `compose_unfixed_'. + + * ebzip/filename.c (compose_existent_path_name, + compose_existent_path_name2, compose_existent_path_name3): Rename + prefix from `compose_exisntent_' to `compose_fixed_'. + + * lib/text.c (eb_read_text_internal): Fix ISO 8859-1 code point range, + reported by HASEGAWA Masafumi. + +2001-02-12 Motoyuki Kasahara + + * ebzip/ebzip.c: Split the file into 9 files; eb/copyfile.c, + eb/ebzip.c, eb/ebzip.h, eb/unzipbook.c, eb/unzipfile.c, eb/zipbook.c, + eb/zipfile.c, eb/zipinfobook.c and eb/zipinfofile.c. + + * ebzip/zipbook.c (zip_book, zip_book_eb, zip_book_epwing): + Add the prefix `ebzip_', and revised. + * ebzip/zipfile.c (zip_file): Ditto. + * ebzip/unzipbook.c (unzip_book, unzip_book_eb, unzip_book_epwing): + Ditto. + * ebzip/unzipfile.c (unzip_file): Ditto. + * ebzip/zipinfobook.c (zipinfo_book, unzip_book_eb, + unzip_book_epwing): Ditto. + * ebzip/zipinfofile.c (zipinfo_file): Ditto. + + * ebzip/ebzip.h (zip_level, keep_flag, quiet_flag, test_flag, + overwirte_mode): Add the prefx `ebzip_'. + + * libebutils/Makefile.am (INCLUDES): Remove `-DUSE_FAKELOG'. + * libebutils/Makefile.am (noinst_HEADERS): Remove `fakelog.h'. + * libebutils/Makefile.am (libebutils_a_SOURCES): Remove `fakelog.c'. + * libebutils/fakelog.c, libebutils/fakelog.h: Removed. + * libebutils/makedir.c: Don't use fakelog. + + * libebutils/makedir.c (make_missing_directory_chaing): Removed. + +2001-02-11 Motoyuki Kasahara + + * m4/gettext.m4 (AM_GNU_GETTEXT_HACKED): Find gettext() in libc. + + * eb/search.c (eb_hit_list_keyword, eb_hit_list_multi): Comparison + Group entry with `context->word', not `context->canonicalized_word'. + Pill Book 2001 needs this fix. + + * eb/configure.in (AM_INIT_AUTOMAKE): Set version to `3.0alpha5'. + +2001-02-09 Motoyuki Kasahara + + * eb/filename.c (eb_canonicalize_path_name): Fix typo, reported + by Satomi Igi. + + * eb/internal.h.in (EB_SUFFIX_ORG): Defined. + * eb/subbook.c (eb_set_subbook_epwing): Try to open `HONMON2.ORG'. + * eb/subbook.c (eb_set_subbook_epwing): Assume HONMON(.EBZ) file + has graphic and sound data regardless of EPWING version. + * ebzip/ebzip.c (zip_book, unzip_book, zipinfo_book): Support + `HONMONS', `HONMONG' and `HONMON2.ORG' files. + * ebzip/ebzip.c (zip_book): When compress HONMON2, output the result + to HONMON2.EBZ, not `HONMON.EBZ'. + * ebzip/ebzip.c (unzip_book): When uncompress HONMON2.EBZ, output the + result to `HONMON2.ORG', not `HONMON2' or `HONMON'. + +2001-02-06 Motoyuki Kasahara + + * zlib/Makefile.am (AC_CHECK_FUNCS): Fix typo (vnsprintf -> vsnprintf). + Reported by Takashi NEMOTO. + * m4/gettext.m4: When tests, use the locale name `en_US' instead of + `en'. Reported by Takashi NEMOTO. + * libebutils/Makefile.am (INCLUDES): Use @INTLINCS@, not `-I../intl' + Reported by Takashi NEMOTO. + * intl/libgettext.h: Added again. Since `intl/bindtextdomain.c' + includes the file. Reported by Takashi NEMOTO. + +2001-02-03 Motoyuki Kasahara + + * Version 3.0alpha4. + + * po/Makefile.in, eb/po/Makefile (DISTFILES): Distribute + `Makefile.in', not `Makefile.in.in'. Add `$(CATALOGS)'. + * po/Makefile.in, eb/po/Makefile (distclean): Don't delete `Makefil.in' + itself. + * eb/text.c (eb_read_text_internal): Dispatch the BEGIN_WAVE hook. + +2001-01-31 Motoyuki Kasahara + + * eb/defs.h (EB_Appendix_Subbook_Struct): Rename `appendix_zio' to + `zio'. + * eb/defs.h (EB_Font_Struct): Rename `font_zio' to `zio'. + + * eb/graphic.c: Removed. + * eb/Makefile.am (libeb_la_SOURCES): Remove `eb/graphic.c'. + * eb/defs.h (EB_Subbook_Struct): The member `graphic' is removed. + * eb/ebinfo.c (output_information): Delete `graphic search' + information. + + * eb/defs.h (EB_Subbook_Struct): The member `sound' is added. + * eb/subbook.c (eb_initialize_indexes): Recognize 0xd8 as sound data. + + * eb/defs.h (EB_Binary_Context_Struct): Add the members; + `cache_buffer', `cache_length' and `cache_offset'. + * eb/binary.c (eb_set_binary_wave): Add the argument `type'. + * eb/binary.c (eb_est_binary_wave, eb_set_binary_color_graphic, + eb_set_binary_mpeg, eb_read_binary, eb_unset_binary): Update cache + data. + + * eb/Makefile.am (pkginclude_HEADERS): Add `zio.h'. + +2001-01-28 Motoyuki Kasahara + + * ebfont/ebfont.c (make_subbook_size_image_fonts): Fix typo. + + * eb/uint.c: Renamed to `eb/bcd.c'. + * eb/uint.c: Delete definition of eb_uint1(), eb_uint2(), eb_uint4() + and eb_uint4_le(). + + * eb/zio.h: New file. + * eb/defs.h (EB_Zip_Code ,EB_Huffman_Node): Move declaration of + these types to `eb/zio.h'. + * eb/defs.h (EB_SIZE_EBZIP_HEADER, EB_SIZE_EBZIP_MARGIN, + EB_MAX_EBZIP_LEVEL, EB_HUFFMAN_NODE_INTERMEDIATE, + EB_HUFFMAN_NODE_EOF, EB_HUFFMAN_NODE_LEAF8, EB_HUFFMAN_NODE_LEAF16, + EB_HUFFMAN_NODE_LEAF32, EB_ZIO_NONE, EB_ZIO_EBZIP1, EB_ZIO_EPWING, + EB_ZIO_EPWING6, EB_ZIO_SEBXA, EB_ZIO_INVALID): Move definition of + these cpp macros to `eb/zio.h'. + * eb/zio.c: Include `eb/zio.h'. + * eb/defs.h: Include `eb/zio.h'. + + * eb/zio.h (EB_Zip): Renamed to `Zio'. + * eb/zio.h (EB_Zip_Code): Renamed to `Zio_Code'. + * eb/defs.h (EB_SIZE_EBZIP_HEADER): Renamed to `ZIO_SIZE_EBZIP_HEADER'. + * eb/defs.h (EB_SIZE_EBZIP_MARGIN): Renamed to `ZIO_SIZE_EBZIP_MARGIN'. + * eb/defs.h (EB_MAX_EBZIP_LEVEL): Renamed to `ZIO_MAX_EBZIP_LEVEL'. + * eb/defs.h (EB_HUFFMAN_NODE_INTERMEDIATE): Renamed to + `ZIO_HUFFMAN_NODE_INTERMEDIATE'. + * eb/defs.h (EB_HUFFMAN_NODE_EOF): Renamed to `ZIO_HUFFMAN_NODE_EOF'. + * eb/defs.h (EB_HUFFMAN_NODE_LEAF8): Renamed to + `ZIO_HUFFMAN_NODE_LEAF8'. + * eb/defs.h (EB_HUFFMAN_NODE_LEAF16): Renamed to + `ZIO_HUFFMAN_NODE_LEAF16'. + * eb/defs.h (EB_HUFFMAN_NODE_LEAF32): Renamed to + `ZIO_HUFFMAN_NODE_LEAF32'. + * eb/defs.h (EB_ZIO_NONE): Renamed to `ZIO_NONE'. + * eb/defs.h (EB_ZIO_EBZIP1): Renamed to `ZIO_EBZIP1'. + * eb/defs.h (EB_ZIO_EPWING): Renamed to `ZIO_EPWING'. + * eb/defs.h (EB_ZIO_EPWING6): Renamed to `ZIO_EPWING6'. + * eb/defs.h (EB_ZIO_SEBXA): Renamed to `ZIO_SEBXA'. + * eb/defs.h (EB_ZIO_INVALID): Renamed to `ZIO_INVALID'. + + * eb/unebzip.c, eb/unzepwng.c, eb/unzsebxa.c: Removed. + The contents of those files are moved to `eb/zio.c'. + + * eb/defs.h (EB_Appendix_Subbook_Struct): Rename `appendix_zip' to + `appendix_zio'. + * eb/defs.h (EB_Appendix_Subbook_Struct): Remove `appendix_file'. + * eb/defs.h (EB_Font_Struct): Rename `font_zip' to `font_zio'. + * eb/defs.h (EB_Font_Struct): Delete `font_file'. + * eb/defs.h (EB_Subbook_Struct): Rename `text_zip' to `text_zio'. + * eb/defs.h (EB_Subbook_Struct): Delete `text_file'. + * eb/defs.h (EB_Subbook_Struct): Rename `graphic_zip' to `graphic_zio'. + * eb/defs.h (EB_Subbook_Struct): Delete `graphic_file'. + * eb/defs.h (EB_Subbook_Struct): Rename `sound_zip' to `sound_zio'. + * eb/defs.h (EB_Subbook_Struct): Delete `sound_file'. + * eb/defs.h (EB_Subbook_Struct): Add `movie_zip'. + * eb/defs.h (EB_Binary_Context_Struct): Delete `file'. + * eb/defs.h (EB_Binary_Context_Struct): Rename `zip' to `zio'. + + * eb/zio.c: Don't include `ebconfig.h', `errorh.h' nor `internal.h'. + * eb/zio.c (eb_zinitialize): Renamed to `zio_initialize_library'. + * eb/zio.c (eb_zfinalize): Renamed to `zio_finalize_library'. + * eb/zio.c (eb_zopen): Renamed to `zio_open'. + * eb/zio.c (eb_zopen_none): Renamed to `zio_open_none'. + * eb/zio.c (eb_zopen_ebzip): Renamed to `zio_open_ebzip'. + * eb/zio.c (eb_zopen_epwing): Renamed to `zio_open_epwing'. + * eb/zio.c (eb_zopen_epwing6): Renamed to `zio_open_epwing6'. + * eb/zio.c (eb_zopen_sebxa): Renamed to `zio_open_sebxa'. + * eb/zio.c (eb_zclose): Renamed to `zio_close'. + * eb/zio.c (eb_zlseek): Renamed to `zio_lseek'. + * eb/zio.c (eb_zread): Renamed to `zio_read'. + * eb/zio.c (eb_zread_ebzip): Renamed to `zio_read_ebzip'. + * eb/zio.c (eb_zread_epwing): Renamed to `zio_epwing'. + * eb/zio.c (eb_make_epwing_huffman_tree): Renamed to + `zio_make_epwing_huffman_tree'. + * eb/zio.c (eb_unzip_slice_ebzip1): Renamed to + `zio_unzip_slice_ebzip1'. + * eb/zio.c (eb_unzip_slice_epwing): Renamed to + `zio_unzip_slice_epwing'. + * eb/zio.c (eb_unzip_slice_epwing6): Renamed to + `zio_unzip_slice_epwing6'. + * eb/zio.c (eb_initialize, eb_finalize, eb_reopen, eb_file): + New functions. + * eb/zio.c (eb_read_all): Renamed to `zio_read_raw'. + + * eb/zio.c (Zio): Add the member `file'. + + * eb/zio.c (zio_close, zio_lseek, zio_read, zio_read_ebzip, + eb_zread_epwing, eb_zread_sebxa): Delete 2nd argument `file'. + + * eb/zio.c (zio_uint1, zio_uint2, zio_uint4): Defined. + Don't use eb_uint1, eb_uint2 or zio_uint4. + + * eb/appendix.c (eb_finalize_appendix): Finalize `appendix_zio' + in all subbooks. + * eb/book.c (eb_finalize_book): Ditto. + + * eb/appendix.c (eb_initialize_appendix_catalog): Use zio to + open a catalog file. + * eb/book.c (eb_initialize_catalog): Ditto. + + * eb/book.c (eb_fix_misleaded_book): New function. + * eb/book.c (eb_initialize_catalog): Fix chachacter-code information + by calling eb_fix_misleaded_book(). + + * eb/appendix.c (eb_initialize_catalog): Initialize `appendix_zio' in + an EB_Appendix_Subbook Object. + * eb/book.c (eb_initialize_catalog): Initialize `text_zio', + `graphic_zio', `sound_zio and movie_zio' in an EB_Book_Subbook object. + +2001-01-27 Motoyuki Kasahara + + * eb/error.h: Rivse error codes. + * eb/error.c (error_messages): Revised. + * eb/binary.c (eb_set_binary_mpeg): Fix a bug in initialization of + binary context. + * eb/filename.c (eb_decompose_movie_file_name): New function. + * eb/filename.c (eb_compose_movie_file_name): Don't believe file name + consists of 8 characters. + + * eb/text.c (SIZE_FEW_REST): Change the value from 40 to 48. + * eb/text.c (eb_read_text_internal): BEGIN_MPEG hook was not called + correctly. Fixed. + + * eb/subbook.c (eb_set_subbook_epwing): Don't suppose graphic or + sound data are in HONMON file if EPWING version is 5 or later. + +2001-01-23 Motoyuki Kasahara + + * eb/error.h (EB_ERR_BAD_FILE_NAME, EB_ERR_BAD_DIR_NAME): Add these + error codes. + + * eb/filename.c (eb_fix_directory_name, eb_fix_directory_name2, + eb_fix_file_name, eb_fix_file_name2, eb_fix_file_name3, + eb_compose_path_name, eb_compose_path_name2, eb_compose_path_name3): + eb_compose_movie_file_name): Return EB_Error_Code, not {0 or -1}. + +2001-01-21 Motoyuki Kasahara + + * eb/error.h, eb/error.c (EB_ERR_FAIL_OPEN_BIANRY, + EB_ERR_FAIL_READ_BINARY, EB_ERR_FAIL_SEEK_BINARY, EB_ERR_UNEXP_BINARY, + EB_ERR_NO_CUR_BINARY, EB_ERR_NO_SUCH_BINARY): Add these error codes. + + * eb/binary.h: New file. + * eb/Makefile.am (pkginclude_HEADERS): Add binary.h. + + * eb/text.h, eb/internal.h.in: Move function declaration of + eb_uint1(), eb_uint2(), eb_uint4(), eb_bcd2(), eb_bcd4() and eb_bcd6() + from eb/text.h to eb/internal.h.in. + +2001-01-20 Motoyuki Kasahara + + * configure.in, m4/gettext.m4 (AM_GNU_GETTEXT): renamed to + AM_GNU_GETTEXT_HACKED. + * m4/gettext.m4: Use the language `en' instead of `fr' in the test + program. + + * eb/defs.h (EB_Subbook_Struct): Fix array length of `text_file_name', + `graphic_file_name' and `sound_file_name'. + + * eb/internal.h.in: Declare eb_intialize_binary(). + * eb/binary.c: Added. + * eb/subbook.c: Call eb_initialize_binary() to initialize a binary + context. + + * eb/Makefile.am (libeb_la_SOURCES): Add `binary.c'. + +2001-01-17 Motoyuki Kasahara + + * eb/text.c (EB_MAX_ARGV): Change the value from 4 to 6. + + * eb/filename.c (eb_compose_movie_file_name): Defined. + + * ebzip/ebzip.c (zip_eb_book): Renamed to zip_book_eb(). + * ebzip/ebzip.c (zip_epwing_book): Renamed to zip_book_epwing(). + * ebzip/ebzip.c (unzip_eb_book): Renamed to unzip_book_eb(). + * ebzip/ebzip.c (unzip_epwing_book): Renamed to unzip_book_epwing(). + * ebzip/ebzip.c (zipinfo_eb_book): Renamed to zipinfo_book_eb(). + * ebzip/ebzip.c (zipinfo_epwing_book): Renamed to + zipinfo_book_epwing(). + + * eb/defs.h (EB_Subbook_Struct): Add the following members; + `graphic_file', `graphic_zip', `sound_file' and `sound_zip'. + * eb/internal.h.in (EB_FILE_NAME_HONMONG, EB_FILE_NAME_HONMONS): + Defined. + * eb/subbook.c (eb_set_subbook): Split this function into + eb_set_subbook(), eb_set_subbook_eb() and eb_set_subbook_epwing(). + * eb/subook.c (eb_set_subbook_epwing): Try opening graphic and sound + files. + + * eb/uint.c, eb/internal.h.in (eb_uint4_le): Defined. + + * eb/defs.h (EB_Binary_Context_Struct, EB_Binary_Context): Defined. + * eb/defs.h (EB_Book_Struct): Add the member `binary_context'. + + * eb/text.h: (EB_HOOK_BEGIN_BITMAP, EB_HOOK_END_BITMAP, + EB_HOOK_BEGIN_BMP, EB_HOOK_BEGIN_JPEG, EB_HOOK_END_COLOR_GRAPHIC, + EB_HOOK_BEGIN_IN_BMP, EB_HOOK_BEGIN_IN_JPEG, + EB_HOOK_END_IN_COLOR_GRAPHIC, EB_HOOK_BEGIN_WAVE, EB_HOOK_END_WAVE, + EB_HOOK_BEGIN_MPEG, EB_HOOK_END_MPEG): Defined. + * eb/defs.h (EB_NUMBER_OF_HOOKS): Updated. + + * eb/zio.c (zio_reopen): become `static' function. + * eb/zio.h (ZIO_REOPEN): Added. + * eb/zio.c (zio_open): Recognize the compression mode `ZIO_REOPEN'. + * eb/zio.c (zio_mode): New function. + + * eb/book.c (eb_filenalize_book): Don't call zio_finalize() for + `movie_zio'. Call zio_finalize() for `language_zio'. + +2001-01-16 Motoyuki Kasahara + + * eb/internal.h (EB_Subbook_Struct): Remove the member + `stream_directory_name'. + * eb/subbook.c (eb_set_subbook): Don't initialize + `subbook->stream_directory_name'. + + * eb/text.h (EB_HOOK_STOP_CODE, EB_HOOK_BEGIN_BITMAP, + EB_HOOK_END_BITMAP, EB_HOOK_BEGIN_BMP, EB_HOOK_BEGIN_JPEG, + EB_HOOK_END_IMAGE, EB_HOOK_BEGIN_IN_BMP, EB_HOOK_BEGIN_IN_JPEG, + EB_HOOK_END_IN_IMAGE, EB_HOOK_BEGIN_WAVE, EB_HOOK_END_WAVE, + EB_HOOK_BEGIN_MPEG, EB_HOOK_END_MPEG): Define new text hooks. + + * eb/text.c (SIZE_FEW_REST): Change the value from 16 to 40. + +2001-01-14 Motoyuki Kasahara + + * eb/defs.h (EB_Binary_Context_Struct, EB_Binary_Context, + EB_Binary_Code): Defined. + +2001-01-11 Motoyuki Kasahara + + * m4/gettext.m4 (AM_GNU_GETTEXT): Set LC_ALL to `fr', and set LANGUAGE + to empty string. + + * ebzip/ebzip.c (zip_epwing_book, unzip_epwing_book, + zipinfo_epwing_book): Fix filenames in error messages. + +2001-01-03 Motoyuki Kasahara + + * lib/strcasecmp.c (strncasecmp): Fix a bug that the function returns + wrong result when comparison length is 0. + * libebutils/strcasecmp.c (strncasecmp): Ditto. + + * eb/Makefile.am (SUBDIRS): Don't use @POSUB@. + +2001-01-02 Motoyuki Kasahara + + * configure.in (AC_ARG_WITH): Fix a bug that configure cannot + recognize --with-included-zlib option. Reported by Kazuhiko. + +2001-01-01 Motoyuki Kasahara + + * po/Makefile.in.in, eb/po/Makefile.in.in: Use `ENABLE_NLS', not + `USE_NLS'. + + * eb/Makefile.am (SUBDIRS): Set to `po', not `@POSUB@'. + +2000-12-31 Motoyuki Kasahara + + * intl/Makefile.am (noinst_HEADERS): Remove `libgettext.h'. Add + `libintl.h' instead. + * intl/Makefile.am (BUILT_SOURCES): Remove libintl.h. + * intl/Makefile.am (DISTCLEANFILES): Remove libintl.h. + + * po/Makefile.in.in, eb/po/Makefile.in.in (ja_JP.SJIS): Remove the + target. + + * gttest.po, gttest.mo: New files. + * Makefile.am (EXTRA_DIST): Add `gttest.mo' and `gttest.po'. + * Makefile.am (gttest.mo): New target. + * m4/gettext.m4: Fully revised. + * configure.in (AC_OUTPUT): Fix an output file name. + +2000-12-30 Motoyuki Kasahara + + * libebutils/Makefile.am (EXTRA_DIST): Delete `memset.c', `strerror.c' + and `strcasecmp.c'. Automake recognizes them as distirbution files. + +2000-12-29 Motoyuki Kasahara + + * Makefile.am (ACLOCAL_AMFLAGS): Defined. + + * m4/ssizet.m4 (AX_TYPE_SSIZE_T): Renamed to `AC_TYPE_SSIZE_T'. + * m4/utimbuf.m4 (AX_HAVE_STRUCT_UTIMBUF): Renamed to + `AC_STRUCT_UTIMBUF'. + * configure.in: Use new macro names described above. + + * m4/libtool.m4: New file. + (This file will be removed when a bug in libtool.m4 distributed + with Libtool is fixed.) + * m4/Makefile.am (EXTRA_DIST): Add `libtool.m4'. + +2000-12-23 Motoyuki Kasahara + + * Use autoconf 2.49b, automake 1.4b, and libtool 1.3c (checkout + 2000-12-18). + * depcomp: New file. + + * configure.in: Call `AX_TYPE_SSIZE_T' instead of + `AC_CHECK_TYPE(ssize_t, int)'. + + * lib/fakelog.c (fakelog): Use memcpy() instead of strcpy() to + expand `%m'. + + * m4/Makefile.am, m4/eb3.m4, m4/gettext.m4, m4/lcmessage.m4, + m4/ssize_t.m4, m4/utimbuf.m4: New files. + * configure.in (AC_OUTPUT): Add `m4/Makefile.in'. + * Makefile.am (SUBDIRS): Add `m4'. + + * acconfig.h, acinclude.m4: Removed. + + * intl/Makefile.am, eb/Makefile.am, libebutils/Makefile.am, + ebfont/Makefile.am, ebinfo/Makefile.am, ebzip/Makefile.am, + doc/Makefile.am, doc-ja/Makefile.am: + Remove @MAKE_SET@. + +2000-12-06 Motoyuki Kasahara + + * Version 3.0alpha3. + + * ebzip/Makefile.am (INCLUDES): Delete `-I$(top_srcdir)'. + * ebzip/Makefile.am (INCLUDES): Add `-I../eb' and `-I$(top_srcdir)/eb'. + * ebzip/ebzip.c: Include `*.h' in the `../eb' directory, not `eb/*.h'. + +2000-11-28 Motoyuki Kasahara + + * eb/subbook.c (eb_subbook_directory, eb_subbook_directory2): + All letters in a directory name are converted to lower letters + that were converted to upper letters. + * libebutils/ebutils.c (parse_subbook_name_argument): Ditto. + +2000-11-23 Motoyuki Kasahara + + * intl/Makefile.am: Don't make a symbolc link `libintl.h'. + + * eb/font.c (eb_set_font): Set font files to -1. + * eb/font.c (eb_unset_font): Check file descriptor before close + the file. + +2000-11-18 Motoyuki Kasahara + + * configure.in (AC_OUTPUT_COMMANDS): Copy `intl/libgettext.h' to + `intl/libintl.h'. + + * eb/filename.c, ebzip/filename.c, ebfont/ebfont.c: Define the macro + `F_' to resolve path notation problem between UNIX and DOS. + + * ebconfig.h: New file. + * appendix.c, appsub.c, bitmap.c, book.c, copyright.c, eb.c, + endword.c, error.c, exactword.c, filename.c, font.c, graphic.c, + hook.c, jacode.c, keyword.c, language.c, lock.c, match.c, menu.c, + message.c, multi.c, narwalt.c, narwfont.c, search.c, setword.c, + stopcode.c, subbook.c, text.c, uint.c, unzebzip.c, unzepwing.c, + unzsebxa.c, widefont.c, word.c, zio.c: + Include `ebconfig.h'. + Dont' include public headers nor define public macros. + * Makefile.am (noinst_HEADERS): Add `ebconfig.h'. + + * eb/search.c (eb_and_hit_lists): In its prototype declaration, + type of the 4th argument is changed from (EB_Hit [N1][]) to + (EB_Hit [][N2]). + +2000-11-14 Motoyuki Kasahara + + * Makefile.am (CLEANFILES): Add stamp-widealt-h, stamp-widefont-h, + widealt.c and widefont.c. + * Makefile.am (BUILT_SOURCES): Add widealt.c and widefont.c. + * Makefile.am (widealt.c, stamp-widealt-h): Add the targets. + * Makefile.am (widefont.c, stamp-widefont-h): Add the targets. + * widealt.c, widefont.c: Generated from narwalt.c and narwfont.c. + +2000-11-08 Motoyuki Kasahara + + * eb/text.c (eb_read_text_internal): + * eb/text.h (EB_HOOK_END_CANDIDATE): Split this hook into + EB_HOOK_END_CANDIDATE_GROUP and EB_HOOK_END_CANDIDATE_LEAF. + * eb/text.h (EB_HOOK_BEGIN_SOUND, EB_HOOK_END_SOUND, + EB_HOOK_BEGIN_PICTURE, EB_HOOK_END_PICTURE): Removed temporary. + * eb/defs.h (EB_NUMBER_OF_HOOKS): Updated. + + * eb/defs.h (EB_Text_Context): Add the members `candidate' and + `is_candidate'. + * eb/text.c (eb_current_candidate): New function. + + * eb/text.c (eb_read_internal): Manage the current candidate. + * eb/text.c (eb_seek_text, eb_read_text, eb_read_heading): + Clear the current candidate. + + * eb/text.c (eb_seek_text): Complain if the given position is not + valid. + +2000-11-07 Motoyuki Kasahara + + * eb/hook.c (euc_a1_to_ascii_table, euc_a1_to_ascii_table): + The tables start with the character 0xa0 and end with 0xff. + * eb/hook.c (EUC_TO_ASCII_TABLE_START, EUC_TO_ASCII_TABLE_END): + Defined + * eb/hook.c (eb_hook_euc_to_ascii): Use new convertion tables. + + * eb/multi.c (eb_multi_entry_candidates): Return EB_ERR_NO_CANDIDATES + not EB_ERR_NO_SUCH_SEARCH if the multi entry doesn't have candidates. + + * eb/error.c (EB_ERR_STOP_CODE): Defined. + * eb/error.c (EB_ERR_HOOK_WORKSPACE): Removed. + * eb/hook.c (eb_hook_stop_code): Return EB_ERR_STOP_CODE when the + stop code is found. + * eb/text.c (eb_read_text_internal): Return only when STOP_CODE hook + function returns EB_ERR_STOP_CODE. + +2000-11-06 Motoyuki Kasahara + + * eb/text.c (eb_read_text_internal): `argv' must be `unsigned int []'. + * eb/text.c (eb_read_text_internal): Set MSB of argv[0] passed to + NARROW_JISX0208, WIDE_JISX0208, GB2312 hooks. + +2000-11-04 Motoyuki Kasahara + + * eb/text.c: Include . + +2000-11-03 Motoyuki Kasahara + + * eb/defs.h (EB_Text_Context_Strcut): + The member `work_buffer', `work_length' and `work_step' are removed. + The member `out', `out_rest_length', `unprocessed', `in_step', + `out_step' and `unprocessed_size' are added. + * eb/text.c (eb_read_text_internal): `text_p' and `text_rest_length' + are now recorded in `book->text_context.out' and + `book->text_context.out_rest_length'. + * eb/defs.h (EB_MAX_WORK_LENGTH): Removed. + + * eb/text.c (eb_read_text_internal): Don't write `\0' on the tail + of text buffer. + + * eb/text.c (eb_write_text_byte1, eb_write_text_byte2, + eb_write_text_string, eb_write_text): New functions. + * eb/text.c (eb_read_text_internal): Use eb_write_text*() functions + to write characters to a text buffer. Don't write directly. + + * eb/defs.h (EB_Hook_Struct): The type of `argv' is changed from + `const int *' to `const unsigned int *'. + + * eb/defs.h (EB_Hook_Struct): Add the new argument `container' + and remove `workbuf'. + * eb/hook.c (eb_hook_euc_to_ascii, eb_hook_stop_code, + eb_hook_narrow_character_text, eb_hook_wide_character_text, + eb_hook_empty): Ditto. + * eb/text.c (eb_read_text, eb_read_heading): Add the new argument + `container'. + + * eb/hook.c (eb_hook_newline): New function. + * eb/hook.c (eb_initialize_hookset): Set EB_HOOK_NEWLINE of the + default hookset. + +2000-10-31 Motoyuki Kasahara + + * ebinfo/ebinfo.c (output_information): In the font-size and + font-range paramter lines, output a newline character even + when an error occurs. + +2000-10-30 Motoyuki Kasahara + + * eb/hook.c (eb_hook_stop_code): Return EB_ERR_HOOK_WORKSPACE + not -1 when a stop code is found. + + * eb/text.c (eb_read_text, eb_read_heading, eb_read_text_internal): + give up formatting text when a hook function returns any other value + than EB_SUCCESS. + +2000-10-27 Motoyuki Kasahara + + * ebzip/filename.c (compose_exisitent_path_name, + compose_exisitent_path_name2, compose_exisitent_path_name3): + New functions. + * ebzip/ebzip.c (zip_eb_book, zip_epwing_book, unzip_eb_book, + unzip_epwing_book, zipinfo_eb_book, zipinfo_epwing_book): Use + compose_exisitent_path_name*() functions instead of sprintf(). + + * eb/filename.c (eb_canonicalize_path_name): Don't expand `/./' + and `/../' in the given path name. + +2000-10-26 Motoyuki Kasahara + + * eb/subbook.c (eb_set_subbook): Set `book->subbook_current->text_file' + to 1 when no text file exists. + +2000-10-21 Motoyuki Kasahara + + * eb/text.c (eb_read_text_internal): Cache controll bug was still + remained. Fix the bug. + + * doc-ja/ebinfo-ja.texi: Include `ebinfo-ver.texi', not `version.texi'. + +2000-10-20 Motoyuki Kasahara + + * Version 3.0alpha2. + + * doc-ja/Makefile.am (EXTRA_DIST): Remove `stamp-eb'. + * doc-ja/Makefile.am (stamp-eb): Remove the target. + + * eb/text.c (eb_read_text_internal): Fix a cache controll bug. + Reported by Rei. + +2000-10-17 Motoyuki Kasahara + + * eb/ebzip.c (zip_epwing_book): Fix a bug that it tries to compress + non-existant font files. + * eb/text.c (eb_read_text_internal): Check text-end-flag, + cache buffer, and unprocessed data in the text context, in + this order. + +2000-09-30 Motoyuki Kasahara + + * eb/zio.c (eb_zopen_epwing): Add missing initialization code for + the variable `read_length'. + +2000-09-24 Motoyuki Kasahara + + * eb/defs.h (EB_Language_Struct): the member `offset' is renamed to + `location'. + * eb/defs.h (EB_Zip_Struct): likewise. + + * eb/appsub.c (eb_initialize_appendix_subbook): value passed to + eb_zlseek() must be off_t. + * eb/font.c (eb_initialize_font): Likewise. + * eb/language.c (eb_set_language): Likewise. + * eb/multi.c (eb_initialize_multi_search): Likewise. + * eb/narwalt.c (eb_narrow_character_text_jis): Likewise. + * eb/narwalt.c (eb_narrow_character_text_latin): Likewise. + * eb/narwfont.c (eb_initialize_narrow_font): Likewise. + * eb/narwfont.c (eb_narrow_character_bitmap_jis): Likewise. + * eb/narwfont.c (eb_narrow_character_bitmap_latin): Likewise. + * eb/search.c (eb_presearch_word): Likewise. + * eb/search.c (eb_hit_list_word): Likewise. + * eb/search.c (eb_hit_list_keyword): Likewise. + * eb/search.c (eb_hit_list_multi): Likewise. + * eb/subbook.c (eb_initialize_subbook): Likewise. + * eb/widealt.c (eb_wide_character_text_jis): Likewise. + * eb/widealt.c (eb_wide_character_text_latin): Likewise. + * eb/widefont.c (eb_initialize_wide_font): Likewise. + * eb/widefont.c (eb_wide_character_bitmap_jis): Likewise. + * eb/widefont.c (eb_wide_character_bitmap_latin): Likewise. + * eb/text.c (eb_initialize_text): `book->text_context.location' + must be calculated with `off_t' values. + + * po/POTFILES.in: Add `libebutils/getopt.c'. + + * eb/zio.c (eb_zopen_none): Get file size, reported by Takashi NEMOTO. + +2000-09-09 Motoyuki Kasahara + + * eb/defs.h (EB_Subbook_Struct): Add the member `cross'. + * eb/subbook.c (eb_initialize_subbook): Also initialize the member + `cross'. + * eb/subbook.c (eb_initialize_indexes): Recognize index code + 0x81 as Cross-Index. + +2000-09-07 Motoyuki Kasahara + + * eb/setword.c (eb_fix_word_latin): Renamed to `eb_convert_latin'. + * eb/setword.c (eb_fix_word_jis): Renamed to `eb_convert_euc_jp'. + + * eb/setword.c (eb_fix_word): New static function. + * eb/setword.c (eb_set_word, eb_set_endword, eb_set_keyword): + Call `eb_fix_word' to fix `word' and `canonicalized_word' according + with index page style. + * eb/setword.c (eb_set_endword): Get index page style from endword + search indexes, not from word search. + * eb/setword.c (eb_set_keyword): Get index page style from keyword + search indexes, not from word search. + + * eb/libintl_r.c: New file. + * eb/error.c (gettext_mutex): Moved to `libintl_r.c'. + * eb/error.c (eb_error_message): Do not lock. + * eb/error.c (eb_error_message_r): New function. + + * eb/lock.c (eb_pthread_enabled): New function. + * eb/eb.c (eb_nls_enabled): New function. + + * eb/Makefile.am (pkginclude_HEADERS): Add `libintl_r.h'. + * eb/Makefile.am (libintl_la_SOURCES): Add `libintl_r.c'. + + * eb/subbook.c (eb_set_subbook): Don't return an error code when + no text file exists. + + * eb/setword.c (eb_convert_euc_jp): Accept local character + 0xa121 ... 0xfe7e. + + * eb/subbook.c (eb_initialize_subbook): Becomes static function. + * eb/appsub.c (eb_initialize_appendix_subbook): Likewise. + + * eb/text.c (eb_read_text, eb_read_heading, eb_forward_text, + eb_read_text_internal): Discard `const' of the argument `hookset'. + + * eb/subbook.c (eb_set_subbook): Add missing call of eb_unlock(). + + * eb/text.c (eb_fowrard_text): Don't unlock `cache_mutex'. + * eb/text.c (eb_fowrard_heading): Likewise. + + * eb/zio.c (eb_zread_ebzip, eb_zread_epwing, eb_zread_sebxa): Don't + lock or unkock `cache_mutex'. + * eb/zio.c (eb_zread): Lock and unkock `cache_mutex'. + + * eb/internal.h.in (EB_ZIP_INVALID): Defined. + * eb/zip.c (eb_zopen_none, eb_zopen_ebzip, eb_zopen_epwing, + eb_zopen_epwing6): Now they are static functions. + * eb/zip.c (eb_zopen): New function. + + * eb/appsub.c (eb_set_subbook): Call eb_zopen(), instead of + eb_zopen_ZIPTYPE() functions. + * eb/font.c (eb_set_font): Likewise. + * eb/language.c (eb_initialize_language): Likewise. + * eb/language.c (eb_set_language): Likewise. + * eb/subbook.c (eb_set_subbook): Likewise. + * ebzip/ebzip.c (zip_eb_book, zip_epwing_book, unzip_eb_book, + unzip_epwing_book, zipinfo_eb_book, zipinfo_epwing_book): Likewise. + * ebzip/ebzip.c (zip_file, unzip_file, zipinfo_file): The argument + `in_open_function' is replaced to `in_zip_code'. + + * ebzip/ebzip.c (zipinfo_file): Call `stat' before open a file. + + * ebzip/ebzip.c (zipinfo_epwing_book): Skip font entires whose + code is EB_FONT_INVALID. + +2000-09-05 Motoyuki Kasahara + + * eb/internal.h.in, libebutils/ebutils.c, ebfont/ebfont.c, + ebinfo/ebinfo.c, ebzip/ebzip.c: Define `_' and `N_' macros even + when ENABLE_NLS is not defined. + +2000-08-11 Motoyuki Kasahara + + * ebfont/ebfont.c (make_subbook_size_image_fonts): Fixed bugs + that use old API. Reported by Takashi NEMOTO. + * eb/book.c (eb_initialize_catalog): Fix a bug that wrong font code + is set to EB_Font struct. Reported by Takashi NEMOTO. + + * eb/internal.h.in (EB_INDEX_STYLE_REVERSED_CONVERT): Defined. + Super Tougou Jisho 2000 sets 2 to the katakana index style parameter. + * eb/setword.c (eb_convert_hiragana_jis): New function. + Convert all hiragana characters in a string to katakana. + * eb/setword.c (eb_set_word): If the katakana index style parameter + is EB_INDEX_STYLE_REVERSED_CONVERT, call eb_convert_hiragana_jis(). + +2000-08-04 Motoyuki Kasahara + + * eb/internal.h.in (eb_initialize_lock, eb_finalize_lock, eb_lock, + eb_unlock): Add function declarations. + * eb/font.c (eb_set_font): Set the variable `subbook' after + lock the book. + * eb/font.c (eb_set_font, eb_font_list, eb_have_font): Set the + variable `subbook' after lock the book. + + * eb/Makefile.am (libeb_la_SOURCES): Add lock.c. + +2000-07-21 Motoyuki Kasahara + + * Version 3.0alpha1. + + * eb/defs.h (EB_Huffman_Node_Struct): The type of the member `value' + is changed to `unsigned int'. + + * eb/epwunzip.c (eb_unzip_slice_epwing6): New function. + + * libebutils/ebutils.c (fix_file_name, parse_case_argument, + parse_suffix_argument): Removed. + + * eb/internal.h.in: Include `config.h'. + * eb/internal.h.in: Always includes `defs.h'. + * eb/internal.h: Delete extern declaration of `eb_option'. + + * eb/font.c, eb/message.c, eb/search.c, eb/text.c: Remove cpp macro + definition of `memmove'. + * eb/internal.h.in: Add cpp macro definition of `memmove'. + * eb/filename.c: Remove cpp macro definition of `strcasecmp' and + `strncasecmp'. + * eb/internal.h.in: Add cpp macro definition of `strcasecmp' and + `strncasecmp'. + + * ebzip/ebzip.c (short_options, long_options): Delete `--suffix' + and `--case' options. + +2000-07-20 Motoyuki Kasahara + + * eb/filename.c (eb_fix_file_name2, eb_fix_file_name3): New functions. + * ebzip/filename.c (compose_out_file_name, compose_out_file_name2, + compose_out_file_name3): New functions, New file. + * eb/Makefile.am (ebzip_SOURCES): Add `filename.c'. + * ebzip/ebzip.c (zip_book, unzip_book, zipinfo_book): Rewritten. + * ebzip/ebzip.c: Delete `--case' and `--suffix' options. + + * eb/defs.h (EB_ZIP_EPWING): Assign the value `100'. + * eb/defs.h (EB_ZIP_EPWING6, EB_ZIP_SEBXA): New macros. + + * eb/internal.h.in (EB_HUFFMAN_NODE_EOF, EB_HUFFMAN_NODE_LEAF8, + EB_HUFFMAN_NODE_LEAF16): Assign new values. + * eb/internal.h.in (EB_HUFFMAN_NODE_LEAF32): Defined. + + * eb/zio.c (eb_zread_ebzipped): Renamed to eb_zread_ebzip(). + * eb/zio.c (eb_zread_epwzipped): Renamed to eb_zread_epwing(). + * eb/ebunzip1.c (eb_ebunzip1_slice): Renamed to + eb_unzip_slice_ebzip1().. + * eb/epwunzip.c (eb_epwunzip_slice): Renamed to + eb_unzip_slice_epwing(). + + * eb/ebunzip1.c: Renamed to eb/unzebzip.c. + * eb/epwunzip.c: Renamed to eb/unzepwing.c. + * eb/unzsebxa.c: New file. + +2000-07-16 Motoyuki Kasahara + + * eb/subbook.c (eb_initialize_all_subbooks): Also set each font. + * eb/subbook.c (eb_initialize_all_subbooks): Call eb_unset_subbook() + if an error occurs. + + * ebzip/Makefile.am (ebzip_SOURCES): Remove `filelist.c'. + * ebzip/ebzip.c: Remove function declarations of + initialize_file_name_list(), finalize_file_name_list() and + add_file_name_list(). + +2000-07-09 Motoyuki Kasahara + + * eb/narwfont.c (eb_narrow_font_file_name, eb_narrow_font_file_name2): + Removed. + * eb/widefont.c (eb_wide_font_file_name, eb_wide_font_file_name2): + Removed. + + * eb/font.c (eb_initialize_fonts, eb_initialize_eb_fonts, + eb_initialize_epwing_fonts): Removed. + * eb/font.c (eb_initialize_font): New function. + * eb/narwfont.c (eb_initialize_narrow_font): New function. + * eb/widefont.c (eb_initialize_wide_font): New function. + * eb/appendix.c (eb_initialize_appendix_catalog): Adapt to new + file name composition rule. + * eb/appsub.c (eb_set_subbook): Likewise. + * eb/book.c (eb_initialize_catalog): Likewise. + * eb/font.c (eb_set_font): Likewise. + * eb/language.c (eb_initialize_language): Likewise. + * eb/language.c (eb_set_language): Likewise. + * eb/subbook.c (eb_set_subbook): Likewise. + + * eb/zio.c (eb_zopen, eb_zopen2): Removed. + * eb/zio.c (eb_zopen_none): New function. + * eb/zio.c (eb_zopen_ebzipped): Renamed to `eb_zopen_ebzip' and + changed to non-static. + * eb/zio.c (eb_zopen_epwing): Renamed to `eb_zopen_epwing' and + changed to non-static. + + * eb/appendix.c (eb_initialize_appendix_catalog): Adjuts subbook + directory names. + * eb/book.c (eb_initialize_catalog): Likewise. + * eb/appsub.c (eb_initialize_appendix_subbook): Adjust data directory + name. + * eb/subbook.c (eb_initialize_subbook): Adjust date, gaiji, stream + and movie directory names. + + * configure.in (AC_HEADER_DIRENT): Added. + + * eb/subbook.c (eb_initialize_subbook): Don't call + eb_initialize_fonts(). + + * eb/defs.h (EB_CASE_UNCHANGE, EB_CASE_UPPER, EB_CASE_LOWER): Deleted. + * eb/defs.h (EB_SUFFIX_UNCHANGE, EB_SUFFIX_NONE, EB_SUFFIX_DOT, + EB_SUFFIX_PERIOD, EB_SUFFIX_VERSION, EB_SUFFIX_BOTH): Deleted. + * eb/ebzip.c (CASE_UNCHANGE, CASE_UPPER, CASE_LOWER): Defined. + * eb/ebzip.c (SUFFIX_UNCHANGE, SUFFIX_NONE, SUFFIX_DOT, + SUFFIX_VERSION, SUFFIX_BOTH): Defined. + + * eb/defs.h (EB_FILE_NAME_START, EB_FILE_NAME_SOUND, + EB_FILE_NAME_CATALOG, EB_FILE_NAME_LANGUAGE, EB_FILE_NAME_WELCOME, + EB_FILE_NAME_CATALOGS, EB_FILE_NAME_HONMON, EB_FILE_NAME_HONMON2, + EB_FILE_NAME_APPENDIX, EB_FILE_NAME_FUROKU, EB_DIRECTORY_NAME_DATA, + EB_DIRECTORY_NAME_GAIJI, EB_DIRECTORY_NAME_STREAM, + EB_DIRECTORY_NAME_MOVIE): Move these definitions to `eb/internal.h.in' + and convert their values to lower cases. + * eb/internal.h.in (EB_SUFFIX_EBZ): Defined. + * eb/internal.h.in (EB_SUFFIX_NONE): Defined. + * eb/internal.h.in (EB_FILE_NAME_HONMONS): Defined. + * eb/internal.h.in (EB_FILE_NAME_HONMONG): Defined. + * eb/internal.h.in (EB_FILE_NAME_VTOC): Removed. + + * eb/ebinfo.c (output_information): Adapt to new EB_FONT_* macro + values. They were 16, 24, 30, 48, but now they are 0, 1, 2, 3. + +2000-07-08 Motoyuki Kasahara + + * eb/defs.h (EB_MAX_BASE_NAME_LENGTH): Renamed to + EB_MAX_DIRECTORY_NAME_LENGTH. + * eb/defs.h (EB_MAX_FILE_NAME_LENGTH): Defined. + + * eb/defs.h (EB_Subbook_Struct): Add the member `version'. + * eb/book.c (eb_initialize_catalog): Set format version. + + * eb/zio.c (eb_zopen_epwzipped): Check if least frequent node + is found or not after scanning a node list. + + * eb/strcasecmp.c: New file. + * eb/Makefile.am (libeb_la_SOURCES): Add `strcasecmp.c'. + + * libebutil/strcasecmp.c: Include `sys/type.h'. + + * eb/defs.h (EB_Subbook_Struct): Rename the member `directory' to + `directory_name', + * eb/defs.h (EB_Subbook_Struct): Add the member `data_directory_name', + `gaiji_directory_name', `movie_directory_name', + `stream_directory_name', `text_file_name', `graphic_file_name', + and `sound_file_name'. + * eb/defs.h (EB_Book_Struct): Remove the member `case_code' and + `suffix_code'. + * eb/defs.h (EB_Appendix_Struct): Add the member `data_directory_name', + and `appendix_file_name'. + * eb/defs.h (EB_Appendix_Subbook_Struct): Rename the member + `directory' to `directory_name', + * eb/defs.h (EB_APpendix_Subbook_Struct): Remove the member + `case_code' and `suffix_code'. + + * eb/filename.c (eb_catalog_file_name): Removed. + * eb/filename.c (eb_appendix_catalog_file_name): Removed. + * eb/filename.c (eb_canonicalize_appendix_file_name): Removed. + * eb/filename.c (eb_canonicalize_file_name_internal): Renamed to + `eb_canonicalize_file_name'. The original `eb_canonicalize_file_name' + is overwritten. + * eb/filename.c (eb_fix_file_name): Removed. + * eb/filename.c (eb_fix_appendix_file_name): Removed. + * eb/filename.c (eb_fix_file_name_internal): Removed. + * eb/filename.c (eb_fix_directory_name, eb_fix_sub_directory_name): + New functions. + * eb/filename.c (eb_fix_file_name, eb_compose_file_name, + eb_compose_file_name2, eb_compose_file_name3): New functions. + + * eb/defs.h (EB_DIRECTORY_NAME_DATA, EB_DIRECTORY_NAME_GAIJI, + EB_DIRECTORY_NAME_STREAM): Moved to eb/internal.h.in. + * eb/internal.h.in (EB_DIRECTORY_NAME_STREAM, + EB_DIRECTORY_NAME_MOVIE): Defined. + + * eb/font.h (EB_FONT_16, EB_FONT_24, EB_FONT_30, EB_FONT_48): + Change their integer values. + + * eb/defs.h (EB_Font_Struct): Remove the memeber `width' and `height'. + * eb/defs.h (EB_Font_Struct): Add the memeber `available' and + `font_code'. + * eb/defs.h (EB_Subbook_Struct): Remove the memeber `font_count'. + * eb/defs.h (EB_Subbook_Struct): Split the memeber `fonts' into + `narrow_fonts' and `wide_fonts'. + * eb/book.c (eb_initialize_catalog): Assume that the order of font + names is always wide-16, -24, -30, -48, narrow-16, -24, -30, -48. + + * eb/font.c (eb_initialize_eb_fonts, eb_initialize_epwing_fonts, + eb_font, eb_set_font, eb_unset_font, eb_font_list, eb_have_font): + Catch up with new EB_Font_Struct. + * eb/narwfont.c (eb_have_narrow_font, eb_narrow_font_width, + eb_narrow_font_width2, eb_narrow_font_size, eb_narrow_font_size2, + eb_narrow_font_file_name, eb_narrow_font_file_name2, + eb_narrow_font_start, eb_narrow_font_end, + eb_narrow_character_bitmap_jis, eb_narrow_character_bitmap_latin): + Likewise. + * eb/widefont.c (eb_have_wide_font, eb_wide_font_width, + eb_wide_font_width2, eb_wide_font_size, eb_wide_font_size2, + eb_wide_font_file_name, eb_wide_font_file_name2, + eb_wide_font_start, eb_wide_font_end, + eb_wide_character_bitmap_jis, eb_wide_character_bitmap_latin): + Likewise. + * eb/subbook.c (eb_initialize_indexes): Likewise. + + * eb/font.c (eb_font_height, eb_font_height2): New functions. + * eb/font.h (EB_HEIGHT_FONT_16, EB_HEIGHT_FONT_24, EB_HEIGHT_FONT_30, + EB_HEIGHT_FONT_48): Defined. + + * eb/defs.h (EB_Subbook_Struct): Rename the member `zip' to + `text_zip'. + * eb/defs.h (EB_Appendix_Subbook_Struct): Rename the member `zip' to + `appendix_zip'. + +2000-06-24 Motoyuki Kasahara + + * eb/subbook.c (eb_initialize_subbook): Fix bugs that EB 2.x API + are remained. + + * eb/setword.c (eb_fix_word_jis): Initialize `c1' and `c2' to + avoid GCC warning `might be used uninitialized...'. + + * eb/search.c (eb_presearch_word): Return EB_ERR_FAIL_SEEK_TEXT + when eb_zlseek() failed, and EB_ERR_FAIL_READ_TEXT when eb_zread(). + + * eb/exactword.c (eb_search_exactword): Return EB_ERR_NO_SUCH_FONT + when invalid font height is given. + + * eb/bitmap.c (eb_narrow_font_xbm_size): Return EB_ERR_NO_SUCH_FONT + when invalid font height is given. + * eb/bitmap.c (eb_narrow_font_xpm_size): Likewise. + * eb/bitmap.c (eb_narrow_font_gif_size): Likewise. + * eb/bitmap.c (eb_wide_font_xbm_size): Likewise. + * eb/bitmap.c (eb_wide_font_xpm_size): Likewise. + * eb/bitmap.c (eb_wide_font_gif_size): Likewise. + + * eb/appendix.c (eb_initialize_appendix_catalog): Return + EB_ERR_FAIL_OPEN_CATAPP when failed to open the catalog file. + * eb/book.c (eb_initialize_catalog): Return EB_ERR_FAIL_OPEN_CAT when + failed to open the catalog file. + + * eb/hook.c: Include appendix.h. + + * configure.in (AC_OUTPUT_COMMANDS): Remove `libintl.h', linked + from `libgettext.h' by gettext.m4. + * intl/Makefile.am: Make a symlink from `libgettext.h' to `libintl.h'. + + * eb/zio.c (eb_zopen, eb_zopen2): Support DOS style path, reported + by Kazuhiro Ito. + + * Makefile.am (SUBDIRS): Don't use ${INTL_SUBDIR} for `intl' + because automake complains. + * intl/Makefile.am (INCLUDED_LIBINTL): Use this conditional + to determine whether we build `libintl.la' or not. + * Makefile.am (intl/lib_LTLIBRARIES): Set to $(INTL_LTLIB). + +2000-06-17 Motoyuki Kasahara + + * ebrefile/ebrefile.in: Fix a bug that ebrefile fills the reserved-1 + with 0x00, reported by Takashi NEMOTO. + +2000-06-13 Motoyuki Kasahara + + * eb/keyword.c (eb_search_keyword): Type of 2nd argument is changed + from `const *[]' to `const * const []'. + * eb/multi.c (eb_search_multi): Likewise. + + * configure.in (ZLIBLIBS): Fixed a bug that this variable was not + set when zlib was built from included sources,reported by Kazuhiro + Ito. + * eb/filename.c (eb_canonicalize_file_name_internal for DOS): + EB Library 2.x API code was remained, reported by Kazuhiro Ito. + Fixed. + +2000-06-11 Motoyuki Kasahara + + * ebzip/ebzip.c (zip_file): Type of 2nd argument is changed from + `const char **' to `const char * const *'. + * ebzip/ebzip.c (unzip_file): Likewise + * ebzip/ebzip.c (zip_finfo): Likewise. + + * libebutils/ebutils.c (parse_case_argument): Control reached end of + non-void function. Fixed. + * libebutils/ebzip.c (parse_suffix_argument): Likewise. + * libebutils/getumask.c: Include `sys/stat.h'. + + * eb/book.c (misleaded_book_table): Type is changed from + `const char *[]' to `const char * const[]'. + * eb/error.c (error_messages): Likewise. + +2000-05-27 Motoyuki Kasahara + + * Version 3.0alpha0. + + * configure.in: Add `--enable-pthread', `--with-pthread-cppflags', + `--with-pthread-cflags' and ``--with-pthread-ldflags'. + * configure.in (AC_TRY_LINK): Add a test program that checks Pthread. + + * configure.in (WITH_ZLIB): Renamed to `INCLUDED_ZLIB'. + + * configure.in: Add `--with-gettext-includes' and + `--with-gettext-libraries' options. + + * configure.in (EBCONF_ZLIBINCS, EBCONF_ZLIBLIBS, PTHREAD_CPPFLAGS, + PTHREAD_CFLAGS, PTHREAD_LDFLAGS, EBCONF_INTLINCS, EBCONF_INTLLIBS, + EBCONF_EBINCS, EBCONF_EBLIBS): Substitute these variables, for + generating eb.conf. + * Makefile.am (sysconf_DATA): Add `eb.conf'. + * Makefile.am (CLEANFILES): Add `eb.conf'. + * Makefile.am (EXTRA_DIST): Add `eb.conf.in'. + * Makefile.am (eb.conf): New target. + +2000-05-22 Motoyuki Kasahara + + * configure.in: Remove the `--enable-ja-doc' option. + * Makefile.am (ENABLE_JA_DOC): Remvoe the condition. + * Makefile.am (SUBDIRS): Remove $(JA_DOC_SUBDIR). + + * configure.in (AC_OUTPUT): Add `eb_r/Makefile'. + * Makefile.am (ENABLE_PTHREAD): Add the condition. + * Makefile.am (SUBDIRS): Add $(EB_R_SUBDIR). + * eb_r/Makefile.am: New file. + + * eb/defs.h (EB_Text_Context_Struct): Add `auto_stop_code'. + * eb/text.c (eb_seek_text): Initialize `auto_stop_code' of the + text context in `book'. + * eb/text.c (eb_read_text_internal): Update `auto_stop_code' + when the control sequence 0x41 is seen. + * eb/hook.c (eb_hook_stop_code): Don't assume the control sequence + 0x09 as the stop code. + + * eb/text.h (EB_HOOK_STOPCODE): Renamed to EB_HOOK_STOP_CODE. + +2000-05-21 Motoyuki Kasahara + + * eb/Makefile.am (install-data-hook): Removed. + +2000-05-20 Motoyuki Kasahara + + * libebtuils/Makefile.am (libebutils_a_SOURCES): Add `ebtuils.c'. + * libebtuils/Makefile.am (INCLUDES): Add `-I$(top_srcdir)/intl'. + * libebtuils/ebtuils.c: New file. + * libebtuils/ebtuils.c (output_try_help, output_version, + parse_case_argument, parse_suffix_argument, + parse_subbook_name_argument, find_subbook, fix_file_name, + canonicalize_path): Define these functions. + * libebtuils/ebtuils.c (program_name, program_version, invoked_name): + Define these global variables. + * ebfont/ebfont.c (program_name, program_version, invoked_name): + these global variables are removed. + * ebinfo/ebinfo.c (program_name, program_version, invoked_name): + Likewise. + * ebzip/ebzip.c (program_name, program_version, invoked_name): + Likewise. + * ebfont/ebfont.c (parse_subbook_name_argument, find_subbook, + output_version, output_try_help, canonicalize_path): + these global functions are removed. + * ebinfo/ebinfo.c (output_version, output_try_help): + Likewise. + * ebzip/ebzip.c (output_version, output_try_help, + parse_subbook_name_argument, find_subbook, fix_file_name, + canonicalize_path): + Likewise. + +2000-05-18 Motoyuki Kasahara + + * eb/Makefile.am (EXTRA_DIST): Add `internal.h.in'. + * eb/Makefile.am (CLEANFILES): Defined and add + `stamp-defs-h` and `internal.h' to this macro. + * eb/Makefile.am (BUILT_SOURCES): Defined as `internal.h'. + * eb/Makefile.am (noinst_HEADERS): Add `internal.h'. + * eb/Makefile.am (internal.h, stamp-internal-h): New targets. + +2000-05-14 Motoyuki Kasahara + + * move-if-change: New script. + * Makfile.am (EXTRA_DIST): Add `move-if-change'. + * libebutils/Makefile.am (EXTRA_DIST): Add `ebutils.h.in'. + * libebutils/Makefile.am (CLEANFILES): Defined and add + `stamp-defs-h` and `ebutils.h' to this macro. + * libebutils/Makefile.am (BUILT_SOURCES): Defined as `ebutils.h'. + * libebutils/Makefile.am (noinst_HEADERS): Add `ebutils.h'. + * libebutils/Makefile.am (ebutils.h, stamp-ebutils-h): New targets. + + * eb/error.c, ebfont/ebfont.c, ebinfo/ebinfo.c, ebzip/ebzip.c, + ebzip/filelist.c: Support gettext. + * ebfont/ebfont.c, ebinfo/ebinfo.c, ebzip/ebzip.c: Include + locale.h, libintil.h and ebutils.h. + * ebfont/ebfont.c, ebinfo/ebinfo.c, ebzip/ebzip.c (main): Call + setlocale(), bindtextdomain() and textdomain() when NLS is enabled. + + * ebfont/Makefile.am, ebinfo/Makefile.am, ebzip/Makefile.am + (INCLUDES): Add `-I$(srcdir)/../intl'. + * ebfont/Makefile.am (ebfont_LDADD): Add @INTLLIBS@. + * ebinfo/Makefile.am (ebinfo_LDADD): Likewise. + * ebzip/Makefile.am (ebzip_LDADD): Likewise. + * ebfont/Makefile.am (ebfont_DEPENDENCIES): Add @INTLDEPS@. + * ebinfo/Makefile.am (ebinfo_DEPENDENCIES): Likewise. + * ebzip/Makefile.am (ebzip_DEPENDENCIES): Likewise. + + * po/Makefile.in.in, eb/po/Makefile.in.in: Support DESTDIR. + * po/Makefile.in.in, eb/po/Makefile.in.in (TEXTDOMAIN, top_builddir, + subdir): Defined. + * po/Makefile.in.in, eb/po/Makefile.in.in: Don't use $PACKAGE for + text domain name. Use $TEXTDOMAIN, instead. + * po/Makefile.in.in, eb/po/Makefile.in.in: Don't use `basename'. + * po/Makefile.in.in, eb/po/Makefile.in.in: Use `$(top_builddir)' not + '..'. Use `$(top_srcdir) not `$(srcdir)/.' + * po/Makefile.in.in, eb/po/Makefile.in.in: Use `$(top_builddir)/intl' + not `../intl'. Use `$(top_srcdir)/../intl' not `$(srcdir)/../intl'. + * po/Makefile.in.in, eb/po/Makefile.in.in: Set @localedir@ to + $localedir. + * po/Makefile.in.in, eb/po/Makefile.in.in: Use `$(subdir)' not `po'. + +2000-05-13 Motoyuki Kasahara + + * eb/po: New directory. + * eb/Makefile.am (SUBDIRS): Add `po'. + * configure.in (AC_OUTPUT): Add `eb/po/Makefile.in'. + * configure.in (AC_OUTPUT_COMMANDS): Generate `Makefile' from + `Makefile.in'. + * configuer.in: Subst `localedir'. + * acconfig.h (ENABLE_NLS, HAVE_CATGETS, HAVE_GETTEXT, HAVE_LC_MESSAGES, + HAVE_STPCPY): Defined. + + * configure.in (DEPENDENCIES_FOR_LIBZ): Renamed to `ZLIBDEPS'. + * configure.in (LDADD_FOR_LIBZ): Renamed to `ZLIBLIBS'. + * configure.in (INCLUDES_FOR_LIBZ): Renamed to `ZLIBINCS'. + +2000-05-11 Motoyuki Kasahara + + * configure.in (--with-zlib): Renamed to `--with-included-zlib'. + * Invoke gettexize. + * configure.in (ALL_LINGUAS, AM_GNU_GETTEXT): Added. + * Makefile.am (SUBDIRS): Add `intl' and `po'. + * configure.in (AC_OUTPUT): Add `intl/Makefile' and `po/Makefile'. + +2000-05-05 Motoyuki Kasahara + + * acconfig.h (USE_FAKELOG, EB_BUILD_LIBRARY): Remove the definitions. + * eb/Makefile.am (INCLUDES): Add `-DEB_BUILD_LIBRARY'. + * libebutils/Makefile.am (INCLUDES): Defined as `-DUSE_FAKELOG'. + +2000-05-03 Motoyuki Kasahara + + * eb/error.h (EB_ERR_NO_CANDIDATES): Added. + + * eb/language.h (EB_LANG_ENGLISH, EB_LANG_FRENCH, EB_LANG_GERMAN, + EB_LANG_ITALIAN, EB_LANG_SPANISH, EB_LANG_JAPANESE, EB_LANG_DANISH, + EB_LANG_FINNISH, EB_LANG_SWEDISH, EB_LANG_NORWEGIAN, EB_LANG_DUTCH, + EB_LANG_POLISH): Rename _LANG_ to _LANGUAGE_. + * eb/language.h (EB_MSG_WORD_SEARCH, EB_MSG_END_SEARCH, + EB_MSG_KEY_SEARCH, EB_MSG_MENU_SEARCH, EB_MSG_MULTI_SEARCH, + EB_MSG_GRAPHIC_SEARCH, EB_MSG_BOOK_CONTAIN, EB_MSG_ENTER_WORD, + EB_MSG_ENTER_WORDS, EB_MSG_SUCCESSFUL, EB_MSG_ENTRY, EB_MSG_ENTRIES, + EB_MSG_SEARCH_FAIL, EB_MSG_PUSH_NO, EB_MSG_INSERT_DISC, + EB_MSG_CANT_READ, EB_MSG_REINSERT_DISC, EB_MSG_CLEAN_DISC, + EB_MSG_NOT_EB_DISC, EB_MSG_SEARCHING, EB_MSG_CHANGING_BATT, + EB_MSG_DRY_BATT, EB_MSG_CHARGE_END, EB_MSG_BATT_EMPTY, + EB_MSG_BATT_CHANGE, EB_MSG_CANT_CHANGE_BATT, EB_MSG_SELECT_LANGUAGE, + EB_MSG_MENU): Rename _MSG_ to _MESSAGE_. + + * eb/language.h (EB_MESSAGE_INVALID): Defined. + * eb/language.h (EB_LANG_ERROR): Renamed to EB_LANGUAGE_INVALID. + * eb/defs.h (EB_MULTI_INVALID, EB_MULTI_ENTRY_INVALID): Defined. + + * eb/defs.h (EB_CHARCODE_ERROR): Renamed to EB_CHARCODE_INVALID. + * eb/defs.h (EB_WORD_ERROR): Renamed to EB_WORD_INVALID. + * eb/defs.h (EB_TEXT_ERROR): Renamed to EB_TEXT_INVALID. + * eb/defs.h (EB_DISC_ERROR): Renamed to EB_DISC_INVALID. + * eb/defs.h (EB_SUBBOOK_ERROR): Renamed to EB_SUBBOOK_INVALID. + * eb/defs.h (EB_MULTI_ERROR): Renamed to EB_MULTI_INVALID. + * eb/defs.h (EB_MULTI_ENTRY_ERROR): Renamed to + EB_MULTI_ENTRY_INVALID. + * eb/font.h (EB_FONT_ERROR): Renamed to EB_FONT_INVALID. + +2000-03-29 Motoyuki Kasahara + + * ebinfo/ebinfo.c (output_multi_information): Fix the length of + an entry label buffer. + + * eb/stopcode.c (eb_have_stopcode): Renamed to eb_have_stop_code(). + * eb/stopcode.c (eb_stopcode): Renamed to eb_stop_code(). + * eb/hook.c (eb_hook_stopcode): Renamed to eb_hook_stop_code(). + + * eb/defs.h (EB_Appendix_Subbook_Struct): the members `narw_start' + `narw_end' and `narw_page' are renamed to `narrow_start', `narrow_end' + and `narrow_page'. + * eb/def.sh (EB_Appendix_Struct): the member `narw_cache' is renamed + to `narrow_cache'. + * eb/defs.h (EB_Subbook_Struct): the member `narw_current' is + renamed to `narrow_current'. + * eb/defs.h (EB_Text_Context_Struct): the member `narw_flag' is + renamed to `narrow_flag'. + + * eb/defs.h (EB_Alternation_Cache_Struct): the memeber `char_no' is + renamed to `character_number'. + * eb/defs.h (EB_Appendix_Subbook_Struct): the memeber `char_code' is + renamed to `character_code'. + * eb/defs.h (EB_Subbook_Struct): Likewise. + + * eb/error.h (EB_NUM_ERRORS): Renamed to EB_NUMBER_OF_ERRORS. + * eb/def.s (EB_NUM_HOOKS): Renamed to EB_NUMBER_OF_HOOKS. + * eb/def.s (EB_NUM_SEARCH_CONTEXTS): Renamed to + EB_NUMBER_OF_SEARCH_CONTEXTS. + +2000-03-27 Motoyuki Kasahara + + * ebzip/ebzip.c: Don't include `ctype.h'. Define compatible + character test and letter conversion macros. + * ebinfo/ebinfo.c: Likewise. + + * eb/defs.h (EB_EB_MAXLEN_WORD): Renamed to EB_MAX_WORD_LENGTH. + * eb/defs.h (EB_MAXLEN_EB_TITLE): Renamed to EB_MAX_EB_TITLE_LENGTH. + * eb/defs.h (EB_MAXLEN_EPWING_TITLE): Renamed to + EB_MAX_EPWING_TITLE_LENGTH. + * eb/defs.h (EB_MAXLEN_TITLE): Renamed to EB_MAX_TITLE_LENGTH. + * eb/defs.h (EB_MAXLEN_BASENAME): Renamed to EB_MAX_BASE_NAME_LENGTH. + * eb/defs.h (EB_MAXLEN_LANGNAME): Renamed to + EB_MAX_LANGUAGE_NAME_LENGTH. + * eb/defs.h (EB_MAXLEN_MESSAGE): Renamed to EB_MAX_MESSAGE_LENGTH. + * eb/defs.h (EB_MAXLEN_MULTI_LABEL): Renamed to + EB_MAX_MULTI_LABEL_LENGTH. + * eb/defs.h (EB_MAXLEN_ALTERNATION_TEXT): Renamed to + EB_MAX_ALTERNATION_TEXT_LENGTH. + * eb/error.h (EB_MAXLEN_ERROR_MESSAGE): Renamed to + EB_MAX_ERROR_MESSAGE_LENGTH. + + * eb/defs.h (EB_FILENAME_START): Renamed to EB_FILE_NAME_START. + * eb/defs.h (EB_FILENAME_SOUND): Renamed to EB_FILE_NAME_SOUND. + * eb/defs.h (EB_FILENAME_CATALOG): Renamed to EB_FILE_NAME_CATALOG. + * eb/defs.h (EB_FILENAME_LANGUAGE): Renamed to EB_FILE_NAME_LANGUAGE. + * eb/defs.h (EB_FILENAME_VTOC): Renamed to EB_FILE_NAME_VTOC. + * eb/defs.h (EB_FILENAME_WELCOME): Renamed to EB_FILE_NAME_WELCOME. + * eb/defs.h (EB_FILENAME_CATALOGS): Renamed to EB_FILE_NAME_CATALOGS. + * eb/defs.h (EB_FILENAME_HONMON): Renamed to EB_FILE_NAME_HONMON. + * eb/defs.h (EB_FILENAME_HONMON2): Renamed to EB_FILE_NAME_HONMON2. + * eb/defs.h (EB_FILENAME_APPENDIX): Renamed to EB_FILE_NAME_APPENDIX. + * eb/defs.h (EB_FILENAME_FUROKU): Renamed to EB_FILE_NAME_FUROKU. + + * eb/defs.h (EB_DIRNAME_DATA): Renamed to EB_DIRECTORY_NAME_DATA. + * eb/defs.h (EB_DIRNAME_GAIJI): Renamed to EB_DIRECTORY_NAME_GAIJI. + + * eb/defs.h (EB_Font_Struct): Rename the member `filename' to + `file_name'. + + * eb/font.h (EB_ERR_EMPTY_FILENAME): Renamed to EB_ERR_EMPTY_FILE_NAME. + * eb/font.h (EB_ERR_TOO_LONG_FILENAME): Renamed to + EB_ERR_TOO_LONG_FILENAME. + + * eb/error.h (EB_ERR_EMPTY_FILENAME): EB_ERR_EMPTY_FILE_NAME. + * eb/error.h (EB_ERR_TOO_LONG_FILENAME): EB_ERR_TOO_LONG_FILE_NAME. + +2000-02-27 Motoyuki Kasahara + + * eb/defs.h (EB_Search_Context): Add the member `keyword_heading' + for keyword search. + + * eb/text.c, eb/text.h (eb_seek, eb_tell): Renamed to eb_seek_text() + and eb_tell_text(). + +2000-02-10 Motoyuki Kasahara + + * eb/zio.c (eb_zopen_epwzipped): Fix offset passed to lseek(). + Reported by Takashi NEMOTO. + +2000-01-23 Motoyuki Kasahara + + * configure.in (--with-zlib): zlib is detected automatically. + + * acconfig.h (MAILING_ADDRESS, PACKAGE, VERSION, RETSIGTYPE_VOID, + HAVE_STRUCT_UTIMBUF, WITH_SYMBOL_UNDERSCORE, DOS_FILE_PATH, + EXEEXT_EXE): Removed. + * acinclude.m4 (HAVE_STRUCT_UTIMBUF): Specify the third argument + of AC_DEFINE. + * cofigure.in (RETSIGTYPE_VOID): Likewise. + * cofigure.in (EXEEXT_EXE): Likewise. + + * configure.in: Delete the `--enable-samples' option. + * Makefile.am (ENABLE_SAMPLES): Remove the condition variable. + + * doc/Makfile.am (info_TEXINFOS): Remove eb.texi. + * doc/Makfile.am (eb_TEXINFOS): Removed. + * doc/Makfile.am (EXTRA_DIST): Remove `stamp-eb'. + * doc/Makfile.am (eb-ver.texi, stamp-eb): Delete the targets. + + * eb/filename.c: Don't use ctype.h. + + * eb/text.c, eb/text.h (eb_forward_text): New function. + * eb/text.c, eb/eb.h (eb_forward_heading): New function. + * eb/search.c (eb_hit_list_keyword): Use eb_forward_heading() + to get heading position. + +2000-01-22 Motoyuki Kasahara + + * ebfont/ebfont.c (canonicalize_path): New function, copied + from eb/ebzip.c. + * ebzip/ebzip.c (main): Don't call eb_canoncalize_filename() to + canonicalize `out_path'. Use canonicalize_path() instead. + * ebfont/ebfont.c (make_book_fonts): Check whether `book_path' + is "/". + + * eb/setword.c (eb_convert_lower_latin): Also convert alphaet + with an accent mark to the corresponding upper letter. + + * eb/font.c, eb/font.h (eb_font_count): Removed. + * eb/subbook.c, eb/eb.h (eb_subbook_count): Removed. + * eb/appsub.c, eb/eb.h (eb_appendix_subbook_count): Removed. + * eb/language.c, eb/language.h (eb_language_count): Removed. + * eb/message.c, eb/language.h (eb_message_count): Removed. + * eb/multi.c, eb/eb.h (eb_multi_search_count): Removed. + * eb/multi.c, eb/eb.h (eb_multi_entry_count): Removed. + +2000-01-18 Motoyuki Kasahara + + * eb/hook.c (euc2ascii_table_a1, euc2ascii_table_a3): Renamed + to `euc_a1_to_ascii_table' and `euc_a3_to_ascii_table'. + + * eb/defs.h (EB_TEXT_ERROR): Defined. + * eb/text.c (eb_read_text, eb_heading, eb_rawtext): If it returns + with an error, set context mode to `EB_TEXT_ERROR'. + + * ebappendix/ebappendix.in ($copyright): Defined and use it + when `ebappendix --version'. + * ebrefile/ebrefile.in ($copyright): Likewise. + +2000-01-16 Motoyuki Kasahara + + * eb/text.c (eb_text, eb_heading, eb_rawtext): Renamed to + eb_read_text(), eb_read_heading(), eb_read_rawtext(). + + * eb/defs.h (EB_CASE_UNCHANGE, EB_SUFFIX_UNCHANGE): Define the cpp + macros. + + * ebinfo/ebinfo.c (output_error_message): New static function. + * ebinfo/ebinfo.c: Use output_error_message() to output an error + messge. + + * ebzip/ebzip.c (find_subbook): Oputput an error message when + an errorr occurs. + * ebzip/ebzip.c: Return EB_SUBBOOK_ERROR rather than -1 if + the target subbook is not found. + +2000-01-15 Motoyuki Kasahara + + * eb/match.c (eb_match_exactword): Also ignores NULs in the + tail of a pattern. + + * eb/search.c (eb_presearch_word, eb_hit_list_word, + eb_hit_list_keyword, eb_hit_list_multi): Support DUDEN, which + has leaf index pages of fixed length entires. + + * eb/defs.h (Text_Context_Struct): Remove the membsers + `modifier_hook' and `reference_hook'. + * eb/text.c (eb_read_internal): Delete operations to `modifier_hook' + and `reference_hook'. + * eb/text.h (EB_HOOK_NARROW, EB_HOOK_SUBSCRIPT, EB_HOOK_SUPERSCRIPT, + EB_HOOK_EMPHASIS, EB_HOOK_PICTURE, EB_HOOK_MENU, EB_HOOK_SOUND, + EB_HOOK_REFERENCE, EB_HOOK_KEYWORD): Remove these hook codes. + * eb/defs.h (EB_NUM_HOOKS): Updated. + +2000-01-13 Motoyuki Kasahara + + * eb/defs.h (EB_Hook_Struct): The member `function' is pointer + to a function that returns `EB_Error_Code', not `int'. + + * eb/error.h (EB_NO_ERR): Renamed to `EB_SUCCESS'. + + * eb/search.c (EB_PAGE_ID_LEAF, EB_PAGE_ID_START, EB_PAGE_ID_END, + EB_PAGE_ID_HAVE_GROUP): Define these cpp macros. + * eb/search.c (eb_presearch_word, eb_hit_list_word, + eb_hit_list_keyword, eb_hit_list_multi): Use EB_PAGE_ID_* macros + to check page id. + +2000-01-10 Motoyuki Kasahara + + * eb/text.c (eb_read_internal): Discard cache data when read error + occurs. + * eb/search.c (eb_hit_list_word, eb_hit_list_keyword, + eb_hit_list_multi): Likewise. + + * eb/search.c (cache_rest_length): Declare as an auto variable + in eb_read_internal(), not static variable in this file. + * eb/search.c (cache_location, cache_length): New static variables. + * eb/text.c (eb_read_internal): Check cache status before processing + text. + + * eb/eb.c, eb/book.c: All the functions defined in eb/eb.c + are moved to `eb/book.c'. + * eb/eb.c, eb/eb.h (eb_initialize_library, eb_finalize_library): + New functions. + * eb/book.c (eb_initialize, eb_clear): Renamed to + `eb_initialize_book' and `eb_finalize_book'. + * eb/appendix.c (eb_clear_appendix): Renamed to `eb_finalize_appendix'. + + * eb/book.c (eb_finalize_book): Don't call eb_initialize_book(). + Reset variables by itself. + * eb/appendix.c (eb_finalize_appendix): Don't call + eb_finalize_appendix(). Reset variables by itself. + + * ebzip/ebzip.c (canonicalize_path): New function. + * ebzip/ebzip.c (main): Don't call eb_canoncalize_filename() to + canonicalize `out_path'. Use canonicalize_path() instead. + * ebzip/ebzip.c (main): Define `book_path' as an array of char, + rather than a pointer to char. Copy a book's path to it, and + call canonicalize_path() to canonicalize it. + * ebzip/ebzip.c (zip_book, unzip_book, zipinfo_book): Also takes + `book_path' as an argument. Refer it rather than `book->path'. + * ebzip/ebzip.c (zip_book, unzip_book, zipinfo_book): Check whether + `book_path' and/or `out_path' is "/". + +2000-01-09 Motoyuki Kasahara + + * eb/zio.c (eb_zclaer): dispose `cache_buffer' only when it is not + NULL. + * eb/zio.c (eb_zclaer): Renamed to eb_zfinalize(). + * eb/zio.c (eb_zinitialize): Add the new function. + * eb/zio.c (eb_zinitialize, eb_zread_ebzipped, eb_zread_epwzipped): + Allocate memory to `cache_buffer' in the new function eb_zinitialize() + rather than eb_zread_ebzipped() or eb_zread_epwzipped(). + + * eb/text.c (eb_text, eb_heading): Don't initialize `default_hookset'. + * eb/text.c (default_hookset): Move to `hook.c' and renamed to + `eb_default_hookset'. + * eb/internal.h (eb_default_hookset): Declare as an external variable. + * eb/hook.c, eb/internal.h (eb_initialize_default_hookset): + Add the function. + + * ebzip/ebzip.c (main): Go to `die' when eb_subbook_list() fails, + or when an unknown subbook is specified. + * eb/ebzip.c (main): Call eb_clear() at the end of the routine. + + * eb/search.c (eb_hit_list): Fully re-written to support + keyword and multi search. + + * eb/search.c (eb_initialize_search): Initialize also + `search_contexts[0].code' in a book. + * eb/search.c (eb_presearch_word, eb_hit_list_word, + eb_hit_list_keyword, eb_hit_list_multi): Take a search context + as a second argument to record search parameters. + * eb/search.c (eb_search_word_internal): Use search context + in a target book. + * eb/search.c (eb_hit_list): Likewise. + * eb/search.c (eb_hit_list_internal): Likewise. + * eb/exactword.c (eb_search_exactword): Likewise. + * eb/word.c (eb_search_word): Likewise. + * eb/endword.c (eb_search_endword): Likewise. + +2000-01-08 Motoyuki Kasahara + + * eb/defs.h (EB_BOOK_NONE): Define the cpp macro. + * eb/text.c (eb_initialize_text, eb_read_internal): Use EB_BOOK_NONE + rather than -1, to represent no cache data is buffered. + * eb/search.c (eb_initialize_search, eb_presearch_word): Likewise. + + * eb/appsub.c (eb_initialize_appendix_subbook, + eb_set_appendix_subbook): Define the `succeeded' label, and + go to there when there is nothing to be done in the latter of the + function. + * eb/font.c (eb_set_font) Likewise. + * eb/language.c (eb_set_language): Likewise. + * eb/narwalt.c (eb_narrow_character_text_jis, + eb_narrow_character_text_latin): Likewise. + * eb/narwfont.c (eb_have_narrow_font): Likewise. + eb/search.c (eb_presearch_word, eb_hit_list_word, eb_hit_list_keyword, + eb_hit_list_multi): Likewise. + * eb/subbook.c (eb_initialize_subbook, eb_set_subbook): Likewise. + * eb/widealt.c (eb_wide_character_text_jis, + eb_wide_character_text_latin): Likewise. + * eb/widefont.c (eb_have_wide_font): Likewise. + + * eb/appendix.c, eb/appsub.c, eb/copyright.c, eb/eb.c, + eb/exactword.c, eb/filename.c, eb/font.c, eb/graphic.c, eb/hook.c, + eb/keyword.c, eb/language.c, eb/menu.c, eb/message.c, eb/multi.c, + eb/narwalt.c, eb/narwfont.c, eb/search.c, eb/setword.c, eb/stopcode.c, + eb/subbook.c, eb/text.c, eb/widealt.c, eb/widefont.c, eb/word.c: + Define the `failed' label in most functions. Go to there + if error. + + * eb/defs.h (EB_SUBBOOK_ERROR): Define the cpp macro. + * eb/appsub.c (eb_appendix_subbook): Return EB_SUBBOOK_ERROR + rather than -1 if error. + * eb/subbook.c (eb_subbook): Likewise. + + * eb/defs.h (EB_DISC_ERROR): Define the cpp macro. + * eb/eb.c (eb_disc_type): Return EB_DISC_ERROR rather than -1 + if error. + * eb/defs.h (EB_CHARCODE_ERROR): Define the cpp macro. + * eb/eb.c (eb_character_code): Return EB_CHARCODE_ERROR rather than + -1 if error. + + * eb/font.h (EB_FONT_ERROR): Define the cpp macro. + * eb/eb.c (eb_font): Return EB_FONT_ERROR rather than -1 if error. + + * eb/language.h (EB_LANG_ERROR): Define the cpp macro. + * eb/setword.c (eb_language): Return EB_LANG_ERROR rather than + -1 if error. + + * eb/setword.c (eb_reverse_word_latin): Don't check whether + `word_length' is 0. This is not needed. + * eb/setword.c (eb_reverse_word_jis): Don't check whether + `word_length' is less than 2. This is not needed. + + * eb/messages.c (eb_initialize_messages): Return 0 or -1. + + * eb/narwalt.c (eb_narrow_alt_start, eb_narrow_alt_end): + Return -1 if an error occurs. + * eb/widealt.c (eb_wide_alt_start, eb_wide_alt_end): Likewise. + +2000-01-07 Motoyuki Kasahara + + * eb/defs.h (EB_Appendix_Struct, EB_Book_Struct, EB_Hookset_Struct): + Add a member named `error'. + * eb/appendix.c (eb_initialize_appendix): Initialize `error' to 0. + * eb/eb.c (eb_initialize): Initialize `error' to 0. + * eb/hook.c (eb_initialize_hookset): Initialize `error' to 0. + + * eb/setword.c (eb_fix_word_latin, eb_fix_word_jis): + Takes the argument `book' as the first argument. + + * eb/appendix.c, eb/appsub.c, eb/hook.c, eb/narwalt.c, eb/widealt.c: + Set `appendix->error' instead of `eb_error', if an error occurs. + * eb/copyright.c, eb/eb.c, eb/error.c, eb/font.c, eb/graphic.c, + eb/keyword.c, eb/language.c, eb/match.c, eb/menu.c, eb/message.c, + eb/multi.c, eb/narwfont.c, eb/search.c, eb/setword.c, eb/stopcode.c, + eb/subbook.c, eb/text.c, eb/uint.c, eb/widefont.c: Set `book->error' + instead of `eb_error', if an error occurs. + * eb/hookset.c: Set `hookset->error' instead of `eb_error', + if an error occurs. + + * eb/filename.c (eb_canonicalize_filename, + eb_canonicalize_filename_internal, eb_canonicalize_appendix_filename): + Rename the original `eb_canonicalize_filename()' to `...internal()', + and add the argument `error'. + Add the new function `eb_canonicalize_filename()' and + `eb_canonicalize_appendix_filename()'. + * filename.c (eb_catalog_filename_internal, + eb_fix_filename_internal): Call `eb_canonicalize_filename_internal()', + instead of `eb_canonicalize_filename'. + * eb/eb.c (eb_bind): Call `eb_canonicalize_appendix_filename()', + instead of `eb_canonicalize_filename'. + + * eb/error.c, eb/error.h (eb_error): Removed. + * eb/error.c, eb/error.h (eb_error, eb_appendix_error, + eb_hookset_error): Add these functions. + * eb/error.c, eb/error.h (eb_error_message, eb_error_message2): + The original eb_error_message2() is renamed to eb_error_message(). + The original eb_error_message() is overwritten. + + * eb/narwfont.c (eb_narrow_font_width2, eb_narrow_font_size2): + Don't set `eb_error'. + * eb/widefont.c (eb_wide_font_width2, eb_wide_font_size2): + Likewise. + * eb/bitmap.c (eb_narrow_font_xbm_size, eb_narrow_font_xpm_size, + eb_narrow_font_gif_size, eb_wide_font_xbm_size, + eb_wide_font_xpm_size, eb_wide_font_gif_size): + Likewise. + + * eb/text.c, eb/text.h (eb_initialize_hookset, eb_set_hook, + eb_set_hooks): Move to `eb/hook.c'. + * eb/hook.c, eb/text/h (eb_hook_stopcode_dummy, + eb_hook_stopcode_mixed): Removed. + + * Makefile.am (EXTRA_DIST): Add `ChangeLog.0'. + + * eb/font.c (eb_font_count): Return -1 if an error occurs. + + * eb/appendix.c (eb_bind_appendix): Don't call + eb_initialize_appendix(), but eb_clear_appendix(). + +2000-01-06 Motoyuki Kasahara + + * eb/defs.h (EB_Subbook): Rename the member `multi' to `multis'. + + * eb/font.c (eb_initialize_eb_fonts, eb_initialize_epwing_fonts): + Use memmove(), not memcpy(). + * eb/message.c (eb_initialize_messages): Likewise. + * eb/text.c (eb_read_internal): Likewise. + * eb/font.c, eb/message.c, eb/text.c: Check for HAVE_MEMMOVE. + * eb/memmove.c: New file. + * eb/internal.h: Declare eb_memmove(). + * eb/Makefile.am (libeb_la_SOURCES): Add `memmove.c'. + * configure.in (AC_CHECK_FUNCS): Add `memmove'. + + * eb/search.c: Include string.h, and check HAVE_MEMCPY and + MEMMOVE. + + * libebutils/memset.c (memset): Type of return value is `VOID *', + not `void *'. + +2000-01-05 Motoyuki Kasahara + + * eb/defs.h (EB_SEARCH_EXACTWORD, EB_SEARCH_WORD, EB_SEARCH_ENDWORD, + EB_SEARCH_KEYWORD, EB_SEARCH_MULTI,EB_SEARCH_NONE): Defined. + * eb/defs.h (EB_Search_Code, EB_Text_Code): Defined. + * eb/defs.h (EB_Multi_Search_Struct, EB_Search): Defined. + * eb/defs.h (EB_Search_Context_Struct, EB_Search_Context): Defined. + * eb/defs.h (EB_Multi_Entry_Struct, EB_Multi_Entry): Merged to + `EB_Search_Struct' and `EB_Search'. + * eb/defs.h (EB_Search_Context_Struct): Add the member `label' and + `candidates_page', and rename `page' to `index_page'. + * eb/defs.h (EB_Multi_Search_Struct): Add the member `search', and + change the type of `entries' from `EB_Multi_Entry' to `EB_Search'. + * eb/defs.h (EB_Subbook_STruct): Change the type of `multi' from + `EB_Search[]' to `EB_Multi_Search[]'. + + * eb/eb.h: Declaration of functions defined in eb/filename.c + are moved to `eb/internal.h'. + + * eb/search.c: Move eb_have_word_search() and eb_search_word() + to the new file eb/word.c. + * eb/search.c: Move eb_have_endword_search() and eb_search_endword() + to eb/endword.c, new file. + * eb/search.c: Move eb_have_endword_search() and eb_search_endword() + to the new file eb/endword.c. + * eb/search.c: Move eb_have_exactword_search() and + eb_search_exactword() to the new file eb/exactword.c. + + * eb/multi.c, eb/eb.h (eb_multi_entry_have_exactword_search, + eb_multi_entry_have_word_search, eb_multi_entry_have_endword_search, + eb_multi_entry_have_keyword_search): Removed. + * eb/multi.c, eb/eb.h (eb_multi_entry_have_candidates, + eb_multi_entry_candidates): Added these functions. + * eb/multi.c, eb/eb.h (eb_search_multi): Added these functions. + + * eb/error.h (EB_ERR_DIFF_SUBBOOK, EB_ERR_DIFF_BOOK, + EB_ERR_NO_PREV_SEARCH, EB_ERR_NO_PREV_CONTENT, + EB_ERR_NO_SUCH_MULTI_ID, EB_ERR_NO_SUCH_ENTRY_ID): Removed. + * eb/error.h (EB_ERR_FAIL_OPEN_START, EB_ERR_FAIL_READ_START, + EB_ERR_FAIL_SEEK_START, EB_ERR_UNEXP_START, EB_ERR_NO_START): + Removed these obsolete error code names that are remained for + backword compatibility. + + * eb/error.h (EB_ERR_TOO_MANY_WORDS, EB_ERR_NO_WORD): Add these + to the error code list. + + * eb/hook.c (euc2ascii_table_a1, euc2ascii_table_a3) Declared + as `const'. + + * eb/keyword.c: Define `eb_search_keyword()'. + + * eb/setword.c, eb/internal.h (eb_set_keyword, eb_set_multiword): + Added these functions. + + * eb/subbook.c (eb_initialize_indexes): Initialize `label' and + `candidates_page', the struct members in `EB_Search'. + + * eb/search.c (comparison_result, word, canonicalized_word, page, + offset, page_id, entry_count, entry_index): These static variables + are moved to struct members of `EB_Search_Context'. + * eb/search.c (subbook_code): The static variable are removed. + * eb/search.c (book_code, page_buffer, bufp): These static variables + are renamed to `cache_book_code', `cache_buffer' and `cachep'. + * eb/search.c (cache_page): New static variable. + + * eb/search.c (eb_search_word_internal): Renamed to + `eb_presearch_word'. + * eb/search.c (eb_hit_list_internal): Renamed to `eb_hit_list_word'. + * eb/search.c (eb_hit_list_word): Read a page at the beginning of + the loop, instead of the tail. + * eb/search.c (eb_hit_list_keyword, eb_hit_list_multi): New functions. + * eb/defs.h (EB_Book_Struct): Add the member `search_contexts'. + * eb/defs.h (EB_Search_Context_Struct): Defined. + + * eb/ebinfo.c (output_multi_information): Output `with candidates' + instead of `search methods'. + +2000-01-03 Motoyuki Kasahara + + * eb/setword.c (jisx0208_table, jisx0201_table, long_vowel_table, + voiced_consonant_table): Declared as `const'. + * eb/hook.c (euc2ascii_table_a1, euc2ascii_table_a3): Likewise. + + * eb/defs.h, eb/internal.h: All functions defined in `eb/filename.h' + are declared in `eb/internal.h', not `eb/defs.h'. + + * eb/text.h: Use `EB_UINT_FUNCTION', not `EB_UINT_FUNC'. + +1999-12-28 Motoyuki Kasahara + + * eb/bitmap.c (gif_preamble): Renamed to `gif_default_preamble'. + * eb/bitmap.c (eb_bitmap_to_gif): Don't modify `gif_default_preamble'. + +1999-12-26 Motoyuki Kasahara + + * eb/text.c (eb_read_internal): Discard cache buffered in + `cache_buffer' if different book's data are cached. + * eb/text.c (eb_read_internal): Update `book->text_context.location' + when the pointed character is prossessed. + + * eb/text.c (eb_initialize_text): Rewritten. + + * eb/text.c (eb_text): Don't check for EB_ERR_NO_PREV_CONTENT, + EB_ERR_DIFF_BOOK or EB_ERR_DIFF_SUBBOOK error. + * eb/text.c (eb_heading): Likewise. + + * eb/text.c, eb_text.h (eb_tell): Add this function. + + * eb/text.c (eb_set_hook): Don't test whether `hook->code' is + EB_HOOK_NULL. + + * eb/text.c (bookcode, pagebuf, pagebufp, pagerest): Renamed to + `cache_book_code`, `cache_buffer`, `cachep` and `cache_rest_length'. + * eb/text.c (callcount, subcode, location, workbuf, worklen, + modhook, refhook, narwflag, charapp, bookeof, textend, skipcode): + Remove these static variables. + * eb/defs.h (EB_Book_Struct): Add the member `text_context'. + * eb/defs.h (EB_Text_Context_Struct): Defined. + + * eb/bitmap.c, eb/copyright.c, eb/ebunzip1.c, eb/error.c, + eb/filename.c, eb/graphic.c, eb/hook.c, eb/menu.c, eb/setword.c, + eb/stopcode.c, eb/uint.c: Include `internal.h'. + * eb/uint.c: Undefine the cpp macros eb_uint1, eb_uint2, eb_uint3 + and eb_uint4. + + * eb/defs.h, eb/appendix.h, eb/eb.h, eb/error.h, eb/font.h, + eb/internal.h, eb/language.h, eb/text.h (EB_P): + Defined in eb/defs.h only. + + * eb/appsub.c, eb/appendix.h (eb_appendix_subbook2): Removed. + + * eb/defs.h, eb/text.h (EB_Hook, EB_Hookset): Move definitions + from eb/text.h to eb/defs.h, + * eb/defs.h (EB_Book_Struct): Rename the member `sub_count' to + `subbook_count', `sub_current' to `subbook_current', `lang_count' + to `language_count' and `lang_current' to `language_current'. + * eb/defs.h (EB_Subbook_Struct): Rename the member `sub_file' to + `text_file', `word_alpha' to `word_alphabet' and `endword_alpha' + to `endword_alphabet'. + * eb/defs.h (EB_Language_Struct): Rename the member `msg_count' to + `message_count'. + * eb/defs.h (EB_Appendix_Struct): Rename the member `sub_count' to + `subbook_count', and `sub_current' to `subbook_current'. + * eb/defs.h (EB_Alternation_Cache_Struct): Rename the member + `charno' to `char_no'. + * eb/defs.h (EB_Huffman_Node_Struct): Change the type of the members + `left` and `right` to `EB_Huffman_Node'. + * eb/defs.h (EB_Huffman_Node, EB_Zip, EB_Alternation_Cache, + EB_Appendix_Subbook, EB_Appendix, EB_Font, EB_Language, + EB_Multi_Entry, EB_Search, EB_Subbook, EB_Text_Context, EB_Book, + EB_Position, EB_Hit, EB_Hook, EB_Hookset): Typedef'ed first, + and then define their conrete structs. + * eb/defs.h, eb/error.h (EB_Error_Code): + Move definition from eb/error.h to eb/defs.h. + * eb/defs.h, eb/text.c (EB_MAXLEN_TEXT_WORK, EB_NUM_HOOKS): + Move definitions from eb/text.c to eb/defs.h. + * eb/defs.h, eb/text.c (CONTENT_TEXT, CONTENT_HEADING, + CONTENT_RAWTEXT): Move definitions from eb/text.c to eb/defs.h, + and renamed to EB_TEXT_TEXT, EB_TEXT_HEADING and EB_TEXT_RAWTEXT. + Add the new content type macro `EB_TEXT_NONE'. + * eb/defs.h (EB_WORD_ALPHA): Renamed to `EB_WORD_ALPHABET'. + + * eb/error.c (messages): Add the `const' modifier. + +1999-12-13 Motoyuki Kasahara + + * eb/error.h: Rename the error code + EB_ERR_FAIL_OPEN_START to EB_ERR_FAIL_OPEN_TEXT, + EB_ERR_FAIL_READ_START to EB_ERR_FAIL_READ_TEXT, + EB_ERR_FAIL_SEEK_START to EB_ERR_FAIL_SEEK_TEXT, + EB_ERR_UNEXP_START to EB_ERR_UNEXP_TEXT, + and EB_ERR_NO_START to EB_ERR_NO_TEXT. + The old error code names are obsoleted, but still available. + + * eb/defs.h (EB_WORD_ALPHA): Renamed to `EB_WORD_ALPHABET'. + * eb/defs.h (EB_Alternation_Cache): Rename the structure member + `charno' to `char_no'. + * eb/defs.h (EB_Appendix): Rename the structure member + `sub_file' to `appendix_file', + `sub_count' to `subbook_count' + and `sub_current' to `subbook_current'. + * eb/defs.h (EB_Language): Rename the structure member + `msg_count' to `message_count'. + * eb/defs.h (EB_Book): Rename the structure member + `sub_file' to `text_file', + `word_alpha' to `word_alphabet', + `endword_alpha' to `endword_alphabet', + `sub_count' to `subbook_count', + `sub_current' to `subbook_current'. + `sub_count' to `subbook_count', + and `lang_current' to `language_current'. + +1999-12-12 Motoyuki Kasahara + + * eb/error.c (messages): Modify the error message of the error + code 39 (EB_ERR_NO_START). + + * eb/text.c, eb/internal.h (eb_initialize_text): Add an argument + `book'. Initialize variables only when a code of `book' is + equal to `bookcode'. + * eb/seaarch.c, eb/internal.h (eb_initialize_search): Likewise. + + * eb/text.c (eb_text, eb_heading, eb_rawtext): Check `bookcode' + for the EB_ERR_NO_PREV_CONTENT error when `callcount' is 0. + + * eb/text.c (eb_tell): Add a new function. + + * eb/text.c (eb_text_internal): Don't go to `at_end' when + no enough space is left on the text buffer. + diff --git a/ChangeLog.2 b/ChangeLog.2 new file mode 100644 index 0000000..775864b --- /dev/null +++ b/ChangeLog.2 @@ -0,0 +1,1409 @@ +2003-12-28 Motoyuki Kasahara + + * Version 4.0. + + * eb/defs.h: Do not be generated from `eb/defs.h.in' any longer. + * eb/Makefile.am (EXTRA_DIST, MAINTAINERCLEANFILES): Delete + `stamp-defs-h' and `defs.h.in'. + * eb/Makefile.am (BUILT_SOURCES): Delete `defs.h'. + + * configure.ac (AC_ARG_ENABLE): Add `--enable-ebnet' option. + * eb/Makefile.am (libeb_ebnet_sources): Define the variable according + with ENABLE_EBNET. + + * samples/Makefile.am (noinst_PROGRAMS): Add `booklist'. + * doc-ja/Makefile.am (eb_ja_TEXINFOS, MAINTAINERCLEANFILES): + add `booklist-c.texi'. + + * eb/zio.h: Fix TIME_WITH_SYS_TIME check code. + + * eb/defs.h: Include `sysdefs.h'. Use `EB_ENABLE_PTHREAD' and + `EB_ENABLE_EBNET', instead of `EBCONF_ENABLE_PTHREAD' and + `EBCONF_ENABLE_EBNET'. + * eb/Makefile.am (CLEANFILES): Add `stamp-sysdefs-h' and `sysdefs.h'. + * eb/Makefile.am (BUILT_SOURCES): Add `sysdefs.h' + * eb/Makefile.am (nodist_pkginclude_HEADERS): Defined. + +2003-12-22 Motoyuki Kasahara + + * m4/eb3.m4: Renamed to `eb4.m4'. + * m4/Makefile.am (m4data_DATA, EXTRA_DIST): Rename `eb4.m4' to + `eb3.m4'. + + * Use Autoconf-2.59, Automake-1.8 and Libtool-1.5. + * m4/eb4.m4, m4/gettext.m4, m4/herrno.m4, m4/in6addr.m4, + m4/lcmessage.m4, m4/libtool.m4, m4/sockaddrin6.m4, + m4/utimbuf.m4, m4/voidpointer.m4: Quote function name to be defined + in AC_DEFUN. + + * m4/eb4.m4 (AC_REQUIRE): Add AC_C_PROTOTYPES. + +2003-12-21 Motoyuki Kasahara + + * eb.conf.in: Always define EBCONF_ENABLE_EBNET. + * m4/eb3.m4: Check EBCONF_ENABLE_EBNET. + * eb/defs.h.in: Use EBCONF_ENABLE_EBNET instead of ENABLE_EBNET. + + * eb/error.c, eb/error.h: Add two error codes EB_ERR_UNBOUND_BOOKLIST + and EB_ERR_NO_SUCH_BOOK. + * eb/defs.h, eb/booklist.c, eb/booklist.h: APIs for EB_BookList + are revised. eb_booklist_book_count(), eb_booklist_book_name() + and eb_booklist_book_title() return EB_Error_Code. + * eb/defs.h, eb/booklist.c, eb/booklist.h: Support for pthread. + * eb/defs.h, eb/booklist.c, eb/booklist.h: Add internal object counter + for EB_BookList. + +2003-11-23 Motoyuki Kasahara + + * config.guess, config.sub, depcomp, install-sh, missing, + mkinstalldirs, doc/mdate-sh, doc-ja/mdate-sh: + Import from Autocomake-1.7.9. + +2003-11-22 Motoyuki Kasahara + + * m4/Makefile.am (EXTRA_DIST): Add `voidpointer.m4'. + + * eb/search.c (eb_hit_list_keyword, eb_hit_list_multi): + Don't perform comparison of input keyword and group entry element. + + * eb/readtext.c (eb_read_text_internal): Fix a bug that EB Library + crashes when it outputs a debug log. + +2003-11-19 Motoyuki Kasahara + + * configure.ac (AC_C_VOID_POINTER, AC_C_PROTOTYPES): Added. + * configure.ac (AC_C_VOID_POINTER): Added. + * m4/voidpointer.m4: Define `AC_C_VOID_POINTER'. + * ebrefile/ebrefile.c, ebfont/ebfont.c, eb/zio.c, eb/memmove.c, + eb/zio.h, eb/urlparts.c, eb/urlparts.h, eb/linebuf.c, eb/build-pre.h, + eb/linebuf.h, eb/defs.h.in, eb/filename.c, eb/log.c, eb/multiplex.c, + eb/getaddrinfo.c, eb/eb.h, eb/getaddrinfo.h, eb/ebnet.c, + ebstopcode/ebstopcode.c, libebutils/getopt.c, libebutils/yesno.h, + libebutils/getopt.h, libebutils/ebutils.c, libebutils/makedir.h, + libebutils/getumask.h, libebutils/samefile.h, libebutils/memset.c, + ebinfo/ebinfo.c, ebzip/ebzip.h: + Use PROTOTYPES and VOID, instead of __STDC__ and WIN32. + + * eb/log.c, eb/build-pre.h, eb/eb.h: Use `stdarg.h' if __STDC__ or + MSVC is defined. + +2003-11-12 Motoyuki Kasahara + + * eb/match.c (eb_match_word_jis_kana): Rename the function to + `eb_match_word_kana_group'. + Add variant function eb_match_word_kana_group_single(). + * eb/match.c (eb_exact_match_word_jis_kana): Rename the function to + `eb_exact_match_word_kana_group'. + Add variant function eb_match_exact_word_kana_group_single(). + +2003-10-19 Motoyuki Kasahara + + * Version 4.0beta3. + + * ebstopcode/ebstopcode.c (parse_text_position_argument): Add check + codes for page:offset. + +2003-10-18 Motoyuki Kasahara + + * ebstopcode/ebstopcode.c: Add `--text-position' (-p) option. + +2003-10-14 Motoyuki Kasahara + + * doc-ja/c2texi: Expand tabs to spaces. + +2003-10-13 Motoyuki Kasahara + + * eb/subbook.c, eb/urlparts.c, eb/build-pre.h, eb/filename.c, + eb/ebnet.c, libebutils/ebutils.c, ebfont/ebfont.c, + ebrefile/ebrefile.c, ebstopcode/ebstopcode.c, ebzip/ebzip.c, + ebzip/ebzip.h: Don't redefine or use ctype macros such as isalpha(). + Define and use ASCII_ISXXX() macros instead. + +2003-10-04 Motoyuki Kasahara + + * eb/Makefile.am (stamp-defs-h, stamp-build-post-h, stamp-widealt-h, + stamp-widefont-h): Insert "automatically generated from ..." messages + to the source files. + + * m4/gettext.m4 (eb_GNU_GETTEXT): Also checks for iconv.h, + libcharset.h, iconv_open(), libiconv_open(), locale_charset() and + -liconv. Also add the ICONVINCS and ICONVLIBS variables. + * m4/gettext.m4 (eb_GNU_GETTEXT): Don't add iconv_includes to INTLINCS. + * configure.ac (AC_CHECK_FUNCS): Add nl_langinfo(). + * configure.ac (AC_CHECK_HEADERS): Add `langinfo.h'. + + * ebfont/Makefile.am (ebfont_LDADD, ebfont_DEPENDENCIES): + Add $(ICONVLIBS) and $(ICONVDEPS) respectively. + * ebinfo/Makefile.am (ebinfo_LDADD, ebinfo_DEPENDENCIES): Ditto + * ebrefile/Makefile.am (ebrefile_LDADD, ebrefile_DEPENDENCIES): Ditto + * ebstopcode/Makefile.am (ebstopcode_LDADD, ebstopcode_DEPENDENCIES): + Ditto + * ebzip/Makefile.am (ebzip_LDADD, ebzip_DEPENDENCIES): Ditto + + * libebutils/puts_eucjp.c: New file. + * libebutils/Makefile.am (libebutils_a_SOURCES): Add puts_eucjp.c + * libebutils/Makefile.am (INCLUDES): Add @ICONVINCS@ + + * ebinfo/ebinfo.c: Print EUC-JP strings as the current locale + encoding with fputs_eucjp_to_locale(). + * ebstopcode/ebstopcode.c: Ditto. + + * ebzip/ebzip.c (main): Also recognize "ebzipinfo.exe" and "ebzipinf" + as the `invoked_base_name' when EXEEXT_EXE is defined. + +2003-10-03 Motoyuki Kasahara + + * eb/build-post.h.in (LOCALEDIR): Renamed to EB_LOCALEDIR. + * eb/build-post.h.in (LOCALEDIR): Set to localedir() if WIN32. + * ebutils/ebutils.h.in (LOCALEDIR): Ditto. + + * eb/Makefile.am (dist_libeb_la_SOURCES, nodist_libeb_la_SOURCES): + Move `widealt.c' and `widefont.c' from nodist_ to to dist_. + * eb/Makefile.am (CLEANFILES, MAINTAINERCLEANFILES): + Move `stamp-wide-alt-h', `stamp-wide-font-h', `widealt.c' and + `widefont.c' from CLEANFILES to MAINTAINERCLEANFILES. + * eb/Makefile.am (EXTRA_DIST): Add ``stamp-wide-alt-h' and + `stamp-wide-font-h'. + + * eb/Makefile.am (dist_pkginclude_HEADERS, nodist_pkginclude_HEADERS): + Move `defs.h' from nodist_ to to dist_. + * eb/Makefile.am (CLEANFILES, MAINTAINERCLEANFILES): + Move `stamp-defs-h' from CLEANFILES to MAINTAINERCLEANFILES. + * eb/Makefile.am (EXTRA_DIST): Add ``stamp-defs-h'. + +2003-09-23 Motoyuki Kasahara + + * configure.ac (AC_INIT): Set version to 4.0beta3. + + * eb/build-pre.h, eb/refile.c, ebfont/ebfont.c, eb/urlparts.c, + ebstopcode/ebstopcode.c, libebutils/ebutils.c, ebzip/ebzip.h + Undefine ctype macros if defined. + + * ebzip/unzipfile (EB_P): Delete definition of the cpp macro. + + * eb/ebnet.c (ebnet_get_booklist): Fix a bug. Don't call close() + directly to close a connection. Call ebnet_disconnect_socket() + instead. + + * configure.ac (AC_CHECK_FUNCS): Delete `syslog' and `vsyslog'. + Add `dup2' instead. + * eb/ebnet.c (ebnet_read): Change type of the first argument + `file' from `int' to `int *'. It means the given file descriptor + might be changed by ebnet_read(). + + * eb/multiplex.c: On WIN32, call closesocket() instead of close() + to close a socket. + + * eb/zio.c, eb/build-post.h.in (is_ebnet_url): Don't call + strncasecmp(). + + * eb/filename.c (eb_fix_path_name_suffix, eb_compose_path_name, + eb_compose_path_name2, eb_compose_path_name3): Supprt for EBNET URL + handle on WIN32. + * eb/ebnet.c (ebnet_initialize): Call WSAStartup() if WIN32. + * eb/muliplex.c (ebnet_connect_socket): Replace dup() with + WSADuplicateSocket() if WIN32. + + * ebinfo/ebinfo.c (output_booklist): Call eb_initialize_library() + and eb_finalize_library(). + +2003-09-21 Motoyuki Kasahara + + * eb/match.c (eb_match_word_jis_kana): Fix a bug that it never returns + 0 even if `word' matches `pattern'. + + * eb/keyword.c (eb_search_keyword): Perform `word search' for each + keyword. + eb/multi.c (eb_search_multi): Perform `word search' for each entry + if the entry doesn't have candidates. + + * libebutils/makedir.c (make_missing_directory): Support for WIN32. + * eb/log.c (eb_log): Ditto. + * eb/linebuf.c: Ditto. + * eb/getaddrinfo.c, eb/getaddrinfo.h: Ditto. + * eb/dummyin6.c, eb/dummyin6.h: Ditto. + * eb/linebuf.c (read_line_buffer, binary_read_line_buffer): For WIN32, + use recv() rather than read(). + * eb/filename.c (eb_path_name_zio_code): Support for Win32. + + * libebutils/getopt.c: Include if exists. + + * eb/Makefile.am (noinst_HEADERS): `build-post.h' is now + nodist_noinst_HEADERS. + +2003-09-01 Motoyuki Kasahara + + * Version 4.0beta2. + + * eb/defs.h.in (EB_Search_Context_Struct): Add `compare_pre'. + * eb/match.c (eb_pre_match_word, eb_exact_pre_match_word_jis, + eb_exact_pre_match_word_latin): New functions for pre-search. + *eb/search.c (eb_presearch_word): Use `compare_pre' for comparision. + + * eb/match.c (eb_match_word_jis_kana, eb_match_exactword_jis_kana): + Fix bugs in comparision of Kana characters. + +2003-08-30 Motoyuki Kasahara + + * Version 4.0beta1. + + * eb/error.c, eb/error.h: Add EB_ERR_NO_ALT and EB_ERR_NO_STOPCODE. + * eb/stopcode.c: Set stop_code[0] and stop_code[1] to -1 if an error + occurs. + + * samples/Makefile.am (noinst_PROGRAMS): Add `appendix'. + * samples/appendix.c: New file. + +2003-08-24 Motoyuki Kasahara + + * eb/multiplex.c (ebnet_connect_socket): Fix a bug in duplication + of socket entry. + + * eb/narwfont.c (eb_open_narrow_font_file): Fix bugs in LOG() calls. + +2003-08-15 Motoyuki Kasahara + + * configure.ac (AC_INIT): Set version to "4.0beta1". + +2003-08-14 Motoyuki Kasahara + + * eb/Makefile.am (dist_libeb_la_SOURCES): Add `booklist.c'. + * eb/Makefile.am (dist_pkginclude_HEADERS): Add `booklist.h'. + * eb/booklist.c: New file. + * eb/defs.h.in (EB_BookList_Entry, EB_BookList): New structured types. + * eb/ebnet.h (EBNET_MAX_BOOK_TITLE_LENGTH): Defined. + * eb/ebnet.c (ebnet_get_booklist): New function. + * ebinfo/ebinf.c (output_booklist): New function. + * ebinfo/ebinf.c (main): Add `--booklist' and `-l' options. + * ebinfo/ebinfo.c (output_information, output_multi_information): + Return `EB_Error_Code' instead of `int'. + +2003-08-09 Motoyuki Kasahara + + * eb/appendix.in: delete `--case' and `--suffix' options. + Now ebappendix checks all existing directories and files. + +2003-07-30 Motoyuki Kasahara + + * configure.ac, ebstopchk/ebstopchk.c, ebstopchk/Makefile.am: + Rename `ebstopchk' to `ebstopcode'. + + * Makefile.am (EXTRA_DIST): Add `misc/ebdump', `misc/ebfixlog' and + `misc/eb-index-info'. + +2003-07-24 Motoyuki Kasahara + + * eb/bitmap.c (eb_wide_font_xbm_size, eb_wide_font_xpm_size, + eb_wide_font_gif_size, eb_wide_font_bmp_size): Fix bugs that they + returned size of narrow font. + + * eb/defs.h.in (EB_Search_Context_Struct): Rename `compare_pre' and + `compare_hit' to `compare_single' and `compare_group'. + + * eb/match.c: Revise string comparison functions. + * eb/word.c (eb_search_word), eb/endword.c (eb_search_endword), + eb/exactword.c (eb_search_exactword), eb/keyword.c (eb_search_keyword), + eb/multi.c (eb_search_multi): Likewise. + eb/search.c (eb_hit_list_word, eb_hit_list_keyword, + eb_hit_list_multi): Likewise. + +2003-07-19 Motoyuki Kasahara + + * eb/narwfont.c (eb_open_narrow_font_file): Fix a bug that it + cannot open a font file in EB/EBG/EBXA/S-EBXA/EBXA-C. + + * eb/subbook.c (eb_load_subbook_indexes): Fix a bug in word search + that EB Library sometimes cannot have found words. + * eb/match.c (eb_match_word_latin, eb_match_word_jis, + eb_exact_match_word_latin, eb_exact_match_word_jis): Ditto. + +2003-07-11 Motoyuki Kasahara + + * eb/ebnet.c (ebnet_read): Output a log message upon return. + +2003-07-03 Motoyuki Kasahara + + * eb/book.c (misleaded_book_table): + Add "Japanese-English-Spanish Jiten (YRRS-060)". + +2003-06-11 Motoyuki Kasahara + + * Version 4.0beta0. + + * eb/multiplex.c (ebnet_connect_socket): Fix a bug that it tries to + connect with an empty address. + +2003-06-07 Motoyuki Kasahara + + * eb/defs.h.in (EB_Font_Struct): Add `glyphs'. + * eb/narwfont.c (eb_load_narrow_font): Split it into + eb_open_narrow_font_file() and eb_load_narrow_font_header(). + * eb/narwfont.c (eb_load_narrow_font_glyphs): New function. + * eb/font.c (eb_load_fonts): Renamed to eb_load_font_headers(). + Don't call eb_set_font(). + * eb/font.c (eb_set_font, eb_narrow_character_bitmap_jis, + eb_narrow_character_bitmap_latin): Load font glyph data to memory. + + * eb/narwfont.c (eb_narrow_font_size2): Add missing `break' statements + in a `switch' block. + +2003-06-05 Motoyuki Kasahara + + * configure.ac (AC_INIT): Set version to 4.0beta0. + + * eb/appendix.c (eb_initialize_appendix, eb_bind_appendix, + eb_finalize_appendix): Add ebnet supprt codes. + * eb/ebnet.c (ebnet_bind_appendix, ebnet_finalize_appendix): + New functions. + * eb/defs.h.in (EB_Appendix_Struct): Add `ebnet_file'. + +2003-05-22 Motoyuki Kasahara + + * eb/ebnet.c, eb/multiplex.c: Implement automatic reconnection. + + * eb/multiplex.c (hello_hook, bye_hook): They are now static variables + in this file. + * eb/multiplex.c (ebnet_set_hello_hook, ebnet_set_bye_hook): + New functions. + * eb/multiplex.c (ebnet_initialize): + Renamed to `ebnet_initialize_multiplex'. + * eb/ebnet.c (ebnet_initialize): New function. + * eb/multiplex.c (ebnet_mark_as_lost_sync): + Renamed to `ebnet_set_lost_sync'. + +2003-05-12 Motoyuki Kasahara + + * eb/font.c (eb_load_fonts): Load 8x16 and 16x16 fonts only for + efficiency. + +2003-05-07 Motoyuki Kasahara + + * m4/Makefile.am (EXTRA_DIST): Add `herrno.m4', `in6addr.m4', + `sockaddrin6.m4' and `sockinttypes.m4'. + * configure.ac (AC_CHECK_LIB): Check resolv, bind, nsl and socket + libraries. + +2003-05-06 Motoyuki Kasahara + + * configure.ac (AC_INIT): Set version to 4.0alpha0. + * configure.ac (LIBEB_VERSION_INFO): Set to `8:0:0'. + * configure.ac (EB_VERSION_MAJOR, EB_VERSION_MINOR): + Set EB_VERSION_MAJOR to `4' and EB_VERSION_MINOR to `0'. + +2003-05-05 Motoyuki Kasahara + + * configure.ac (AC_ARG_ENABLE): Add `--enable-ipv6' option for + ebnet support. + * configure.ac (AC_REPLACE_FUNCS): Add `strtol'. + * configure.ac (AC_TYPE_IN_PORT_T, AC_TYPE_SA_FAMILY_T, + AC_TYPE_SOCKLEN_T, AC_STRUCT_IN6_ADDR, AC_STRUCT_SOCKADDR_IN6, + AC_STRUCT_SOCKADDR_STORAGE, AC_DECL_IN6ADDR_ANY, + AC_DECL_IN6ADDR_LOOPBACK): Added for ebnet support. + * configure.ac (AC_CHECK_FUNCS): Add getaddrinfo(), getnameinfo() + and gai_strerror() for ebnet support. + * eb/Makefile.am (dist_libeb_la_SOURCES): Add `ebnet.c', + `multiplex.c', `linebuf.c', `urlparts.c', `getaddrinfo.c' + and `dummyin6.c' for ebnet support. + * configure.ac (noinst_HEADERS): Add `dummyin6.h', `ebnet.h', + `getaddrinfo.h', `linebuf.h' and `urlparts.h' for ebnet support. + * eb/build-pre.h (addrinfo, getaddrinfo, freeaddrinfo, getnameinfo, + gai_strerror, in6addr_any, in6addr_loopback): Define if missing. + * eb/erro.c, eb/error.h (EB_ERR_EBNET_UNSUPPORTED, + EB_ERR_EBNET_FAIL_CONNECT, EB_ERR_EBNET_SERVER_BUSY, + EB_ERR_EBNET_NO_PERMISSION): Add the error codes. + * eb/build-post.h.in, eb/zio.c (is_ebnet_url): Defined. + + * eb/eb.c (eb_initialize_library, eb_finalize_library): Add ebnet + support codes. + * eb/book.c (eb_initialize_book, eb_bind, eb_finalize_book): Ditto. + * eb/zio.c (eb_read_raw): Ditto. + * eb/zio.c (eb_open_raw, eb_close_raw, eb_lseek_raw): New functions. + Any other functions in eb/zio.c must not call open(), close(), + lseek() or read() directly. + + * eb/ebzip.c (main): Complain if book path is ebnet URL. + +2003-04-26 Motoyuki Kasahara + + * eb/build-post.h.in (EB_MAX_RELATIVE_PATH_LENGTH): Defined. + +2003-03-29 Motoyuki Kasahara + + * configure.ac (AC_REPLACE_FUNCS): Add strtol.c. + * libebutils/strtol.c: New file. + + * configure.ac (AC_CONFIG_FILES): Add `ebstopchk/Makefile'. + * Makefile.am (SUBDIRS): Add `ebstopchk'. + * ebstopchk/ebstopchk.c, ebstopchk/Makefile.am: New files. + * po-ebutils/Makefile.in (POTFILES): + Add `$(top_srcdir)/ebstopchk/ebstopchk.c'. + +2003-03-05 Motoyuki Kasahara + + * Version 3.3.2. + + * configure.ac (LIBEB_VERSION_INFO): Change LIBEB_VERSION_INFO from + 7:0:2 to 7:2:1. The previous version 7:0:2 is wrong. + + * configure.ac (AC_INIT): Set version to 3.3.2. + + * eb/book.c (misleaded_book_table): Add `Nichi-Ei-Futsu Jiten' + YRRS-059. + +2003-03-01 Motoyuki Kasahara + + * Version 3.3.1. + + * configure.ac (LIBEB_VERSION_INFO): Change LIBEB_VERSION_INFO from + 7:0:1 to 7:0:2. + * configure.ac (AC_INIT): Set version to 3.3.1. + +2003-02-28 Motoyuki Kasahara + + * eb/match.c (eb_match_canonicalized_word, + eb_exact_match_canonicalized_word): If first `length' characters + of `canonicalized_word' and `pattern' are equivalent, the functions + return 0. This change is for EPWING Genius Eiwa Daijiten. + +2003-02-16 Motoyuki Kasahara + + * eb/readtext.c (eb_read_text, eb_read_heading, eb_read_text_internal, + eb_forward_text, eb_backward_text): Fix bugs in call of LOG(). + +2003-02-11 Motoyuki Kasahara + + * eb/multi.c (eb_initialize_multi_searches): Fix a bug that it + doesn't initialize multi search entries correctly. + +2003-02-07 Motoyuki Kasahara + + * Version 3.3. + + * configure.ac (AC_INIT): Set VERSION to 3.3. + +2003-02-01 Motoyuki Kasahara + + * eb/binary.c (eb_read_binary_generic): Fix a bug that it cannot + read an MPEG file correctly. + +2003-01-12 Motoyuki Kasahara + + * Version 3.3beta3. + + * doc-ja/Makefile.am (eb-ver.texi, stamp-eb): Add missing targets. + * doc-ja/Makefile.am (EXTRA_DIST): Add `stamp-eb'. + + * eb/multi.c (eb_load_multi_searches): Set index style flags. + + * configure.ac (AC_INIT): Set version to `3.3beta3'. + +2002-10-30 Motoyuki Kasahara + + * Version 3.3beta2. + + * configure.ac (AC_INIT): Set version to 3.3beta2. + + * eb/bitmap.c (eb_narrow_font_xbm_size, eb_narrow_font_xpm_size, + eb_narrow_font_gif_size, eb_narrow_font_bmp_size, + eb_wide_font_xbm_size, eb_wide_font_xpm_size, + eb_wide_font_gif_size, eb_wide_font_bmp_size): Fix bugs that + those functions always return EB_ERR_NO_SUCH_FONT, reported by + NISHIKAWA. + + * m4/Makefile.am: Install `eb3.m4' in `$(datadir)/aclocal', + rathar than `$(pkgdatadir)', suggested by Takashi NEMOTO. + + * eb/book.c (eb_load_catalog_epwing): Fix minor bugs, reported + by Takashi NEMOTO. + +2002-10-08 Motoyuki Kasahara + + * eb/subbook.c (eb_load_subbook_indexes): Get index location + using `subbook->index_page'. + +2002-10-07 Motoyuki Kasahara + + * eb/appsub.c (eb_set_appendix_subbook, eb_set_appendix_subbook_eb, + eb_set_appendix_subbook_epwing): Fix error recovery codes. + * eb/subbook.c (eb_set_subbook, eb_set_subbook_eb, + eb_set_subbook_epwing): Ditto. + * eb/narwfont.c (eb_load_narrow_font): Ditto. + * eb/font.c (eb_set_font): Ditto. + +2002-10-06 Motoyuki Kasahara + + * eb/defs.h.in (EB_Subbook_Struct): add the `initialized' member. + * eb/font.c (eb_initialize_fonts): Reset `font->initialized'. + * eb/font.c (eb_load_fonts): New internal function. + * eb/narwfont.c (eb_load_narrow_font): Don't complain if it cannot + open a font file. Set `font->initialized' upon success. + * eb/subbook.c (eb_set_subbook): Call eb_load_fonts(). + + * eb/subbook.c (eb_set_subbook, eb_load_subbook): Set + `subbook->initialized' by eb_set_subbook(). + +2002-09-28 Motoyuki Kasahara + + * Version 3.3beta1. + + * eb/book.c (eb_load_catalog_epwing): Don't complain when it fails + to read extended information block. + + * configure.ac (AC_INIT): Set version to `3.3beta1'. + +2002-09-26 Motoyuki Kasahara + + * configure.ac (AM_CONFIG_HEADER): Use `AC_CONFIG_HEADER' instead. + * configure.ac (AC_CYGWIN, AC_MINGW32): Removed. + * configure.ac (AC_INIT, AM_INIT_AUTOMAKE): Package name and version + are set with AC_INIT, not AM_INIT_AUTOMAKE. + +2002-09-08 Motoyuki Kasahara + + * eb/defs.h.in (EB_Text_Context): Rename `text_end_flag' to + `text_status'. + * eb/defs.h.in (EB_Text_Status_Code): Define the type and its + possible values. + * eb/readtext.c (eb_forward_text): Fix a bug that eb_forward_text() + doesn't return EB_ERR_END_OF_CONTENT when the current file pointer + is at 1f03. + +2002-09-05 Motoyuki Kasahara + + * eb/appsub.c (eb_load_appendix_subbook): Fix a bug that the function + resets alt-text data for local characters if the appendix doesn't + define stop code. + +2002-08-30 Motoyuki Kasahara + + * eb/multi.c (eb_multi_label): Generate labels written in ASCII + if the book is written in ISO 8859-1. + +2002-08-24 Motoyuki Kasahara + + * Version 3.3beta0. + + * configure.ac (AM_INIT_AUTOMAKE): Set version to `3.3beta0'. + * configure.ac (EB_VERSION_MINOR): Set to 3. + * configure.ac (LIBEB_VERSION_INFO): Set to 7:0:1. + + * samples/font.c: New sample program. + * samples/Makefile.am (noinst_PROGRAMS): Add `font'. + * doc-ja/Makefile.am (eb_ja_TEXINFOS): add `font-c.texi'. + +2002-08-23 Motoyuki Kasahara + + * decomp, install-sh, mkinstalldirs, missing: Imported from + Automake-1.6.3. + + * eb/text.h: add EB_HOOK_BEGIN_IN_COLOR_BMP and + EB_HOOK_BEGIN_IN_COLOR_JPEG. + * eb/text.c: support those hooks for handling of inline color graphic. + +2002-08-21 Motoyuki Kasahara + + * eb/refile.c (refile_catalog): Fix a bug that extended information + blocks of eliminated subbooks are copied to `catalogs.new'. + +2002-08-20 Motoyuki Kasahara + * eb/binary.c (eb_set_binary_mono_graphic, eb_set_binary_gray_graphic): + Don't read data from `honmong', but `honmon' or `honmon2' when + the book is EPWING. + + * eb/defs.h.in (EB_SIZE_EBZIP_HEADER): Removed. + +2002-08-17 Motoyuki Kasahara + + * eb/defs.h.in (EB_Book_Struct): Delete `version'. + * eb/defs.h.in (EB_Subook_Struct): Add `text_hint_zio_code', + `graphic_hint_zio_code' and `sound_hint_zio_code'. + + * eb/book.c (eb_load_catalog): Revised. + Get text, graphic and sound file names from the `catalogs' file, + if the book is EPWING. + * eb/subbook.c (eb_set_subbook_epwing): Likewise. + * eb/filename.c (eb_find_file_name): `target_file_name' can be + equal to `found_file_name'. + + * eb/build-post.h.in (EB_FILE_NAME_START, EB_FILE_NAME_HONMON, + EB_FILE_NAME_APPENDIX, EB_FILE_NAME_FUROKU): Defined. + * eb/defs.h.in (EB_SIZE_EB_CATALOG, EB_SIZE_EPWING_CATALOG): + Moved to `eb/built-post.h.in'. + + * eb/build-post.h.in (EB_MAX_SEARCH_TITLES): Defined. + * eb/defs.h.in (EB_MAX_MULTI_SEARCHES): Change the value from 8 + to 10. + * eb/defs.h.in (EB_MAX_MULTI_TITLE_LENGTH): Defined. + * eb/defs.h.in (EB_Subbook_Struct): Add `search_title_page'. + * eb/defs.h.in (EB_Multi_Search_Struct): Add `title'. + * eb/multi.c (eb_load_multi_titles, eb_multi_title): New functions. + * eb/ebinfo.c (output_multi_information): Also output search titles. + +2002-08-16 Motoyuki Kasahara + + * Version 3.2.3. + + * eb/subbook.c (eb_set_subbook_epwing): Open `honmon2' for + sound or graphic file if `honmong' or `honmons' doesn't exist. + * eb/binary.c (eb_set_binary_wave): Fix a bug that the function + composes broken WAVE header. + + * eb/text.h, eb/readtext.c: Define `EB_HOOK_BEGIN_DECORATION' and + `EB_HOOK_END_DECORATION', requested from Kenichi SUTO. + +2002-06-10 Motoyuki Kasahara + + * Version 3.2.2. + + * configure.ac (AM_INIT_AUTOMAKE): Set version to 3.2.2. + * configure.ac (LIBEB_VERSION_INFO): Change the version info from + 6:1:0 to 6:2:0. + + * eb/appsub.c (eb_load_appendix_subbook): Fix a bug that EB Library + complains about absenseof alternation text definition. + + * missing, install-sh, mkinstalldirs, depcomp, doc/mdate-sh, + doc-ja/mdate-sh: Imported from automake-1.6.1. + + * libebutils/ebutils.c (output_version): Shorten the version info + massage. + +2002-03-21 Motoyuki Kasahara + + * ebzip/copyfile.c (ebzip_copy_file): fix type of the variable + `in_length'. + +2002-03-13 Motoyuki Kasahara + + * Version 3.2.1. + + * Import zlib-1.1.4. + + * eb/readtext.c (eb_is_stop_code): Fix a bug that it cannot + find stop-code when using appendix. + + * configure.ac (AM_INIT_AUTOMAKE): Set version to 3.2.1. + * configure.ac (LIBEB_VERSION_INFO): Change it from 6:0:0 to 6:1:0. + +2002-02-09 Motoyuki Kasahara + + * Version 3.2. + + * configure.ac(AM_INIT_AUTOMAKE): Set version to 3.2. + +2002-01-23 Motoyuki Kasahara + + * Version 3.2beta3. + + * po-eb/Makefile.in, po-ebutil/Makefile.in (DESTDIR): + Don't set DESTDIR in those files. + + * eb/filename.c (eb_find_file_name): Return a filename with highest + preference. + + * eb/zio.h (ZIO_P): Defined. + * eb/zio.c (LOG): Generate log codes if EB_BUILD_LIBRARY is defined. + + * eb/bitmap.c, eb/binary.c, eb/readtest.c: Supress warnings by + "gcc -Wconversion". + +2002-01-22 Motoyuki Kasahara + + * m4/eb3.m4 (AC_REQUIRE): Also AC_FUNC_VPRINTF is required. + + * eb/memmove.c (memmove): The function name should be eb_memmove(). + * eb/strcasecmp.c (eb_strcasecmp, eb_strncasecmp): Revised. + * libebutils/strcasecmp.c (strcasecmp, strncasecmp): Revised. + + * eb/build-post.h.in, eb/eb.h: Move declation of eb_enable_log() + and eb_disable_log() from `eb/build-post.h.in' to `eb/eb.h'. + * eb/log.c (eb_log_stderr): Do noting if the system doesn't have + vprintf() or dopront(). + * eb/log.c (eb_initialize_log): New function. + Definition of the EB_DEBUG environment variable is checked here. + * eb/log.c (eb_set_log_function, eb_enable_log, eb_disable_log): + Call eb_initialize_log() if not initialized yet. + + * config.guess: Use "2002-01-02". + * config.sub: Use "2002-01-10". + * depcomp, missing, mkinstalldirs: Import from Automake-1.5b. + + * configure.ac (AM_INIT_AUTOMAKE): Set version to 3.2beta3. + + * filename.c (eb_canonicalze_path_name): Delete "./" and "." + at the beginning of a given path name. + +2002-01-19 Motoyuki Kasahara + + * libebutils/getopt.c, libebutils/getopt.h: Delete `optreset' support + that is local extension to POSIX2. + + * Version 3.2beta2. + + * ebfont/ebfont.c (main): Stop parsing command line options when + getopt_long() returns -1 not EOF. + * ebinfo/ebinfo.c (main): Ditto. + * ebrefile/ebrefile.c (main): Ditto. + * ebzip/ebzip.c (main): Ditto. + * libebutils/getopt.c, libebutils/getopt.h, libebutils/getopt1.c: + Use getopt_long() taken from NetBSD, not from GLIBC. + * libebutils/Makefile.am (libebutils_a_SOURCES): Delete getopt1.c. + + * eb/hook.c, eb/search.c, eb/subbook.c, eb/zio.c, ebrefile/ebrefile.c, + ebzip/sebxa.c, ebzip/unzipfile.c, ebzip/zipfile.c, + libebutils/getumask.c: Supress warnings by "gcc -Wconversion". + +2002-01-18 Motoyuki Kasahara + + + * configure.ac (AM_INIT_AUTOMAKE): Set version to "3.2beta2". + + * eb/zio.c (zio_unzip_slice_ebzip1): Fix a decompression bug. + + * eb/defs.h (EB_MULTI_ENTRY_INVALID): Deleted. + + * configure.ac (EB_VERSION_MAJOR, EB_VERSION_MINOR): AC_SUBST + variables. + * eb/Makefile.am (nodist_pkginclude_HEADERS): Add defs.h. + * eb/Makefile.am (pkginclude_HEADERS): use dist_pkginclude_HEADERS + instead. + * eb/defs.h: Now this file is generated from eb/defs.h.in by Makefile. + * eb/defs.h.in: New file. + * eb/Makefile.am (BUILT_SOURCES): Add defs.h. + * eb/Makefile.am (EXTRA_DIST): Add defs.h.in. + * eb/Makefile.am (CLEANFILES): Add stamp-defs-h and defs.h. + * eb/Makefile.am (defs.h, stamp-defs-h): New targets. + + * eb/Makefile.am (nodist_libeb_la_SOURCES): Add widealt.c and + widefont.c. + * eb/Makefile.am (libeb_la_SOURCES): use dist_libeb_la_SOURCES instead. + + * eb/Makefile.am (dist_noinst_HEADERS): Add ebutils.h. + * eb/Makefile.am (noinst_HEADERS): use nodist_noinst_HEADERS instead. + + * configure.ac (AC_ARG_ENABLE): Delete --enable-debug option. + * eb/build-post.h.in (LOG): Revised. + * eb/build-post.h.in (eb_log_flag): New global variable. + * eb/log.c (eb_enable_log, eb_disable_log): New functions. + * eb/log.c (eb_set_log_function): Also set zio log function. + * eb/log.c (eb_log, eb_log_stderr): Mutx lock with `log_mutex' is + done by eb_log_stderr(), not eb_log(). + * eb/zio.c (zio_log_function, zio_log_flag): New variables. + * eb/zio.c (zio_enable_log, zio_disable_log, zio_set_log_function, + * eb/zio.c (LOG): Revised. + zio_log): New functions. + + * eb/hook.c (eb_set_hooks): Log debug messages if `eb_log_flag' + is not 0. + * eb/keyword.c (eb_search_keyword): Ditto. + * eb/multi.c (eb_search_multi): Ditto. + + * eb/eb.c (eb_initialize_library): Enable debug mode if the + EB_DEBUG environment variable is defined. + +2002-01-01 Motoyuki Kasahara + + * Version 3.2beta1. + + * po-eb/Makefile.in, po-ebutils/Makefile.in (CATALOGS): Renamed + to `MOFILES'. + * po-eb/Makefile.in, po-ebutils/Makefile.in (POFILES): Added. + * po-eb/Makefile.in, po-ebutils/Makefile.in (DISTFILES): Add POFILES. + + * eb/text.h (EB_HOOK_BEGIN_IN_COLOR_BMP, EB_HOOK_BEGIN_IN_COLOR_JPEG, + EB_HOOK_END_IN_COLOR_GRAPHIC): Removed. + * eb/text.h (EB_HOOK_BEGIN_GRAPHIC_REFERENCE, + EB_HOOK_END_GRAPHIC_REFERENCE, EB_HOOK_GRAPHIC_REFERENCE): Added. + * eb/readtext.c (eb_read_text_internal): Add handling of 1f4c and 1f6c + control sequences. + + * eb/zio.c (eb_read_ebzip, eb_unzip_slice_ebzip): Uncompress data + with small buffer. + * eb/zio.h (ZIO_MAX_EBZIP_LEVEL): Changed from 3 to 5. + +2001-12-16 Motoyuki Kasahara + + * eb/zio.c (zio_unzip_slice_ebzip1): Fix a memory leak bug. + +2001-11-25 Motoyuki Kasahara + + * eb/readtext.c (eb_read_rawtext): Fix a bug in handling of context + code, reported by Takashi NEMOTO. + + * eb/bitmap.c (eb_narrow_font_bmp_size, eb_wide_font_bmp_size, + eb_bitmap_to_bmp): New functions. + + * eb/font.c (main): `error_code' was used uninitialized. Fixed. + +2001-11-16 Motoyuki Kasahara + + * eb/ebzip1.c (ebzip1_slice): We must call deflateEnd() even when + deflate() doesn't succeed. + * eb/subbook.c (eb_set_subbook_epwing): We assume that "honmons" + in EPWING6 CD-ROM has been compressed, not plain. + +2001-11-11 Motoyuki Kasahara + + * eb/ebzip.c (eb_unzip_slice_epwing6): Fix a bug that it cannot + uncompress a page of compression_type != 0, reported by ISHIKAWA + Naoya. + +2001-11-05 Motoyuki Kasahara + + * eb/binary.c (eb_unset_binary): Fix typo in a log message. + * eb/subbook.c (eb_unset_subbook): Ditto. + + * eb/subbook.c (eb_set_subbook): Fix a bug that the library + opens a directory with open() if there isn't "honmons" but "honmon2". + This problem is reported by Yamagata san. + +2001-11-01 Motoyuki Kasahara + + * eb/binary.c (eb_set_binary_mono_graphic): For Kanjigen (EB), + allow the 0x1f31 escape sequence with arguments of 8 bytes, + reported by Yamagata san. + +2001-10-27 Motoyuki Kasahara + + * Version 3.2beta0. + + * doc-ja/Makefile.am (info_TEXINFOS): List in one line to avoid + a bug of GNU automake-1.5. + + * configure.ac (AC_ARG_ENABLE): Add `--enable-samples'. + * Makefile.am (SAMPLES_SUBDIR): New variable. + * Makefile.am (SUBDIRS): Add $(SAMPLES_SUBDIR). + * samples/Makefile.am, samples/disctype.c, samples/subbook.c, + samples/word.c: Revised. + * samples/initexit.c, samples/text.c: New files. + + * configure.ac (LIBEB_VERSION_INFO): Set to `6:0:0'. + +2001-10-26 Motoyuki Kasahara + + * m4/libtool.m4, ltmain.sh: Import libtool-1.4.2. + +2001-10-25 Motoyuki Kasahara + + * eb/error.h (EB_ERR_TEXT_END): Renamed to `EB_ERR_END_OF_CONTENT'. + + * doc-ja/Makefile.am (info_TEXINFOS): Add `eb-ja.texi'. + * doc-ja/Makefile.am (eb_ja_TEXINFOS): Defined. + * doc-ja/Makefile.am (C2TEXI): Defined. + * doc-ja/eb-ja.texi: Added. + * doc-ja/Makefile.am (EXTRA_DIST): Add `c2texi'. + + * doc-ja/c2texi: Delete copyright notice, #ifdef and #endif lines. + +2001-10-23 Motoyuki Kasahara + + * eb/build-post.h.in (EB_TEXT_NONE): Renamed to EB_TEXT_SEEKED. + * eb/error.h (EB_ERR_NO_PREV_SEEK): New error code. + * eb/readtext.c (eb_read_text, eb_read_heading, eb_read_rawtext, + eb_forward_text, eb_backward_text): If text_context code is + EB_TEXT_INVALID, return EB_ERR_NO_PREV_SEEK. + + * eb/readtext.c (eb_backward_text): Fix a bug that it misses + detecting the backward location. + +2001-10-22 Motoyuki Kasahara + + * eb/defs.h (EB_Appendix_Subbook_Struct): Rename `stop0' to + `stop_code0', and `stop1' to `stop_code1' respectively. + + * eb/text.c, eb/readtext.c: Rename text.c to readtext.c, and + create text.c, again. + * eb/Makefile.am (libeb_la_SOURCES): Add `readtext.c'. + + * eb/readtext.c (eb_backward_text): New function. + + * configure.ac (AM_INIT_AUTOMAKE): Set version to 3.2beta0. + +2001-10-20 Motoyuki Kasahara + + * eb/text.h (EB_HOOK_STOP_CODE): Removed. + * eb/error.h (EB_ERR_STOP_CODE): Removed. + * eb/hook.c: (eb_hook_stop_code): Removed. + * eb/text.c (eb_is_stop_code): New function. + * eb/text.c (eb_reset_text_context): Don't reset `location'. + * eb/text.c (eb_seek_text, eb_read_text, eb_read_heading, + eb_read_rawtext, eb_forward_text, eb_forward_heading): Use + eb_reset_text_context(). + * eb/error.h (EB_ERR_STOP_CODE): Removed. + * eb/error.h (EB_ERR_TEXT_END): New error code. + + * eb/text.c (eb_read_text_internal): Add the `forward_only' argument. + * eb/text.c (eb_forward_text): Remove the `hookset' argument. + * eb/text.c (eb_forward_text, eb_forward_heading): Revised. + * eb/defs.h (EB_Text_Context_Struct): Delete `in_step'. + + * eb/search.c (eb_reset_search_context): Fix log format. + * eb/search.c (eb_initialize_default_hookset): Ditto. + +2001-10-11 Motoyuki Kasahara + + * eb/narwfont.c (eb_load_narrow_font): Check range of character + numbers strictly. + * eb/appsub.c (eb_load_appendix_subbook): Likewise. + + * eb/narwfont.c (eb_load_narrow_font): Close a font file if the + number of local character is 0. + +2001-10-05 Motoyuki Kasahara + + * eb/text.c (eb_is_text_stopped): New function. + +2001-10-03 Motoyuki Kasahara + + * m4/Makefile.am (EXTRA_DIST, pkgdata_DATA): Remove `ssizet.m4'. + + * eb/filename.c (eb_path_name_zio_code): Fix a bug in path name + adjustment. + + * eb/hook.c (eb_hook_newline): Use `EB_SUCCESS', not `0'. + + * eb/narwfont.c (eb_load_narrow_font): Log on exit. + +2001-10-01 Motoyuki Kasahara + + * eb/log.c (eb_log): Add missing va_end() call. + + * eb/defs.h (EB_MAX_KEYWORDS, EB_NUMBER_OF_SEARCH_CONTEXTS): They + are now aliases of EB_MAX_MULTI_ENTRIES. + +2001-09-27 Motoyuki Kasahara + + * m4/eb3.m4 (AC_REQUIRE): Don't request `AC_TYPE_SSIZE_T'. + Check with AC_CHECK_TYPE(ssize_t, int), instead. + * m4/ssizet.m4: Removed. + * configure.ac (AC_TYPE_SSIZE_T): Removed. Use AC_CHECK_TYPE instead. + +2001-09-24 Motoyuki Kasahara + + * eb/subbook.c (eb_load_all_subbooks): Upon return, unset subbook. + + * eb/defs.h: Include . + * eb/defs.h (EB_MAX_PATH_LENGTH): New macro. + * eb/build-pre.h (PATH_MAX): Removed. Use EB_MAX_PATH_LENGTH instead. + + * m4/eb3.m4 (AC_CHECK_HEADERS): Defined. Check `limits.h'. + + * eb/multi.c (eb_multi_entry_count): New function. + * eb/multi.c (eb_multi_entry_list): Revised. + New implementation is based on eb_multi_entry_count(). + * ebinfo/ebinfo.c (output_multi_information): + Use eb_multi_entry_count() instead of eb_multi_entry_list(). + +2001-09-20 Motoyuki Kasahara + + * ebfont/ebfont.c, ebinfo/ebinfo.c, ebrefile/ebrefile.c, + ebzip/ebzip.c (main): Check return value of eb_initialize_library(). + +2001-09-08 Motoyuki Kasahara + + * ebzip/copyfile.c, ebzip/sebxa.c, ebzip/unzipbook.c, + ebzip/unzipfile.c, ebzip/zipbook.c, ebzip/zipfile.c, + ebzip/zipinfobook.c, ebzip/zipinfofile.c: Don't include "eb.h", + "error.h", "font.h" nor "build-post.h", reported by satomii. + * ebzip/ebzip.h: Include "build-post.h", reported by satomii. + + * ebrefile/ebrefile.c (main): Fix the bug of the order of + arguments passed to refile_book(), reported by satomii. + + * ebzip/ebzip1.c, eb/defs.h: Don't use `EB_SIZE_EBZIP_MARGIN'. + + * eb/binary.h: Delete declaration of eb_initialize_binary(), reported + by Takashi NEMOTO. + * eb/log.c: Include instead of if `WIN32' is + defined, requested by satomii. + * eb/zio.h: In function declaration, describe types of arguments if + `WIN32' is defined, requested by satomii. + + * libebutils/ebutils.c (canonicalize_path): Add DOS version. + +2001-08-30 Motoyuki Kasahara + + * Version 3.1. + + * configure.ac (AC_INIT): Don't pass unique file as an argument. + Use AC_CONFIG_SRCDIR instead. + * configure.ac (AC_PREREQ): Set to 2.52. + +2001-08-29 Motoyuki Kasahara + + * configure.ac (AM_INIT_AUTOMAKE): Set version to 3.1. + + * eb/zio.c (zio_open_plain): Set `slice_size'. + * eb/zio.c (zio_unzip_slice_sebxa): If copy offset is out of range, + fill 0x00. + + * po-ebutils/Makefile.am (POTFILES): Add `ebzip/sebxa.c'. + * ebzip/Makefile.am (ebzip_SOURCES): Add `sebxa.c'. + * ebzip/sebxa.c: New file. + + * ebzip/copyfile.c: Include "eb.h", "error.h" and "build-post.h". + * ebzip/unzipbook.c (ebzip_unzip_book_eb): Fix START file after + compression. + + * ebzip/unzipfile.c (ebzip_unzip_file): Splited into + ebzip_unzip_file() ebzip_unzip_start_file() and + ebzip_unzip_file_internal(). + * ebzip/zipfile.c (ebzip_zip_file): Splited into + ebzip_zip_file() ebzip_zip_start_file() and + ebzip_zip_file_internal(). + * ebzip/zipinfofile.c (ebzip_zipinfo_file): Splited into + ebzip_zipinfo_file() ebzip_zipinfo_start_file() and + ebzip_zipinfo_file_internal(). + + * ebzip/zipinfobook.c (ebzip_zipinfo_book_eb): + Call ebzip_zipinfo_start_file() rather than ebzip_zipinfo_file() to + inspect START file. + * ebzip/zipbook.c (ebzip_zip_book_eb): + Call ebzip_zip_start_file() rather than ebzip_zip_file() to + compress START file. + * ebzip/unzipbook.c (ebzip_unzip_book_eb): + Call ebzip_unzip_start_file() rather than ebzip_unzip_file() + to uncompress START file. + +2001-08-28 Motoyuki Kasahara + + * eb/zio.c (zio_unzip_slice_sebxa): Fix a critical bug that any + uncompression requests cannot be performed correctly. + +2001-08-14 Motoyuki Kasahara + + * eb/match.c (eb_match_word_latin, eb_exact_match_word_latin): + The function names ware exchanged by mistake, reported by + HASEGAWA Masafumi. Fixed. + * eb/appendix.h (eb_load_all_appendix_subbooks): Add missing + function declaration, reported by HASEGAWA Masafumi. + * eb/defs.h (EB_VERSION_MINOR): Set the macro to `1', reported + by HASEGAWA Masafumi. + + * configure.ac (AC_ARG_ENABLE, AC_ARG_WITH): Use AC_HELP_STRING. + * m4/gettext.m4 (AC_ARG_ENABLE, AC_ARG_WITH): Likewise. + * m4/eb3.m4 (AC_ARG_ENABLE, AC_ARG_WITH): Likewise. + * configure.ac (AC_OUTPUT): Use AC_CONFIG_FILES to specify + configuration file names. Call AC_OUTPUT with no argument. + + * configure.ac (AM_INIT_AUTOMAKE): Set version to 3.1beta2. + +2001-08-13 Motoyuki Kasahara + + * eb/configure.ac (AC_ARG_ENABLE): Disable `--enable-debug' by + default, reported by Kazu TAKAGI. + +2001-08-07 Motoyuki Kasahara + + * Version 3.1beta1. + + * eb/configure.ac (LIBEB_VERSION_INFO): Set the varaible to 5:0:0. + + * eb/ebconfig.h: Renamed to `eb/build-pre.h'. + * eb/internal.h.in: Renamed to `eb/build-post.h'. + + * ebrefile/ebrefile.c: Include "*.h" not "eb/*.h". + * ebrefile/Makefile.am (INCLUDES): Delete `-I$(top_srcdir)' and + add `-I../eb -I$(top_srcdir)/eb' instead. + +2001-08-06 Motoyuki Kasahara + + * missing: Import from Automake 1.4j. + + * eb/defs.h (EB_Lock_Struct, EB_Lock): Define the types + if ENABLE_PTHREAD or EBCONF_ENABLE_PTHREAD is defined. + +2001-08-04 Motoyuki Kasahara + + * ebzip/common.c, ebzip/copyfile.c, ebzip/ebzip.c, + ebzip/unzipbook.c, ebzip/unzipfile.c, ebzip/zipbook.c, + ebzip/zipfile.c, ebzip/zipinfobook.c, ebzip/zipinfofile.c, + ebzip/ebzip.h: Inclusions of header files and definitions of missing + macros in *.c are moved to `ebzip/ebzip.h'. + + * configure.ac (AC_CHECK_HEADERS): Add `pthread.h'. + +2001-08-03 Motoyuki Kasahara + + * eb/ebconfig.h, eb/memmove.c, eb/zio.c, libebutils/memset.c: + lib/memset.c: Don't define VOID if it has been defined. + * eb/ebconfig.h, eb/defs.h: Don't define EB_P if WIN32 is defined. + * configure.ac (AC_CHECK_HEADERS): Add `sys/utime.h'. + * win32/config.h, win32/dirent.h, win32/dirent.c, win32/funcname.h, + win32/unistd.h, win32/zconfig.h: Add new directory `win32' and put + new files on the directory. + + * eb/ebconfig.h (F_): Delete the macro. + * eb/filename.c (eb_canonicalize_path_name): In DOS version, replace + all '/' in the given path with `\\'. + * eb/filename.c (eb_canonicalize_path_name): Use strchr() to check + if the given path name represents root. + * eb/filename.c (eb_compose_path_name, eb_compose_path_name2, + eb_compose_path_name3): Revised. + +2001-08-01 Motoyuki Kasahara + + * eb/search.c (eb_initialize_search, eb_finalize_search): + Delete the first argument `EB_Book *'. + + * eb/bitmap.c, eb/narwalt.c, eb/font.c. eb/narwfont.c, eb/setword.c, + eb/subbook.c, eb/text.c: + Add debug codese. + + * eb/book.c (eb_bind): Assign a book code at first. + * eb/appendix (eb_bind_appendix): Likewise. + + * eb/multi.c (eb_finalie_multi_searches): Revised. + + * eb/narwfont.c (eb_narrow_font_size2): Fix a bug. Add missing + `return' statement. + + * eb/log.c (log_mutex): New variable. + * eb/log.c (eb_log): Lock `log_mutex' at invoking log function. + + * eb/text.c (eb_invalidate_text_context): New function. + * eb/text.c (eb_read_text, eb_read_heading, eb_read_rawtext, + eb_forward_text, eb_forward_heading): Call eb_invalidate_text_context() + upon failure return. + +2001-07-31 Motoyuki Kasahara + + * eb/binary.c (eb_set_binary_mpeg): Fix a critical bug in file name + composition. + + * eb/book.c (eb_finalize_book): Revised. + + * eb/binary.c, eb/book.c, eb/copyright.c, eb/eb.c eb/endword.c, + eb/exactword.c, eb/hook.c, eb/keyword.c, eb/menu.c, eb/multi.c, + eb/stopcode.c, eb/subbook.c, eb/word.c: Add debug codes. + + * eb/subbook.c: Include "binary.h". + + * eb/zio.c (ZIO_ID_NONE): Defined. + * eb/zio.c (cache_file): Renamed to `cache_zio_id'. + * eb/zio.c (cache_mutex): Renamed to `zio_mutex'. + * eb/zio.c (zio_open): Initialize `zio' again if file descriptor + the given `zio' holds is active. + * eb/zio.c (zio_open_plain, zio_open_ebzip, zio_open_epwing, + zio_open_epwing6): Assign ID to `zio'. + +2001-07-30 Motoyuki Kasahara + + * eb/appendix.c (eb_initialize_appendix_catalog): Renamed to + eb_load_appendix_catalog(). + * eb/appendix.c (eb_initialize_alt_cache): Renamed to + eb_initialize_alt_caches(). + * eb/appendix.c (eb_initialize_appendix): Initialize all members + in EB_Appendix. + * eb/appendix.c (eb_finalize_appendix): Revised. + + * eb/appendix.h (eb_initialize_all_appendix_subbooks): Define the + macro for backward compatibility. + + * eb/appsub.c (eb_initialize_appendix_subbook): Renamed to + eb_load_appendix_subbook(). + * eb/appsub.c (eb_finalize_appendix_subbooks): New function. + * eb/appsub.c (eb_initialize_appendix_subbooks): New function. + * eb/appsub.c (eb_load_all_appendix_subbooks): New function. + + * eb/binary.c (eb_initialize_binary): Renamed to + eb_initialize_binary_context(). Initialize all members in + EB_Binary_Context. + * eb/binary.c (eb_finalize_binary_context): New function. + * eb/binary.c (eb_reset_binary_context): New function. + + * eb/book.c (eb_initialize_catalog): Renamed to eb_load_catalog(). + * eb/book.c (eb_initialize_language): Renamed to eb_load_language(). + * eb/book.c (eb_initialize_book): Initialize all members to EB_Book. + * eb/book.c (eb_finalize_book): Revised. + + * eb/book.h (eb_initialize_all_subbooks): Define the macro for + backward compatibility. + + * eb/font.c (eb_initialize_fonts): New function. + * eb/font.c (eb_finalize_fonts): New function. + + * eb/hook.c (eb_finalize_hookset): Reset all the hooks. + + * eb/internal.h.in (EB_ARRANGE_INVALID): New macro. + + * eb/multi.c (eb_initialize_multi_searches): New function. + * eb/multi.c (eb_finalize_multi_searches): New function. + * eb/multi.c (eb_initialize_multi_search): Renamed to + eb_load_multi_search(). + + * eb/narwfont.c (eb_initialize_narrow_font): Renamed to + eb_load_narrow_font(). + + * eb/search.c (eb_initialize_search): Renamed to + eb_initialize_search_contexts(). Initialize all members in + EB_Search_Context. + * eb/search.c (eb_finalize_search_contexts): New function. + * eb/search.c (eb_reset_search_contexts): New function. + * eb/search.c (eb_initialize_search): New function. + * eb/search.c (eb_finalize_search): New function. + * eb/search.c (eb_initialize_searches): New function. + * eb/search.c (eb_finalize_searches): New function. + + * eb/subbook.c (eb_initialize_subbook): Renamed to eb_load_subbook(). + * eb/subbook.c (eb_initialize_indexes): Renamed to + eb_load_subbook_indexes(). + * eb/subbook.c (eb_load_subbook_indexes): Call eb_initialize_search() + to initialize EB_Search. + + * eb/text.c (eb_initialize_text): Renamed to + eb_initialize_text_context(). Initialize all members in + EB_Text_Context. + * eb/text.c (eb_finalize_text_context): New function. + * eb/text.c (eb_reset_text_context): New function. + + * eb/appendix.c, eb/appsub.c: Add debug codes. + * eb/defs.h (EB_Appendix_Struct): Add member `code'. + * eb/appendix.c (appendix_counter): New static variable. + + * eb/log.c: Include "internal.h". + +2001-07-25 Motoyuki Kasahara + + * eb/search.c (eb_presearch_word): Don't set `context->entry_length' + to 0 at successful return. + +2001-07-24 Motoyuki Kasahara + + * eb/zio.h (Zio_Struct): Add `id'. + * eb/zio.c (zio_counter): New static variable. + * eb/zio.c (zio_initialize): manage zio_counter, and assign the + counter value to `zio->id'. + * eb/zio.c (LOG): Defile this macro if ENABLE_DEBUG. + + * eb/log.c (eb_quoted_string): Prepare multiple static buffers. + * eb/log.c (eb_quoted_string): Accept NULL pattern. + * eb/log.c (eb_quoted_string): Encode '=' character as `=3D'. + +2001-07-22 Motoyuki Kasahara + + * eb/Makefile.am (libeb_la_SOURCES): Add `log.c'. + * eb/eb.h: Include if __STDC__ is defined. + * eb/error.c (error_strings): New static variable. + * eb/error.c (eb_error_string): New function. + * eb/error.c (unknown): Deleted. + * eb/internal.h.in (LOG): New macro. + * eb/match.c, eb/search.c: Output log messages. + +2001-07-18 Motoyuki Kasahara + + * ebzip/zipfile.c (ebzip_zip_file): Don't call utime() if + HAVE_STRUCT_UTIMBUF is not defined. + * ebzip/unzipfile.c (ebzip_unzip_file): Ditto. + * ebzip/copyfile.c (ebzip_copy_file): Ditto. + * ebzip/ebzip.c (parse_skip_content_argument): Defined as `static' + function. + * ebzip/copyfile.c (ebzip_copy_files_in_directory): Fix a bug that + the function always returns -1. + +2001-07-17 Motoyuki Kasahara + + * Version 3.1beta0. + + * eb/text.c (eb_read_text_internal): Suppose that area of user + defined characters in EPWING and EB* is 0xa121 ... 0xfe7f. + + * eb/configure.ac (LIBEB_VERSION_INFO): Set the varaible to 4:2:0. + * eb/configure.ac (AM_INIT_AUTOMAKE): Set version to 3.1.0beta0. + + * Makefile.am (EXTRA_DIST): Add `ChangeLog.1'. + +2001-07-16 Motoyuki Kasahara + + * eb/filename.c (eb_canonicalize_font_file_name): Renamed to + eb_canonicalize_file_name(). + + * eb/zio.h (ZIO_NONE): Renamed to ZIO_PLAIN. + * eb/zio.c (zio_open_none): Renamed to zio_open_plain(). + +2001-07-13 Motoyuki Kasahara + + * eb/match.c (eb_match_word, eb_match_exactword): + Renamed to eb_match_canonicalized_word() and + eb_exact_match_canonicalized_word(). + * eb/match.c (eb_match_word_latin, eb_match_word_jis, + eb_exact_match_word_latin, eb_exact_match_word_jis): New functions. + * eb/defs.h (EB_Search_Context_Struct): split `compare' into + `compare_pre' and `compare_hit'. + * eb/word.c (eb_search_word): Change policy of choosing search + function. + * eb/exactword.c (eb_search_exactword): Ditto. + * eb/endword.c (eb_search_endword): Ditto. + * eb/keyword.c (eb_search_keyword): Ditto. + * eb/multi.c (eb_search_multi): Ditto. + +2001-07-12 Motoyuki Kasahara + + * eb/defs.h (EB_Subbook_Struct): Add the member `text'. + * eb/subbook.c (eb_initialize_indexes): Revise S-EBXA compression + support code. + * eb/zio.c (zio_set_sebxa_mode): New function. + * eb/zio.c (zio_read_sebxa, zio_unzip_slice_sebxa): Revised and + Enabled. + * eb/zio.c (zio_read): Enable S-EBXA support code. + +2001-07-09 Motoyuki Kasahara + + * eb/filename.c (eb_find_file_name, eb_find_file_name2, + eb_find_file_name3): Change API of the internal functions. + * eb/filename.c (eb_path_name_zio_code): New function. + + * eb/appendix.c (EB_HINT_INDEX_CATALOG, EB_HINT_INDEX_CATALOGS, + catalog_hint_list): Deleted. + * eb/appsub.c (EB_HINT_INDEX_APPENDIX, EB_HINT_INDEX_APPENDIX_EBZ, + appendix_hint_list, EB_HINT_INDEX_FUROKU, EB_HINT_INDEX_FUROKU_EBZ, + furoku_hint_list): Deleted. + * eb/book.c (EB_HINT_INDEX_CATALOG, EB_HINT_INDEX_CATALOGS, + catalog_hint_list, EB_HINT_INDEX_LANGUAGE, EB_HINT_INDEX_LANGUAGE_EBZ, + language_hint_list): Deleted. + * eb/subbook.c (EB_HINT_INDEX_START, EB_HINT_INDEX_START_EBZ, + start_hint_list): Deleted. + * eb/subbook.c (EB_HINT_INDEX_HONMON_EBZ, EB_HINT_INDEX_HONMON2, + EB_HINT_INDEX_HONMON2_EBZ, EB_HINT_INDEX_HONMON2_ORG, + honmon_hint_list, EB_HINT_INDEX_HONMONG, EB_HINT_INDEX_HONMONG_EBZ, + EB_HINT_INDEX_HONMONG_ORG, honmong_hint_list, EB_HINT_INDEX_HONMONS, + EB_HINT_INDEX_HONMONS_EBZ, EB_HINT_INDEX_HONMONS_ORG, + honmons_hint_list): Deleted. + + * ebrefile/ebrefile.c (HINT_INDEX_CATALOG, HINT_INDEX_CATALOGS, + catalog_hint_list): Deleted. + + * ebzip/unzipbook.c (catalog_hint_list, language_hint_list, + catalogs_hint_list): Deleted. + * ebzip/zipbook.c (catalog_hint_list, language_hint_list, + catalogs_hint_list): Deleted. + * ebzip/zipinfobook.c (catalog_hint_list, language_hint_list, + catalogs_hint_list): Deleted. + +2001-06-25 Motoyuki Kasahara + + * Version 3.0.1. + + * configure.ac (LIBEB_VERSION_INFO): Set version to 4:1:0. + +2001-06-22 Motoyuki Kasahara + + * configure.ac (AM_INIT_AUTOMAKE): Set version to 3.0.1. + + * eb/text.c (eb_read_text_internal): Fix a bug of handling BG 2312 + character. + * eb/text.c (eb_read_text_internal): Add code to process escape + sequence 0x1f53. + +2001-06-12 Motoyuki Kasahara + + * eb/book.c (eb_initialize_language): Don't return a value, since + this is `void' function. + + * ebrefile/ebrefile.c: Don't include . + * ebrefile/ebrefile.c: Fix definition of `_' and `N_' macros. + +2001-06-11 Motoyuki Kasahara + + * libebutils/memset.c: Internally convert the 2nd argument (copy + value) to unsigned char, as ISO/IEC 9899:1990 says. diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..2e1837d --- /dev/null +++ b/INSTALL @@ -0,0 +1,203 @@ +$BI,MW$J%=%U%H%&%'%"(B +================== + +$BK\%=%U%H%&%'%"$r%$%s%9%H!<%k$9$k$K$O!"A0$b$C$F(B zlib $B$r%$%s%9%H!<%k$7$F(B +$B$*$/I,MW$,$"$j$^$9!#(Bzlib $B$Ol=j$+$iF~l9g$b$"$j$^(B +$B$9!#(B + + +$B4pK\E*$J%$%s%9%H!<%kJ}K!(B +======================== + +$BK\%=%U%H%&%'%"$N:G$bC1=c$J%3%s%Q%$%kJ}K!$O/!9;~4V$,(B + $B$+$+$j$^$9!#(B + + $Bl9g$O!"(B + `make check' $B$rC$9$3$H$,$G$-$^$9!#(B $B0l=o$K(B `configure' $B$,@8@.$7$?%U%!%$%k$b>C$9(B + $B$K$O(B ($B$3$&$9$k$3$H$G!"JL$N(B +============== + + $B%G%U%)%k%H$G$O!"(B`make install' $B$r$l0[$J$C(B +$B$?%$%s%9%H!<%k@h$K%$%s%9%H!<%k$9$k$3$H$b2DG=$G$9!#(B `configure' $B$KBP$7(B +$B$F(B `--exec-prefix=$B%Q%9(B' $B$r;XDj$9$k$H!"%W%m%0%i%`$d%i%$%V%i%j$J$I$N%$%s(B +$B%9%H!<%k@h$,!V%Q%9!W$KJQ$o$j$^$9!#%I%-%e%a%s%H$d!"%G!<%?%U%!%$%k$J$I$O!"(B +$BDL>o$N%$%s%9%H!<%k@h$K%$%s%9%H!<%k$5$l$^$9!#(B + + $B2C$($F!"$"$J$?$,DL>o$H$O0[$J$C$?%G%#%l%/%H%j%l%$%"%&%H$r:NMQ$7$F$$$k(B +$B>l9g$O!"(B`--bindir=$B%Q%9(B' $B$H$$$C$?%*%W%7%g%s$r;XDj$9$k$3$H$G!"FCDj$N$K@\F,<-$d@\Hx<-$rIU2C$9$k$3$H$,$G$-$^$9!#(B + +`configure' $B$NF0:n$N@)8f(B +======================== + + `configure' $B$Oo(B + `./config.cache' $B$G$9$,!"Be$o$j$K!V%U%!%$%k!W$rMQ$$$^$9!#(B + `configure' $B$r%G%P%C%0$9$k$H$-$O!"%U%!%$%k(B $B$K(B `/dev/null' $B$r;XDj(B + $B$9$k$3$H$G!"%-%c%C%7%e$rM^@)$9$k$3$H$,$G$-$^$9!#(B + +`--help' + `configure' $B$N%*%W%7%g%s$N0lMw$rI=<($7$F!"=*N;$7$^$9!#(B + +`--quiet' +`--silent' +`-q' + $B$I$N%A%'%C%/9`L\$r9T$C$F$$$k$N$+$r<($9%a%C%;!<%8$r=PNO$7$^$;$s!#(B + $BDL>o$N%a%C%;!<%8=PNO$r$9$Y$FM^@)$9$k$K$O!"(B`/dev/null' $B$X%j%@%$%l(B + $B%/%H$7$F2<$5$$(B ($B$?$@$7!"%(%i!<%a%C%;!<%8$K$D$$$F$O=PNO$5$l$F$7$^(B + $B$$$^$9$,(B)$B!#(B + +`--srcdir=$B%G%#%l%/%H%j(B' + $B%=%U%H%&%'%"$N%=!<%9%3!<%I$rC5$7=P$9:]$K!"!V%G%#%l%/%H%j!W$rC5$7$^(B + $B$9!#DL>o!"(B`configure' $B$O<+F0E*$K%G%#%l%/%H%j$r7hDj$7$^$9!#(B + +`--version' + `configure' $B%9%/%j%W%H$,$I$N%P!<%8%g%s$N(B Autoconf $B$K$h$C$F@8@.$5(B + $B$l$?$N$+$rI=<($7!"=*N;$7$^$9!#(B + +$BLr$KN)$D>lLL$O8B$i$l$^$9$,!"(B`configure' $B$K$OB>$K$b$$$/$D$+$N%*%W%7%g%s(B +$B$,MQ0U$5$l$F$$$^$9!#(B + +$BA*Br2DG=$J5!G=$N0lMw(B +==================== + + $BK\%=%U%H%&%'%"$N(B `configure' $B$O0J2<$K5-$7$?(B `--enable-' $B$*$h$S(B +`--with-' $B%*%W%7%g%s$rG'<1$7$^$9!#(B + +`--enable-ebnet' + $B1s3V%"%/%;%9BP1~$rM-8z$K$7$^$9!#L5;XDj;~$O(B `yes' $B$G$9!#(B + +`--enable-ipv6' + $B1s3V%"%/%;%9$G$N(B IPv6 $BBP1~$rM-8z$K$7$^$9!#(BIPv6 $B$KBP1~$7$?%7%9%F%`(B + $B$G$O!"L5;XDj;~$O(B `yes' $B$,;XDj$5$l$?$b$N$H$_$J$5$l$^$9!#(B`yes' $B$r;X(B + $BDj$7$?$K$b$+$+$o$i$:!"(B`configure' $B$,(B IPv6 $B$r;H$C$?%5%s%W%k%W%m%0%i(B + $B%`$N%3%s%Q%$%k$K<:GT$9$k$H!"%(%i!<$,Js9p$5$l$^$9!#(B`--enable-ebnet= + no' $B$r;XDj$7$?>l9g!"$3$N%*%W%7%g%s$OL5;k$5$l$^$9!#(B + +`--enable-pthread' + $B%3%s%Q%$%k$5$l$?(B EB $B%i%$%V%i%j$K(B pthread $BBP1~%3!<%I$,IU2C$5$^$9!#(B + $BL5;XDj;~$O(B `no' $B$G$9!#(B`yes' $B$r;XDj$7$?$K$b$+$+$o$i$:!"(B`configure' + $B$,(B pthread $B$r;H$C$?%5%s%W%k%W%m%0%i%`$N%3%s%Q%$%k$dH$7$^$9!#(B + +`--with-zlib-libraries=DIR' + DIR $B%G%#%l%/%H%j$K%$%s%9%H!<%k$5$l$F$$$k(B zlib $B$N%i%$%V%i%j%U%!%$(B + $B%k$r;2>H$7$^$9!#(B + +`--enable-nls' + $B%a%C%;!<%8$N9q:]2=5!G=(B ($B@53N$K$O(B NLS $B$O(B Native/National Language + Support)$B!#(BEB $B%i%$%V%i%j$*$h$S%f!<%F%#%j%F%#$O!"%a%C%;!<%8$N9q:]2=(B + $B5!G=$,M-8z$K$J$k$h$&$K%3%s%Q%$%k$5$l$^$9!#(B + + $B$3$N5!G=$r;H$&$K$O(B GNU gettext $B$,I,MW$G$9!#%7%9%F%`$K(B GNU gettext + $B$,$J$1$l$P!"$3$N%=%U%H%&%'%"$r%$%s%9%H!<%k$9$kA0$K(B GNU gettext $B$r%$(B + $B%s%9%H!<%k$7$F2<$5$$!#K\%=%U%H%&%'%"$O!"$?$H$($P(B Solaris $B$NH$7$^$9!#%a%C%;!<%8$N9q:]2=5!G=$,L58z$K$J$C$F$$$k>l9g!"$3$N(B + $B%*%W%7%g%s$O0UL#$r;}$A$^$;$s!#(B + +`--with-gettext-libraries=DIR' + DIR $B%G%#%l%/%H%j$K%$%s%9%H!<%k$5$l$F$$$k(B gettext $B$N%i%$%V%i%j%U%!(B + $B%$%k$r;2>H$7$^$9!#%a%C%;!<%8$N9q:]2=5!G=$,L58z$K$J$C$F$$$k>l9g!"(B + $B$3$N%*%W%7%g%s$O0UL#$r;}$A$^$;$s!#(B + +`--with-iconv-includes=DIR' + DIR $B%G%#%l%/%H%j$K%$%s%9%H!<%k$5$l$F$$$k(B iconv $B$N%X%C%@%U%!%$%k(B + $B$r;2>H$7$^$9!#%a%C%;!<%8$N9q:]2=5!G=$,L58z$K$J$C$F$$$k>l9g!"$"$k(B + $B$$$O%7%9%F%`>e$N(B gettext() $B4X?t$,(B iconv() $B$r;HMQ$7$J$$>l9g!"$3$N(B + $B%*%W%7%g%s$O0UL#$r;}$A$^$;$s!#(B + +`--with-iconv-libraries=DIR' + DIR $B%G%#%l%/%H%j$K%$%s%9%H!<%k$5$l$F$$$k(B iconv $B$N%i%$%V%i%j%U%!(B + $B%$%k$r;2>H$7$^$9!#%a%C%;!<%8$N9q:]2=5!G=$,L58z$K$J$C$F$$$k>l9g!"(B + $B$"$k$$$O%7%9%F%`>e$N(B gettext() $B4X?t$,(B iconv() $B$r;HMQ$7$J$$>l9g!"(B + $B$3$N%*%W%7%g%s$O0UL#$r;}$A$^$;$s!#(B + +`--enable-shared' + $B6&M-%i%$%V%i%jHG$N(B EB $B%i%$%V%i%j$r:n@.$7$^$9!#L5;XDj;~$O(B `yes' $B$G(B + $B$9!#(B + +`--enable-static' + $B@EE*%i%$%V%i%jHG$N(B EB $B%i%$%V%i%j$r:n@.$7$^$9!#L5;XDj;~$O(B `yes' $B$G(B + $B$9!#(B + +`--with-gnu-ld' + C $B%3%s%Q%$%i$,(B GNU ld $B$r;HMQ$7$F$$$k$H2>Dj$7$^$9!#(B + $BL5;XDj;~$O!"(B`no' $B$G$9!#(B + +`--disable-libtool-lock' + $B%m%C%/$7$J$$$h$&$K$7$^$9!#(B($BJBNs%3%s%Q%$%k$O!"@5$7$/9T$o$l$J$$2DG=(B + $B@-$,$"$j$^$9!#(B) + +`--enable-samples' + $B%5%s%W%k%W%m%0%i%`$b%3%s%Q%$%k$9$k$h$&$K$7$^$9!#L5;XDj;~$O(B `no' $B$G(B + $B$9!#%3%s%Q%$%k$7$F$b!"%5%s%W%k%W%m%0%i%`$O2?=h$K$b%$%s%9%H!<%k$5$l(B + $B$^$;$s!#(B + +`--enable-largefile' + 2GB $B$rD6$($k!"Bg$-$J%U%!%$%k$r07$($k$h$&$K$7$^$9!#%7%9%F%`B&$GBP1~(B + $B$7$F$$$J$$$H!";XDj$7$F$b8z2L$O$"$j$^$;$s!#L5;XDj;~$O(B `yes' $B$G$9!#(B diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..9ae991e --- /dev/null +++ b/Makefile.am @@ -0,0 +1,41 @@ +ACLOCAL_AMFLAGS = -I m4 + +if ENABLE_SAMPLES +SAMPLES_SUBDIR = samples +else +SAMPLES_SUBDIR = +endif + +SUBDIRS = eb libebutils ebappendix ebfont ebinfo ebrefile ebstopcode ebzip \ + doc po-eb po-ebutils m4 $(SAMPLES_SUBDIR) + +EXTRA_DIST = ChangeLog.0 ChangeLog.1 ChangeLog.2 move-if-change \ + eb.conf.in misc/ebfixlog misc/ebdump +CLEANFILES = eb.conf + +appendixdir = $(pkgdatadir)/appendix +appendix_DATA = +sysconf_DATA = eb.conf + +eb.conf: eb.conf.in Makefile + rm -f $@ + sed -e 's;\@VERSION\@;$(VERSION);' \ + -e 's;\@EBCONF_EBINCS\@;$(EBCONF_EBINCS);' \ + -e 's;\@EBCONF_EBLIBS\@;$(EBCONF_EBLIBS);' \ + -e 's;\@EBCONF_ZLIBINCS\@;$(EBCONF_ZLIBINCS);' \ + -e 's;\@EBCONF_ZLIBLIBS\@;$(EBCONF_ZLIBLIBS);' \ + -e 's;\@ENABLE_PTHREAD\@;$(ENABLE_PTHREAD);' \ + -e 's;\@PTHREAD_CPPFLAGS\@;$(PTHREAD_CPPFLAGS);' \ + -e 's;\@PTHREAD_CFLAGS\@;$(PTHREAD_CFLAGS);' \ + -e 's;\@PTHREAD_LDFLAGS\@;$(PTHREAD_LDFLAGS);' \ + -e 's;\@ENABLE_NLS\@;$(ENABLE_NLS);' \ + -e 's;\@EBCONF_INTLINCS\@;$(EBCONF_INTLINCS);' \ + -e 's;\@EBCONF_INTLLIBS\@;$(EBCONF_INTLLIBS);' \ + -e 's;\@ENABLE_EBNET\@;$(ENABLE_EBNET);' \ + $(srcdir)/$@.in > $@.tmp + cp $@.tmp $@ + chmod 644 $@ + rm -f $@.tmp + +gttest.mo: gttest.po + $(MSGFMT) -o gttest.mo gttest.po diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..84bbe32 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,761 @@ +# Makefile.in generated by automake 1.10.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = . +DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/config.h.in \ + $(top_srcdir)/configure $(top_srcdir)/po-eb/Makefile.in \ + $(top_srcdir)/po-ebutils/Makefile.in AUTHORS COPYING ChangeLog \ + INSTALL NEWS compile config.guess config.sub depcomp \ + install-sh ltmain.sh missing +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/in6addr.m4 $(top_srcdir)/m4/largefile.m4 \ + $(top_srcdir)/m4/lcmessage.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/sockaddrin6.m4 \ + $(top_srcdir)/m4/sockinttypes.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = po-eb/Makefile po-ebutils/Makefile +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(appendixdir)" "$(DESTDIR)$(sysconfdir)" +appendixDATA_INSTALL = $(INSTALL_DATA) +sysconfDATA_INSTALL = $(INSTALL_DATA) +DATA = $(appendix_DATA) $(sysconf_DATA) +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = eb libebutils ebappendix ebfont ebinfo ebrefile \ + ebstopcode ebzip doc po-eb po-ebutils m4 samples +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +EBCONF_EBINCS = @EBCONF_EBINCS@ +EBCONF_EBLIBS = @EBCONF_EBLIBS@ +EBCONF_INTLINCS = @EBCONF_INTLINCS@ +EBCONF_INTLLIBS = @EBCONF_INTLLIBS@ +EBCONF_ZLIBINCS = @EBCONF_ZLIBINCS@ +EBCONF_ZLIBLIBS = @EBCONF_ZLIBLIBS@ +EB_VERSION_MAJOR = @EB_VERSION_MAJOR@ +EB_VERSION_MINOR = @EB_VERSION_MINOR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_EBNET = @ENABLE_EBNET@ +ENABLE_NLS = @ENABLE_NLS@ +ENABLE_PTHREAD = @ENABLE_PTHREAD@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +ICONVINCS = @ICONVINCS@ +ICONVLIBS = @ICONVLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLINCS = @INTLINCS@ +INTLLIBS = @INTLLIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBEB_VERSION_INFO = @LIBEB_VERSION_INFO@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAILING_ADDRESS = @MAILING_ADDRESS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_CPPFLAGS = @PTHREAD_CPPFLAGS@ +PTHREAD_LDFLAGS = @PTHREAD_LDFLAGS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +ZLIBDEPS = @ZLIBDEPS@ +ZLIBINCS = @ZLIBINCS@ +ZLIBLIBS = @ZLIBLIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgdocdir = @pkgdocdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +ACLOCAL_AMFLAGS = -I m4 +@ENABLE_SAMPLES_FALSE@SAMPLES_SUBDIR = +@ENABLE_SAMPLES_TRUE@SAMPLES_SUBDIR = samples +SUBDIRS = eb libebutils ebappendix ebfont ebinfo ebrefile ebstopcode ebzip \ + doc po-eb po-ebutils m4 $(SAMPLES_SUBDIR) + +EXTRA_DIST = ChangeLog.0 ChangeLog.1 ChangeLog.2 move-if-change \ + eb.conf.in misc/ebfixlog misc/ebdump + +CLEANFILES = eb.conf +appendixdir = $(pkgdatadir)/appendix +appendix_DATA = +sysconf_DATA = eb.conf +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +am--refresh: + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \ + cd $(srcdir) && $(AUTOMAKE) --gnu \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) + +config.h: stamp-h1 + @if test ! -f $@; then \ + rm -f stamp-h1; \ + $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ + else :; fi + +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status config.h +$(srcdir)/config.h.in: $(am__configure_deps) + cd $(top_srcdir) && $(AUTOHEADER) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +po-eb/Makefile: $(top_builddir)/config.status $(top_srcdir)/po-eb/Makefile.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +po-ebutils/Makefile: $(top_builddir)/config.status $(top_srcdir)/po-ebutils/Makefile.in + cd $(top_builddir) && $(SHELL) ./config.status $@ + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool config.lt +install-appendixDATA: $(appendix_DATA) + @$(NORMAL_INSTALL) + test -z "$(appendixdir)" || $(MKDIR_P) "$(DESTDIR)$(appendixdir)" + @list='$(appendix_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(appendixDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(appendixdir)/$$f'"; \ + $(appendixDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(appendixdir)/$$f"; \ + done + +uninstall-appendixDATA: + @$(NORMAL_UNINSTALL) + @list='$(appendix_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(appendixdir)/$$f'"; \ + rm -f "$(DESTDIR)$(appendixdir)/$$f"; \ + done +install-sysconfDATA: $(sysconf_DATA) + @$(NORMAL_INSTALL) + test -z "$(sysconfdir)" || $(MKDIR_P) "$(DESTDIR)$(sysconfdir)" + @list='$(sysconf_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(sysconfDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(sysconfdir)/$$f'"; \ + $(sysconfDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(sysconfdir)/$$f"; \ + done + +uninstall-sysconfDATA: + @$(NORMAL_UNINSTALL) + @list='$(sysconf_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(sysconfdir)/$$f'"; \ + rm -f "$(DESTDIR)$(sysconfdir)/$$f"; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(am__remove_distdir) + test -d $(distdir) || mkdir $(distdir) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + distdir) \ + || exit 1; \ + fi; \ + done + -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r $(distdir) +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-lzma: distdir + tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.lzma*) \ + unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && cd $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck + $(am__remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' +distuninstallcheck: + @cd $(distuninstallcheck_dir) \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-recursive +all-am: Makefile $(DATA) config.h +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(appendixdir)" "$(DESTDIR)$(sysconfdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-hdr \ + distclean-libtool distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: install-appendixDATA + +install-dvi: install-dvi-recursive + +install-exec-am: install-sysconfDATA + +install-html: install-html-recursive + +install-info: install-info-recursive + +install-man: + +install-pdf: install-pdf-recursive + +install-ps: install-ps-recursive + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-appendixDATA uninstall-sysconfDATA + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ + install-strip + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am am--refresh check check-am clean clean-generic \ + clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \ + dist-gzip dist-lzma dist-shar dist-tarZ dist-zip distcheck \ + distclean distclean-generic distclean-hdr distclean-libtool \ + distclean-tags distcleancheck distdir distuninstallcheck dvi \ + dvi-am html html-am info info-am install install-am \ + install-appendixDATA install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip install-sysconfDATA installcheck installcheck-am \ + installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am uninstall-appendixDATA \ + uninstall-sysconfDATA + + +eb.conf: eb.conf.in Makefile + rm -f $@ + sed -e 's;\@VERSION\@;$(VERSION);' \ + -e 's;\@EBCONF_EBINCS\@;$(EBCONF_EBINCS);' \ + -e 's;\@EBCONF_EBLIBS\@;$(EBCONF_EBLIBS);' \ + -e 's;\@EBCONF_ZLIBINCS\@;$(EBCONF_ZLIBINCS);' \ + -e 's;\@EBCONF_ZLIBLIBS\@;$(EBCONF_ZLIBLIBS);' \ + -e 's;\@ENABLE_PTHREAD\@;$(ENABLE_PTHREAD);' \ + -e 's;\@PTHREAD_CPPFLAGS\@;$(PTHREAD_CPPFLAGS);' \ + -e 's;\@PTHREAD_CFLAGS\@;$(PTHREAD_CFLAGS);' \ + -e 's;\@PTHREAD_LDFLAGS\@;$(PTHREAD_LDFLAGS);' \ + -e 's;\@ENABLE_NLS\@;$(ENABLE_NLS);' \ + -e 's;\@EBCONF_INTLINCS\@;$(EBCONF_INTLINCS);' \ + -e 's;\@EBCONF_INTLLIBS\@;$(EBCONF_INTLLIBS);' \ + -e 's;\@ENABLE_EBNET\@;$(ENABLE_EBNET);' \ + $(srcdir)/$@.in > $@.tmp + cp $@.tmp $@ + chmod 644 $@ + rm -f $@.tmp + +gttest.mo: gttest.po + $(MSGFMT) -o gttest.mo gttest.po +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..b2df1b6 --- /dev/null +++ b/NEWS @@ -0,0 +1,535 @@ +若吾с 4.4.3 筝祉紊雁: + +* 若吾с4.4.2с掩ゃ若吾с潟罩cc + 若吾с潟т信罩c +* 膣違筝桁篆罩c + +若吾с 4.4.2 筝祉紊雁: + +* 括<ャ若≪с筝篆罩c +* ebzip 篌檎傑罩e幻腟篋腟篋潟若1c障筝桁篆罩 + +* ebzip 鴻≪若<ゃ潟若絎茵障筝桁 + 篆罩c +* ebzip <≪上眼 + +若吾с 4.4.1 筝祉紊雁: + +* 糸喝0若帥宴若帥主<ゃ紊с + 2GB 罩c宴cт信罩c + +若吾с 4.4 筝祉紊雁: + +* 2GB 莇紊с<ゃ宴激鴻眼 + 絲上>散 +* EBZIP綵√х軒<ゃс42949672961099511627775ゃ (4GB1TB) + <ゃ茵憝号荀鎘ebzip, ebunzip 荀鎘羃帥cх軒 + 割叱綣泣茵 +* ebzip, ebunzip c篏紊掩篏若<祉若 + 冴腟篋筝桁篆罩c + +若吾с 4.3.4 筝祉紊雁: + +* 医cebinfo 阪蕁絖篆罩c +* 羈: ゃ篏紊眼с掩ゃ若吾с潟贋 + + +若吾с 4.3.3 筝祉紊雁: + +* Cygwin, MinGW DLL 篏с +* Windows ebzipinfo 医幻腟篋筝桁篆罩c + +若吾с 4.3.2 筝祉紊雁: + +* 若吾с 4.3.1 с掩ゃ垬cт信罩c +* ebinfo ユ茯<祉若吾腥榊醇絖cт信罩c + +若吾с 4.3.1 筝祉紊雁: + +* 祉<ゃ怨ぇ絖篏帥祉若帥茯粋昭筝桁 + 篆罩c +* 糸若 Panasonic KX-EBP2 篁絮絲上 +* ebnet с<若若潟莎激筝桁篆罩c + +若吾с 4.3 筝祉紊雁: + +* EPWING ц違c掩翫罩c≪祉 + с筝桁篆罩c +* `ebunzip --test' 糸<ゃ筝吾障筝桁 + 篆罩c +* ebappendix `catalogs.app' 茯粋昭с糸綵√ appendix + 障筝桁篆罩c +* у篁弱括絲上 + API eb_have_image_menu() eb_image_menu() 菴遵 + 鴻EB_HOOK_BEGIN_IMAGE_PAGE, EB_HOOK_END_IMAGE_PAGE, + EB_HOOK_BEGIN_CLICKABLE_AREA, EB_HOOK_END_CLICKABLE_AREA 4ゃ菴遵 + + +若吾с 4.2.2 筝祉紊雁: + +* 4.2.1 ф祁ャ筝 EPWING 罩c宴筝桁篆罩c +* eb.conf EBCONF_ENABLE_NLS ゃ罩c祉筝桁篆罩 + +* 喝0<ゃ冴障筝桁腟紮 +* 筝 Linux 医 configure NLS (Native/National Language + Support) 鴻筝桁篆罩c +* 膣違筝桁ゃ篆罩c + +若吾с 4.2.1 筝祉紊雁: + +* 筝桁ゃ篆罩c + +若吾с 4.2 筝祉紊雁: + +* 号膣≪絲上 + ∽ eb_have_cross_search(), eb_search_cross() ゃ菴遵 + 障ebinfo 号膣≪宴阪c +* 祉<ゃ腟九障劫菴∽ eb_compose_movie_path_name() + ゃ菴遵 +* ebrefile 帥違<ゃ筝吾 + 筝吾帥違<ゃ".old" ・絨上篁<ゃ + 篆絖 +* zlib 羞私 + configure --with-included-zlib 激с潟ゃ +* 筝桁ゃ篆罩c + +若吾с 4.1.3 筝祉紊雁: + +* 若吾с 4.1.2 с掩ゃ垬cт信罩c +* `make install' 紊掩筝桁篆罩c + +若吾с 4.1.2 筝祉紊雁: + +* 劫悟сEB ゃ悟莠c茯罎膣≪с + 筝桁篆罩c +* FreeBSD-5.3-RELEASE make 紊掩筝桁篆罩c +* Windows 医ebzip 潟潟莎桁潟潟 (ebunzip.exe, + ebzipinfo.exe ) 罩c篏羆阪с筝桁篆罩 + + +若吾с 4.1.1 筝祉紊雁: + +* 若cc潟潟с綣違激激с (箴: ebzip + --level) 絲障綣違羝<潟潟医幻腟篋筝桁 + 篆罩c +* eb_write_text_byte2() 若帥吾莨若筝桁篆罩c +* ャ<潟 HTML <ゃ鴻帥ゃ紊眼 + +若吾с 4.1 筝祉紊雁: + +* BSD ゃ祉潟鴻。 +* ebfont PNG 綵√糸<ゃс + ebfont --image-format 激с潟 `png' 絎с +* ゃ eb_narrow_font_png_size(), eb_wide_font_png_size(), + eb_bitmap_to_png() +* eb_bitmap_to_xbm(), eb_bitmap_to_xpm(), eb_bitmap_to_gif(), + eb_bitmap_to_bmp() EB_Error_Code 菴 +* ゃх軒若帥c激ャ合茵 + +* `ebzip' START/HONMON <ゃх軒絲上 + 剛贋膣≪c +* ユ茯ャ<潟 HTML 綵√ч絽 +* 沿ャ<潟ゃ + +若吾с 4.0.1 筝祉紊雁: + +* <ゃ EB_P, ZIO_P 絎臂篆罩c +* `ebzipinfo' `--skip-content movie' 激с潟絎 + 祉<ゃ宴茵腓冴 +* `ebzip', `ebunzip' 画倶<祉若吾罔羣阪с閞羣 + 阪茵腓冴 + +若吾с 4.0 筝祉紊雁: + +* EB_BookList ∫c API 壕 +* EB_ERR_UNBOUND_BOOKLIST, EB_ERR_NO_SUCH_BOOK 2 ゃ + 潟若菴遵 +* `eb3.m4' `eb4.m4' 劫 +* `configure' `--enable-ebnet' 激с潟菴遵 +* `eb/flags.h' ゃ潟鴻若 + <ゃ`eb/defs.h' include +* 紊с活蚕綺筝桁ゃ篆罩c + +若吾с 4.0beta3 筝祉紊雁: + +* EUC-JP 篁ュユ茯潟潟若c潟違絲上 +* Windows 絲上潟若ゃ篁 + Windows 筝 EB ゃ茵`eb-win32' 宴若 + 篏睡筝 +* `ebstopcode' `--text-position' (`-p') 激с潟菴遵 + +若吾с 4.0beta2 筝祉紊雁: + +* 罎膣≪<純紊с筝桁篆罩c + +若吾с 4.0beta1 筝祉紊雁: + +* `ebstopchk' `ebstopcode' 劫 + 潟潟 `--stop-code' 激с潟 `--code' 劫 +* `ebappendix' `--case', `--suffix' 激с潟ゃ +* `ebappendix' ユ茯ャ<潟 +* `ebinfo' `--book-list' 激с潟菴遵 +* `ebdump', `ebfixlog' `misc' 泣cャ +* 筝桁ゃ篆罩c + +若吾с 4.0beta0 筝祉紊雁: + +* ≪祉鴻絲上 +* `ebstopchk' 潟潟菴遵 + +若吾с 3.3.2 筝祉紊雁: + +* 掩ゃ若吾с括垩篆罩c +* ヨ延颴吾(YRRS-059) 絲上 + +若吾с 3.3.1 筝祉紊雁: + +* EPWING 吾若≪壕怨紊ц吾絲上 +* 茲罎膣≪筝桁篆罩c +* 違≪若筝桁篆罩c + +若吾с 3.3 筝祉紊雁: + +* eb_read_binary_mpeg() 筝桁篆罩c + +若吾с 3.3beta3 筝祉紊雁: + +* 茲罎膣≪篆罩c +* 荵遵墾筝桁ゃ篆罩c + +若吾с 3.3beta2 筝祉紊雁: + +* 紊с活蚕綺筝桁ゃ篆罩c +* `eb3.m4' `$(datadir)/aclocal' ゃ潟鴻若 + +若吾с 3.3beta1 筝祉紊雁: + +* 筝桁ゃ篆罩c + +若吾с 3.3beta0 筝祉紊雁: + +* EPWING <ゃх軒帥ゃ荀潟若紊у吾鴻 +* ∽ eb_multi_title() 菴遵 + ∽違劫茲罎膣≪蕁緇∽違篏睡c + `ebinfo' 潟潟 `--multi-search' (`-m') 絎茲罎膣 + 蕁茵腓冴c +* `ebrefile' 筝桁篆罩c +* ゃ潟ゃ括糸絲上鴻若帥吾 2 腮蕁菴遵 + + +若吾с 3.2.3 筝祉紊雁: + +* PCM 喝0若帥筝桁篆罩c +* 鴻 2 腮蕁菴遵 + +若吾с 3.2.2 筝祉紊雁: + +* appendix 筝桁篆罩c +* gettext <祉若吾帥違篆罩c + +若吾с 3.2.1 筝祉紊雁: + +* 鴻茯粋昭帥若潟篆罩c +* zlib-1.1.4 莨若 + +若吾с 3.2 筝祉紊雁: + +* 鴻 + +若吾с 3.2beta3 筝祉紊雁: + +* ゃ潟鴻若莎激筝桁ゃ篆罩c + +若吾с 3.2beta2 筝祉紊雁: + +* 医紊 EB_DEBUG 絎臂EB ゃ + <祉若吾阪 + `configure' `--enable-debug' 激с潟ゃ +* EBZIP х軒綵√若帥篌檎激翫順筝桁篆罩c + +若吾с 3.2beta1 筝祉紊雁: + +* `ebzip' 蕭х軒 3 5 紊眼 +* 筝桁ゃ篆罩c + +若吾с 3.2beta0 筝祉紊雁: + +* eb_backward_text() 絎茖eb_forward_text() 壕 +* EB ゃ違潟違ャ<潟 (ユ茯) 緇羇祉 +* 泣潟違緇羇祉 + +若吾с 3.1 筝祉紊雁: + +* х軒 S-EBXA 吾泣若筝桁篆罩c + +若吾с 3.1beta1 筝祉紊雁: + +* 違潟若篁 + 潟若 `configure --enable-debug' 鴻 +* eb_initialize_all_subbooks() eb_load_all_subbooks() 劫 + eb_initialize_all_appendix_subbooks() eb_load_all_appendix_subbooks() + 劫 + 緇剛с障с CPP 絎臂 + +* "DUDEN" (EBG) 吾絲上緇羇祉 +* 若c潟 CD-ROM 筝桁 + 篆罩c +* EB ゃ喝紮若潟若若若 + 茵c +* 荵遵墾筝桁ゃ篆罩c + +若吾с 3.1beta0 筝祉紊雁: + +* х軒 S-EBXA 絲上 +* 純若若帥c鴻 DP-S1000 篁絮ユ紊х丞吾絲上 + +若吾с 3.0.1 筝祉紊雁: + +* 筝桁ゃ篆罩c + +若吾с 3.0 筝祉紊雁: + +* EB LANGUAGE 若帥吾絲上 + +若吾с 3.0beta1 筝祉紊雁: + +* `ebrefile' C ф吾眼 + ユ茯<祉若吾帥違 +* 筝桁ゃ篆罩c + +若吾с 3.0beta0 筝祉紊雁: + +* GNU gettext 0.10.36 libintl 絲上 + 宴若吾若cc若臂ゃlibiconv 純 + 潟c + `configure' `--with-iconv-includes', `--with-iconv-libraries' + 激с潟菴遵 +* libintl 純若鴻潟若ゃ + `configure' `--with-included-gettext' 激с潟ゃ + libintl 激鴻違NLS (Native/National Language Support) + ≦鴻 +* EPWING EB ≪糸若帥絲上 +* `ebzip' 祉糸喝0若帥<ゃ絲上c + `ebzip' `--skip-content' (`-s') 激с潟菴遵 +* 荵遵墾筝桁篆罩c + +若吾с 3.0alpha4 筝祉紊雁: + +* EPWING 祉若帥主糸若帥絲上 +* EB ゃ≪宴若激с喝M4 <ゃ + `eb3.m4' (Autoconf 2.49 綽荀) + +若吾с 3.0alpha3 筝祉紊雁: + +* 鴻∫c API 鴻 + +若吾с 3.0alpha2 筝祉紊雁: + +* 筝桁篆罩c + +若吾с 3.0alpha1 筝祉紊雁: + +* EPWING V6 х軒綵√絲上 +* <ゃc紊ф絖/絨絖・絨上筝莢 + 罨絋∴ +* `ebzip' `--suffix', `--case' 激с潟ゃ +* 潟∫c API ュ慌紊眼 +* 荵遵墾筝桁蚊篆罩c + +若吾с 3.0alpha0 筝祉紊雁: + +* 茲罎膣≪絲上 +* >散罎膣≪絲上 +* GNU gettext NLS (Native/National Language Support) + ユ茯<祉若吾帥違 +* 絎薑 Pthread 絲上 + `configure' `--enable-pthreads' 激с潟菴遵 +* `configure' zlib 荀ゃ冴 +* API 紊眼 + 若吾с 2.x API 篋鴻ゃ +* 荵遵墾筝桁篆罩c + +若吾с 2.3.7 筝祉紊雁: + +* "DUDEN Die sinn-und sachverwandten Worter" (EBG) "DUDEN Das + Fremdworterbuch" 絲上 + +若吾с 2.3.6 筝祉紊雁: + +* ユ茯茯綵紊х鎧 (EPWING, 絏羈∽後) ч筝桁篆罩c +* "EDICT" (JIS X 4081, 若莨) ч筝桁篆罩c + +若吾с 2.3.5 筝祉紊雁: + +* 鴻 + +若吾с 2.3.4 筝祉紊雁: + +* EPWING 篌檎激若潟筝桁篆罩c +* 荵遵墾筝桁ゃ篆罩c + +若吾с 2.3.3 筝祉紊雁: + +* 掩ゃ若吾с括垩篆罩c + +若吾с 2.3.2 筝祉紊雁: + +* 荵遵墾筝桁篆罩c + +(若吾с 2.3.1 若鴻) + +若吾с 2.3 筝祉紊雁: + +* 鴻 + +若吾с 2.3beta3 筝祉紊雁: + +* 鴻 + +若吾с 2.3beta2 筝祉紊雁: + +* 鴻 + +若吾с 2.3beta1 筝祉紊雁: + +* 絎薑 EBXA-C 絲上 +* 絎薑阪絖 (stop-code) 罎冴絲上 + +若吾с 2.3beta0 筝祉紊雁: + +* EPWING х軒綵√ух軒 CD-ROM 悟絲上 +* `ebzip' 演ャ<祉若吾紊眼 +* `ebrefile' 筝桁篆罩c + `ebrefile' `ebzip' 綺с帥違<ゃ「茵c + c + +若吾с 2.2.1 筝祉紊雁: + +* samples samples-ja 腟怨 +* `configure' `--enable-samples' 激с潟菴遵 +* DOS, Windows, OS/2 吾絲上劫 + +若吾с 2.2 筝祉紊雁: + +* EB ゃャ<潟菴遵 + +若吾с 2.1.2 筝祉紊雁: + +* 掩ゃ若吾с括垩篆罩c +* FreeBSD-ELF 絲上 libtool 篏帥 + +若吾с 2.1.1 筝祉紊雁: + +* Windows VC++ 潟若ゃ菴遵 +* 筝桁篆罩c + +若吾с 2.1 筝祉紊雁: + +* 筝桁篆罩c + +若吾с 2.1beta2 筝祉紊雁: + +* `ebzip' х軒 3 域┃ +* 違 `ebrefile' 潟潟菴遵 + +若吾с 2.1beta1 筝祉紊雁: + +* 筝桁篆罩c + +若吾с 2.1beta0 筝祉紊雁: + +* `ebfont' ャ<潟菴遵 +* ユ茯ャ<潟菴遵 +* `configure' `--with-zlib', `--with-zlib-includes', + `--with-zlib-libraries' 激с潟菴遵 +* CD-ROM 悟х軒/篌檎激絲上 +* 違 `ebzip' 潟潟菴遵 +* `ebappendix' `--filename-case' 激с潟 `--case' 劫 +* `ebappendix' `--no-catalogs' 激с潟菴遵 +* `ebfont' `--subbook' (`-S') 激с潟莇潟 +* `ebfont' c罕紊眼 +* zlib 純若鴻潟若莨若 +* 筝桁篆罩c + +若吾с 2.0.3 筝祉紊雁: + +* 筝桁篆罩c + +若吾с 2.0.2 筝祉紊雁: + +* 筝桁篆罩c + +若吾с 2.0.1 筝祉紊雁: + +* 鴻 + +若吾с 2.0 筝祉紊雁: + +* 筝桁篆罩c + +若吾с 2.0beta1 筝祉紊雁: + +* `ebappendix' 激с `--filename-cases' `--filename-case' + 劫 +* 筝桁篆罩c + +若吾с 2.0beta0 筝祉紊雁: + +* GNU libtool EB ゃ掩ゃ潟潟 + с +* ∽違ゃ潟帥若с若鴻紊眼 + EB ゃ 1.0.x 2.0 сゃ篋膊 +* `ebinfo' Texinfo ャ<潟菴遵 +* JIS X 4081-1996 祉荐菴違絲上 +* 純若鴻潟若絽宴若吾c罕紊眼 +* `ebappendix' `--no-catalogs' 激с潟ゃ +* 筝桁篆罩c + +若吾с 1.0.6 筝祉紊雁: + +* 筝桁篆罩c + +若吾с 1.0.5 筝祉紊雁: + +* 筝桁篆罩c + +若吾с 1.0.4 筝祉紊雁: + +* 鴻 + +若吾с 1.0.3 筝祉紊雁: + +* "Concise Oxford dicitionary" 絲上 +* 茲違≪若dс潟潟ゃ≪ Makefile.am 筝桁 + 篆罩c + 茲違腮蕁潟潟ャ若推с宴若吾潟潟ゃс + c +* 紊∽違ゃ潟帥若с若鴻紊眼 +* 筝桁篆罩c + +若吾с 1.0.2 筝祉紊雁: + +* EB ゃ∽違ゃ菴遵 + ∽違CD-ROM 悟絎臂紊絖糸<ゃ + 絲上糸鏄√XBM, XPM GIF +* 筝桁篆罩c + +若吾с 1.0.1 筝祉紊雁: + +* JIS X 4081-1996 荐茵腓阪九勝荐菴医茯茘 +* ゃ EPWING 悟с羲√剛贋膣≪с +* EPWING 若若肴怨莨吾絲上 +* 筝桁篆罩c + +若吾с 1.0 筝祉紊雁: + +* 筝桁篆罩c + +若吾с 1.0beta2 筝祉紊雁: + +* 筝桁篆罩c + +若吾с 1.0beta1 筝祉紊雁: + +* appendix 若帥<ゃ綵√紊眼 +* 筝桁篆罩c diff --git a/README b/README new file mode 100644 index 0000000..39c55e0 --- /dev/null +++ b/README @@ -0,0 +1,71 @@ + + EB $B%i%$%V%i%j(B + CD-ROM $B=q@R$K%"%/%;%9$9$k$?$a$N(B C $B$N%i%$%V%i%j(B + + +EB $B%i%$%V%i%j$O(B CD-ROM $B=q@R$K%"%/%;%9$9$k$?$a$N(B C $B$N%i%$%V%i%j$G$9!#(B +UNIX $B7O(B OS $B$*$h$S(B Windows (2000$B0J9_(B) $B$N%7%9%F%`>e$GF0:n$5$;$k$3$H$,$G(B +$B$-$^$9!#(B($B$?$@$7!"(BWindows $B$G%3%s%Q%$%k$9$k$K$O!"JL%Q%C%1!<%8$,I,MW$G$9!#(B) + +EB $B%i%$%V%i%j$O(B EB, EBG, EBXA, EBXA-C, S-EBXA $B$*$h$S(B EPWING $B7A<0$N(B +CD-ROM $B=q@R$KBP1~$7$F$$$^$9!#$3$l$i$O!"(B +$B$N(B ISO 9660 $B7A<0$HF1$8MWNN$G%^%&%s%H$9$k$3$H$,$G$-$^$9!#(B + +$B$^$?!"(BEB $B%i%$%V%i%j$O4v$D$+$N%f!<%F%j%F%#%3%^%s%I$bDs6!$7$F$$$^$9!#(B + + ebappendix appendix ($BIUO?(B) $B%G!<%?$r@07A$9$k(B + ebfont CD-ROM $B=q@RFb$N30;z$N%U%)%s%H%G!<%?$rpJs$r=PNO$9$k(B + ebrefile CD-ROM $B=q@R$N%+%?%m%0%U%!%$%k$r9=@.$7D>$9(B + ebstopcode CD-ROM $B=q@R$NK\J8$N6h@Z$j%3!<%I$r8!::$9$k(B + ebunzip CD-ROM $B=q@R$r?-D9$9$k(B + ebzip CD-ROM $B=q@R$r05=L$9$k(B + ebzipinfo CD-ROM $B=q@R$N05=L>pJs$r=PNO$9$k(B + + +$B%P!<%8%g%s(B 4.0 $B$+$i!"(BEB $B%i%$%V%i%j$OB>$N%[%9%H$N=q@R$K%"%/%;%9$G$-$k(B +$B$h$&$K$J$j$^$7$?!#1s3V%"%/%;%9MQ$N<1JL;R$r;H$&$3$H$G!"B>%[%9%H>e$N(B +CD-ROM $B=q@R$r;XDj$9$k$3$H$,$G$-$^$9!#$3$N<1JL;R$O!":<$B%]!<%H(B>/<$B=q@RL>(B> (CD-ROM $B=q@RK\BN(B) + ebnet://<$B%[%9%H(B>:<$B%]!<%H(B>/<$B=q@RL>(B>.app ($BIUO?%Q%C%1!<%8(B) + +<$B%[%9%H(B> $B$O1s3V%[%9%H$N(B IP $B%"%I%l%9$b$7$/$O%[%9%HL>$G$9!#$?$@$7!"(BIPv6 +$B%"%I%l%9$r;XDj$9$k>l9g$O!"%"%I%l%9$r(B `[' $B$H(B `]' $B$G0O$`I,MW$,$"$j$^$9!#(B +<$B%]!<%H(B> $B$O!"$=$N%[%9%H$,BT$A' $B$NItJ,$O>JN,2D(B +$BG=$G$9!#(B + +$B0J2<$KNc$r5-$7$^$9!#(B + ebnet://eb.example.com/dict + ebnet://eb.example.com:22010/dict.app + ebnet://192.168.1.1/dict.app + ebnet://192.168.1.1:22010/dict + ebnet://[fe80::290:27ff:fe3]/dict.app + ebnet://[fe80::290:27ff:fe3]:22010/dict + +$B1s3V%"%/%;%9$r9T$&$K$O!"(BEBNETD $B$r(B <$B%[%9%H(B> $B>e$K%$%s%9%H!<%k$9$kI,MW$,(B +$B$"$j$^$9!#(BEBNETD $B$O!"(BEB Library $BMQ$N1s3V%"%/%;%9%5!<%P$N%=%U%H%&%'%"(B +$B$G$9!#(B + +EB $B%i%$%V%i%j$O%U%j!<%=%U%H%&%'%"$G$9!#%=!<%9%3!<%I$*$h$S%P%$%J%j$r!"(B +$B$$$o$f$k(B Modified BSD $B%i%$%;%s%9(B $B$N2<$G;HMQ$9$k$3$H$,2DG=$G$9!#(B +($B%P!<%8%g%s(B 4.1$B$h$j$bA0$N$b$N$O!"(BGPL $B$r:NMQ$7$F$$$^$7$?!#(B) +$B%i%$%;%s%9$K4X$7$F!">\$7$/$O(B COPYING $B$H$$$&1QJ8$N%U%!%$%k$r;2>H$7$F(B +$B2<$5$$!#(B + +$B:G?7$N(B EB $B%i%$%V%i%j$OpJs$O sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH])dnl +_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +#serial 4 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[# Autoconf 2.62 quotes --file arguments for eval, but not when files +# are listed without --file. Let's play safe and only enable the eval +# if we detect the quoting. +case $CONFIG_FILES in +*\'*) eval set x "$CONFIG_FILES" ;; +*) set x $CONFIG_FILES ;; +esac +shift +for mf +do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 13 + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.60])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl +dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. +m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, + [m4_fatal([AC_INIT should be called with package and version arguments])])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl +]) +]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_arg=$1 +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) + +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 5 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([missing])dnl +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_MKDIR_P +# --------------- +# Check for `mkdir -p'. +AC_DEFUN([AM_PROG_MKDIR_P], +[AC_PREREQ([2.60])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, +dnl while keeping a definition of mkdir_p for backward compatibility. +dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. +dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of +dnl Makefile.ins that do not define MKDIR_P, so we do our own +dnl adjustment using top_builddir (which is defined more often than +dnl MKDIR_P). +AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl +case $mkdir_p in + [[\\/$]]* | ?:[[\\/]]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac +]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Copyright (C) 2006 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# This macro is traced by Automake. +AC_DEFUN([_AM_SUBST_NOTMAKE]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + +m4_include([m4/gettext.m4]) +m4_include([m4/in6addr.m4]) +m4_include([m4/largefile.m4]) +m4_include([m4/lcmessage.m4]) +m4_include([m4/libtool.m4]) +m4_include([m4/ltoptions.m4]) +m4_include([m4/ltsugar.m4]) +m4_include([m4/ltversion.m4]) +m4_include([m4/lt~obsolete.m4]) +m4_include([m4/sockaddrin6.m4]) +m4_include([m4/sockinttypes.m4]) diff --git a/compile b/compile new file mode 100755 index 0000000..1b1d232 --- /dev/null +++ b/compile @@ -0,0 +1,142 @@ +#! /bin/sh +# Wrapper for compilers which do not understand `-c -o'. + +scriptversion=2005-05-14.22 + +# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. +# Written by Tom Tromey . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +case $1 in + '') + echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: compile [--help] [--version] PROGRAM [ARGS] + +Wrapper for compilers which do not understand `-c -o'. +Remove `-o dest.o' from ARGS, run PROGRAM with the remaining +arguments, and rename the output as expected. + +If you are trying to build a whole package this is not the +right script to run: please start by reading the file `INSTALL'. + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "compile $scriptversion" + exit $? + ;; +esac + +ofile= +cfile= +eat= + +for arg +do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as `compile cc -o foo foo.c'. + # So we strip `-o arg' only if arg is an object. + eat=1 + case $2 in + *.o | *.obj) + ofile=$2 + ;; + *) + set x "$@" -o "$2" + shift + ;; + esac + ;; + *.c) + cfile=$1 + set x "$@" "$1" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift +done + +if test -z "$ofile" || test -z "$cfile"; then + # If no `-o' option was seen then we might have been invoked from a + # pattern rule where we don't need one. That is ok -- this is a + # normal compilation that the losing compiler can handle. If no + # `.c' file was seen then we are probably linking. That is also + # ok. + exec "$@" +fi + +# Name of file we expect compiler to create. +cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'` + +# Create the lock directory. +# Note: use `[/.-]' here to ensure that we don't use the same name +# that we are using for the .o file. Also, base the name on the expected +# object file name, since that is what matters with a parallel build. +lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d +while true; do + if mkdir "$lockdir" >/dev/null 2>&1; then + break + fi + sleep 1 +done +# FIXME: race condition here if user kills between mkdir and trap. +trap "rmdir '$lockdir'; exit 1" 1 2 15 + +# Run the compile. +"$@" +ret=$? + +if test -f "$cofile"; then + mv "$cofile" "$ofile" +elif test -f "${cofile}bj"; then + mv "${cofile}bj" "$ofile" +fi + +rmdir "$lockdir" +exit $ret + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/config.guess b/config.guess new file mode 100755 index 0000000..f32079a --- /dev/null +++ b/config.guess @@ -0,0 +1,1526 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +# Free Software Foundation, Inc. + +timestamp='2008-01-23' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[456]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:[3456]*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + EM64T | authenticamd) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-gnu + else + echo ${UNAME_MACHINE}-unknown-linux-gnueabi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + or32:Linux:*:*) + echo or32-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-gnu + exit ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^LIBC/{ + s: ::g + p + }'`" + test x"${LIBC}" != x && { + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit + } + test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..92f1f6b --- /dev/null +++ b/config.h.in @@ -0,0 +1,196 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if build with ebnet support */ +#undef ENABLE_EBNET + +/* Define if build with IPv6 support */ +#undef ENABLE_IPV6 + +/* Define if NLS is requested */ +#undef ENABLE_NLS + +/* Define if pthread support is enabled. */ +#undef ENABLE_PTHREAD + +/* Define if command names have the suffix \`.exe' */ +#undef EXEEXT_EXE + +/* Define to 1 if you have the `atoll' function. */ +#undef HAVE_ATOLL + +/* Define to 1 if you have the header file. */ +#undef HAVE_DIRECT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the `gai_strerror' function. */ +#undef HAVE_GAI_STRERROR + +/* Define to 1 if you have the `getaddrinfo' function. */ +#undef HAVE_GETADDRINFO + +/* Define to 1 if you have the `getnameinfo' function. */ +#undef HAVE_GETNAMEINFO + +/* Define to 1 if you have the header file. */ +#undef HAVE_ICONV_H + +/* Define to 1 if you have the `iconv_open' function. */ +#undef HAVE_ICONV_OPEN + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LANGINFO_H + +/* Define to 1 if you have the `LC_MESSAGES' locale category */ +#undef HAVE_LC_MESSAGES + +/* Define to 1 if you have the `bind' library (-lbind). */ +#undef HAVE_LIBBIND + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBCHARSET_H + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +#undef HAVE_LIBNSL + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +#undef HAVE_LIBRESOLV + +/* Define to 1 if you have the `socket' library (-lsocket). */ +#undef HAVE_LIBSOCKET + +/* Define to 1 if you have the `locale_charset' function. */ +#undef HAVE_LOCALE_CHARSET + +/* Define to 1 if you have the header file. */ +#undef HAVE_LOCALE_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MBSTRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `nl_langinfo' function. */ +#undef HAVE_NL_LANGINFO + +/* Define to 1 if you have the header file. */ +#undef HAVE_NL_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_PTHREAD_H + +/* Define to 1 if you have the `setlocale' function. */ +#undef HAVE_SETLOCALE + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strcasecmp' function. */ +#undef HAVE_STRCASECMP + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if defines `struct in6_addr' */ +#undef HAVE_STRUCT_IN6_ADDR + +/* Define to 1 if defines `struct sockaddr_in6' */ +#undef HAVE_STRUCT_SOCKADDR_IN6 + +/* Define to 1 if defines `struct sockaddr_storage' */ +#undef HAVE_STRUCT_SOCKADDR_STORAGE + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the `_atoi64' function. */ +#undef HAVE__ATOI64 + +/* Define to 1 if you have the `_getdcwd' function. */ +#undef HAVE__GETDCWD + +/* Define to 1 if `in6addr_any' is declared by */ +#undef IN6ADDR_ANY_DECLARED + +/* Define to 1 if `in6addr_loopback' is declared by */ +#undef IN6ADDR_LOOPBACK_DECLARED + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#undef LT_OBJDIR + +/* Mailing address */ +#undef MAILING_ADDRESS + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to `1' if printf() recognizes "I64" modifier for __int64 */ +#undef PRINTF_I64_MODIFIER + +/* Define to `1' if printf() recognizes "ll" modifier for long long */ +#undef PRINTF_LL_MODIFIER + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION + +/* Number of bits in a file offset, on hosts where this is settable. */ +#undef _FILE_OFFSET_BITS + +/* Define for large files, on AIX-style hosts. */ +#undef _LARGE_FILES + +/* Define to `unsigned char', `unsigned short', `unsigned int' or `unsigned + long' according with size of `sin_port' in `struct sockaddr_in', if + , or does not define + `in_port_t'. */ +#undef in_port_t + +/* Define to `int' if does not define. */ +#undef mode_t + +/* Define to `unsigned char', `unsigned short', `unsigned int' or `unsigned + long' according with size of `sa_family' in `struct sockaddr', if + or does not define `sa_family_t'. */ +#undef sa_family_t + +/* Define to `int' if or does not define. */ +#undef socklen_t + +/* Define to `int' if does not define. */ +#undef ssize_t diff --git a/config.sub b/config.sub new file mode 100755 index 0000000..6759825 --- /dev/null +++ b/config.sub @@ -0,0 +1,1658 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +# Free Software Foundation, Inc. + +timestamp='2008-01-16' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ + uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fido | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | mcore | mep \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | mt \ + | msp430 \ + | nios | nios2 \ + | ns16k | ns32k \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | score \ + | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nios-* | nios2-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tile*) + basic_machine=tile-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/configure b/configure new file mode 100755 index 0000000..17a336c --- /dev/null +++ b/configure @@ -0,0 +1,17418 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.63 for eb 4.4.3. +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no +fi + + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + case $as_dir in + /*) + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +(as_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell bug-autoconf@gnu.org about your system, + echo including any error possibly output before this message. + echo This can help us improve future autoconf versions. + echo Configuration will now proceed without shell functions. +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + + + +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$lt_ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$lt_ECHO" | sed 's,\\\\\$\\$0,'$0','` + ;; +esac + +ECHO=${lt_ECHO-echo} +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then + # Yippee, $ECHO works! + : +else + # Restart under the correct shell. + exec $SHELL "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat <<_LT_EOF +$* +_LT_EOF + exit 0 +fi + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test -z "$lt_ECHO"; then + if test "X${echo_test_string+set}" != Xset; then + # find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if { echo_test_string=`eval $cmd`; } 2>/dev/null && + { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null + then + break + fi + done + fi + + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : + else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$ECHO" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + ECHO='print -r' + elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} + else + # Try using printf. + ECHO='printf %s\n' + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + ECHO="$CONFIG_SHELL $0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$CONFIG_SHELL $0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do + if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "$0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} + else + # Oops. We lost completely, so just stick with echo. + ECHO=echo + fi + fi + fi + fi + fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +lt_ECHO=$ECHO +if test "X$lt_ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then + lt_ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" +fi + + + + +exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Identity of this package. +PACKAGE_NAME='eb' +PACKAGE_TARNAME='eb' +PACKAGE_VERSION='4.4.3' +PACKAGE_STRING='eb 4.4.3' +PACKAGE_BUGREPORT='' + +ac_unique_file="eb/eb.c" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='LTLIBOBJS +EBCONF_EBLIBS +EBCONF_EBINCS +EBCONF_INTLLIBS +EBCONF_INTLINCS +PTHREAD_LDFLAGS +PTHREAD_CFLAGS +PTHREAD_CPPFLAGS +ENABLE_PTHREAD +EBCONF_ZLIBLIBS +EBCONF_ZLIBINCS +EXEEXT_EXE_FALSE +EXEEXT_EXE_TRUE +LIBOBJS +ENABLE_EBNET_FALSE +ENABLE_EBNET_TRUE +ENABLE_EBNET +ZLIBDEPS +ZLIBLIBS +ZLIBINCS +pkgdocdir +ENABLE_SAMPLES_FALSE +ENABLE_SAMPLES_TRUE +MSGMERGE +XGETTEXT +MSGFMT +INTLLIBS +INTLINCS +ENABLE_NLS +ICONVLIBS +ICONVINCS +PERL +CPP +OTOOL64 +OTOOL +LIPO +NMEDIT +DSYMUTIL +lt_ECHO +RANLIB +AR +OBJDUMP +LN_S +NM +ac_ct_DUMPBIN +DUMPBIN +LD +FGREP +EGREP +GREP +SED +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build +LIBTOOL +am__fastdepCC_FALSE +am__fastdepCC_TRUE +CCDEPMODE +AMDEPBACKSLASH +AMDEP_FALSE +AMDEP_TRUE +am__quote +am__include +DEPDIR +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +MAILING_ADDRESS +EB_VERSION_MINOR +EB_VERSION_MAJOR +LIBEB_VERSION_INFO +am__untar +am__tar +AMTAR +am__leading_dot +SET_MAKE +AWK +mkdir_p +MKDIR_P +INSTALL_STRIP_PROGRAM +STRIP +install_sh +MAKEINFO +AUTOHEADER +AUTOMAKE +AUTOCONF +ACLOCAL +VERSION +PACKAGE +CYGPATH_W +am__isrc +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +enable_dependency_tracking +enable_shared +enable_static +with_pic +enable_fast_install +with_gnu_ld +enable_libtool_lock +enable_largefile +enable_nls +with_gettext_includes +with_gettext_libraries +with_iconv_includes +with_iconv_libraries +enable_samples +enable_pthread +with_pthread_cppflags +with_pthread_cflags +with_pthread_ldflags +with_pkgdocdir +with_zlib_includes +with_zlib_libraries +enable_ebnet +enable_ipv6 +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 + { (exit 1); exit 1; }; } + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 + { (exit 1); exit 1; }; } + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 + { (exit 1); exit 1; }; } + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 + { (exit 1); exit 1; }; } + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { $as_echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { $as_echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2 + { (exit 1); exit 1; }; } ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + { $as_echo "$as_me: error: working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { $as_echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2 + { (exit 1); exit 1; }; } + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures eb 4.4.3 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/eb] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of eb 4.4.3:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + --enable-shared[=PKGS] build shared libraries [default=yes] + --enable-static[=PKGS] build static libraries [default=yes] + --enable-fast-install[=PKGS] + optimize for fast installation [default=yes] + --disable-libtool-lock avoid locking (might break parallel builds) + --disable-largefile omit support for large files + --enable-nls Native Language Support [yes] + --enable-samples compile sample programs default=no + --enable-pthread build pthread safe libraries [no] + --enable-ebnet EBNET support [yes] + --enable-ipv6 IPv6 support for EBNET [yes] (if the system + supports IPv6) + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-pic try to use only PIC/non-PIC objects [default=use + both] + --with-gnu-ld assume the C compiler uses GNU ld [default=no] + --with-gettext-includes=DIR + gettext include files are in DIR + --with-gettext-libraries=DIR + gettext library files are in DIR + --with-iconv-includes=DIR + iconv include files are in DIR + --with-iconv-libraries=DIR + iconv library files are in DIR + --with-pthread-cppflags=FLAGS + additional CPPFLAGS for pthread support + --with-pthread-cflags=FLAGS + additional CFLAGS for pthread support + --with-pthread-ldflags=FLAGS + additional LDFLAGS for pthread support + --with-pkgdocdir=DIR HTML documents in DIR [default=DATADIR/eb/doc] + --with-zlib-includes=DIR + zlib include files are in DIR + --with-zlib-libraries=DIR + zlib library files are in DIR + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +eb configure 4.4.3 +generated by GNU Autoconf 2.63 + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by eb $as_me 4.4.3, which was +generated by GNU Autoconf 2.63. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" +done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args '$ac_arg'" + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------------- ## +## File substitutions. ## +## ------------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + ac_site_file1=$CONFIG_SITE +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test -r "$ac_site_file"; then + { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + + + + + + + + + + + + + + + + + + + + + + + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + +am__api_version='1.10' + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 +$as_echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} + { (exit 1); exit 1; }; } +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + +done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ $as_echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +$as_echo_n "checking whether build environment is sane... " >&6; } +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { { $as_echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +$as_echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { { $as_echo "$as_me:$LINENO: error: newly created file is older than distributed files! +Check your system clock" >&5 +$as_echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +{ $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. +# By default was `s,x,x', remove it if useless. +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' +program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { $as_echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 +$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +{ $as_echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5 +$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } +if test -z "$MKDIR_P"; then + if test "${ac_cv_path_mkdir+set}" = set; then + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir (GNU coreutils) '* | \ + 'mkdir (coreutils) '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + break 3;; + esac + done + done +done +IFS=$as_save_IFS + +fi + + if test "${ac_cv_path_mkdir+set}" = set; then + MKDIR_P="$ac_cv_path_mkdir -p" + else + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + test -d ./--version && rmdir ./--version + MKDIR_P="$ac_install_sh -d" + fi +fi +{ $as_echo "$as_me:$LINENO: result: $MKDIR_P" >&5 +$as_echo "$MKDIR_P" >&6; } + +mkdir_p="$MKDIR_P" +case $mkdir_p in + [\\/$]* | ?:[\\/]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_AWK+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:$LINENO: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ $as_echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + { { $as_echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +$as_echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE='eb' + VERSION='4.4.3' + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_STRIP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:$LINENO: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + + + + + +LIBEB_VERSION_INFO=16:0:0 + + +EB_VERSION_MAJOR=4 +EB_VERSION_MINOR=4 + + + +MAILING_ADDRESS='m-kasahr@sra.co.jp' + + +cat >>confdefs.h <<_ACEOF +#define MAILING_ADDRESS "$MAILING_ADDRESS" +_ACEOF + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:$LINENO: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:$LINENO: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:$LINENO: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:$LINENO: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } + +# Provide some information about the compiler. +$as_echo "$as_me:$LINENO: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { (ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi + +{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +if test -z "$ac_file"; then + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; }; } +fi + +ac_exeext=$ac_cv_exeext + +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } + fi + fi +fi +{ $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +fi + +rm -f conftest$ac_cv_exeext +{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if test "${ac_cv_objext+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_c89=$ac_arg +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:$LINENO: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:$LINENO: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ $as_echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +$as_echo_n "checking for style of include used by $am_make... " >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi + + +{ $as_echo "$as_me:$LINENO: result: $_am_result" >&5 +$as_echo "$_am_result" >&6; } +rm -f confinc confmf + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + +depcc="$CC" am_compiler_list= + +{ $as_echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + +case `pwd` in + *\ * | *\ *) + { $as_echo "$as_me:$LINENO: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 +$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; +esac + + + +macro_version='2.2.6' +macro_revision='1.3012' + + + + + + + + + + + + + +ltmain="$ac_aux_dir/ltmain.sh" + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + { { $as_echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 +$as_echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} + { (exit 1); exit 1; }; } + +{ $as_echo "$as_me:$LINENO: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if test "${ac_cv_build+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + { { $as_echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +$as_echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 +$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 +$as_echo "$as_me: error: invalid value of canonical build" >&2;} + { (exit 1); exit 1; }; };; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:$LINENO: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if test "${ac_cv_host+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 +$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} + { (exit 1); exit 1; }; } +fi + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 +$as_echo "$as_me: error: invalid value of canonical host" >&2;} + { (exit 1); exit 1; }; };; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5 +$as_echo_n "checking for a sed that does not truncate output... " >&6; } +if test "${ac_cv_path_SED+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ + for ac_i in 1 2 3 4 5 6 7; do + ac_script="$ac_script$as_nl$ac_script" + done + echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed + $as_unset ac_script || ac_script= + if test -z "$SED"; then + ac_path_SED_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue +# Check for GNU ac_path_SED and select it if it is found. + # Check for GNU $ac_path_SED +case `"$ac_path_SED" --version 2>&1` in +*GNU*) + ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo '' >> "conftest.nl" + "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_SED_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_SED="$ac_path_SED" + ac_path_SED_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_SED_found && break 3 + done + done +done +IFS=$as_save_IFS + if test -z "$ac_cv_path_SED"; then + { { $as_echo "$as_me:$LINENO: error: no acceptable sed could be found in \$PATH" >&5 +$as_echo "$as_me: error: no acceptable sed could be found in \$PATH" >&2;} + { (exit 1); exit 1; }; } + fi +else + ac_cv_path_SED=$SED +fi + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_SED" >&5 +$as_echo "$ac_cv_path_SED" >&6; } + SED="$ac_cv_path_SED" + rm -f conftest.sed + +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" + + + + + + + + + + + +{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if test "${ac_cv_path_GREP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done +done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:$LINENO: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done +done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:$LINENO: checking for fgrep" >&5 +$as_echo_n "checking for fgrep... " >&6; } +if test "${ac_cv_path_FGREP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 + then ac_cv_path_FGREP="$GREP -F" + else + if test -z "$FGREP"; then + ac_path_FGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in fgrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue +# Check for GNU ac_path_FGREP and select it if it is found. + # Check for GNU $ac_path_FGREP +case `"$ac_path_FGREP" --version 2>&1` in +*GNU*) + ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'FGREP' >> "conftest.nl" + "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_FGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_FGREP="$ac_path_FGREP" + ac_path_FGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_FGREP_found && break 3 + done + done +done +IFS=$as_save_IFS + if test -z "$ac_cv_path_FGREP"; then + { { $as_echo "$as_me:$LINENO: error: no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +$as_echo "$as_me: error: no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } + fi +else + ac_cv_path_FGREP=$FGREP +fi + + fi +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_FGREP" >&5 +$as_echo "$ac_cv_path_FGREP" >&6; } + FGREP="$ac_cv_path_FGREP" + + +test -z "$GREP" && GREP=grep + + + + + + + + + + + + + + + + + + + +# Check whether --with-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then + withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + { $as_echo "$as_me:$LINENO: checking for ld used by $CC" >&5 +$as_echo_n "checking for ld used by $CC... " >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + { $as_echo "$as_me:$LINENO: checking for GNU ld" >&5 +$as_echo_n "checking for GNU ld... " >&6; } +else + { $as_echo "$as_me:$LINENO: checking for non-GNU ld" >&5 +$as_echo_n "checking for non-GNU ld... " >&6; } +fi +if test "${lt_cv_path_LD+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &5 +$as_echo "$LD" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi +test -z "$LD" && { { $as_echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 +$as_echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} + { (exit 1); exit 1; }; } +{ $as_echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } +if test "${lt_cv_prog_gnu_ld+set}" = set; then + $as_echo_n "(cached) " >&6 +else + # I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 &5 +$as_echo "$lt_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$lt_cv_prog_gnu_ld + + + + + + + + + +{ $as_echo "$as_me:$LINENO: checking for BSD- or MS-compatible name lister (nm)" >&5 +$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } +if test "${lt_cv_path_NM+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_nm_to_check="${ac_tool_prefix}nm" + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/$lt_tmp_nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS="$lt_save_ifs" + done + : ${lt_cv_path_NM=no} +fi +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5 +$as_echo "$lt_cv_path_NM" >&6; } +if test "$lt_cv_path_NM" != "no"; then + NM="$lt_cv_path_NM" +else + # Didn't find any BSD compatible name lister, look for dumpbin. + if test -n "$ac_tool_prefix"; then + for ac_prog in "dumpbin -symbols" "link -dump -symbols" + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_DUMPBIN+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$DUMPBIN"; then + ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +DUMPBIN=$ac_cv_prog_DUMPBIN +if test -n "$DUMPBIN"; then + { $as_echo "$as_me:$LINENO: result: $DUMPBIN" >&5 +$as_echo "$DUMPBIN" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$DUMPBIN" && break + done +fi +if test -z "$DUMPBIN"; then + ac_ct_DUMPBIN=$DUMPBIN + for ac_prog in "dumpbin -symbols" "link -dump -symbols" +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DUMPBIN"; then + ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN +if test -n "$ac_ct_DUMPBIN"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_DUMPBIN" >&5 +$as_echo "$ac_ct_DUMPBIN" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_DUMPBIN" && break +done + + if test "x$ac_ct_DUMPBIN" = x; then + DUMPBIN=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DUMPBIN=$ac_ct_DUMPBIN + fi +fi + + + if test "$DUMPBIN" != ":"; then + NM="$DUMPBIN" + fi +fi +test -z "$NM" && NM=nm + + + + + + +{ $as_echo "$as_me:$LINENO: checking the name lister ($NM) interface" >&5 +$as_echo_n "checking the name lister ($NM) interface... " >&6; } +if test "${lt_cv_nm_interface+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:4405: $ac_compile\"" >&5) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&5 + (eval echo "\"\$as_me:4408: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&5 + (eval echo "\"\$as_me:4411: output\"" >&5) + cat conftest.out >&5 + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest* +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_nm_interface" >&5 +$as_echo "$lt_cv_nm_interface" >&6; } + +{ $as_echo "$as_me:$LINENO: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } +fi + +# find the maximum length of command line arguments +{ $as_echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5 +$as_echo_n "checking the maximum length of command line arguments... " >&6; } +if test "${lt_cv_sys_max_cmd_len+set}" = set; then + $as_echo_n "(cached) " >&6 +else + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8 ; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test "X"`$SHELL $0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ + = "XX$teststring$teststring"; } >/dev/null 2>&1 && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac + +fi + +if test -n $lt_cv_sys_max_cmd_len ; then + { $as_echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5 +$as_echo "$lt_cv_sys_max_cmd_len" >&6; } +else + { $as_echo "$as_me:$LINENO: result: none" >&5 +$as_echo "none" >&6; } +fi +max_cmd_len=$lt_cv_sys_max_cmd_len + + + + + + +: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} + +{ $as_echo "$as_me:$LINENO: checking whether the shell understands some XSI constructs" >&5 +$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } +# Try some XSI features +xsi_shell=no +( _lt_dummy="a/b/c" + test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,, \ + && eval 'test $(( 1 + 1 )) -eq 2 \ + && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ + && xsi_shell=yes +{ $as_echo "$as_me:$LINENO: result: $xsi_shell" >&5 +$as_echo "$xsi_shell" >&6; } + + +{ $as_echo "$as_me:$LINENO: checking whether the shell understands \"+=\"" >&5 +$as_echo_n "checking whether the shell understands \"+=\"... " >&6; } +lt_shell_append=no +( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ + >/dev/null 2>&1 \ + && lt_shell_append=yes +{ $as_echo "$as_me:$LINENO: result: $lt_shell_append" >&5 +$as_echo "$lt_shell_append" >&6; } + + +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi + + + + + +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac + + + + + + + + + +{ $as_echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5 +$as_echo_n "checking for $LD option to reload object files... " >&6; } +if test "${lt_cv_ld_reload_flag+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_reload_flag='-r' +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5 +$as_echo "$lt_cv_ld_reload_flag" >&6; } +reload_flag=$lt_cv_ld_reload_flag +case $reload_flag in +"" | " "*) ;; +*) reload_flag=" $reload_flag" ;; +esac +reload_cmds='$LD$reload_flag -o $output$reload_objs' +case $host_os in + darwin*) + if test "$GCC" = yes; then + reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' + else + reload_cmds='$LD$reload_flag -o $output$reload_objs' + fi + ;; +esac + + + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. +set dummy ${ac_tool_prefix}objdump; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_OBJDUMP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$OBJDUMP"; then + ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +OBJDUMP=$ac_cv_prog_OBJDUMP +if test -n "$OBJDUMP"; then + { $as_echo "$as_me:$LINENO: result: $OBJDUMP" >&5 +$as_echo "$OBJDUMP" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OBJDUMP"; then + ac_ct_OBJDUMP=$OBJDUMP + # Extract the first word of "objdump", so it can be a program name with args. +set dummy objdump; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OBJDUMP"; then + ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_OBJDUMP="objdump" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP +if test -n "$ac_ct_OBJDUMP"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_OBJDUMP" >&5 +$as_echo "$ac_ct_OBJDUMP" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OBJDUMP" = x; then + OBJDUMP="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OBJDUMP=$ac_ct_OBJDUMP + fi +else + OBJDUMP="$ac_cv_prog_OBJDUMP" +fi + +test -z "$OBJDUMP" && OBJDUMP=objdump + + + + + + + + + +{ $as_echo "$as_me:$LINENO: checking how to recognize dependent libraries" >&5 +$as_echo_n "checking how to recognize dependent libraries... " >&6; } +if test "${lt_cv_deplibs_check_method+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# `unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given extended regex. +# If you have `file' or equivalent on your system and you're not sure +# whether `pass_all' will *always* work, you probably want this one. + +case $host_os in +aix[4-9]*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi[45]*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump', + # unless we find 'file', for example because we are cross-compiling. + if ( file / ) >/dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +cegcc) + # use the weaker test based on 'objdump'. See mingw*. + lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]' + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[3-9]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +esac + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5 +$as_echo "$lt_cv_deplibs_check_method" >&6; } +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + + + + + + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_AR+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { $as_echo "$as_me:$LINENO: result: $AR" >&5 +$as_echo "$AR" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_AR"; then + ac_ct_AR=$AR + # Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_AR="ar" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 +$as_echo "$ac_ct_AR" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_AR" = x; then + AR="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +else + AR="$ac_cv_prog_AR" +fi + +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru + + + + + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_STRIP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:$LINENO: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +test -z "$STRIP" && STRIP=: + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_RANLIB+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:$LINENO: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +test -z "$RANLIB" && RANLIB=: + + + + + + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Check for command to grab the raw symbol name followed by C symbol from nm. +{ $as_echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5 +$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } +if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then + $as_echo_n "(cached) " >&6 +else + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRST]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[BCDT]' + ;; +cygwin* | mingw* | pw32* | cegcc*) + symcode='[ABCDGISTW]' + ;; +hpux*) + if test "$host_cpu" = ia64; then + symcode='[ABCDEGRST]' + fi + ;; +irix* | nonstopux*) + symcode='[BCDEGRST]' + ;; +osf*) + symcode='[BCDEGQRST]' + ;; +solaris*) + symcode='[BDRT]' + ;; +sco3.2v5*) + symcode='[DT]' + ;; +sysv4.2uw2*) + symcode='[DT]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[ABDT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[ABCDGIRSTW]' ;; +esac + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function + # and D for any global variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK '"\ +" {last_section=section; section=\$ 3};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ +" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ +" s[1]~/^[@?]/{print s[1], s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_LT_EOF + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Now try to grab the symbols. + nlist=conftest.nm + if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5 + (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 + fi + else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done + +fi + +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + { $as_echo "$as_me:$LINENO: result: failed" >&5 +$as_echo "failed" >&6; } +else + { $as_echo "$as_me:$LINENO: result: ok" >&5 +$as_echo "ok" >&6; } +fi + + + + + + + + + + + + + + + + + + + + + + + +# Check whether --enable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval=$enable_libtool_lock; +fi + +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '#line 5617 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + { $as_echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5 +$as_echo_n "checking whether the C compiler needs -belf... " >&6; } +if test "${lt_cv_cc_needs_belf+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + lt_cv_cc_needs_belf=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + lt_cv_cc_needs_belf=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5 +$as_echo "$lt_cv_cc_needs_belf" >&6; } + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +sparc*-*solaris*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) LD="${LD-ld} -m elf64_sparc" ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; +esac + +need_locks="$enable_libtool_lock" + + + case $host_os in + rhapsody* | darwin*) + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. +set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_DSYMUTIL+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$DSYMUTIL"; then + ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +DSYMUTIL=$ac_cv_prog_DSYMUTIL +if test -n "$DSYMUTIL"; then + { $as_echo "$as_me:$LINENO: result: $DSYMUTIL" >&5 +$as_echo "$DSYMUTIL" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DSYMUTIL"; then + ac_ct_DSYMUTIL=$DSYMUTIL + # Extract the first word of "dsymutil", so it can be a program name with args. +set dummy dsymutil; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DSYMUTIL"; then + ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL +if test -n "$ac_ct_DSYMUTIL"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_DSYMUTIL" >&5 +$as_echo "$ac_ct_DSYMUTIL" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_DSYMUTIL" = x; then + DSYMUTIL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DSYMUTIL=$ac_ct_DSYMUTIL + fi +else + DSYMUTIL="$ac_cv_prog_DSYMUTIL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. +set dummy ${ac_tool_prefix}nmedit; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_NMEDIT+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$NMEDIT"; then + ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +NMEDIT=$ac_cv_prog_NMEDIT +if test -n "$NMEDIT"; then + { $as_echo "$as_me:$LINENO: result: $NMEDIT" >&5 +$as_echo "$NMEDIT" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_NMEDIT"; then + ac_ct_NMEDIT=$NMEDIT + # Extract the first word of "nmedit", so it can be a program name with args. +set dummy nmedit; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_NMEDIT"; then + ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_NMEDIT="nmedit" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT +if test -n "$ac_ct_NMEDIT"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_NMEDIT" >&5 +$as_echo "$ac_ct_NMEDIT" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_NMEDIT" = x; then + NMEDIT=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + NMEDIT=$ac_ct_NMEDIT + fi +else + NMEDIT="$ac_cv_prog_NMEDIT" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. +set dummy ${ac_tool_prefix}lipo; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_LIPO+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$LIPO"; then + ac_cv_prog_LIPO="$LIPO" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_LIPO="${ac_tool_prefix}lipo" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +LIPO=$ac_cv_prog_LIPO +if test -n "$LIPO"; then + { $as_echo "$as_me:$LINENO: result: $LIPO" >&5 +$as_echo "$LIPO" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_LIPO"; then + ac_ct_LIPO=$LIPO + # Extract the first word of "lipo", so it can be a program name with args. +set dummy lipo; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_LIPO+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_LIPO"; then + ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_LIPO="lipo" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO +if test -n "$ac_ct_LIPO"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_LIPO" >&5 +$as_echo "$ac_ct_LIPO" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_LIPO" = x; then + LIPO=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + LIPO=$ac_ct_LIPO + fi +else + LIPO="$ac_cv_prog_LIPO" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. +set dummy ${ac_tool_prefix}otool; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_OTOOL+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$OTOOL"; then + ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_OTOOL="${ac_tool_prefix}otool" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +OTOOL=$ac_cv_prog_OTOOL +if test -n "$OTOOL"; then + { $as_echo "$as_me:$LINENO: result: $OTOOL" >&5 +$as_echo "$OTOOL" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OTOOL"; then + ac_ct_OTOOL=$OTOOL + # Extract the first word of "otool", so it can be a program name with args. +set dummy otool; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OTOOL"; then + ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_OTOOL="otool" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL +if test -n "$ac_ct_OTOOL"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_OTOOL" >&5 +$as_echo "$ac_ct_OTOOL" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OTOOL" = x; then + OTOOL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OTOOL=$ac_ct_OTOOL + fi +else + OTOOL="$ac_cv_prog_OTOOL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. +set dummy ${ac_tool_prefix}otool64; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_OTOOL64+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$OTOOL64"; then + ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +OTOOL64=$ac_cv_prog_OTOOL64 +if test -n "$OTOOL64"; then + { $as_echo "$as_me:$LINENO: result: $OTOOL64" >&5 +$as_echo "$OTOOL64" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OTOOL64"; then + ac_ct_OTOOL64=$OTOOL64 + # Extract the first word of "otool64", so it can be a program name with args. +set dummy otool64; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OTOOL64"; then + ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_OTOOL64="otool64" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 +if test -n "$ac_ct_OTOOL64"; then + { $as_echo "$as_me:$LINENO: result: $ac_ct_OTOOL64" >&5 +$as_echo "$ac_ct_OTOOL64" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OTOOL64" = x; then + OTOOL64=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OTOOL64=$ac_ct_OTOOL64 + fi +else + OTOOL64="$ac_cv_prog_OTOOL64" +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:$LINENO: checking for -single_module linker flag" >&5 +$as_echo_n "checking for -single_module linker flag... " >&6; } +if test "${lt_cv_apple_cc_single_mod+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_apple_cc_single_mod=no + if test -z "${LT_MULTI_MODULE}"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&5 + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&5 + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_apple_cc_single_mod" >&5 +$as_echo "$lt_cv_apple_cc_single_mod" >&6; } + { $as_echo "$as_me:$LINENO: checking for -exported_symbols_list linker flag" >&5 +$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } +if test "${lt_cv_ld_exported_symbols_list+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + lt_cv_ld_exported_symbols_list=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + lt_cv_ld_exported_symbols_list=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS="$save_LDFLAGS" + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_ld_exported_symbols_list" >&5 +$as_echo "$lt_cv_ld_exported_symbols_list" >&6; } + case $host_os in + rhapsody* | darwin1.[012]) + _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[91]*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + 10.[012]*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test "$lt_cv_apple_cc_single_mod" = "yes"; then + _lt_dar_single_mod='$single_module' + fi + if test "$lt_cv_ld_exported_symbols_list" = "yes"; then + _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + if test "$DSYMUTIL" != ":"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:$LINENO: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if test "${ac_cv_header_stdc+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_stdc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_stdc=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +for ac_header in dlfcn.h +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +# Set options + + + + enable_dlopen=no + + + enable_win32_dll=no + + + # Check whether --enable-shared was given. +if test "${enable_shared+set}" = set; then + enableval=$enable_shared; p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_shared=yes +fi + + + + + + + + + + # Check whether --enable-static was given. +if test "${enable_static+set}" = set; then + enableval=$enable_static; p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_static=yes +fi + + + + + + + + + + +# Check whether --with-pic was given. +if test "${with_pic+set}" = set; then + withval=$with_pic; pic_mode="$withval" +else + pic_mode=default +fi + + +test -z "$pic_mode" && pic_mode=default + + + + + + + + # Check whether --enable-fast-install was given. +if test "${enable_fast_install+set}" = set; then + enableval=$enable_fast_install; p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_fast_install=yes +fi + + + + + + + + + + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ltmain" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + + + + + + + + + + + + + + + + + + + + + + + + + +test -z "$LN_S" && LN_S="ln -s" + + + + + + + + + + + + + + +if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi + +{ $as_echo "$as_me:$LINENO: checking for objdir" >&5 +$as_echo_n "checking for objdir... " >&6; } +if test "${lt_cv_objdir+set}" = set; then + $as_echo_n "(cached) " >&6 +else + rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5 +$as_echo "$lt_cv_objdir" >&6; } +objdir=$lt_cv_objdir + + + + + +cat >>confdefs.h <<_ACEOF +#define LT_OBJDIR "$lt_cv_objdir/" +_ACEOF + + + + + + + + + + + + + + + + + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld="$lt_cv_prog_gnu_ld" + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + { $as_echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5 +$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then + $as_echo_n "(cached) " >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/${ac_tool_prefix}file; then + lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + { $as_echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 +$as_echo "$MAGIC_CMD" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + + +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + { $as_echo "$as_me:$LINENO: checking for file" >&5 +$as_echo_n "checking for file... " >&6; } +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then + $as_echo_n "(cached) " >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/file; then + lt_cv_path_MAGIC_CMD="$ac_dir/file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + { $as_echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 +$as_echo "$MAGIC_CMD" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + else + MAGIC_CMD=: + fi +fi + + fi + ;; +esac + +# Use C for the default configuration in the libtool script + +lt_save_CC="$CC" +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +objext=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + + + + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* + +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* + + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + +lt_prog_compiler_no_builtin_flag= + +if test "$GCC" = yes; then + lt_prog_compiler_no_builtin_flag=' -fno-builtin' + + { $as_echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } +if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_rtti_exceptions=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="-fno-rtti -fno-exceptions" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:7474: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:7478: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_rtti_exceptions=yes + fi + fi + $RM conftest* + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } + +if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then + lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" +else + : +fi + +fi + + + + + + + lt_prog_compiler_wl= +lt_prog_compiler_pic= +lt_prog_compiler_static= + +{ $as_echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +$as_echo_n "checking for $compiler option to produce PIC... " >&6; } + + if test "$GCC" = yes; then + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_static='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + lt_prog_compiler_pic='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + ;; + + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + ;; + + interix[3-9]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic=-Kconform_pic + fi + ;; + + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + else + lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static='-non_shared' + ;; + + linux* | k*bsd*-gnu) + case $cc_basename in + # old Intel for x86_64 which still supported -KPIC. + ecc*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='--shared' + lt_prog_compiler_static='--static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + ccc*) + lt_prog_compiler_wl='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + xl*) + # IBM XL C 8.0/Fortran 10.1 on PPC + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-qpic' + lt_prog_compiler_static='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C 5.9 + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Wl,' + ;; + *Sun\ F*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='' + ;; + esac + ;; + esac + ;; + + newsos6) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + + rdos*) + lt_prog_compiler_static='-non_shared' + ;; + + solaris*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + lt_prog_compiler_wl='-Qoption ld ';; + *) + lt_prog_compiler_wl='-Wl,';; + esac + ;; + + sunos4*) + lt_prog_compiler_wl='-Qoption ld ' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_prog_compiler_pic='-Kconform_pic' + lt_prog_compiler_static='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + unicos*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_can_build_shared=no + ;; + + uts4*) + lt_prog_compiler_pic='-pic' + lt_prog_compiler_static='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared=no + ;; + esac + fi + +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic= + ;; + *) + lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" + ;; +esac +{ $as_echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5 +$as_echo "$lt_prog_compiler_pic" >&6; } + + + + + + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic"; then + { $as_echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 +$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } +if test "${lt_cv_prog_compiler_pic_works+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_pic_works=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic -DPIC" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:7813: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:7817: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_pic_works=yes + fi + fi + $RM conftest* + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works" >&5 +$as_echo "$lt_cv_prog_compiler_pic_works" >&6; } + +if test x"$lt_cv_prog_compiler_pic_works" = xyes; then + case $lt_prog_compiler_pic in + "" | " "*) ;; + *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; + esac +else + lt_prog_compiler_pic= + lt_prog_compiler_can_build_shared=no +fi + +fi + + + + + + +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" +{ $as_echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } +if test "${lt_cv_prog_compiler_static_works+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_static_works=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_static_works=yes + fi + else + lt_cv_prog_compiler_static_works=yes + fi + fi + $RM -r conftest* + LDFLAGS="$save_LDFLAGS" + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works" >&5 +$as_echo "$lt_cv_prog_compiler_static_works" >&6; } + +if test x"$lt_cv_prog_compiler_static_works" = xyes; then + : +else + lt_prog_compiler_static= +fi + + + + + + + + { $as_echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if test "${lt_cv_prog_compiler_c_o+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_c_o=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:7918: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:7922: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5 +$as_echo "$lt_cv_prog_compiler_c_o" >&6; } + + + + + + + { $as_echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if test "${lt_cv_prog_compiler_c_o+set}" = set; then + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_c_o=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:7973: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:7977: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5 +$as_echo "$lt_cv_prog_compiler_c_o" >&6; } + + + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + { $as_echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +$as_echo_n "checking if we can lock with hard links... " >&6; } + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + { $as_echo "$as_me:$LINENO: result: $hard_links" >&5 +$as_echo "$hard_links" >&6; } + if test "$hard_links" = no; then + { $as_echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + + + + + + + { $as_echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + + runpath_var= + allow_undefined_flag= + always_export_symbols=no + archive_cmds= + archive_expsym_cmds= + compiler_needs_object=no + enable_shared_with_static_runtimes=no + export_dynamic_flag_spec= + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + hardcode_automatic=no + hardcode_direct=no + hardcode_direct_absolute=no + hardcode_libdir_flag_spec= + hardcode_libdir_flag_spec_ld= + hardcode_libdir_separator= + hardcode_minus_L=no + hardcode_shlibpath_var=unsupported + inherit_rpath=no + link_all_deplibs=unknown + module_cmds= + module_expsym_cmds= + old_archive_from_new_cmds= + old_archive_from_expsyms_cmds= + thread_safe_flag_spec= + whole_archive_flag_spec= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + ld_shlibs=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec= + fi + supports_anon_versioning=no + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[3-9]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='' + ;; + m68k) + archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + allow_undefined_flag=unsupported + always_export_symbols=no + enable_shared_with_static_runtimes=yes + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs=no + fi + ;; + + interix[3-9]*) + hardcode_direct=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu) + tmp_diet=no + if test "$host_os" = linux-dietlibc; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test "$tmp_diet" = no + then + tmp_addflag= + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + lf95*) # Lahey Fortran 8.1 + whole_archive_flag_spec= + tmp_sharedflag='--shared' ;; + xl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + compiler_needs_object=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test "x$supports_anon_versioning" = xyes; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + xlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' + hardcode_libdir_flag_spec= + hardcode_libdir_flag_spec_ld='-rpath $libdir' + archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + ld_shlibs=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test "$ld_shlibs" = no; then + runpath_var= + hardcode_libdir_flag_spec= + export_dynamic_flag_spec= + whole_archive_flag_spec= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix[4-9]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds='' + hardcode_direct=yes + hardcode_direct_absolute=yes + hardcode_libdir_separator=':' + link_all_deplibs=yes + file_list_spec='${wl}-f,' + + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + export_dynamic_flag_spec='${wl}-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag="-z nodefs" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag=' ${wl}-bernotok' + allow_undefined_flag=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec='$convenience' + archive_cmds_need_lc=yes + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='' + ;; + m68k) + archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + + bsdi[45]*) + export_dynamic_flag_spec=-rdynamic + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + enable_shared_with_static_runtimes=yes + ;; + + darwin* | rhapsody*) + + + archive_cmds_need_lc=no + hardcode_direct=no + hardcode_automatic=yes + hardcode_shlibpath_var=unsupported + whole_archive_flag_spec='' + link_all_deplibs=yes + allow_undefined_flag="$_lt_dar_allow_undefined" + case $cc_basename in + ifort*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test "$_lt_dar_can_shared" = "yes"; then + output_verbose_link_cmd=echo + archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + + else + ld_shlibs=no + fi + + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + freebsd1*) + ld_shlibs=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9*) + if test "$GCC" = yes; then + archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + export_dynamic_flag_spec='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_flag_spec_ld='+b $libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + hardcode_direct_absolute=yes + export_dynamic_flag_spec='${wl}-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + hardcode_shlibpath_var=no + ;; + *) + hardcode_direct=yes + hardcode_direct_absolute=yes + export_dynamic_flag_spec='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" + cat >conftest.$ac_ext <<_ACEOF +int foo(void) {} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' + +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS="$save_LDFLAGS" + else + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' + fi + archive_cmds_need_lc='no' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + inherit_rpath=yes + link_all_deplibs=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + newsos6) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_shlibpath_var=no + ;; + + *nto* | *qnx*) + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + hardcode_shlibpath_var=no + hardcode_direct_absolute=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + else + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + else + ld_shlibs=no + fi + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + fi + archive_cmds_need_lc='no' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + archive_cmds_need_lc='no' + hardcode_libdir_separator=: + ;; + + solaris*) + no_undefined_flag=' -z defs' + if test "$GCC" = yes; then + wlarc='${wl}' + archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='${wl}' + archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. GCC discards it without `$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test "$GCC" = yes; then + whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + else + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' + fi + ;; + esac + link_all_deplibs=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds='$CC -r -o $output$reload_objs' + hardcode_direct=no + ;; + motorola) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + no_undefined_flag='${wl}-z,text' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + no_undefined_flag='${wl}-z,text' + allow_undefined_flag='${wl}-z,nodefs' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='${wl}-R,$libdir' + hardcode_libdir_separator=':' + link_all_deplibs=yes + export_dynamic_flag_spec='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac + + if test x$host_vendor = xsni; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + export_dynamic_flag_spec='${wl}-Blargedynsym' + ;; + esac + fi + fi + +{ $as_echo "$as_me:$LINENO: result: $ld_shlibs" >&5 +$as_echo "$ld_shlibs" >&6; } +test "$ld_shlibs" = no && can_build_shared=no + +with_gnu_ld=$with_gnu_ld + + + + + + + + + + + + + + + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + { $as_echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl + pic_flag=$lt_prog_compiler_pic + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc=no + else + archive_cmds_need_lc=yes + fi + allow_undefined_flag=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + { $as_echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5 +$as_echo "$archive_cmds_need_lc" >&6; } + ;; + esac + fi + ;; +esac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +$as_echo_n "checking dynamic linker characteristics... " >&6; } + +if test "$GCC" = yes; then + case $host_os in + darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; + *) lt_awk_arg="/^libraries:/" ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` + else + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary. + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path/$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" + else + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' +BEGIN {RS=" "; FS="/|\n";} { + lt_foo=""; + lt_count=0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo="/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[lt_foo]++; } + if (lt_freq[lt_foo] == 1) { print lt_foo; } +}'` + sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix[4-9]*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[123]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix[3-9]*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # Some binutils ld are patched to set DT_RUNPATH + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ + LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then + shlibpath_overrides_runpath=yes +fi + +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +{ $as_echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +$as_echo "$dynamic_linker" >&6; } +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then + sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +fi +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then + sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +$as_echo_n "checking how to hardcode library paths into programs... " >&6; } +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || + test -n "$runpath_var" || + test "X$hardcode_automatic" = "Xyes" ; then + + # We can hardcode non-existent directories. + if test "$hardcode_direct" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && + test "$hardcode_minus_L" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +{ $as_echo "$as_me:$LINENO: result: $hardcode_action" >&5 +$as_echo "$hardcode_action" >&6; } + +if test "$hardcode_action" = relink || + test "$inherit_rpath" = yes; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + + + + + + + if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32* | cegcc*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + { $as_echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_dl_dlopen=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dl_dlopen=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + +fi + + ;; + + *) + { $as_echo "$as_me:$LINENO: checking for shl_load" >&5 +$as_echo_n "checking for shl_load... " >&6; } +if test "${ac_cv_func_shl_load+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define shl_load to an innocuous variant, in case declares shl_load. + For example, HP-UX 11i declares gettimeofday. */ +#define shl_load innocuous_shl_load + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char shl_load (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef shl_load + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char shl_load (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_shl_load || defined __stub___shl_load +choke me +#endif + +int +main () +{ +return shl_load (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_func_shl_load=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_shl_load=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 +$as_echo "$ac_cv_func_shl_load" >&6; } +if test "x$ac_cv_func_shl_load" = x""yes; then + lt_cv_dlopen="shl_load" +else + { $as_echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 +$as_echo_n "checking for shl_load in -ldld... " >&6; } +if test "${ac_cv_lib_dld_shl_load+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char shl_load (); +int +main () +{ +return shl_load (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_dld_shl_load=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dld_shl_load=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 +$as_echo "$ac_cv_lib_dld_shl_load" >&6; } +if test "x$ac_cv_lib_dld_shl_load" = x""yes; then + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" +else + { $as_echo "$as_me:$LINENO: checking for dlopen" >&5 +$as_echo_n "checking for dlopen... " >&6; } +if test "${ac_cv_func_dlopen+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define dlopen to an innocuous variant, in case declares dlopen. + For example, HP-UX 11i declares gettimeofday. */ +#define dlopen innocuous_dlopen + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char dlopen (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef dlopen + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_dlopen || defined __stub___dlopen +choke me +#endif + +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_func_dlopen=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_dlopen=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 +$as_echo "$ac_cv_func_dlopen" >&6; } +if test "x$ac_cv_func_dlopen" = x""yes; then + lt_cv_dlopen="dlopen" +else + { $as_echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_dl_dlopen=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dl_dlopen=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + { $as_echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 +$as_echo_n "checking for dlopen in -lsvld... " >&6; } +if test "${ac_cv_lib_svld_dlopen+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsvld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_svld_dlopen=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_svld_dlopen=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 +$as_echo "$ac_cv_lib_svld_dlopen" >&6; } +if test "x$ac_cv_lib_svld_dlopen" = x""yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" +else + { $as_echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 +$as_echo_n "checking for dld_link in -ldld... " >&6; } +if test "${ac_cv_lib_dld_dld_link+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dld_link (); +int +main () +{ +return dld_link (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_dld_dld_link=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dld_dld_link=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 +$as_echo "$ac_cv_lib_dld_dld_link" >&6; } +if test "x$ac_cv_lib_dld_dld_link" = x""yes; then + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" +fi + + +fi + + +fi + + +fi + + +fi + + +fi + + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + { $as_echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 +$as_echo_n "checking whether a program can dlopen itself... " >&6; } +if test "${lt_cv_dlopen_self+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +#line 10773 "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +} +_LT_EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self=no + fi +fi +rm -fr conftest* + + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 +$as_echo "$lt_cv_dlopen_self" >&6; } + + if test "x$lt_cv_dlopen_self" = xyes; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + { $as_echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 +$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } +if test "${lt_cv_dlopen_self_static+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self_static=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +#line 10869 "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +} +_LT_EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self_static=no + fi +fi +rm -fr conftest* + + +fi +{ $as_echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 +$as_echo "$lt_cv_dlopen_self_static" >&6; } + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + + + + + + + + + + + + + + + + + +striplib= +old_striplib= +{ $as_echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 +$as_echo_n "checking whether stripping libraries is possible... " >&6; } +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + fi + ;; + *) + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + ;; + esac +fi + + + + + + + + + + + + + # Report which library types will actually be built + { $as_echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 +$as_echo_n "checking if libtool supports shared libraries... " >&6; } + { $as_echo "$as_me:$LINENO: result: $can_build_shared" >&5 +$as_echo "$can_build_shared" >&6; } + + { $as_echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 +$as_echo_n "checking whether to build shared libraries... " >&6; } + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[4-9]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + { $as_echo "$as_me:$LINENO: result: $enable_shared" >&5 +$as_echo "$enable_shared" >&6; } + + { $as_echo "$as_me:$LINENO: checking whether to build static libraries" >&5 +$as_echo_n "checking whether to build static libraries... " >&6; } + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + { $as_echo "$as_me:$LINENO: result: $enable_static" >&5 +$as_echo "$enable_static" >&6; } + + + + +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC="$lt_save_CC" + + + + + + + + + + + + + + ac_config_commands="$ac_config_commands libtool" + + + + +# Only expand once: + + +{ $as_echo "$as_me:$LINENO: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } +fi + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + +done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_PERL+set}" = set; then + $as_echo_n "(cached) " >&6 +else + case $PERL in + [\\/]* | ?:[\\/]*) + ac_cv_path_PERL="$PERL" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_PERL="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + test -z "$ac_cv_path_PERL" && ac_cv_path_PERL="no" + ;; +esac +fi +PERL=$ac_cv_path_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:$LINENO: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + +if test "$PERL" = no; then + { $as_echo "$as_me:$LINENO: WARNING: perl not found" >&5 +$as_echo "$as_me: WARNING: perl not found" >&2;} + PERL=/usr/bin/perl +fi + +# Check whether --enable-largefile was given. +if test "${enable_largefile+set}" = set; then + enableval=$enable_largefile; +fi + +if test "$enable_largefile" != no; then + + { $as_echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5 +$as_echo_n "checking for special C compiler options needed for large files... " >&6; } +if test "${ac_cv_sys_largefile_CC+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_cv_sys_largefile_CC=no + if test "$GCC" != yes; then + ac_save_CC=$CC + while :; do + # IRIX 6.2 and later do not support large files by default, + # so use the C compiler's -n32 option if that helps. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF + rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + break +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext + CC="$CC -n32" + rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_sys_largefile_CC=' -n32'; break +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext + break + done + CC=$ac_save_CC + rm -f conftest.$ac_ext + fi +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5 +$as_echo "$ac_cv_sys_largefile_CC" >&6; } + if test "$ac_cv_sys_largefile_CC" != no; then + CC=$CC$ac_cv_sys_largefile_CC + fi + + { $as_echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5 +$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } +if test "${ac_cv_sys_file_offset_bits+set}" = set; then + $as_echo_n "(cached) " >&6 +else + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_sys_file_offset_bits=no; break +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#define _FILE_OFFSET_BITS 64 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_sys_file_offset_bits=64; break +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cv_sys_file_offset_bits=unknown + break +done +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5 +$as_echo "$ac_cv_sys_file_offset_bits" >&6; } +case $ac_cv_sys_file_offset_bits in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits +_ACEOF +;; +esac +rm -rf conftest* + if test $ac_cv_sys_file_offset_bits = unknown; then + { $as_echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5 +$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } +if test "${ac_cv_sys_large_files+set}" = set; then + $as_echo_n "(cached) " >&6 +else + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_sys_large_files=no; break +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#define _LARGE_FILES 1 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_sys_large_files=1; break +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cv_sys_large_files=unknown + break +done +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5 +$as_echo "$ac_cv_sys_large_files" >&6; } +case $ac_cv_sys_large_files in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _LARGE_FILES $ac_cv_sys_large_files +_ACEOF +;; +esac +rm -rf conftest* + fi +fi + + +{ $as_echo "$as_me:$LINENO: checking for ll modifier of printf" >&5 +$as_echo_n "checking for ll modifier of printf... " >&6; } +if test "${ac_cv_func_printf_ll+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +else + cat >conftest.$ac_ext <<_ACEOF + + #include + #include + #include + int main() { + char buffer[128]; + sprintf(buffer, "%llx", (unsigned long long) 1 << 32); + return (strcmp(buffer, "100000000") == 0) ? 0 : 1; + } + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_printf_ll=yes +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_printf_ll=no +fi +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_printf_ll" >&5 +$as_echo "$ac_cv_func_printf_ll" >&6; } +{ $as_echo "$as_me:$LINENO: checking for I64 modifier of printf" >&5 +$as_echo_n "checking for I64 modifier of printf... " >&6; } +if test "${ac_cv_func_printf_i64+set}" = set; then + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +else + cat >conftest.$ac_ext <<_ACEOF + + #include + #include + #include + int main() { + char buffer[128]; + sprintf(buffer, "%I64x", (unsigned __int64) 1 << 32); + return (strcmp(buffer, "100000000") == 0) ? 0 : 1; + } + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_printf_i64=yes +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_printf_i64=no +fi +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_printf_i64" >&5 +$as_echo "$ac_cv_func_printf_i64" >&6; } +if test "$ac_cv_func_printf_ll" = yes; then + +cat >>confdefs.h <<\_ACEOF +#define PRINTF_LL_MODIFIER 1 +_ACEOF + +fi +if test "$ac_cv_func_printf_i64" = yes; then + +cat >>confdefs.h <<\_ACEOF +#define PRINTF_I64_MODIFIER 1 +_ACEOF + +fi + + INTLINCS= + INTLDEPS= + INTLLIBS= + + + + + + +for ac_header in locale.h nl_types.h +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_func in setlocale +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + if test $ac_cv_header_locale_h = yes; then + { $as_echo "$as_me:$LINENO: checking for LC_MESSAGES" >&5 +$as_echo_n "checking for LC_MESSAGES... " >&6; } +if test "${am_cv_val_LC_MESSAGES+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF + +#include +int +main() +{ + return LC_MESSAGES; +} + +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + am_cv_val_LC_MESSAGES=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + am_cv_val_LC_MESSAGES=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $am_cv_val_LC_MESSAGES" >&5 +$as_echo "$am_cv_val_LC_MESSAGES" >&6; } + if test $am_cv_val_LC_MESSAGES = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_LC_MESSAGES 1 +_ACEOF + + fi + fi + + # Check whether --enable-nls was given. +if test "${enable_nls+set}" = set; then + enableval=$enable_nls; ENABLE_NLS=$enableval +else + ENABLE_NLS=auto +fi + + + +# Check whether --with-gettext-includes was given. +if test "${with_gettext_includes+set}" = set; then + withval=$with_gettext_includes; gettext_includes="-I${withval}" +else + gettext_includes='' +fi + + + +# Check whether --with-gettext-libraries was given. +if test "${with_gettext_libraries+set}" = set; then + withval=$with_gettext_libraries; gettext_libraries="-L${withval}" +else + gettext_libraries='' +fi + + + +# Check whether --with-iconv-includes was given. +if test "${with_iconv_includes+set}" = set; then + withval=$with_iconv_includes; iconv_includes="-I${withval}" +else + iconv_includes='' +fi + + + +# Check whether --with-iconv-libraries was given. +if test "${with_iconv_libraries+set}" = set; then + withval=$with_iconv_libraries; iconv_libraries="-L${withval}" +else + iconv_libraries='' +fi + + + ICONVINCS= + ICONVLIBS= + save_CPPFLAGS=$CPPFLAGS + save_LIBS=$LIBS + CPPFLAGS="$save_CPPFLAGS $iconv_includes" + LIBS="$save_LIBS $iconv_libraries" + { $as_echo "$as_me:$LINENO: checking for iconv_open in -liconv" >&5 +$as_echo_n "checking for iconv_open in -liconv... " >&6; } +if test "${ac_cv_lib_iconv_iconv_open+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-liconv $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char iconv_open (); +int +main () +{ +return iconv_open (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_iconv_iconv_open=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_iconv_iconv_open=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_iconv_iconv_open" >&5 +$as_echo "$ac_cv_lib_iconv_iconv_open" >&6; } +if test "x$ac_cv_lib_iconv_iconv_open" = x""yes; then + ICONVLIBS="$iconv_libraries -liconv"; LIBS="$LIBS -liconv" +fi + + + +for ac_func in iconv_open locale_charset +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + +for ac_header in iconv.h libcharset.h +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + if test $ac_cv_func_iconv_open != no; then + ICONVINCS="$iconv_includes" + fi + CPPFLAGS=$save_CPPFLAGS + LIBS=$save_LIBS + + + + INTLINCS= + INTLLIBS= + try_nls=no + + { $as_echo "$as_me:$LINENO: checking for NLS support" >&5 +$as_echo_n "checking for NLS support... " >&6; } + + if test $ENABLE_NLS != no; then + save_CPPFLAGS=$CPPFLAGS + save_LIBS=$LIBS + + CPPFLAGS="$save_CPPFLAGS $gettext_includes" + LIBS="$save_LIBS $gettext_libraries -lintl $iconv_libraries -liconv" + cat >conftest.$ac_ext <<_ACEOF + +#include +#ifdef ENABLE_NLS +#undef ENABLE_NLS +#endif +#define ENABLE_NLS 1 +#ifdef HAVE_LOCALE_H +#include +#endif +#include + +int +main() +{ +#ifdef HAVE_SETLOCALE + setlocale(LC_ALL, ""); +#endif + bindtextdomain("gttest", ".locale"); + textdomain("gttest"); + gettext("foo"); + return 0; +} + +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + try_nls=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + try_nls=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + + if test "$try_nls" = yes; then + INTLINCS="$gettext_includes" + INTLLIBS="$gettext_libraries -lintl $iconv_libraries -liconv" + fi + + if test "$try_nls" = no; then + CPPFLAGS="$save_CPPFLAGS $gettext_includes" + LIBS="$save_LIBS $gettext_libraries -lintl" + cat >conftest.$ac_ext <<_ACEOF + +#include +#ifdef ENABLE_NLS +#undef ENABLE_NLS +#endif +#define ENABLE_NLS 1 +#ifdef HAVE_LOCALE_H +#include +#endif +#include + +int +main() +{ +#ifdef HAVE_SETLOCALE + setlocale(LC_ALL, ""); +#endif + bindtextdomain("gttest", ".locale"); + textdomain("gttest"); + gettext("foo"); + return 0; +} + +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + try_nls=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + try_nls=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + + if test "$try_nls" = yes; then + INTLINCS="$gettext_includes" + INTLLIBS="$gettext_libraries -lintl" + fi + fi + + if test "$try_nls" = no; then + CPPFLAGS="$save_CPPFLAGS" + LIBS="$save_LIBS $iconv_libraries -liconv" + cat >conftest.$ac_ext <<_ACEOF + +#include +#ifdef ENABLE_NLS +#undef ENABLE_NLS +#endif +#define ENABLE_NLS 1 +#ifdef HAVE_LOCALE_H +#include +#endif +#include + +int +main() +{ +#ifdef HAVE_SETLOCALE + setlocale(LC_ALL, ""); +#endif + bindtextdomain("gttest", ".locale"); + textdomain("gttest"); + gettext("foo"); + return 0; +} + +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + try_nls=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + try_nls=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + + if test "$try_nls" = yes; then + INTLINCS= + INTLLIBS="$iconv_libraries -liconv" + fi + fi + + if test "$try_nls" = no; then + CPPFLAGS="$save_CPPFLAGS" + LIBS="$save_LIBS" + cat >conftest.$ac_ext <<_ACEOF + +#include +#ifdef ENABLE_NLS +#undef ENABLE_NLS +#endif +#define ENABLE_NLS 1 +#ifdef HAVE_LOCALE_H +#include +#endif +#include + +int +main() +{ +#ifdef HAVE_SETLOCALE + setlocale(LC_ALL, ""); +#endif + bindtextdomain("gttest", ".locale"); + textdomain("gttest"); + gettext("foo"); + return 0; +} + +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + try_nls=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + try_nls=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + + if test "$try_nls" = yes; then + INTLINCS= + INTLLIBS= + fi + fi + + CPPFLAGS=$save_CPPFLAGS + LIBS=$save_LIBS + fi + + if test $ENABLE_NLS = auto; then + ENABLE_NLS=$try_nls + fi + + { $as_echo "$as_me:$LINENO: result: $try_nls" >&5 +$as_echo "$try_nls" >&6; } + + if test $ENABLE_NLS = yes; then + if test $try_nls = no; then + { { $as_echo "$as_me:$LINENO: error: gettext not available" >&5 +$as_echo "$as_me: error: gettext not available" >&2;} + { (exit 1); exit 1; }; } + fi + fi + + + + + localedir='$(datadir)/locale' + + if test $ENABLE_NLS = yes; then + +cat >>confdefs.h <<\_ACEOF +#define ENABLE_NLS 1 +_ACEOF + + fi + + for ac_prog in gmsgfmt msgfmt +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_MSGFMT+set}" = set; then + $as_echo_n "(cached) " >&6 +else + case $MSGFMT in + [\\/]* | ?:[\\/]*) + ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_MSGFMT="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + ;; +esac +fi +MSGFMT=$ac_cv_path_MSGFMT +if test -n "$MSGFMT"; then + { $as_echo "$as_me:$LINENO: result: $MSGFMT" >&5 +$as_echo "$MSGFMT" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$MSGFMT" && break +done +test -n "$MSGFMT" || MSGFMT=":" + + for ac_prog in gxgettext xgettext +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_XGETTEXT+set}" = set; then + $as_echo_n "(cached) " >&6 +else + case $XGETTEXT in + [\\/]* | ?:[\\/]*) + ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_XGETTEXT="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + ;; +esac +fi +XGETTEXT=$ac_cv_path_XGETTEXT +if test -n "$XGETTEXT"; then + { $as_echo "$as_me:$LINENO: result: $XGETTEXT" >&5 +$as_echo "$XGETTEXT" >&6; } +else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$XGETTEXT" && break +done +test -n "$XGETTEXT" || XGETTEXT=":" + + MSGMERGE=msgmerge + + + +# Check whether --enable-samples was given. +if test "${enable_samples+set}" = set; then + enableval=$enable_samples; case "${enableval}" in + yes) samples=true ;; + no) samples=false ;; + *) { { $as_echo "$as_me:$LINENO: error: invalid argument to --enable-samples" >&5 +$as_echo "$as_me: error: invalid argument to --enable-samples" >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + samples=false +fi + + if test ${samples} = true; then + ENABLE_SAMPLES_TRUE= + ENABLE_SAMPLES_FALSE='#' +else + ENABLE_SAMPLES_TRUE='#' + ENABLE_SAMPLES_FALSE= +fi + + +# Check whether --enable-pthread was given. +if test "${enable_pthread+set}" = set; then + enableval=$enable_pthread; case "${enableval}" in + yes) ENABLE_PTHREAD=yes ;; + no) ENABLE_PTHREAD=no ;; + *) { { $as_echo "$as_me:$LINENO: error: invalid argument to --enable-pthread" >&5 +$as_echo "$as_me: error: invalid argument to --enable-pthread" >&2;} + { (exit 1); exit 1; }; } ;; +esac +else + ENABLE_PTHREAD=no +fi + + + +# Check whether --with-pthread-cppflags was given. +if test "${with_pthread_cppflags+set}" = set; then + withval=$with_pthread_cppflags; PTHREAD_CPPFLAGS="${withval}" +else + PTHREAD_CPPFLAGS='' +fi + + + +# Check whether --with-pthread-cflags was given. +if test "${with_pthread_cflags+set}" = set; then + withval=$with_pthread_cflags; PTHREAD_CFLAGS="${withval}" +else + PTHREAD_CFLAGS='' +fi + + + +# Check whether --with-pthread-ldflags was given. +if test "${with_pthread_ldflags+set}" = set; then + withval=$with_pthread_ldflags; PTHREAD_LDFLAGS="${withval}" +else + PTHREAD_LDFLAGS='' +fi + + + +# Check whether --with-pkgdocdir was given. +if test "${with_pkgdocdir+set}" = set; then + withval=$with_pkgdocdir; pkgdocdir="${withval}" +else + pkgdocdir='${datadir}/eb/doc' +fi + + + +{ $as_echo "$as_me:$LINENO: checking for pthread" >&5 +$as_echo_n "checking for pthread... " >&6; } +if test $ENABLE_PTHREAD = no; then + try_pthread=no +else + save_CPPFLAGS=$CPPFLAGS + save_CFLAGS=$CFLAGS + save_LDFLAGS=$LDFLAGS + CPPFLAGS="$CPPFLAGS $PTHREAD_CPPFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LDFLAGS="$LDFLAGS $PTHREAD_LDFLAGS" + cat >conftest.$ac_ext <<_ACEOF + +#include +static pthread_mutex_t m=PTHREAD_MUTEX_INITIALIZER; + +int +main() +{ + pthread_mutex_lock(&m); + return 0; +} + +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + try_pthread=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + try_pthread=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + CPPFLAGS=$save_CPPFLAGS + CFLAGS=$save_CFLAGS + LDFLAGS=$save_LDFLAGS +fi +{ $as_echo "$as_me:$LINENO: result: $try_pthread" >&5 +$as_echo "$try_pthread" >&6; } +if test $ENABLE_PTHREAD = yes; then + if test $try_pthread = no; then + { { $as_echo "$as_me:$LINENO: error: pthread not available" >&5 +$as_echo "$as_me: error: pthread not available" >&2;} + { (exit 1); exit 1; }; } + fi +fi + +if test $ENABLE_PTHREAD = yes; then + +cat >>confdefs.h <<\_ACEOF +#define ENABLE_PTHREAD 1 +_ACEOF + + CPPFLAGS="$CPPFLAGS $PTHREAD_CPPFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LDFLAGS="$LDFLAGS $PTHREAD_LDFLAGS" +fi + + +# Check whether --with-zlib-includes was given. +if test "${with_zlib_includes+set}" = set; then + withval=$with_zlib_includes; z_includedir="${withval}" +else + z_includedir='' +fi + + +if test "X$z_includedir" != X; then + ZLIBINCS="-I$z_includedir" +else + ZLIBINCS='' +fi + + +# Check whether --with-zlib-libraries was given. +if test "${with_zlib_libraries+set}" = set; then + withval=$with_zlib_libraries; z_libdir="${withval}" +else + z_libdir='' +fi + + +if test "X$z_libdir" != X; then + ZLIBLIBS="-L$z_libdir -lz" + ZLIBDEPS='' +else + ZLIBLIBS='-lz' + ZLIBDEPS='' +fi + +{ $as_echo "$as_me:$LINENO: checking for zlib" >&5 +$as_echo_n "checking for zlib... " >&6; } +save_CPPFLAGS=$CPPFLAGS +save_LIBS=$LIBS +CPPFLAGS="$CPPFLAGS $ZLIBINCS" +LIBS="$LIBS $ZLIBLIBS" +cat >conftest.$ac_ext <<_ACEOF + +#include + +int +main() +{ + z_stream stream; inflate(&stream, Z_FINISH); + return 0; +} + +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + try_zlib=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + try_zlib=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +CPPFLAGS=$save_CPPFLAGS +LIBS=$save_LIBS +{ $as_echo "$as_me:$LINENO: result: $try_zlib" >&5 +$as_echo "$try_zlib" >&6; } +if test $try_zlib = no; then + { { $as_echo "$as_me:$LINENO: error: zlib not found" >&5 +$as_echo "$as_me: error: zlib not found" >&2;} + { (exit 1); exit 1; }; } +fi + + + + +# Check whether --enable-ebnet was given. +if test "${enable_ebnet+set}" = set; then + enableval=$enable_ebnet; ENABLE_EBNET="${enableval}" +else + ENABLE_EBNET='yes' +fi + + + if test X$ENABLE_EBNET = Xyes; then + ENABLE_EBNET_TRUE= + ENABLE_EBNET_FALSE='#' +else + ENABLE_EBNET_TRUE='#' + ENABLE_EBNET_FALSE= +fi + + +# Check whether --enable-ipv6 was given. +if test "${enable_ipv6+set}" = set; then + enableval=$enable_ipv6; ENABLE_IPV6="${enableval}" +else + ENABLE_IPV6='auto' +fi + + + + + + + +for ac_header in direct.h langinfo.h mbstring.h pthread.h +do +as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 +$as_echo_n "checking $ac_header usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 +$as_echo_n "checking $ac_header presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 +$as_echo_n "checking for $ac_header... " >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + +fi +as_val=`eval 'as_val=${'$as_ac_Header'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + +{ $as_echo "$as_me:$LINENO: checking for res_query in -lresolv" >&5 +$as_echo_n "checking for res_query in -lresolv... " >&6; } +if test "${ac_cv_lib_resolv_res_query+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lresolv $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char res_query (); +int +main () +{ +return res_query (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_resolv_res_query=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_resolv_res_query=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_resolv_res_query" >&5 +$as_echo "$ac_cv_lib_resolv_res_query" >&6; } +if test "x$ac_cv_lib_resolv_res_query" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBRESOLV 1 +_ACEOF + + LIBS="-lresolv $LIBS" + +fi + +if test "$ac_cv_lib_resolv_res_query" = no; then + +{ $as_echo "$as_me:$LINENO: checking for res_query in -lbind" >&5 +$as_echo_n "checking for res_query in -lbind... " >&6; } +if test "${ac_cv_lib_bind_res_query+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lbind $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char res_query (); +int +main () +{ +return res_query (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_bind_res_query=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_bind_res_query=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_bind_res_query" >&5 +$as_echo "$ac_cv_lib_bind_res_query" >&6; } +if test "x$ac_cv_lib_bind_res_query" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBBIND 1 +_ACEOF + + LIBS="-lbind $LIBS" + +fi + +fi + +{ $as_echo "$as_me:$LINENO: checking for gethostname in -lnsl" >&5 +$as_echo_n "checking for gethostname in -lnsl... " >&6; } +if test "${ac_cv_lib_nsl_gethostname+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lnsl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char gethostname (); +int +main () +{ +return gethostname (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_nsl_gethostname=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_nsl_gethostname=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostname" >&5 +$as_echo "$ac_cv_lib_nsl_gethostname" >&6; } +if test "x$ac_cv_lib_nsl_gethostname" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBNSL 1 +_ACEOF + + LIBS="-lnsl $LIBS" + +fi + + +{ $as_echo "$as_me:$LINENO: checking for socket in -lsocket" >&5 +$as_echo_n "checking for socket in -lsocket... " >&6; } +if test "${ac_cv_lib_socket_socket+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsocket $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char socket (); +int +main () +{ +return socket (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_socket_socket=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_socket_socket=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_socket_socket" >&5 +$as_echo "$ac_cv_lib_socket_socket" >&6; } +if test "x$ac_cv_lib_socket_socket" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSOCKET 1 +_ACEOF + + LIBS="-lsocket $LIBS" + +fi + + + + + + +for ac_func in nl_langinfo _getdcwd atoll _atoi64 +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +for ac_func in strcasecmp +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +else + case " $LIBOBJS " in + *" $ac_func.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext" + ;; +esac + +fi +done + + + +{ $as_echo "$as_me:$LINENO: checking for mode_t" >&5 +$as_echo_n "checking for mode_t... " >&6; } +if test "${ac_cv_type_mode_t+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_cv_type_mode_t=no +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if (sizeof (mode_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if (sizeof ((mode_t))) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_mode_t=yes +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_mode_t" >&5 +$as_echo "$ac_cv_type_mode_t" >&6; } +if test "x$ac_cv_type_mode_t" = x""yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define mode_t int +_ACEOF + +fi + +{ $as_echo "$as_me:$LINENO: checking for ssize_t" >&5 +$as_echo_n "checking for ssize_t... " >&6; } +if test "${ac_cv_type_ssize_t+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_cv_type_ssize_t=no +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if (sizeof (ssize_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if (sizeof ((ssize_t))) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_ssize_t=yes +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_ssize_t" >&5 +$as_echo "$ac_cv_type_ssize_t" >&6; } +if test "x$ac_cv_type_ssize_t" = x""yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define ssize_t int +_ACEOF + +fi + + + + + if test X$ac_exeext = Xyes; then + EXEEXT_EXE_TRUE= + EXEEXT_EXE_FALSE='#' +else + EXEEXT_EXE_TRUE='#' + EXEEXT_EXE_FALSE= +fi + +if test X$ac_exeext = X.exe; then + +cat >>confdefs.h <<\_ACEOF +#define EXEEXT_EXE 1 +_ACEOF + +fi + +if test "$ENABLE_EBNET" = yes; then + +cat >>confdefs.h <<\_ACEOF +#define ENABLE_EBNET 1 +_ACEOF + + + { $as_echo "$as_me:$LINENO: checking for in_port_t" >&5 +$as_echo_n "checking for in_port_t... " >&6; } +if test "${ac_cv_type_in_port_t+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF + +#include +#include +#include +in_port_t in_port; + +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_in_port_t=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_in_port_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_in_port_t" >&5 +$as_echo "$ac_cv_type_in_port_t" >&6; } +if test "$ac_cv_type_in_port_t" != yes; then + ac_cv_sin_port_size=unknown + if test "$cross_compiling" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +else + cat >conftest.$ac_ext <<_ACEOF + + #include + #include + #include + int main() { + struct sockaddr_in addr; + return (sizeof(addr.sin_port) == sizeof(long)) ? 0 : 1; + } + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sin_port_size=long +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + + if test "$cross_compiling" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +else + cat >conftest.$ac_ext <<_ACEOF + + #include + #include + #include + int main() { + struct sockaddr_in addr; + return (sizeof(addr.sin_port) == sizeof(int)) ? 0 : 1; + } + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sin_port_size=int +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + + if test "$cross_compiling" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +else + cat >conftest.$ac_ext <<_ACEOF + + #include + #include + #include + int main() { + struct sockaddr_in addr; + return (sizeof(addr.sin_port) == sizeof(short)) ? 0 : 1; + } + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sin_port_size=short +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + + if test "$cross_compiling" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +else + cat >conftest.$ac_ext <<_ACEOF + + #include + #include + #include + int main() { + struct sockaddr_in addr; + return (sizeof(addr.sin_port) == sizeof(char)) ? 0 : 1; + } + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sin_port_size=char +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + + if test "$ac_cv_sin_port_size" = unknown; then + { { $as_echo "$as_me:$LINENO: error: Failed to get size of sin_port in struct sockaddr_in." >&5 +$as_echo "$as_me: error: Failed to get size of sin_port in struct sockaddr_in." >&2;} + { (exit 1); exit 1; }; } + fi + +cat >>confdefs.h <<_ACEOF +#define in_port_t unsigned $ac_cv_sin_port_size +_ACEOF + +fi + { $as_echo "$as_me:$LINENO: checking for sa_family_t" >&5 +$as_echo_n "checking for sa_family_t... " >&6; } +if test "${ac_cv_type_sa_family_t+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF + +#include +#include +sa_family_t sa_family; + +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_sa_family_t=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_sa_family_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_sa_family_t" >&5 +$as_echo "$ac_cv_type_sa_family_t" >&6; } +if test "$ac_cv_type_sa_family_t" != yes; then + ac_cv_sa_family_size=unknown + if test "$cross_compiling" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +else + cat >conftest.$ac_ext <<_ACEOF + + #include + #include + int main() { + struct sockaddr addr; + return (sizeof(addr.sa_family) == sizeof(long)) ? 0 : 1; + } + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sa_family_size=long +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + + if test "$cross_compiling" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +else + cat >conftest.$ac_ext <<_ACEOF + + #include + #include + int main() { + struct sockaddr addr; + return (sizeof(addr.sa_family) == sizeof(int)) ? 0 : 1; + } + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sa_family_size=int +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + + if test "$cross_compiling" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +else + cat >conftest.$ac_ext <<_ACEOF + + #include + #include + int main() { + struct sockaddr addr; + return (sizeof(addr.sa_family) == sizeof(short)) ? 0 : 1; + } + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sa_family_size=short +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + + if test "$cross_compiling" = yes; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +else + cat >conftest.$ac_ext <<_ACEOF + + #include + #include + int main() { + struct sockaddr addr; + return (sizeof(addr.sa_family) == sizeof(char)) ? 0 : 1; + } + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sa_family_size=char +else + $as_echo "$as_me: program exited with status $ac_status" >&5 +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -rf conftest.dSYM +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + + if test "$ac_cv_sa_family_size" = unknown; then + { { $as_echo "$as_me:$LINENO: error: Failed to get size of sa_family in struct sockaddr." >&5 +$as_echo "$as_me: error: Failed to get size of sa_family in struct sockaddr." >&2;} + { (exit 1); exit 1; }; } + fi + +cat >>confdefs.h <<_ACEOF +#define sa_family_t unsigned $ac_cv_sa_family_size +_ACEOF + +fi + { $as_echo "$as_me:$LINENO: checking for socklen_t" >&5 +$as_echo_n "checking for socklen_t... " >&6; } +if test "${ac_cv_type_socklen_t+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF + +#include +#include +socklen_t socklen; + +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_socklen_t=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_socklen_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_socklen_t" >&5 +$as_echo "$ac_cv_type_socklen_t" >&6; } +if test "$ac_cv_type_socklen_t" != yes; then + +cat >>confdefs.h <<\_ACEOF +#define socklen_t int +_ACEOF + +fi + { $as_echo "$as_me:$LINENO: checking for struct in6_addr" >&5 +$as_echo_n "checking for struct in6_addr... " >&6; } +if test "${ac_cv_struct_in6_addr+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF + +#include +#include +#include +struct in6_addr address; + +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_struct_in6_addr=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_struct_in6_addr=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_struct_in6_addr" >&5 +$as_echo "$ac_cv_struct_in6_addr" >&6; } +if test "$ac_cv_struct_in6_addr" = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_STRUCT_IN6_ADDR 1 +_ACEOF + +fi + { $as_echo "$as_me:$LINENO: checking for struct sockaddr_in6" >&5 +$as_echo_n "checking for struct sockaddr_in6... " >&6; } +if test "${ac_cv_struct_sockaddr_in6+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF + +#include +#include +#include +struct sockaddr_in6 address; + +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_struct_sockaddr_in6=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_struct_sockaddr_in6=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_struct_sockaddr_in6" >&5 +$as_echo "$ac_cv_struct_sockaddr_in6" >&6; } +if test "$ac_cv_struct_sockaddr_in6" = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_STRUCT_SOCKADDR_IN6 1 +_ACEOF + +fi + { $as_echo "$as_me:$LINENO: checking for struct sockaddr_storage" >&5 +$as_echo_n "checking for struct sockaddr_storage... " >&6; } +if test "${ac_cv_struct_sockaddr_storage+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF + +#include +#include +#include +struct sockaddr_storage address; + +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_struct_sockaddr_storage=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_struct_sockaddr_storage=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_struct_sockaddr_storage" >&5 +$as_echo "$ac_cv_struct_sockaddr_storage" >&6; } +if test "$ac_cv_struct_sockaddr_storage" = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_STRUCT_SOCKADDR_STORAGE 1 +_ACEOF + +fi + +if test $ac_cv_struct_in6_addr = no; then + ac_cv_decl_in6addr_any=no +else + { $as_echo "$as_me:$LINENO: checking for in6addr_any declaration in netinet/in.h" >&5 +$as_echo_n "checking for in6addr_any declaration in netinet/in.h... " >&6; } +if test "${ac_cv_decl_in6addr_any+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF + +#include +#include +#include + +void +testfunc() +{ + unsigned char *address; + address = (char *)&in6addr_any; +} + +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_decl_in6addr_any=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_decl_in6addr_any=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_decl_in6addr_any" >&5 +$as_echo "$ac_cv_decl_in6addr_any" >&6; } + if test "$ac_cv_decl_in6addr_any" = yes; then + +cat >>confdefs.h <<\_ACEOF +#define IN6ADDR_ANY_DECLARED 1 +_ACEOF + + fi +fi + +if test $ac_cv_struct_in6_addr = no; then + ac_cv_decl_in6addr_loopback=no +else + { $as_echo "$as_me:$LINENO: checking for in6addr_loopback declaration in netinet/in.h" >&5 +$as_echo_n "checking for in6addr_loopback declaration in netinet/in.h... " >&6; } +if test "${ac_cv_decl_in6addr_loopback+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF + +#include +#include +#include + +int +testfunc() +{ + unsigned char *address; + address = (char *)&in6addr_loopback; +} + +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_decl_in6addr_loopback=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_decl_in6addr_loopback=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_decl_in6addr_loopback" >&5 +$as_echo "$ac_cv_decl_in6addr_loopback" >&6; } + if test "$ac_cv_decl_in6addr_loopback" = yes; then + +cat >>confdefs.h <<\_ACEOF +#define IN6ADDR_LOOPBACK_DECLARED 1 +_ACEOF + + fi +fi + + + + +for ac_func in getaddrinfo getnameinfo gai_strerror +do +as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 +$as_echo_n "checking for $ac_func... " >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + eval "$as_ac_var=yes" +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +as_val=`eval 'as_val=${'$as_ac_var'} + $as_echo "$as_val"'` + if test "x$as_val" = x""yes; then + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + if test "$ENABLE_IPV6" = auto; then + if test "$ac_cv_struct_in6_addr$ac_cv_func_getaddrinfo" = yesyes; then + ENABLE_IPV6=yes + else + ENABLE_IPV6=no + fi + fi + + { $as_echo "$as_me:$LINENO: checking for IPv6 support" >&5 +$as_echo_n "checking for IPv6 support... " >&6; } + if test "$ENABLE_IPV6" = yes; then + if test "$ac_cv_struct_in6_addr" = no; then + { { $as_echo "$as_me:$LINENO: error: IPv6 not available" >&5 +$as_echo "$as_me: error: IPv6 not available" >&2;} + { (exit 1); exit 1; }; } + fi + if test "${ac_cv_func_getaddrinfo}" = no; then + { { $as_echo "$as_me:$LINENO: error: IPv6 not available" >&5 +$as_echo "$as_me: error: IPv6 not available" >&2;} + { (exit 1); exit 1; }; } + fi + +cat >>confdefs.h <<\_ACEOF +#define ENABLE_IPV6 1 +_ACEOF + + fi + { $as_echo "$as_me:$LINENO: result: $ENABLE_IPV6" >&5 +$as_echo "$ENABLE_IPV6" >&6; } +fi + +EBCONF_ZLIBINCS=$ZLIBINCS +EBCONF_ZLIBLIBS=$ZLIBLIBS + + + + + + + + +EBCONF_INTLINCS=$INTLINCS +EBCONF_INTLLIBS=$INTLLIBS + + + +EBCONF_EBINCS='-I$(includedir)' +EBCONF_EBLIBS='-L$(libdir) -leb' + + + +ac_config_headers="$ac_config_headers config.h" + +ac_config_files="$ac_config_files Makefile eb/Makefile libebutils/Makefile ebappendix/Makefile ebfont/Makefile ebinfo/Makefile ebrefile/Makefile ebstopcode/Makefile ebzip/Makefile doc/Makefile po-eb/Makefile po-ebutils/Makefile m4/Makefile samples/Makefile" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${ENABLE_SAMPLES_TRUE}" && test -z "${ENABLE_SAMPLES_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"ENABLE_SAMPLES\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"ENABLE_SAMPLES\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${ENABLE_EBNET_TRUE}" && test -z "${ENABLE_EBNET_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"ENABLE_EBNET\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"ENABLE_EBNET\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${EXEEXT_EXE_TRUE}" && test -z "${EXEEXT_EXE_FALSE}"; then + { { $as_echo "$as_me:$LINENO: error: conditional \"EXEEXT_EXE\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +$as_echo "$as_me: error: conditional \"EXEEXT_EXE\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi + +: ${CONFIG_STATUS=./config.status} +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 + +# Save the log message, to keep $[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by eb $as_me 4.4.3, which was +generated by GNU Autoconf 2.63. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTION]... [FILE]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_version="\\ +eb config.status 4.4.3 +configured by $0, generated by GNU Autoconf 2.63, + with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2008 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' +AWK='$AWK' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + CONFIG_FILES="$CONFIG_FILES '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + { $as_echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { $as_echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# +# INIT-COMMANDS +# +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`' +macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`' +enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`' +enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`' +pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`' +enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`' +host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`' +host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`' +host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`' +build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`' +build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`' +build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`' +SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`' +Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`' +GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`' +EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`' +FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`' +LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`' +NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`' +LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`' +max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`' +ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`' +exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`' +lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`' +lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`' +lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`' +reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`' +reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`' +OBJDUMP='`$ECHO "X$OBJDUMP" | $Xsed -e "$delay_single_quote_subst"`' +deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`' +file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`' +AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`' +AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`' +STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`' +RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`' +old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' +old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' +old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' +CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`' +CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`' +compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`' +GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' +objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`' +SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`' +ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`' +MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`' +need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`' +DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`' +NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`' +LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`' +OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`' +OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`' +libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`' +shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`' +extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' +archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`' +enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`' +export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' +whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' +compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`' +old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`' +old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' +archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' +archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' +module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`' +module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' +with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`' +allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' +no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`' +inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`' +link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`' +fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`' +always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`' +export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`' +exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`' +include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`' +prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`' +file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`' +variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`' +need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' +need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`' +version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`' +runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`' +shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' +shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`' +libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`' +library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`' +soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`' +postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' +postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' +finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`' +finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`' +sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`' +sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`' +enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`' +enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`' +enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`' +old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`' +striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`' + +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# Quote evaled strings. +for var in SED \ +GREP \ +EGREP \ +FGREP \ +LD \ +NM \ +LN_S \ +lt_SP2NL \ +lt_NL2SP \ +reload_flag \ +OBJDUMP \ +deplibs_check_method \ +file_magic_cmd \ +AR \ +AR_FLAGS \ +STRIP \ +RANLIB \ +CC \ +CFLAGS \ +compiler \ +lt_cv_sys_global_symbol_pipe \ +lt_cv_sys_global_symbol_to_cdecl \ +lt_cv_sys_global_symbol_to_c_name_address \ +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ +SHELL \ +ECHO \ +lt_prog_compiler_no_builtin_flag \ +lt_prog_compiler_wl \ +lt_prog_compiler_pic \ +lt_prog_compiler_static \ +lt_cv_prog_compiler_c_o \ +need_locks \ +DSYMUTIL \ +NMEDIT \ +LIPO \ +OTOOL \ +OTOOL64 \ +shrext_cmds \ +export_dynamic_flag_spec \ +whole_archive_flag_spec \ +compiler_needs_object \ +with_gnu_ld \ +allow_undefined_flag \ +no_undefined_flag \ +hardcode_libdir_flag_spec \ +hardcode_libdir_flag_spec_ld \ +hardcode_libdir_separator \ +fix_srcfile_path \ +exclude_expsyms \ +include_expsyms \ +file_list_spec \ +variables_saved_for_relink \ +libname_spec \ +library_names_spec \ +soname_spec \ +finish_eval \ +old_striplib \ +striplib; do + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in reload_cmds \ +old_postinstall_cmds \ +old_postuninstall_cmds \ +old_archive_cmds \ +extract_expsyms_cmds \ +old_archive_from_new_cmds \ +old_archive_from_expsyms_cmds \ +archive_cmds \ +archive_expsym_cmds \ +module_cmds \ +module_expsym_cmds \ +export_symbols_cmds \ +prelink_cmds \ +postinstall_cmds \ +postuninstall_cmds \ +finish_cmds \ +sys_lib_search_path_spec \ +sys_lib_dlsearch_path_spec; do + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Fix-up fallback echo if it was mangled by the above quoting rules. +case \$lt_ECHO in +*'\\\$0 --fallback-echo"') lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\` + ;; +esac + +ac_aux_dir='$ac_aux_dir' +xsi_shell='$xsi_shell' +lt_shell_append='$lt_shell_append' + +# See if we are running on zsh, and set the options which allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi + + + PACKAGE='$PACKAGE' + VERSION='$VERSION' + TIMESTAMP='$TIMESTAMP' + RM='$RM' + ofile='$ofile' + + + + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "eb/Makefile") CONFIG_FILES="$CONFIG_FILES eb/Makefile" ;; + "libebutils/Makefile") CONFIG_FILES="$CONFIG_FILES libebutils/Makefile" ;; + "ebappendix/Makefile") CONFIG_FILES="$CONFIG_FILES ebappendix/Makefile" ;; + "ebfont/Makefile") CONFIG_FILES="$CONFIG_FILES ebfont/Makefile" ;; + "ebinfo/Makefile") CONFIG_FILES="$CONFIG_FILES ebinfo/Makefile" ;; + "ebrefile/Makefile") CONFIG_FILES="$CONFIG_FILES ebrefile/Makefile" ;; + "ebstopcode/Makefile") CONFIG_FILES="$CONFIG_FILES ebstopcode/Makefile" ;; + "ebzip/Makefile") CONFIG_FILES="$CONFIG_FILES ebzip/Makefile" ;; + "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; + "po-eb/Makefile") CONFIG_FILES="$CONFIG_FILES po-eb/Makefile" ;; + "po-ebutils/Makefile") CONFIG_FILES="$CONFIG_FILES po-ebutils/Makefile" ;; + "m4/Makefile") CONFIG_FILES="$CONFIG_FILES m4/Makefile" ;; + "samples/Makefile") CONFIG_FILES="$CONFIG_FILES samples/Makefile" ;; + + *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || +{ + $as_echo "$as_me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=' ' +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } +ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\).*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\).*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ + || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5 +$as_echo "$as_me: error: could not setup config files machinery" >&2;} + { (exit 1); exit 1; }; } +_ACEOF + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_t=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_t"; then + break + elif $ac_last_try; then + { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5 +$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5 +$as_echo "$as_me: error: could not setup config headers machinery" >&2;} + { (exit 1); exit 1; }; } +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5 +$as_echo "$as_me: error: invalid tag $ac_tag" >&2;} + { (exit 1); exit 1; }; };; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + ac_file_inputs="$ac_file_inputs '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:$LINENO: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin" \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir="$ac_dir" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= + +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p +' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + esac \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$tmp/config.h" "$ac_file" \ + || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 +$as_echo "$as_me: error: could not create $ac_file" >&2;} + { (exit 1); exit 1; }; } + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ + || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5 +$as_echo "$as_me: error: could not create -" >&2;} + { (exit 1); exit 1; }; } + fi +# Compute "$ac_file"'s index in $config_headers. +_am_arg="$ac_file" +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$_am_arg" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { $as_echo "$as_me:$LINENO: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || # Autoconf 2.62 quotes --file arguments for eval, but not when files +# are listed without --file. Let's play safe and only enable the eval +# if we detect the quoting. +case $CONFIG_FILES in +*\'*) eval set x "$CONFIG_FILES" ;; +*) set x $CONFIG_FILES ;; +esac +shift +for mf +do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`$as_dirname -- "$mf" || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_dirname -- "$file" || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir=$dirpart/$fdir + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + ;; + "libtool":C) + + # See if we are running on zsh, and set the options which allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + + cfgfile="${ofile}T" + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL + +# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is part of GNU Libtool. +# +# GNU Libtool is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Libtool; see the file COPYING. If not, a copy +# can be downloaded from http://www.gnu.org/licenses/gpl.html, or +# obtained by writing to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + +# The names of the tagged configurations supported by this script. +available_tags="" + +# ### BEGIN LIBTOOL CONFIG + +# Which release of libtool.m4 was used? +macro_version=$macro_version +macro_revision=$macro_revision + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# What type of objects to build. +pic_mode=$pic_mode + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="\$SED -e 1s/^X//" + +# A grep program that handles long lines. +GREP=$lt_GREP + +# An ERE matcher. +EGREP=$lt_EGREP + +# A literal string matcher. +FGREP=$lt_FGREP + +# A BSD- or MS-compatible name lister. +NM=$lt_NM + +# Whether we need soft or hard links. +LN_S=$lt_LN_S + +# What is the maximum length of a command? +max_cmd_len=$max_cmd_len + +# Object file suffix (normally "o"). +objext=$ac_objext + +# Executable file suffix (normally ""). +exeext=$exeext + +# whether the shell understands "unset". +lt_unset=$lt_unset + +# turn spaces into newlines. +SP2NL=$lt_lt_SP2NL + +# turn newlines into spaces. +NL2SP=$lt_lt_NL2SP + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# An object symbol dumper. +OBJDUMP=$lt_OBJDUMP + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == "file_magic". +file_magic_cmd=$lt_file_magic_cmd + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A symbol stripping program. +STRIP=$lt_STRIP + +# Commands used to install an old-style archive. +RANLIB=$lt_RANLIB +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# A C compiler. +LTCC=$lt_CC + +# LTCC compiler flags. +LTCFLAGS=$lt_CFLAGS + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration. +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair. +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# Transform the output of nm in a C name address pair when lib prefix is needed. +global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# An echo program that does not interpret backslashes. +ECHO=$lt_ECHO + +# Used to examine libraries when file_magic_cmd begins with "file". +MAGIC_CMD=$MAGIC_CMD + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Tool to manipulate archived DWARF debug symbol files on Mac OS X. +DSYMUTIL=$lt_DSYMUTIL + +# Tool to change global to local symbols on Mac OS X. +NMEDIT=$lt_NMEDIT + +# Tool to manipulate fat objects and archives on Mac OS X. +LIPO=$lt_LIPO + +# ldd/readelf like tool for Mach-O binaries on Mac OS X. +OTOOL=$lt_OTOOL + +# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. +OTOOL64=$lt_OTOOL64 + +# Old archive suffix (normally "a"). +libext=$libext + +# Shared library suffix (normally ".so"). +shrext_cmds=$lt_shrext_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at link time. +variables_saved_for_relink=$lt_variables_saved_for_relink + +# Do we need the "lib" prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Library versioning type. +version_type=$version_type + +# Shared library runtime path variable. +runpath_var=$runpath_var + +# Shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Command to use after installation of a shared archive. +postinstall_cmds=$lt_postinstall_cmds + +# Command to use after uninstallation of a shared archive. +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# As "finish_cmds", except a single script fragment to be evaled but +# not shown. +finish_eval=$lt_finish_eval + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Compile-time system search path for libraries. +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries. +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + + +# The linker used to build libraries. +LD=$lt_LD + +# Commands used to build an old-style archive. +old_archive_cmds=$lt_old_archive_cmds + +# A language specific compiler. +CC=$lt_compiler + +# Is the compiler the GNU compiler? +with_gcc=$GCC + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc + +# Whether or not to disallow shared libs when runtime libs are static. +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec + +# Whether the compiler copes with passing no objects directly. +compiler_needs_object=$lt_compiler_needs_object + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds + +# Commands used to build a shared archive. +archive_cmds=$lt_archive_cmds +archive_expsym_cmds=$lt_archive_expsym_cmds + +# Commands used to build a loadable module if different from building +# a shared archive. +module_cmds=$lt_module_cmds +module_expsym_cmds=$lt_module_expsym_cmds + +# Whether we are building with GNU ld or not. +with_gnu_ld=$lt_with_gnu_ld + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag + +# Flag that enforces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec + +# If ld is used when linking, flag to hardcode \$libdir into a binary +# during linking. This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld + +# Whether we need a single "-rpath" flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator + +# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes +# DIR into the resulting binary. +hardcode_direct=$hardcode_direct + +# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes +# DIR into the resulting binary and the resulting library dependency is +# "absolute",i.e impossible to change by setting \${shlibpath_var} if the +# library is relocated. +hardcode_direct_absolute=$hardcode_direct_absolute + +# Set to "yes" if using the -LDIR flag during linking hardcodes DIR +# into the resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR +# into the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Set to "yes" if building a shared library automatically hardcodes DIR +# into the library and all subsequent libraries and executables linked +# against it. +hardcode_automatic=$hardcode_automatic + +# Set to yes if linker adds runtime paths of dependent libraries +# to runtime path list. +inherit_rpath=$inherit_rpath + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path=$lt_fix_srcfile_path + +# Set to "yes" if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms + +# Commands necessary for linking programs (against libraries) with templates. +prelink_cmds=$lt_prelink_cmds + +# Specify filename containing input files. +file_list_spec=$lt_file_list_spec + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# ### END LIBTOOL CONFIG + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + +ltmain="$ac_aux_dir/ltmain.sh" + + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + case $xsi_shell in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac +} + +# func_basename file +func_basename () +{ + func_basename_result="${1##*/}" +} + +# func_dirname_and_basename file append nondir_replacement +# perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# Implementation must be kept synchronized with func_dirname +# and func_basename. For efficiency, we do not delegate to +# those functions but instead duplicate the functionality here. +func_dirname_and_basename () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac + func_basename_result="${1##*/}" +} + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +func_stripname () +{ + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary parameter first. + func_stripname_result=${3} + func_stripname_result=${func_stripname_result#"${1}"} + func_stripname_result=${func_stripname_result%"${2}"} +} + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=${1%%=*} + func_opt_split_arg=${1#*=} +} + +# func_lo2o object +func_lo2o () +{ + case ${1} in + *.lo) func_lo2o_result=${1%.lo}.${objext} ;; + *) func_lo2o_result=${1} ;; + esac +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=${1%.*}.lo +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=$(( $* )) +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=${#1} +} + +_LT_EOF + ;; + *) # Bourne compatible functions. + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi +} + +# func_basename file +func_basename () +{ + func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` +} + + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# func_strip_suffix prefix name +func_stripname () +{ + case ${2} in + .*) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; + *) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; + esac +} + +# sed scripts: +my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q' +my_sed_long_arg='1s/^-[^=]*=//' + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` + func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` +} + +# func_lo2o object +func_lo2o () +{ + func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'` +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=`expr "$@"` +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` +} + +_LT_EOF +esac + +case $lt_shell_append in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$1+=\$2" +} +_LT_EOF + ;; + *) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$1=\$$1\$2" +} + +_LT_EOF + ;; + esac + + + sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" + + ;; + + esac +done # for ac_tag + + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..b7e49b3 --- /dev/null +++ b/configure.ac @@ -0,0 +1,338 @@ +dnl * +dnl * Process this file with autoconf to produce a configure script. +dnl * +AC_INIT(eb, 4.4.3) +AC_CONFIG_SRCDIR(eb/eb.c) +AC_PREREQ(2.54) +AM_INIT_AUTOMAKE + +dnl * +dnl * Library version info. +dnl * +LIBEB_VERSION_INFO=16:0:0 +AC_SUBST(LIBEB_VERSION_INFO) + +EB_VERSION_MAJOR=4 +EB_VERSION_MINOR=4 +AC_SUBST(EB_VERSION_MAJOR) +AC_SUBST(EB_VERSION_MINOR) + +dnl * +dnl * Set mailing address. +dnl * +MAILING_ADDRESS='m-kasahr@sra.co.jp' +AC_SUBST(MAILING_ADDRESS) +AC_DEFINE_UNQUOTED(MAILING_ADDRESS, "$MAILING_ADDRESS", [Mailing address]) + +dnl * +dnl * Programs +dnl * +AC_PROG_CC +AC_PROG_LIBTOOL +AC_PROG_LN_S +AC_PROG_INSTALL + +AC_PATH_PROG(PERL, perl, no) +if test "$PERL" = no; then + AC_MSG_WARN(perl not found) + PERL=/usr/bin/perl +fi + +dnl * +dnl * large file support. +dnl * +eb_SYS_LARGEFILE + +dnl * +dnl * GNU gettext +dnl * +eb_GNU_GETTEXT(external) + +dnl * +dnl * --enable-samples option. +dnl * +AC_ARG_ENABLE(samples, +[ --enable-samples compile sample programs [default=no]], +[case "${enableval}" in + yes) samples=true ;; + no) samples=false ;; + *) AC_MSG_ERROR(invalid argument to --enable-samples) ;; +esac], samples=false) +AM_CONDITIONAL(ENABLE_SAMPLES, test ${samples} = true) + +dnl * +dnl * --enable-pthread option. +dnl * +AC_ARG_ENABLE(pthread, +AC_HELP_STRING([--enable-pthread], [build pthread safe libraries [[no]]]), +[case "${enableval}" in + yes) ENABLE_PTHREAD=yes ;; + no) ENABLE_PTHREAD=no ;; + *) AC_MSG_ERROR(invalid argument to --enable-pthread) ;; +esac], ENABLE_PTHREAD=no) + +dnl * +dnl * --with-pthread-cppflags option. +dnl * +AC_ARG_WITH(pthread-cppflags, +AC_HELP_STRING([--with-pthread-cppflags=FLAGS], + [additional CPPFLAGS for pthread support]), +[PTHREAD_CPPFLAGS="${withval}"], [PTHREAD_CPPFLAGS='']) + +dnl * +dnl * --with-pthread-cflags option. +dnl * +AC_ARG_WITH(pthread-cflags, +AC_HELP_STRING([--with-pthread-cflags=FLAGS], + [additional CFLAGS for pthread support]), +[PTHREAD_CFLAGS="${withval}"], [PTHREAD_CFLAGS='']) + +dnl * +dnl * --with-pthread-ldflags option. +dnl * +AC_ARG_WITH(pthread-ldflags, +AC_HELP_STRING([--with-pthread-ldflags=FLAGS], + [additional LDFLAGS for pthread support]), +[PTHREAD_LDFLAGS="${withval}"], [PTHREAD_LDFLAGS='']) + +dnl * +dnl * --with-pkgdocdir option. +dnl * +AC_ARG_WITH(pkgdocdir, +AC_HELP_STRING([--with-pkgdocdir=DIR], + [HTML documents in DIR [[default=DATADIR/eb/doc]]]), +[pkgdocdir="${withval}"],[pkgdocdir='${datadir}/eb/doc']) +AC_SUBST(pkgdocdir) + +dnl * +dnl * Check for pthread. +dnl * +AC_MSG_CHECKING(for pthread) +if test $ENABLE_PTHREAD = no; then + try_pthread=no +else + save_CPPFLAGS=$CPPFLAGS + save_CFLAGS=$CFLAGS + save_LDFLAGS=$LDFLAGS + CPPFLAGS="$CPPFLAGS $PTHREAD_CPPFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LDFLAGS="$LDFLAGS $PTHREAD_LDFLAGS" + AC_LINK_IFELSE([ +#include +static pthread_mutex_t m=PTHREAD_MUTEX_INITIALIZER; + +int +main() +{ + pthread_mutex_lock(&m); + return 0; +} +], + try_pthread=yes, try_pthread=no) + CPPFLAGS=$save_CPPFLAGS + CFLAGS=$save_CFLAGS + LDFLAGS=$save_LDFLAGS +fi +AC_MSG_RESULT($try_pthread) +if test $ENABLE_PTHREAD = yes; then + if test $try_pthread = no; then + AC_MSG_ERROR(pthread not available) + fi +fi + +if test $ENABLE_PTHREAD = yes; then + AC_DEFINE(ENABLE_PTHREAD, 1, [Define if pthread support is enabled.]) + CPPFLAGS="$CPPFLAGS $PTHREAD_CPPFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LDFLAGS="$LDFLAGS $PTHREAD_LDFLAGS" +fi + +dnl * +dnl * --with-zlib-includes option. +dnl * +AC_ARG_WITH(zlib-includes, +AC_HELP_STRING([--with-zlib-includes=DIR], [zlib include files are in DIR]), +[z_includedir="${withval}"], [z_includedir='']) + +if test "X$z_includedir" != X; then + ZLIBINCS="-I$z_includedir" +else + ZLIBINCS='' +fi + +dnl * +dnl * --with-zlib-libraries option. +dnl * +AC_ARG_WITH(zlib-libraries, +AC_HELP_STRING([--with-zlib-libraries=DIR], [zlib library files are in DIR]), + [z_libdir="${withval}"], [z_libdir='']) + +if test "X$z_libdir" != X; then + ZLIBLIBS="-L$z_libdir -lz" + ZLIBDEPS='' +else + ZLIBLIBS='-lz' + ZLIBDEPS='' +fi + +dnl * +dnl * Check for zlib. +dnl * +AC_MSG_CHECKING(for zlib) +save_CPPFLAGS=$CPPFLAGS +save_LIBS=$LIBS +CPPFLAGS="$CPPFLAGS $ZLIBINCS" +LIBS="$LIBS $ZLIBLIBS" +AC_LINK_IFELSE([ +#include + +int +main() +{ + z_stream stream; inflate(&stream, Z_FINISH); + return 0; +} +], + try_zlib=yes, try_zlib=no) +CPPFLAGS=$save_CPPFLAGS +LIBS=$save_LIBS +AC_MSG_RESULT($try_zlib) +if test $try_zlib = no; then + AC_MSG_ERROR(zlib not found) +fi +AC_SUBST(ZLIBINCS) +AC_SUBST(ZLIBLIBS) +AC_SUBST(ZLIBDEPS) + +dnl * +dnl * --enable-ebnet option. +dnl * +AC_ARG_ENABLE(ebnet, +AC_HELP_STRING([--enable-ebnet], [EBNET support [[yes]]]), +[ENABLE_EBNET="${enableval}"], [ENABLE_EBNET='yes']) +AC_SUBST(ENABLE_EBNET) +AM_CONDITIONAL(ENABLE_EBNET, test X$ENABLE_EBNET = Xyes) + +dnl * +dnl * --enable-ipv6 option. +dnl * +AC_ARG_ENABLE(ipv6, +AC_HELP_STRING([--enable-ipv6], + [IPv6 support for EBNET [[yes]] (if the system supports IPv6)]), +[ENABLE_IPV6="${enableval}"], [ENABLE_IPV6='auto']) + +dnl * +dnl * Compiler Characteristics. +dnl * + +dnl * +dnl * Header Files. +dnl * +AC_CHECK_HEADERS(direct.h langinfo.h mbstring.h pthread.h) + +dnl * +dnl * Structures. +dnl * + +dnl * +dnl * Libraries. +dnl * +AC_CHECK_LIB(resolv, res_query) +if test "$ac_cv_lib_resolv_res_query" = no; then + AC_CHECK_LIB(bind, res_query) +fi +AC_CHECK_LIB(nsl, gethostname) +AC_CHECK_LIB(socket, socket) + +dnl * +dnl * Library Functions. +dnl * +AC_CHECK_FUNCS(nl_langinfo _getdcwd atoll _atoi64) +AC_REPLACE_FUNCS(strcasecmp) + +dnl * +dnl * Typedefs. +dnl * +AC_TYPE_MODE_T +AC_CHECK_TYPE(ssize_t, int) + +dnl * +dnl * System services +dnl * +AC_EXEEXT +AC_OBJEXT +AM_CONDITIONAL(EXEEXT_EXE, test X$ac_exeext = Xyes) +if test X$ac_exeext = X.exe; then + AC_DEFINE(EXEEXT_EXE, 1, [Define if command names have the suffix \`.exe']) +fi + +dnl * +dnl * ebnet support +dnl * +if test "$ENABLE_EBNET" = yes; then + AC_DEFINE(ENABLE_EBNET, 1, [Define if build with ebnet support]) + + AC_TYPE_IN_PORT_T + AC_TYPE_SA_FAMILY_T + AC_TYPE_SOCKLEN_T + AC_STRUCT_IN6_ADDR + AC_STRUCT_SOCKADDR_IN6 + AC_STRUCT_SOCKADDR_STORAGE + AC_DECL_IN6ADDR_ANY + AC_DECL_IN6ADDR_LOOPBACK + + AC_CHECK_FUNCS(getaddrinfo getnameinfo gai_strerror) + + if test "$ENABLE_IPV6" = auto; then + if test "$ac_cv_struct_in6_addr$ac_cv_func_getaddrinfo" = yesyes; then + ENABLE_IPV6=yes + else + ENABLE_IPV6=no + fi + fi + + AC_MSG_CHECKING(for IPv6 support) + if test "$ENABLE_IPV6" = yes; then + if test "$ac_cv_struct_in6_addr" = no; then + AC_MSG_ERROR(IPv6 not available) + fi + if test "${ac_cv_func_getaddrinfo}" = no; then + AC_MSG_ERROR(IPv6 not available) + fi + AC_DEFINE(ENABLE_IPV6, 1, [Define if build with IPv6 support]) + fi + AC_MSG_RESULT($ENABLE_IPV6) +fi + +dnl * +dnl * Substitusion for eb.conf. +dnl * +EBCONF_ZLIBINCS=$ZLIBINCS +EBCONF_ZLIBLIBS=$ZLIBLIBS +AC_SUBST(EBCONF_ZLIBINCS) +AC_SUBST(EBCONF_ZLIBLIBS) + +AC_SUBST(ENABLE_PTHREAD) +AC_SUBST(PTHREAD_CPPFLAGS) +AC_SUBST(PTHREAD_CFLAGS) +AC_SUBST(PTHREAD_LDFLAGS) + +EBCONF_INTLINCS=$INTLINCS +EBCONF_INTLLIBS=$INTLLIBS +AC_SUBST(EBCONF_INTLINCS) +AC_SUBST(EBCONF_INTLLIBS) + +EBCONF_EBINCS='-I$(includedir)' +EBCONF_EBLIBS='-L$(libdir) -leb' +AC_SUBST(EBCONF_EBINCS) +AC_SUBST(EBCONF_EBLIBS) + +dnl * +dnl * Output Files. +dnl * +AC_CONFIG_HEADER(config.h) +AC_CONFIG_FILES([Makefile eb/Makefile libebutils/Makefile ebappendix/Makefile + ebfont/Makefile ebinfo/Makefile ebrefile/Makefile ebstopcode/Makefile + ebzip/Makefile doc/Makefile po-eb/Makefile po-ebutils/Makefile + m4/Makefile samples/Makefile]) +AC_OUTPUT diff --git a/depcomp b/depcomp new file mode 100755 index 0000000..e5f9736 --- /dev/null +++ b/depcomp @@ -0,0 +1,589 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2007-03-29.01 + +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software +# Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +case $1 in + '') + echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by `PROGRAMS ARGS'. + object Object file output by `PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputing dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit $? + ;; +esac + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. +## Unfortunately, FreeBSD c89 acceptance of flags depends upon +## the command line argument order; so add the flags where they +## appear in depend2.am. Note that the slowdown incurred here +## affects only configure: in makefiles, %FASTDEP% shortcuts this. + for arg + do + case $arg in + -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; + *) set fnord "$@" "$arg" ;; + esac + shift # fnord + shift # $arg + done + "$@" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the `deleted header file' problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory +## that the space means something, we add a space to the output as +## well. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like `#:fec' to the end of the + # dependency line. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> $depfile + echo >> $depfile + + # The second pass generates a dummy entry for each header file. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> $depfile + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts `$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.u + tmpdepfile2=$base.u + tmpdepfile3=$dir.libs/$base.u + "$@" -Wc,-M + else + tmpdepfile1=$dir$base.u + tmpdepfile2=$dir$base.u + tmpdepfile3=$dir$base.u + "$@" -M + fi + stat=$? + + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +icc) + # Intel's C compiler understands `-MD -MF file'. However on + # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c + # ICC 7.0 will fill foo.d with something like + # foo.o: sub/foo.c + # foo.o: sub/foo.h + # which is wrong. We want: + # sub/foo.o: sub/foo.c + # sub/foo.o: sub/foo.h + # sub/foo.c: + # sub/foo.h: + # ICC 7.1 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using \ : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | + sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp2) + # The "hp" stanza above does not work with aCC (C++) and HP's ia64 + # compilers, which have integrated preprocessors. The correct option + # to use with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + # Much of this is similar to the tru64 case; see comments there. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir.libs/$base.d + "$@" -Wc,+Maked + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + "$@" +Maked + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" + # Add `dependent.h:' lines. + sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" "$tmpdepfile2" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + + if test "$libtool" = yes; then + # With Tru64 cc, shared objects can also be used to make a + # static library. This mechanism is used in libtool 1.4 series to + # handle both shared and static libraries in a single compilation. + # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. + # + # With libtool 1.5 this exception was removed, and libtool now + # generates 2 separate objects for the 2 libraries. These two + # compilations output dependencies in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 + tmpdepfile2=$dir$base.o.d # libtool 1.5 + tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 + tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.o.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + tmpdepfile4=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for `:' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. + "$@" $dashmflag | + sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no + for arg in "$@"; do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + sed '1,2d' "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E | + sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + "$@" || exit $? + IFS=" " + for arg + do + case "$arg" in + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..4656b79 --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,160 @@ +pkgdoc_DATA = eb.html ebappendix.html ebfont.html ebinfo.html ebrefile.html \ + ebstopcode.html ebzip.html + +EXTRA_DIST = eb.html.in ebappendix.html.in ebfont.html.in ebinfo.html.in \ + ebrefile.html.in ebstopcode.html.in ebzip.html.in eb.css ebutils.css \ + c2html html-include html-index html-split html-toc + +CLEANFILES = *.html + +install-data-hook: + for i in $(pkgdoc_DATA); do \ + base="`echo $$i | sed -e 's/\.html//'`"; \ + for j in $$base-[0-9][0-9].html; do \ + test -r $$j || continue; \ + echo " $(INSTALL_DATA) '$$j' '$(DESTDIR)$(pkgdocdir)/$$j'"; \ + $(INSTALL_DATA) "$$j" "$(DESTDIR)$(pkgdocdir)/$$j"; \ + done; \ + done + +uninstall-hook: + for i in $(pkgdoc_DATA); do \ + base="`echo $$i | sed -e 's/\.html//'`"; \ + rm -f "$(DESTDIR)$(pkgdocdir)"/$$base-*.html; \ + done + +version.html: + rm -f $@ + echo $(VERSION) > version.html + +splitted: eb-splitted ebappendix-splitted ebfont-splitted ebinfo-splitted \ + ebrefile-splitted ebstopcode-splitted ebzip-splitted + +eb.html: eb-cat.html + rm -f $@ + $(PERL) $(srcdir)/html-split -Z -p eb -w 2 eb-cat.html + +ebappendix.html: ebappendix-cat.html + rm -f $@ + $(PERL) $(srcdir)/html-split -Z -p ebappendix -w 2 ebappendix-cat.html + +ebfont.html: ebfont-cat.html + rm -f $@ + $(PERL) $(srcdir)/html-split -Z -p ebfont -w 2 ebfont-cat.html + +ebinfo.html: ebinfo-cat.html + rm -f $@ + $(PERL) $(srcdir)/html-split -Z -p ebinfo -w 2 ebinfo-cat.html + +ebrefile.html: ebrefile-cat.html + rm -f $@ + $(PERL) $(srcdir)/html-split -Z -p ebrefile -w 2 ebrefile-cat.html + +ebstopcode.html: ebstopcode-cat.html + rm -f $@ + $(PERL) $(srcdir)/html-split -Z -p ebstopcode -w 2 ebstopcode-cat.html + +ebzip.html: ebzip-cat.html + rm -f $@ + $(PERL) $(srcdir)/html-split -Z -p ebzip -w 2 ebzip-cat.html + + +eb-cat.html: eb.html.in version.html eb-toc.html eb-sample-appendix.html \ + eb-sample-booklist.html eb-sample-disctype.html eb-sample-font.html \ + eb-sample-initexit.html eb-sample-subbook.html eb-sample-text.html \ + eb-sample-word.html eb-index-type.html eb-index-func.html \ + eb-index-const.html + rm -f $@ + $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/eb.html.in + +ebappendix-cat.html: $(srcdir)/ebappendix.html.in version.html \ +ebappendix-toc.html + rm -f $@ + $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebappendix.html.in + +ebfont-cat.html: $(srcdir)/ebfont.html.in version.html ebfont-toc.html + rm -f $@ + $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebfont.html.in + +ebinfo-cat.html: $(srcdir)/ebinfo.html.in version.html ebinfo-toc.html + rm -f $@ + $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebinfo.html.in + +ebrefile-cat.html: $(srcdir)/ebrefile.html.in version.html ebrefile-toc.html + rm -f $@ + $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebrefile.html.in + +ebstopcode-cat.html: $(srcdir)/ebstopcode.html.in version.html \ +ebstopcode-toc.html + rm -f $@ + $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebstopcode.html.in + +ebzip-cat.html: $(srcdir)/ebzip.html.in version.html ebzip-toc.html + rm -f $@ + $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebzip.html.in + + +eb-toc.html: $(srcdir)/eb.html.in + rm -f $@ + $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/eb.html.in > $@ + +ebappendix-toc.html: $(srcdir)/ebappendix.html.in + rm -f $@ + $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebappendix.html.in > $@ + +ebfont-toc.html: $(srcdir)/ebfont.html.in + rm -f $@ + $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebfont.html.in > $@ + +ebinfo-toc.html: $(srcdir)/ebinfo.html.in + rm -f $@ + $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebinfo.html.in > $@ + +ebrefile-toc.html: $(srcdir)/ebrefile.html.in + rm -f $@ + $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebrefile.html.in > $@ + +ebstopcode-toc.html: $(srcdir)/ebstopcode.html.in + rm -f $@ + $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebstopcode.html.in > $@ + +ebzip-toc.html: $(srcdir)/ebzip.html.in + rm -f $@ + $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebzip.html.in > $@ + +eb-sample-appendix.html: $(top_srcdir)/samples/appendix.c + rm -f $@ + $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/appendix.c > $@ + +eb-sample-booklist.html: $(top_srcdir)/samples/booklist.c + rm -f $@ + $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/booklist.c > $@ + +eb-sample-disctype.html: $(top_srcdir)/samples/disctype.c + rm -f $@ + $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/disctype.c > $@ + +eb-sample-font.html: $(top_srcdir)/samples/font.c + rm -f $@ + $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/font.c > $@ + +eb-sample-initexit.html: $(top_srcdir)/samples/initexit.c + rm -f $@ + $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/initexit.c > $@ + +eb-sample-subbook.html: $(top_srcdir)/samples/subbook.c + rm -f $@ + $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/subbook.c > $@ + +eb-sample-text.html: $(top_srcdir)/samples/text.c + rm -f $@ + $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/text.c > $@ + +eb-sample-word.html: $(top_srcdir)/samples/word.c + rm -f $@ + $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/word.c > $@ + + +eb-index-type.html eb-index-func.html eb-index-const.html: \ +$(srcdir)/eb.html.in + $(PERL) $(srcdir)/html-index -h -p eb-index $(srcdir)/eb.html.in diff --git a/doc/Makefile.in b/doc/Makefile.in new file mode 100644 index 0000000..e1d2041 --- /dev/null +++ b/doc/Makefile.in @@ -0,0 +1,552 @@ +# Makefile.in generated by automake 1.10.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = doc +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/in6addr.m4 $(top_srcdir)/m4/largefile.m4 \ + $(top_srcdir)/m4/lcmessage.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/sockaddrin6.m4 \ + $(top_srcdir)/m4/sockinttypes.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(pkgdocdir)" +pkgdocDATA_INSTALL = $(INSTALL_DATA) +DATA = $(pkgdoc_DATA) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +EBCONF_EBINCS = @EBCONF_EBINCS@ +EBCONF_EBLIBS = @EBCONF_EBLIBS@ +EBCONF_INTLINCS = @EBCONF_INTLINCS@ +EBCONF_INTLLIBS = @EBCONF_INTLLIBS@ +EBCONF_ZLIBINCS = @EBCONF_ZLIBINCS@ +EBCONF_ZLIBLIBS = @EBCONF_ZLIBLIBS@ +EB_VERSION_MAJOR = @EB_VERSION_MAJOR@ +EB_VERSION_MINOR = @EB_VERSION_MINOR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_EBNET = @ENABLE_EBNET@ +ENABLE_NLS = @ENABLE_NLS@ +ENABLE_PTHREAD = @ENABLE_PTHREAD@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +ICONVINCS = @ICONVINCS@ +ICONVLIBS = @ICONVLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLINCS = @INTLINCS@ +INTLLIBS = @INTLLIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBEB_VERSION_INFO = @LIBEB_VERSION_INFO@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAILING_ADDRESS = @MAILING_ADDRESS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_CPPFLAGS = @PTHREAD_CPPFLAGS@ +PTHREAD_LDFLAGS = @PTHREAD_LDFLAGS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +ZLIBDEPS = @ZLIBDEPS@ +ZLIBINCS = @ZLIBINCS@ +ZLIBLIBS = @ZLIBLIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgdocdir = @pkgdocdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +pkgdoc_DATA = eb.html ebappendix.html ebfont.html ebinfo.html ebrefile.html \ + ebstopcode.html ebzip.html + +EXTRA_DIST = eb.html.in ebappendix.html.in ebfont.html.in ebinfo.html.in \ + ebrefile.html.in ebstopcode.html.in ebzip.html.in eb.css ebutils.css \ + c2html html-include html-index html-split html-toc + +CLEANFILES = *.html +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu doc/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-pkgdocDATA: $(pkgdoc_DATA) + @$(NORMAL_INSTALL) + test -z "$(pkgdocdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgdocdir)" + @list='$(pkgdoc_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(pkgdocDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgdocdir)/$$f'"; \ + $(pkgdocDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgdocdir)/$$f"; \ + done + +uninstall-pkgdocDATA: + @$(NORMAL_UNINSTALL) + @list='$(pkgdoc_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(pkgdocdir)/$$f'"; \ + rm -f "$(DESTDIR)$(pkgdocdir)/$$f"; \ + done +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(DATA) +installdirs: + for dir in "$(DESTDIR)$(pkgdocdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-pkgdocDATA + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-data-hook + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-pkgdocDATA + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) uninstall-hook + +.MAKE: install-am install-data-am install-strip uninstall-am + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-data-hook install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-pkgdocDATA install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ + ps ps-am uninstall uninstall-am uninstall-hook \ + uninstall-pkgdocDATA + + +install-data-hook: + for i in $(pkgdoc_DATA); do \ + base="`echo $$i | sed -e 's/\.html//'`"; \ + for j in $$base-[0-9][0-9].html; do \ + test -r $$j || continue; \ + echo " $(INSTALL_DATA) '$$j' '$(DESTDIR)$(pkgdocdir)/$$j'"; \ + $(INSTALL_DATA) "$$j" "$(DESTDIR)$(pkgdocdir)/$$j"; \ + done; \ + done + +uninstall-hook: + for i in $(pkgdoc_DATA); do \ + base="`echo $$i | sed -e 's/\.html//'`"; \ + rm -f "$(DESTDIR)$(pkgdocdir)"/$$base-*.html; \ + done + +version.html: + rm -f $@ + echo $(VERSION) > version.html + +splitted: eb-splitted ebappendix-splitted ebfont-splitted ebinfo-splitted \ + ebrefile-splitted ebstopcode-splitted ebzip-splitted + +eb.html: eb-cat.html + rm -f $@ + $(PERL) $(srcdir)/html-split -Z -p eb -w 2 eb-cat.html + +ebappendix.html: ebappendix-cat.html + rm -f $@ + $(PERL) $(srcdir)/html-split -Z -p ebappendix -w 2 ebappendix-cat.html + +ebfont.html: ebfont-cat.html + rm -f $@ + $(PERL) $(srcdir)/html-split -Z -p ebfont -w 2 ebfont-cat.html + +ebinfo.html: ebinfo-cat.html + rm -f $@ + $(PERL) $(srcdir)/html-split -Z -p ebinfo -w 2 ebinfo-cat.html + +ebrefile.html: ebrefile-cat.html + rm -f $@ + $(PERL) $(srcdir)/html-split -Z -p ebrefile -w 2 ebrefile-cat.html + +ebstopcode.html: ebstopcode-cat.html + rm -f $@ + $(PERL) $(srcdir)/html-split -Z -p ebstopcode -w 2 ebstopcode-cat.html + +ebzip.html: ebzip-cat.html + rm -f $@ + $(PERL) $(srcdir)/html-split -Z -p ebzip -w 2 ebzip-cat.html + +eb-cat.html: eb.html.in version.html eb-toc.html eb-sample-appendix.html \ + eb-sample-booklist.html eb-sample-disctype.html eb-sample-font.html \ + eb-sample-initexit.html eb-sample-subbook.html eb-sample-text.html \ + eb-sample-word.html eb-index-type.html eb-index-func.html \ + eb-index-const.html + rm -f $@ + $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/eb.html.in + +ebappendix-cat.html: $(srcdir)/ebappendix.html.in version.html \ +ebappendix-toc.html + rm -f $@ + $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebappendix.html.in + +ebfont-cat.html: $(srcdir)/ebfont.html.in version.html ebfont-toc.html + rm -f $@ + $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebfont.html.in + +ebinfo-cat.html: $(srcdir)/ebinfo.html.in version.html ebinfo-toc.html + rm -f $@ + $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebinfo.html.in + +ebrefile-cat.html: $(srcdir)/ebrefile.html.in version.html ebrefile-toc.html + rm -f $@ + $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebrefile.html.in + +ebstopcode-cat.html: $(srcdir)/ebstopcode.html.in version.html \ +ebstopcode-toc.html + rm -f $@ + $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebstopcode.html.in + +ebzip-cat.html: $(srcdir)/ebzip.html.in version.html ebzip-toc.html + rm -f $@ + $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebzip.html.in + +eb-toc.html: $(srcdir)/eb.html.in + rm -f $@ + $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/eb.html.in > $@ + +ebappendix-toc.html: $(srcdir)/ebappendix.html.in + rm -f $@ + $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebappendix.html.in > $@ + +ebfont-toc.html: $(srcdir)/ebfont.html.in + rm -f $@ + $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebfont.html.in > $@ + +ebinfo-toc.html: $(srcdir)/ebinfo.html.in + rm -f $@ + $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebinfo.html.in > $@ + +ebrefile-toc.html: $(srcdir)/ebrefile.html.in + rm -f $@ + $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebrefile.html.in > $@ + +ebstopcode-toc.html: $(srcdir)/ebstopcode.html.in + rm -f $@ + $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebstopcode.html.in > $@ + +ebzip-toc.html: $(srcdir)/ebzip.html.in + rm -f $@ + $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebzip.html.in > $@ + +eb-sample-appendix.html: $(top_srcdir)/samples/appendix.c + rm -f $@ + $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/appendix.c > $@ + +eb-sample-booklist.html: $(top_srcdir)/samples/booklist.c + rm -f $@ + $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/booklist.c > $@ + +eb-sample-disctype.html: $(top_srcdir)/samples/disctype.c + rm -f $@ + $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/disctype.c > $@ + +eb-sample-font.html: $(top_srcdir)/samples/font.c + rm -f $@ + $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/font.c > $@ + +eb-sample-initexit.html: $(top_srcdir)/samples/initexit.c + rm -f $@ + $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/initexit.c > $@ + +eb-sample-subbook.html: $(top_srcdir)/samples/subbook.c + rm -f $@ + $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/subbook.c > $@ + +eb-sample-text.html: $(top_srcdir)/samples/text.c + rm -f $@ + $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/text.c > $@ + +eb-sample-word.html: $(top_srcdir)/samples/word.c + rm -f $@ + $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/word.c > $@ + +eb-index-type.html eb-index-func.html eb-index-const.html: \ +$(srcdir)/eb.html.in + $(PERL) $(srcdir)/html-index -h -p eb-index $(srcdir)/eb.html.in +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/doc/c2html b/doc/c2html new file mode 100755 index 0000000..a11c5a4 --- /dev/null +++ b/doc/c2html @@ -0,0 +1,51 @@ +#! /usr/bin/perl + +require 5.005; +use Getopt::Std; + +# +# Usage +# +my $usage = "Usage: $0 [-t tab-width] [input-file...]\n"; + +# +# Variables +# +my $tab_width = 8; +my $out_file_name = '-'; + +# +# Parse command line arguments. +# +getopts(':t:', \%options) or die $usage; +$tab_width = $options{t} if (defined($options{t})); + +# +# Convert C to HTML. +# +print "
\n"; +print "
\n";
+
+while (<>) {
+    s/^([ \t]*)//;
+    my $spaces = $1;
+
+    my $col = 0;
+    foreach my $c (unpack('C*', $spaces)) {
+	if ($c eq ord(' ')) {
+	    $col++;
+	} else {
+	    $col = ($col + $tab_width) - ($col % $tab_width);
+	}
+	
+    }
+    print ' ' x $col;
+
+    s|&|&|g;
+    s|<|<|g;
+    s|>|>|g;
+    print;
+}
+
+print "
\n"; +print "
\n"; diff --git a/doc/eb.css b/doc/eb.css new file mode 100644 index 0000000..06131af --- /dev/null +++ b/doc/eb.css @@ -0,0 +1,51 @@ +body { + color: #000000; + background-color: #ffffff; +} + +td { + border-style: solid; + border-width: 1px; +} + +table { + border-style: solid; + border-width: 2px; +} + +h2 { + color: #000000; + font-size: x-large; + padding: 3px; +} + +h3 { + color: #ffffff; + background-color: #8787a7; + font-size: large; + padding: 5px; + border-style: solid; + border-width: 4px; + border-bottom-color: #3f3f5f; + border-right-color: #3f3f5f; + border-top-color: #dfdfff; + border-left-color: #dfdfff; +} + +h4 { + color: #000000; + background-color: #dfdfff; + font-size: medium; + border-color: #3f3f5f; + border-left-style: solid; + border-bottom-style: solid; + border-left-width: 8px; + border-bottom-width: 2px; + padding: 6px; +} + +blockquote.program { + border-style: dotted; + border-width: 1px; + padding-left: 8px; +} diff --git a/doc/eb.html.in b/doc/eb.html.in new file mode 100644 index 0000000..48bcdc8 --- /dev/null +++ b/doc/eb.html.in @@ -0,0 +1,9431 @@ + + + + + + + +EB ライブラリ + + + +

EB ライブラリ

+

+この文書は、EB ライブラリバージョン + +に対応しています。 +

+ +

+目次: +

+ + + +

+Copyright (c) 2001-2006 Motoyuki Kasahara +

+ + +

はじめに

+ +

+EB ライブラリは CD-ROM 書籍にアクセスするための C のライブラリです。 +UNIX 系 OS および Windows (2000以降) のシステム上で動作させることが +できます。 +

+ +

+EB ライブラリは EB, EBG, EBXA, EBXA-C, S-EBXA および EPWING 形式の +CD-ROM 書籍に対応しています。 +これらは、主に日本で販売されている辞書に使われています。 +CD-ROM 書籍自体は ISO 9660 形式になっていますので、他の ISO 9660 形式 +と同じ要領でマウントすることができます。 +

+ +

+本書は、EB ライブラリを使ってアプリケーションプログラムを作成する +開発者向けに、ライブラリの仕様を解説した文書です。 +そして、ライブラリの公式な参照マニュアルでもあります。 +読み進めるにあたって、読者は EB ライブラリおよび CD-ROM 書籍の内部構造 +について知っている必要はありませんが、電子ブックか EPWING を利用して、 +実際に CD-ROM 書籍がどのようなものかを理解しておくことをお薦めします。 +また、C 言語によるプログラミングについては、十分に理解していることを前提 +とします。 +

+ +

+本書の内容に沿って EB ライブラリを使ったアプリケーションプログラムを +作成するには、お使用いのシステムに EB ライブラリと C コンパイラを +インストールしておいて下さい。 +なお、本書では主に UNIX 系 OS を使用した場合について、記述しています。 +

+ +

+EB ライブラリはフリーソフトウェアです。ソースコードおよびバイナリを、 +いわゆる Modified BSD ライセンスの下で使用することが可能です。 +(バージョン 4.1 よりも前のものは、GPL を採用していました。) +詳しくは、ソースコードに付属している COPYING という英文のファイルを参照 +して下さい。 +

+ + +

電子ブックと EPWING について

+ +

+電子ブックと EPWING は、いずれも主に日本で使われている電子書籍の +データ形式の名称で、CD-ROM に収めた形で数々の書籍が市販されています。 +CD-ROM は ISO 9660 形式 なので、CD-ROM ドライブが扱えるシステムであれば、 +容易にアクセスすることができます。 +電子書籍のデータ形式とはいっても、実際は辞書向けに特化した構造となって +おり、市販されている書籍も辞書の類が圧倒的に多いようです。 +

+ +

+電子ブック、EPWING ともに、データ形式に関する規格の全容は一般公開されて +いませんが、EPWING ついては規格の一部が日本工業規格 JIS X 4081 +「電子出版検索データ構造」として公開されています。 +さらに、EPWING と電子ブックのデータ形式は、酷似していることが知られて +います。 +

+ +

+EB ライブラリの開発者も、電子ブック、EPWING 規格の全容は知りません。 +EB ライブラリでは JIS X 4081 の記述をもとに、電子ブック、EPWING を読める +ようにしてあります。 +しかしながら、規格の全容が分からない状態で開発しているため、残念ながら +一部に正しく読めない書籍が存在します。 +

+ + +

本書の構成について

+ +

+次章「EB ライブラリの特徴」では、EB ライブラリが対応している機能、対応 +していない機能について、簡単に説明します。 +また、ライブラリの概略に関して、最初に知っておいたほうが良いと思われる +事柄をいくつか説明しています。 +

+ +

+さらに次の章「プログラムのコンパイル方法」では、EB ライブラリを利用した +プログラムのコンパイル方法を説明します。 +本書のサンプルプログラムをコンパイルするために必要な情報も、この章に +記してあります。 +

+ +

+そして、その次の章「ライブラリの初期化と後始末」からが、実際の +EB ライブラリのプログラミングの解説となります。 +それぞれの章は、次のような節から構成されています。 +ただし、章によっては一部の節がない場合もあります。 +

+ +
+
解説
+
+その章で解説する機能や概念についての基礎知識、EB ライブラリの仕様の +概要について解説しています。 + +
サンプルプログラム
+
+「解説」ではプログラムの断片だけを示すことが多いので、動作可能な +プログラムのサンプルをここで示します。 + +
データ型の詳細
+
+データ型や関数、定数値などについての参照マニュアルです。 +
+ + +

EB ライブラリの特徴

+ +

+前に述べたように、EB ライブラリは、電子ブック (EB, EBG, EBXA, EBXA-C, S-EBXA) +と EPWING 形式の CD-ROM 書籍に対応しています。 +

+ +

+EB ライブラリは、これらの CD-ROM 書籍に対して、次の処理を行うことが +できます。 +

+ +
    +
  • 前方一致検索 +
  • 後方一致検索 +
  • 完全一致検索 +
  • 条件検索 +
  • 複合検索 +
  • 見出しデータの取得 +
  • 本文データの取得 +
  • メニューの取得 +
  • 著作権表示の取得 +
  • カラー図版データの取得 (ただし EPWING のみ) +
  • モノクロ図版データの取得 +
  • 外字データの取得 +
  • 動画データの取得 +
+ +

+この章では、EB ライブラリの概要に関して、あらかじめ知っておいて頂いた +ほうが良いと思われるその他の事柄について、何点か説明します。 +

+ + + +

ヘッダファイル

+ +

+EB ライブラリには、いくつかのヘッダファイルが用意されています。 +

+ +
+
appendix.h
+
+appendix (付録) に関連した宣言、定義を行う。 +
binary.h
+
+バイナリデータに関連した宣言、定義を行う。 +
eb.h
+
+EB ライブラリの基本ヘッダファイル。 +
error.h
+
+エラーコードに関連した宣言、定義を行う。 +
font.h
+
+外字に関連した宣言、定義を行う。 +
text.h
+
+テキストデータ (本文、見出しなど) に関連した宣言、定義を行う。 +
+ +

+これ以外にもいくつかのファイルがインストールされますが、上に挙げた +ヘッダファイルから読み込まれるもので、アプリケーションプログラムが +直接読み込む必要はありません。 +

+ +

+アプリケーションプログラムは、EB ライブラリを使う際にこのヘッダファイル +をファイルの先頭付近で読み込みます。 +

+ +
+
+#include <eb/eb.h>
+#include <eb/error.h>
+
+
+ +

+eb.h ではなく、eb/eb.h を読み込むようにして下さい。 +

+ + +

文字コード

+ +

+EB ライブラリでは、CD-ROM 書籍内のデータを文字列にしてアプリケーション +に渡す際の文字コードを規定しています。 +

+ +

+EBG (海外の電子ブック) については、データが ISO 8859-1 (ラテン文字 1、 +ただし制御文字を除く) で書かれているため、データのやり取りも ISO 8859-1 +で行います。 +ただし、外字だけは 2 バイトで表現し、0x0101 〜 0x1efe の領域を使用します。 +(外字領域の下位 16 ビットは 0x01 〜 0xfe の範囲を使用します。) +

+ +

+EBG, EBXA-C を除いた電子ブック、および EPWING については、データが +JIS X 0208 (日本語のかな漢字) で書かれており、JIS X 0208 を 0x2121 〜 +0x7e7e にマッピングし、0xa121 〜 0xfe7e を外字領域にしています (下図)。 +

+ +
+
+                上位8ビット
+
+         00 21    7e a1    fe
+       00┌──┬─────┬──┬─────┬┐
+         │  │     │  │     ││
+       21├──┼─────┼──┼─────┼┤
+         │  │     │  │     ││
+         │  │JIS X│  │ 外字  ││
+         │  │0208 │  │     ││
+         │  │     │  │     ││
+       7e├──┼─────┼──┼─────┼┤
+下位8ビット   │  │     │  │     ││
+       a1├──┼─────┼──┼─────┼┤
+         │  │     │  │     ││
+         │  │     │  │     ││
+         │  │     │  │     ││
+         │  │     │  │     ││
+       fe├──┼─────┼──┼─────┼┤
+         └──┴─────┴──┴─────┴┘
+
+
+ +

+EB ライブラリでは JIS X 0208 部分を日本語 EUC (EUC-JP) にエンコード +して、アプリケーションとのやり取りも日本語 EUC で行います。 +したがって、JIS X 0208 部分は 0xa1a1 〜 0xfefe にマッピングされます。 +

+ +

+EBXA-C (中日・日中辞書の電子ブック) については、データが JIS X 0208 +(日本語のかな漢字) と GB 2312 (中国語の簡体字) で書かれており、 +JIS X 0208 を 0x2121 〜 0x7e7e にマッピング、 +GB 2312 を 0x21a1 〜 0x7efe にマッピングし、 +0xa121 〜 0xfe7e を外字領域にしています (下図)。 +

+ +
+
+                上位8ビット
+
+         00 21    7e a1    fe
+       00┌──┬─────┬──┬─────┬┐
+         │  │     │  │     ││
+       21├──┼─────┼──┼─────┼┤
+         │  │     │  │     ││
+         │  │JIS X│  │ 外字  ││
+         │  │0208 │  │     ││
+         │  │     │  │     ││
+       7e├──┼─────┼──┼─────┼┤
+下位8ビット   │  │     │  │     ││
+       a1├──┼─────┼──┼─────┼┤
+         │  │     │  │     ││
+         │  │GB   │  │     ││
+         │  │2312 │  │     ││
+         │  │     │  │     ││
+       fe├──┼─────┼──┼─────┼┤
+         └──┴─────┴──┴─────┴┘
+
+
+ +

+EB ライブラリでは、アプリケーションとのやり取りに使う文字コードは、 +日本語 EUC および中国語 EUC (EUC-ZH) です。 +したがって、そのままでは JIS X 0208 と GB 2312 が 0xa1a1 〜 0xfefe に +マッピングされ、衝突してしまいます。 +この問題をどう回避するのかは、アプリケーション側で決める必要があります +(詳しくは、「フックと文字コードの関係」 を参照のこと)。 +

+ +

+電子ブック、EPWING ともに、外字については、アプリケーション側でどう +扱うかを決める必要があります。 +外字について詳しくは 「外字」 を参照のこと。 +

+ + +

圧縮された書籍について

+ +

+EB ライブラは、データを圧縮して収録した書籍を扱うことができます。 +今のところ、次の 4 種類の圧縮方法に対応しています。 +

+ +
+
ebzip 圧縮形式
+
+EB ライブラリ独自の圧縮形式です。 +付属の ebzip コマンドを使うと、この形式で圧縮した書籍を作れます。 + +
EPWING V4, V5 形式
+
+市販の EPWING V4, V5 の書籍の一部に、この形式で圧縮したものがあります。 + +
EPWING V6 形式
+
+市販の EPWING V6 の書籍の一部に、この形式で圧縮したものがあります。 +EPWING V4, V5 形式の改良型です。 + +
S-EBXA 形式
+
+市販の S-EBXA の書籍の一部に、この形式で圧縮したものがあります。 +
+ +

+データの伸長は EB ライブラリ側で自動的に行われるため、 +アプリケーションプログラムからは、アクセスしている書籍が圧縮されているか +どうか分かりません。 +アプリケーションプログラムは、書籍が圧縮されているかどうかで処理を変える +必要はありません。 +

+ + +

遠隔ホスト上の書籍について

+ +

+バージョン 4.0 から、EB ライブラリは他のホストの書籍にアクセスできる +ようになりました。 +

+ +

+遠隔アクセスの処理はすべて EB ライブラリ側で行われますので、 +アプリケーションプログラムは、書籍が自分のホスト上にあるかどうかで、 +EB ライブラリの呼び出し手順を変える必要はありません。 +

+ +

+ただし、他のホストからアクセスすると、処理速度は非常に遅くなります。 +そのため、効率良く処理できるよう、アプリケーションの処理方法を工夫すべき +状況が生じることはあるかも知れません。 +

+ + +

システムの要件

+ +

+アプリケーションプログラムのコンパイルに用いるコンパイラには、 +ANSI (ANSI X3.159-1989, ISO/IEC 9899-1990) 対応のものを対象としています。 +また、システムには POSIX.1 (IEEE Std. 1003.2-1990, ISO/IEC 9945-1:1990) +準拠ないし互換のものを対象としています。 +

+ +

+永らく EB ライブラリでは、古いコンパイラや UNIX 系システムへの対応も +それなりに行われていましたが、バージョン 4.1 からは対応を打ち切っています。 +特に ANSI 対応のコンパイラは必須ですので、ご注意ください。 +

+ + +

プログラムのコンパイル方法

+ +

+本章では、EB ライブラリを利用したプログラムのコンパイルの仕方について、 +2 通りの方法を説明します。 +

+ +

+一つ目は、ごく私的な、小規模のプログラムをコンパイルする際に向いている +てっとり早くコンパイルするための方法です。 +EB ライブラリの使い方を覚える目的で簡単なプログラムを組む際は、こちら +が良いでしょう。 +

+ +

+二つ目は、EB ライブラリを組み込んだアプリケーションをフリーソフトウェア +としてリリースする際に向いている方法です。 +EB ライブラリには、GNU Autoconf, Automake, Libtool を併用する仕組みを +用意してありますので、これらを使ったコンパイル方法について説明します。 +

+ + + +

てっとり早いコンパイル方法

+ +

+アプリケーションプログラムをコンパイルする際は、ヘッダファイルの +ディレクトリ位置を C コンパイラに教えてやる必要があるかも知れません。 +一般に UNIX の C コンパイラでは、-I オプションで位置を指定 +します。 +

+ +
+
+cc -I/usr/local/include -c sample.c
+
+
+ +

+/usr/local/include/eb ではなく、その一つ上を指定します +(「ヘッダファイル」 を参照のこと)。 +

+ +

+次に、リンクして実行バイナリを生成する工程ですが、 +以下に記したライブラリの一部、もしくは全部をリンクします。 +括弧内は、ライブラリのファイル名です (ただし、.a や +.so といった接尾子は省略)。 +

+ +
+
EB ライブラリ (libeb)
+
+EB ライブラリの本体です。このライブラリは必須です。 + +
zlib (libz)
+
+圧縮と伸長を行うライブラリです +(詳しくは @url{http://www.gzip.org/zlib/})。 +ebzip コマンドで圧縮した辞書を扱うために使います。 +このライブラリは必須です。 +EB ライブラリのソースコードには zlib も収録されています。 +システムに zlib が インストールされていなければ、EB ライブラリを +インストールする際に、zlib も自動的にインストールされます。 + +
gettext ライブラリ (libintl)
+
+メッセージの国際化機能 (NLS) を提供するライブラリです +メッセージの国際化機能を有効にして EB ライブラリをコンパイルしている +場合は、必要になるかも知れません。 +gettext の実装は何種類かありますが、EB ライブラリで使用できるのは +メッセージカタログの形式が GNU gettext 互換のものだけです。 + +メッセージの国際化機能を有効にしている場合でも、OS の標準 C ライブラリ +として glibc を採用しているシステムでは、指定する必要はありません。 + +
iconv ライブラリ
+
+文字コード変換のライブラリです。 +gettext ライブラリをリンクする場合、一緒に必要となるかも知れません。 +iconv の実装も何種類かあり、OS によっては最初から添付されています。 +
+ +

+必要なライブラリファイルの名称を、C コンパイラに指定してやります。 +加えて、ファイルの置かれているディレクトリ位置を、C コンパイラに教える +必要があるかも知れません。 +一般に UNIX の C コンパイラでは、-L オプションでディレクトリ +位置を指定し、-l オプションでライブラリのファイル名を指定 +します。 +

+ +
+
+cc sample.o -L/usr/local/lib -leb -lz -lintl -liconv
+
+
+ +

+ただし、共有ライブラリをリンクする場合は、実行時におけるライブラリの +検索パスも合わせて指定する必要があるかも知れません。 +

+ +
+
+cc sample.o -R/usr/local/lib -L/usr/local/lib -leb -lz -lintl -liconv
+
+
+ +

+C コンパイラの使い方に関しての詳細は、C コンパイラのマニュアルを参照 +して下さい。 +

+ + +

Autoconf を併用したコンパイル方法

+ +

+作業の前に、Autoconf, Automake, Libtool は、あらかじめインストールして +おいて下さい。 +Autoconf はバージョン 2.50 以降が必要です。 +

+ +

+まず、アプリケーションプログラムの configure.ac +(もしくは configure.in) に、次の行を加えます。 +

+ +
+
+eb_LIB_EB4
+
+
+ +

+マクロ eb_LIB_EB4 は、EB ライブラリの使用に必要な一切の +チェックを行い、さらに configure に次のオプションを追加 +します。 +

+ +
+
+  --with-eb-conf=FILE     eb.conf file is FILE [SYSCONFDIR/eb.conf]
+
+
+ +

+eb.conf は、EB ライブラリをインストールしたときの情報を記録 +したファイルで、ライブラリと一緒にインストールされます。 +eb_LIB_EB4 はこのファイルを読み込んで、C コンパイラに +渡さなければいけないオプションなどの情報を得ます。 +--eb-conf-file は、eb.conf のファイル名を +明示的に指定するオプションです。 +

+ +

+マクロ eb_LIB_EB4 は、eb4.m4 というファイルで +提供されています。 +EB ライブラリを /usr/local にインストールし、個々のファイル +のインストール先を変更していなければ、/usr/local/share/aclocal +にインストールされます。 +この eb4.m4 をソースコードの適当なディレクトリの下 (たとえば +m4) にコピーして下さい。 +

+ +

+aclocal コマンドで aclocal.m4 を再生成する際は、 +-I オプションでマクロファイルのディレクトリを指定します。 +

+ +
+
+aclocal -I m4
+
+
+ +

+加えて、トップディレクトリの Makefile.am の中にも +aclocal へ渡すオプションを書いておきます。 +

+ +
+
+ACLOCAL_AMFLAGS = -I m4
+
+
+ +

+また、ソースコードのディレクトリに Libtool パッケージがまだ用意されて +いなければ、用意します。 +libtoolize コマンドを実行して下さい。 +Libtool パッケージが、ソースコードのディレクトリにコピーされます。 +

+ +
+
+libtoolize
+
+
+ +

+最後に、コンパイルを行うディレクトリの Makefile.am ファイル +の _LDFLAGSINCLUDES に、次のような値を追加 +します。 +

+ +
+
+program_LDFLAGS = $(EBCONF_EBLIBS) $(EBCONF_ZLIBLIBS) $(EBCONF_INTLLIBS)
+INCLUDES = $(EBCONF_EBINCS)
+
+
+ +

+(program_LDFLAGSprogram のところは、 +アプリケーションプログラムの実際のコマンド名にします。) +

+ + +

EB ライブラリ本体のデバッグ

+ +

+「自分が作ったアプリケーションが正しく動かないのは、ひょっとすると +EB ライブラリのバグが原因ではないか?」という疑問を抱き、EB ライブラリ +の挙動を確認したいと思うことがあるかも知れません。 +

+ +

+そのような場合は、環境変数 EB_DEBUG をセットした状態で +アプリケーションを実行してみて下さい。 +EB ライブラリは標準エラー出力に、次のようなログを (かなり大量ですが) +出力するようになります。 +

+ +
+
+[EB] in: eb_set_font(book=0, font_code=0)
+[EB] in: eb_load_narrow_font(book=0)
+[EB] out: eb_load_narrow_font()
+[EB] in: eb_load_wide_font(book=0)
+[EB] out: eb_load_wide_font()
+[EB] out: eb_set_font() = EB_SUCCESS
+
+
+ +

+これらのログは、関数の呼び出し時の引数列、および関数からの戻り値を +示しています。 +ebfixlog という Perl5 スクリプトを使うと、ログを整形すること +ができます。 +このスクリプトは、EB ライブラリのソースコードの misc +ディレクトリに収められています。 +

+ +

+ebfixlog は、コマンド行の引数として与えられたファイル +(引数が指定されなければ標準入力) からメッセージデータを読み込み、 +次のように字下げして出力します。 +

+ +
+
+[EB] in: eb_set_font(book=0, font_code=0)
+[EB]   in: eb_load_narrow_font(book=0)
+[EB]   out: eb_load_narrow_font()
+[EB]   in: eb_load_wide_font(book=0)
+[EB]   out: eb_load_wide_font()
+[EB] out: eb_set_font() = EB_SUCCESS
+
+
+ +

+通常 ebfixlog スクリプトは、zio および ebnet と呼ばれる、 +EB ライブラリでファイル入出力を受け持つ処理部のログは読み捨てるように +なっています。 +これにより、ログの量がかなり減ります。 +

+ +

+zio は EB ライブラリの低レベル入出力の処理部で、頻繁に呼び出されます。 +問題の原因を調べる際も、まずは読み捨てた方がライブラリの内部動作を追跡 +しやすいでしょう。 +

+ +

+ebfixlog-z オプションを使うと、zio の +メッセージを読み捨てずに出力するようになります。 +

+ +

+ebnet は遠隔アクセスの入出力を処理する部分で、zio よりもさらに +下位レベルに位置します。 +遠隔アクセスの挙動を追跡するとき以外は、読み捨てた方が良いと思います。 +

+ +

+ebfixlog-n オプションを使うと、ebnet, +zio 両方のメッセージを読み捨てずに出力するようになります。 +

+ + +

ライブラリの初期化と後始末

+ +

+この章からは、EB ライブラリのプログラミングについての解説になります。 +

+ +

+まず、アプリケーションプログラムから EB ライブラリを利用するには、 +最初にライブラリを初期化する必要があります。 +

+ +

+ライブラリの初期化を行うには、eb_initialize_library() +という関数を呼び出します。 +

+ +
+
+if (eb_initialize_library() != EB_SUCCESS) {
+    printf("eb_initialize_library() failed\n");
+    exit(1);
+}
+
+
+ +

+同様に、ライブラリを使い終わったら、eb_finalize_library() +という関数を呼び出して後始末をします。 +

+ +
+
+eb_finalize_library();
+
+
+ + + +

サンプルプログラム

+ + + + +

関数の詳細

+ +

+この項で説明している関数を使うには、eb/eb.h を読み込んで下さい。 +

+ +
+
+#include <eb/eb.h>
+
+
+ + +

EB_Error_Code eb_initialize_library ()

+ +

+関数 eb_initialize_library() は、EB ライブラリを初期化します。 +アプリケーションプログラムは、EB ライブラリの他の関数を呼ぶ前に、必ず +一回だけこの関数を呼ぶ必要があります。 +

+ +

+メッセージの国際化機能 (NLS) を有効にして EB ライブラリをコンパイル +した場合、eb_initialize_library()bindtextdomain() を +呼び出します。 +したがって、アプリケーションプログラムが setlocale() を +呼び出すのは、この関数を呼び出す前である必要があります。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、原因を示すエラーコードを返します。 +

+ +

+ライブラリを初期化せずに、EB ライブラリの他の関数を呼んだ場合の動作は +未定義です。 +また、すでに初期化を済ませた状態で、再度 eb_initialize_library() +を呼んでもいけません。 +呼んだ場合の動作は未定義です。 +

+ + +

void eb_finalize_library ()

+ +

+関数 eb_finalize_library() は、EB ライブラリを使い終わった +際の後始末を行います。 +ただし、アプリケーションプログラム側で使用した +EB_BookEB_HooksetEB_Appendix オブジェクトの後始末は行いません。 +オブジェクトを後始末するには、それぞれ専用の関数 +eb_finalize_book()eb_finalize_hookset()、 +eb_finalize_appendix() を各オブジェクトに対して別途 +呼んでやる必要があります。 +

+ +

+ライブラリの後始末をした後は、EB ライブラリのいかなる関数も呼んでは +いけません。 +呼んだ場合の動作は未定義です。 +

+ + +

CD-ROM 書籍と EB_Book オブジェクト

+ +

+EB ライブラリでは、CD-ROM 書籍へのアクセスは、すべて EB_Book 型 +のオブジェクトを介して行います。 +したがって、ほとんどのアプリケーションプログラムは、本章で記述している +処理を必要とするはずです。 +

+ +

+本章では EB_Book オブジェクトの初期化、後始末といった基本的な +取り扱い方について説明します。 +

+ + + +

EB_Book オブジェクト

+ +

+CD-ROM 書籍へアクセスするには、まず EB_Book 型のオブジェクトを +用意します。 +同時に複数の CD-ROM 書籍にアクセスするなら、書籍一冊毎にオブジェクトを +作る必要があります。 +

+ +
+
+EB_Book book;
+
+
+ +

+もちろん、オブジェクトの領域は、malloc() で確保しても +構いません。 +

+ +
+
+EB_Book *book_pointer;
+
+book_pointer = (EB_Book *) malloc(sizeof(EB_Book));
+
+
+ +

+EB_Book オブジェクトの中身 (変数 book の中身 +および book_pointer の指す領域) はまだ初期化されていませんので、 +次の要領でオブジェクトを初期化します。 +

+ +
+
+eb_initialize_book(&book);
+eb_initialize_book(book_pointer);
+
+
+ +

+eb_initialize() へ渡す引数は EB_Book オブジェクト +へのポインタであって、EB_Book オブジェクトそのものでは +ないことに注意して下さい。 +(EB ライブラリの他の関数も、すべてオブジェクトをポインタで渡します。) +

+ +

+CD-ROM 書籍を使うには、続いて EB_Book オブジェクトを +CD-ROM 書籍の実体に結び付けます。 +これは、関数 eb_bind() によって行います。 +

+ +
+
+EB_Book            CD−ROM書籍
+オブジェクト          ┌────────────┐
+┌───┐           │            │
+│   ┝━━━━━━━━━━━┥ /mnt/cdrom │
+└───┘ eb_bind() │            │
+                └────────────┘
+
+
+ +

+実際のプログラムでは、次のようにします。 +

+ +
+
+if (eb_bind(&book, "/mnt/cdrom") != EB_SUCCESS) {
+    printf("eb_bind() failed\n");
+    return;
+}
+
+
+ +

+eb_bind() に渡す書籍のパス (この例では /mnt/cdrom) +は書籍のトップディレクトリ、つまり catalog または +catalogs ファイルのあるディレクトリを指定します。 +

+ +

+EB_Book オブジェクトを使い終わったら、 +eb_finalize_book() を呼んで後始末をします。 +オブジェクトは書籍との結び付きを解かれた状態に戻り、内部で割り当てられた +メモリは解放され、開いていたファイルもすべて閉じられます。 +

+ +
+
+eb_finalize_book(&book);
+eb_finalize_book(book_pointer);
+
+
+ +

+オブジェクトの領域を malloc() で確保した場合は、 +eb_finalize_book() を呼んだ後ならば、オブジェクトの領域を +安全に解放することができます。 +

+ +
+
+free(book_pointer);
+
+
+ + +

遠隔ホストへの eb_bind()

+ +

+前節で説明した eb_bind() を用いて、EB_Book +オブジェクトを遠隔ホストの書籍に結びつけることができます。 +これには、書籍のパスの代わりに、遠隔アクセス用の識別子を指定します。 +識別子は、次のような形式をとります。 +

+ +
+
+ebnet://ホスト:ポート/書籍名
+
+
+ +

+ホスト は遠隔ホストの IP アドレスもしくはホスト名です。 +ただし、IPv6 アドレスを指定する場合は、アドレスを [ と +] で囲む必要があります。 +ポート は、そのホストが待ち受けているポートの番号です。 +ホストが待ち受けているポートが標準の 22010 番であれば、:ポート +の部分は省略可能です。 +

+ +

+以下に eb_bind() のコード例を記します。 +

+ +
+
+if (eb_bind(&book, "ebnet://localhost/cdrom") != EB_SUCCESS) {
+    printf("eb_bind() failed\n");
+    return;
+}
+
+
+ + +

サンプルプログラム

+ +

+このサンプルプログラムでは、CD-ROM 書籍の種類を調べるために、 +eb_disc_code() という関数を使用しています。 +この関数については、「関数の詳細」 を参照のこと。 +

+ + + + +

データ型の詳細

+ +

+この節で説明しているデータ型を使うには、次のようにヘッダファイルを +読み込んで下さい。 +

+ +
+
+#include <eb/eb.h>
+
+
+ + +

EB_Book

+ +

+EB_Book 型は、一冊の CD-ROM 書籍を表します。 +CD-ROM 書籍へのアクセスは、すべてこの型のオブジェクトを介して行います。 +同時に複数の CD-ROM 書籍にアクセスする際は、書籍一冊毎にオブジェクトを +作る必要があります。 +

+ +

+EB_Book オブジェクトの操作は、すべて EB ライブラリが用意 +している関数で行います。 +アプリケーションプログラムは、直接 EB_Book オブジェクトの +メンバを参照したり、セットしたりすべきではありません。 +

+ +

+EB_Book オブジェクトを使用する際は、まずそのオブジェクトに +対して eb_initialize_book() を呼んで初期化しなくては +なりません。 +

+ + +

EB_Disc_Code

+ +

+データ型 EB_Disc_Code は、CD-ROM 書籍の形式コードを表します。 +現在のところ、次の値が定義されています。 +

+ +
+
EB_DISC_EB
+
+電子ブック (EB, EBG, EBXA, EBXA-C, S-EBXA) であることを表します。 + +
EB_DISC_EPWING
+
+EPWING であることを表します。 + +
EB_DISC_INVALID
+
+不正な形式コード値を表します。 +
+ +

+この型は符合付き整数型の別名として定義されていますので、2 つのコードを +2 項演算子 ==!= で一致比較することができます。 +

+ + +

EB_Character_Code

+ +

+データ型 EB_Character_Code は、CD-ROM 書籍で使用される +文字コードを表します。 +現在のところ、次の値が定義されています。 +

+ +
+
EB_CHARCODE_ISO8859_1
+
+ISO 8859-1 (ラテン文字 1) を使用していることを表します。 +電子ブックの EBG はこれです。 + +
EB_CHARCODE_JISX0208
+
+JIS X 0208 (日本語のかな漢字) を使用していることを表します。 +EBG, EBXA-C 以外の電子ブック、および EPWING はすべてこれです。 + +
EB_CHARCODE_JISX0208_GB2312
+
+JIS X 0208 (日本語のかな漢字) と GB 2312 (中国語の簡体字) を併用している +ことを表します。 +電子ブックの EBXA-C はこれです。 + +
EB_CHARCODE_INVALID
+
+不正な文字コード値を表します。 +
+ +

+この型は符合付き整数型の別名として定義されていますので、2 つのコードを +2 項演算子 ==!= で一致比較することができます。 +

+ + +

関数の詳細

+ +

+この節で説明している関数を使うには、次のようにヘッダファイルを読み込んで +下さい。 +

+ +
+
+#include <eb/eb.h>
+
+
+ + +

void eb_initialize_book (EB_Book *book)

+ +

+関数 eb_initialize_book() は、book の指す +EB_Book オブジェクトを初期化します。 +EB_Book オブジェクトに対して EB ライブラリの他の関数を呼ぶ前に、 +必ずそのオブジェクトを初期化しなくてはなりません。 +初期化していないオブジェクトに対して、EB ライブラリの他の関数を呼んだ +場合の動作は未定義です。 +また、すでに初期化したオブジェクトに対して、再度 +eb_initialize_book() を呼んではいけません。 +呼んだ場合の動作は未定義です。 +

+ + +

EB_Error_Code eb_bind (EB_Book *book, const char *path)

+ +

+関数 eb_bind() は、book の指す EB_Book +オブジェクトを、パス path にある CD-ROM 書籍に結び付けます。 +パスには、書籍のトップディレクトリか遠隔アクセス識別子を指定します。 +書籍のトップディレクトリとは、catalog あるいは +catalogs ファイルの存在するディレクトリを指します。 +

+ +

+オブジェクトがすでに書籍に結び付いていた場合、その書籍との結び付きを +解いてから、path にある書籍に結び付けます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +このとき、副本は未選択の状態になります。 +失敗すると、オブジェクトを書籍との結び付きを解かれた状態にして、原因 +を示すエラーコードを返します。 +

+ +

+path は、EB_MAX_PATH_LENGTH バイトに収まていなくては +なりません。 +さらに、path が相対パスのときは、絶対パスに変換した結果がこの長さ +に収まっていなくてはなりません。 +これを超えると、EB_ERR_TOO_LONG_FILE_NAME を返します。 +

+ + +

void eb_finalize_book (EB_Book *book)

+ +

+関数 eb_finalize_book() は、book が指す +EB_Book オブジェクトの後始末を行います。 +

+ +

+オブジェクトが割り当てて管理していたメモリはすべて解放され、 +ファイルディスクリプタもすべて閉じられます。 +オブジェクトが書籍と結び付いていた場合は、結び付きが解かれます。 +

+ +

+後始末をしたオブジェクトに対して eb_bind() を呼ぶことで、 +オブジェクトを再利用することができます。 +

+ + +

int eb_is_bound (EB_Book *book)

+ +

+関数 eb_is_bound() は、book が書籍に結び付いているか +どうかを調べます。 +結び付いていれば 1 を返し、そうでなければ 0 を返します。 +

+ + +

EB_Error_Code eb_path (EB_Book *book const char *path)

+ +

+関数 eb_path() は、book に結び付いている書籍のパス +もしくは遠隔アクセス識別子を、path の指す領域に書き込みます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、path の指す領域に空文字列を書き込み、原因を示す +エラーコードを返します。 +

+ +

+book は、あらかじめ書籍に結び付いている必要があります。 +結びついていない場合は、EB_ERR_UNBOUND_BOOK を返します。 +

+ +

+path に書き込むパス名のバイト数は、最長で +EB_MAX_PATH_LENGTH になります。 +この長さは、末尾のナル文字を含みません。 +関数が返すパスは正規化された形になっているので、eb_bind() に +渡したときのものと同じとは限りません。 +たとえば、相対パスだった場合は、絶対パスに変換されます。 +

+ + +

EB_Error_Code eb_disc_type (EB_Book *book, EB_Disc_Code *disc_code)

+ +

+関数 eb_disc_type() は、book のディスクの形式を +disc_code の指す領域に書き込みます。 +書き込むディスクの形式の値は、EB_Disc_Code 型 +(「[CD-ROM 書籍と EB_Book オブジェクト] データ型の詳細」 を参照のこと) +のいずれかの定数値です。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、disc_code の指す領域に EB_DISC_INVALID +を書き込み、原因を示すエラーコードを返します。 +

+ +

+book は、あらかじめ書籍に結び付いていなければなりません。 +結びついていない場合は、EB_ERR_UNBOUND_BOOK を返します。 +

+ + +

EB_Error_Code eb_character_code (EB_Book *book, EB_Character_Code *character_code)

+ +

+関数 eb_character_code() は、book が書かれている +文字コードを character_code の指す領域に書き込みます。 +書き込む文字コードの値は、EB_Character_Code 型 +(「[CD-ROM 書籍と EB_Book オブジェクト] データ型の詳細」 を参照のこと) +のいずれかの定数値です。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、character_code の指す領域に +EB_CHARCODE_INVALID を書き込み、原因を示すエラーコードを +返します。 +

+ +

+book は、あらかじめ書籍に結び付いていなければなりません。 +結びついていない場合は、EB_ERR_UNBOUND_BOOK を返します。 +

+ + +

エラー処理

+ +

+EB ライブラリの関数の呼び出しは、常に成功するとは限りません。 +たとえば、EB_Book オブジェクトを書籍に結びつける関数 +eb_bind() には、引数として書籍のトップディレクトリを渡しますが、 +存在しないディレクトリを指定した場合、処理は失敗に終わります。 +

+ +

+一般にこうした事象は、ユーザが誤ったパスを指定したときに起こりますが、 +メモリ不足のように、ユーザのミスが原因ではない失敗も起こりえます。 +

+ +

+本章では、関数の呼び出しが失敗した場合の処理について説明します。 +

+ + + +

エラーコードとエラーメッセージ

+ +

+EB ライブラリの関数の多くは、戻り値として EB_Error_Code +型の値を返します。 +処理が成功したときに返す値は EB_SUCCESS ですが、失敗したときは +エラーの原因に応じて様々な値を返します。 +このため、EB ライブラリでは次のような EB_SUCCESS との比較処理 +がよく行われます。 +

+ +
+
+EB_Error_Code error_code;
+
+error_code = eb_bind(&book, "/mnt/cdrom");
+if (error_code != EB_SUCCESS) {
+    printf("eb_bind() failed\n");
+    return;
+}
+
+
+ +

+エラーコードの値は、関数 eb_error_message() によって +エラーメッセージに変換することもできます。 +こうすることで、エラーの原因をアプリケーションプログラムのユーザに +もう少し分かりやすく伝えることができます。 +

+ +
+
+error_code = eb_bind(&book, "/mnt/cdrom");
+if (error_code != EB_SUCCESS) {
+    printf("eb_bind() failed, %s\n",
+        eb_error_message(error_code));
+    return;
+}
+
+
+ +

+error_codeEB_ERR_TOO_LONG_FILENAME に +セットされていれば、次のようなエラーメッセージが出力されます。 +

+ +
+
+too long filename
+
+
+ +

+あるいは、次のように日本語のメッセージかも知れません。 +

+ +
+
+ファイル名が長すぎます
+
+
+ +

+メッセージの国際化機能 (NLS) を無効にして EB ライブラリをコンパイル +した場合は、常に英語のメッセージが返ります。 +有効にした場合は、ロケールの設定によってどちらの言語のメッセージが +返るかが決まります。 +

+ +

+本書ではプログラムを簡潔にするために、エラー処理は最低限しか行って +いません。 +けれども一般のアプリケーションプログラムでは、関数の呼び出しが成功 +したかどうかを常にチェックし、処理が失敗した際はエラーメッセージを出力 +して、ユーザにエラーの原因を伝えるのが望ましいといえます。 +

+ + +

エラーに対する寛容さ

+ +

+EB_Book オブジェクトは、状態に関するパラメタをいくつか持って +います。 +オブジェクトが CD-ROM 書籍に結び付いているかどうかも、こうしたパラメタ +のうちの一つです。 +

+ +

+引数に EB_Book オブジェクトへのポインタを取る関数には、 +あらかじめオブジェクトの特定のパラメタがセットされていることを前提と +しているものもあります。 +たとえば、eb_path() は、オブジェクトが書籍に結び付いていること +を前提としています。 +では、もしも書籍に結び付いていないオブジェクトを eb_path() に +渡したらどうなるでしょうか。 +

+ +
+
+EB_Book book;
+EB_Error_Code error_code;
+char path[EB_MAX_PATH_LENGTH + 1];
+
+eb_initialize_library();
+eb_initialize(&book);
+error_code = eb_path(&book, path);    /* どうなる? */
+
+
+ +

+この場合、eb_path()EB_ERR_UNBOUND_BOOK を +返します。 +EB ライブラリの関数は、必要なパラメタがセットされていないオブジェクトを +検知して拒絶します。 +

+ +

+しかしながら、参照マニュアルで明示されている場合を除いて、EB ライブラリ +の関数は、与えられたポインタが NULL かどうかまでは調べません。 +次のようなことをすると、プログラムを異常終了させてしまいます。 +

+ +
+
+eb_bind(NULL, "/mnt/cdrom");    /* 異常終了! */
+eb_bind(&book, NULL);           /* これも異常終了! */
+
+
+ + +

データ型の詳細

+ +

+この節で説明しているデータ型を使うには、次のようにヘッダファイルを +読み込んで下さい。 +

+ +
+
+#include <eb/error.h>
+
+
+ + +

EB_Error_Code

+ +

+データ型 EB_Error_Code は、EB ライブラリのエラーコードを +表します。 +この型は符合付き整数型の別名として定義されていますので、2 つのコードを +2 項演算子 ==!= で一致比較することができます。 +

+ +

+EB ライブラリでは、全部で EB_NUMBER_OF_ERRORS 個の +フックコードを定義しています。 +エラーコードの一覧については、 +次の節 (「エラーコードの一覧」 を参照のこと) +を参照して下さい。 +

+ + +

エラーコードの一覧

+ +

+この節で説明しているエラーコードを使うには、次のようにヘッダファイルを +読み込んで下さい。 +

+ +
+
+#include <eb/error.h>
+
+
+ + +

定数 EB_SUCCESS

+ +

+成功。 +エラーは起きていない。 +

+ + +

定数 EB_ERR_MEMORY_EXHAUSTED

+ +

+EB ライブラリが malloc() を呼び出したが、NULL +が返ってきた。 +

+ + +

定数 EB_ERR_TOO_LONG_FILE_NAME

+ +

+与えられた書籍のパス名が長すぎる。 +

+ + +

定数 EB_ERR_BAD_FILE_NAME

+ +

+書籍のパス名が不正である。 +

+ + +

定数 EB_ERR_BAD_DIR_NAME

+ +

+ディレクトリ名が不正である。 +(EB ライブラリの内部処理用なので、 +このエラーコードがアプリケーションプログラムに返ることはありません。) +

+ + +

定数 EB_ERR_TOO_LONG_WORD

+ +

+与えられた検索語は長すぎる。 +

+ + +

定数 EB_ERR_BAD_WORD

+ +

+与えられた検索語に不正な文字が含まれている。 +

+ + +

定数 EB_ERR_EMPTY_WORD

+ +

+与えられた検索語は空である。 +

+ + +

定数 EB_ERR_FAIL_GETCWD

+ +

+getcwd() もしくは getwd() が失敗した。 +

+ + +

定数 EB_ERR_FAIL_OPEN_CAT

+ +

+EB ライブラリが、書籍のカタログファイルを開くことに失敗した。 +

+ + +

定数 EB_ERR_FAIL_OPEN_CATAPP

+ +

+EB ライブラリが、appendix のカタログファイルを開くことに失敗した。 +

+ + +

定数 EB_ERR_FAIL_OPEN_TEXT

+ +

+EB ライブラリが、書籍の本文ファイルを開くことに失敗した。 +

+ + +

定数 EB_ERR_FAIL_OPEN_FONT

+ +

+EB ライブラリが、書籍の外字ファイルを開くことに失敗した。 +

+ + +

定数 EB_ERR_FAIL_OPEN_APP

+ +

+EB ライブラリが、appendix ファイルを開くことに失敗した。 +

+ + +

定数 EB_ERR_FAIL_OPEN_BINARY

+ +

+EB ライブラリが、バイナリデータファイルを開くことに失敗した。 +

+ + +

定数 EB_ERR_FAIL_READ_CAT

+ +

+EB ライブラリが、書籍のカタログファイルを読み込むことに失敗した。 +

+ + +

定数 EB_ERR_FAIL_READ_CATAPP

+ +

+EB ライブラリが、appendix のカタログファイルを読み込むことに失敗した。 +

+ + +

定数 EB_ERR_FAIL_READ_TEXT

+ +

+EB ライブラリが、書籍の本文ファイルを読むことに失敗した。 +

+ + +

定数 EB_ERR_FAIL_READ_FONT

+ +

+EB ライブラリが、書籍の外字ファイルを読み込むことに失敗した。 +

+ + +

定数 EB_ERR_FAIL_READ_APP

+ +

+EB ライブラリが、appendix のメインファイルを読み込むことに失敗した。 +

+ + +

定数 EB_ERR_FAIL_READ_BINARY

+ +

+EB ライブラリが、書籍のバイナリデータファイルを読み込むことに失敗した。 +

+ + +

定数 EB_ERR_FAIL_SEEK_CAT

+ +

+EB ライブラリが、書籍のカタログファイルのシークに失敗した。 +

+ + +

定数 EB_ERR_FAIL_SEEK_CATAPP

+ +

+EB ライブラリが、appendix のカタログファイルのシークに失敗した。 +

+ + +

定数 EB_ERR_FAIL_SEEK_TEXT

+ +

+EB ライブラリが、書籍の本文ファイルのシークに失敗した。 +

+ + +

定数 EB_ERR_FAIL_SEEK_FONT

+ +

+EB ライブラリが、書籍の外字ファイルのシークに失敗した。 +

+ + +

定数 EB_ERR_FAIL_SEEK_APP

+ +

+EB ライブラリが、appendix のメインファイルのシークに失敗した。 +

+ + +

定数 EB_ERR_FAIL_SEEK_BINARY

+ +

+EB ライブラリが、書籍のバイナリデータファイルのシークに失敗した。 +

+ + +

定数 EB_ERR_UNEXP_CAT

+ +

+EB ライブラリが、書籍のカタログファイル内で、期待とは異なるデータ列を +見つけた。 +

+ + +

定数 EB_ERR_UNEXP_CATAPP

+ +

+EB ライブラリが、appendix のカタログファイル内で、想定外のデータ列を +見つけた。 +

+ + +

定数 EB_ERR_UNEXP_TEXT

+ +

+EB ライブラリが、書籍の本文ファイル内で、想定外のデータ列を見つけた。 +

+ + +

定数 EB_ERR_UNEXP_FONT

+ +

+EB ライブラリが、書籍の外字ファイル内で、想定外のデータ列を見つけた。 +

+ + +

定数 EB_ERR_UNEXP_APP

+ +

+EB ライブラリが、appendix のメインファイル内で、想定外のデータ列を +見つけた。 +

+ + +

定数 EB_ERR_UNEXP_BINARY

+ +

+EB ライブラリが、書籍のバイナリデータファイル内で、想定外のデータ列を +見つけた。 +

+ + +

定数 EB_ERR_UNBOUND_BOOK

+ +

+呼び出された EB ライブラリの関数は、書籍に結び付けられた +EB_Book オブジェクトを引数にとるが、与えられたオブジェクトは +書籍に結び付けられていなかった。 +

+ + +

定数 EB_ERR_UNBOUND_APP

+ +

+呼び出された EB ライブラリの関数は、appendix に結び付けられた +EB_Appendix オブジェクトを引数にとるが、与えられた +オブジェクトは appendix に結び付けられて +いなかった。 +

+ + +

定数 EB_ERR_NO_SUB

+ +

+書籍は副本を一つも持っていない。 +

+ + +

定数 EB_ERR_NO_APPSUB

+ +

+appendix は副本を一つも持っていない。 +

+ + +

定数 EB_ERR_NO_FONT

+ +

+選択中の副本は、外字を一種類も持っていない。 +

+ + +

定数 EB_ERR_NO_TEXT

+ +

+選択中の副本は、本文データを持っていない。 +

+ + +

定数 EB_ERR_NO_CUR_SUB

+ +

+呼び出された関数は、副本が選択されている EB_Book +オブジェクトを引数としてとるが、与えられたオブジェクトでは選択されて +いなかった。 +

+ + +

定数 EB_ERR_NO_CUR_APPSUB

+ +

+呼び出された関数は、副本が選択されている EB_Appendix +オブジェクトを引数にとるが、与えられたオブジェクトでは選択されて +いなかった。 +

+ + +

定数 EB_ERR_NO_CUR_FONT

+ +

+呼び出された関数は、外字が選択されている EB_Book +オブジェクトを引数にとるが、与えられたオブジェクトでは選択されて +いなかった。 +

+ + +

定数 EB_ERR_NO_CUR_BINARY

+ +

+呼び出された関数は、バイナリデータの読み込み要求をセットしている +EB_Book オブジェクトを引数にとるが、与えられたオブジェクトでは +セットされていなかった。 +

+ + +

定数 EB_ERR_NO_SUCH_SUB

+ +

+EB_Book オブジェクトと副本コードが関数に与えられたが、 +EB_Book オブジェクトに結び付けられている書籍は、その +副本コードに一致する副本を持っていない。 +

+ + +

定数 EB_ERR_NO_SUCH_APPSUB

+ +

+EB_Appendix オブジェクトと副本コードが関数に与えられたが、 +EB_Appendix オブジェクトに結び付けられている appendix は、 +その副本コードに一致する副本を持っていない。 +

+ + +

定数 EB_ERR_NO_SUCH_FONT

+ +

+EB_Book オブジェクトと外字の縦のサイズが関数に与えられたが、 +EB_Book オブジェクトに結びつけられていた書籍で選択中の副本は、 +そのサイズの外字を持っていない。 +

+ + +

定数 EB_ERR_NO_SUCH_CHAR_BMP

+ +

+EB_Book オブジェクトと文字番号が関数に与えられたが、 +EB_Book オブジェクトに結び付けられていた書籍で選択中の副本は、 +その番号の外字のビットマップデータを持っていない。 +

+ + +

定数 EB_ERR_NO_SUCH_CHAR_TEXT

+ +

+EB_Appendix オブジェクトと文字番号が関数に与えられたが、 +EB_Appendix オブジェクトに結び付けられている appendix で +選択中の副本は、その番号の外字の代替文字列を持っていない。 +

+ + +

定数 EB_ERR_NO_SUCH_SEARCH

+ +

+選択中の副本は、指定された検索メソッドを持っていないので、検索は行えない。 +

+ + +

定数 EB_ERR_NO_SUCH_HOOK

+ +

+不正なフックコードが関数に渡された。 +

+ + +

定数 EB_ERR_NO_SUCH_BINARY

+ +

+指定された位置に、指定された形式のバイナリデータは存在しない。 +

+ + +

定数 EB_ERR_DIFF_CONTENT

+ +

+アプリケーションプログラムからテキストデータの取得を要求されたが、指定 +されたテキストデータの種類が、前回リクエストされたときと一致していない。 +

+ + +

定数 EB_ERR_NO_PREV_SEARCH

+ +

+eb_hit_list() が呼び出されたが、アプリケーションプログラム +から前もって検索のリクエストがなされていない。 +

+ + +

定数 EB_ERR_NO_SUCH_MULTI_ID

+ +

+EB_Book オブジェクトと複合検索コードが関数に渡されたが、 +結び付けられた書籍で選択中の副本は、そのコードに一致する複合検索を持って +いない。 +

+ + +

定数 EB_ERR_NO_SUCH_ENTRY_ID

+ +

+EB_Book オブジェクトと複合検索エントリコードが関数に +渡されたが、結び付けられた書籍で選択中の副本は、そのエントリコードに +一致する複合検索エントリを持っていない。 +

+ + +

定数 EB_ERR_TOO_MANY_WORDS

+ +

+アプリケーションプログラムから条件検索もしくは複合検索の検索をリクエスト +されたが、検索語の個数が多すぎる。 +

+ + +

定数 EB_ERR_NO_WORD

+ +

+アプリケーションプログラムから条件検索もしくは複合検索の検索をリクエスト +されたが、検索語がすべて空である。 +

+ + +

定数 EB_ERR_NO_CANDIDATES

+ +

+eb_multi_entry_candidates() が呼び出されたが、 +指定された複合検索エントリは、検索語の候補一覧データを持っていない。 +

+ + +

定数 EB_ERR_END_OF_CONTENT

+ +

+eb_forward_text() あるいは eb_backward_text() +で本文の頭出しを行おうとしたが、すでに本文の末尾ないし先頭に達していて、 +それ以上先に進むことができなかった。 +

+ + +

定数 EB_ERR_NO_PREV_SEEK

+ +

+あらかじめ eb_seek_text() でシークを行っていない状態で、 +テキストデータの読み込みや頭出しを行おうとした。 +

+ + +

定数 EB_ERR_EBNET_UNSUPPORTED

+ +

+この EB ライブラリは、遠隔ホストへのアクセスには対応していない。 +

+ + +

定数 EB_ERR_EBNET_FAIL_CONNECT

+ +

+遠隔ホストへのアクセスを試みたが、サーバ (EBNETD) に接続できなかった。 +

+ + +

定数 EB_ERR_EBNET_SERVER_BUSY

+ +

+遠隔ホストへの接続を行ったが、書籍にアクセスしているクライアントの数が +すでに上限に達しているため、その書籍を利用できなかった。 +

+ + +

定数 EB_ERR_EBNET_NO_PERMISSION

+ +

+遠隔ホストへの接続を行ったが、その書籍への利用権限がないため、サーバ +からアクセスを拒否された。 +

+ + +

定数 EB_ERR_UNBOUND_BOOKLIST

+ +

+呼び出された EB ライブラリの関数は、遠隔ホストに結び付けられた +EB_BookList オブジェクトを引数にとるが、与えられたオブジェクト +は遠隔ホストに結び付けられていなかった。 +

+ + +

定数 EB_ERR_NO_SUCH_BOOK

+ +

+EB_BookList オブジェクトと書籍の要素番号を関数に渡されたが、 +EB_BookList に結び付けられた遠隔ホスト上には、その要素番号に +該当する書籍は存在しない。 +

+ + +

関数の詳細

+ +

+この節で説明している関数を使うには、次のようにヘッダファイルを読み込んで +下さい。 +

+ +
+
+#include <eb/error.h>
+
+
+ + +

const char *eb_error_string (EB_Error_Code error_code)

+ +

+関数 eb_error_string() は、エラーコード error_code +を文字列に変換したものを返します。 +文字列の文字コードは、ASCII になります。 +たとえば、エラーコード値 EB_SUCCESS を渡すと文字列 +"EB_SUCCESS" を返します。 +未知のエラーコードを渡したときは、"EB_ERR_UNKNOWN" を返します。 +

+ + +

const char *eb_error_message (EB_Error_Code error_code)

+ +

+関数 eb_error_message() は、エラーコード error_code +に対応したメッセージを文字列にして返します。 +関数の返すメッセージは、英語か日本語になります。 +

+ +

+国際化機能を有効にして EB ライブラリをコンパイルしていない場合は、常に +英語のメッセージを返します。 +このときのメッセージの文字コードは、ASCII になります。 +

+ +

+メッセージの国際化機能 (NLS) を有効にして EB ライブラリをコンパイル +した場合は、ロケールの設定に応じてどちらの言語のメッセージを返すのか +が決まります。 +また、GNU gettext バージョン 0.36 以降では iconv() と連携することにより、 +メッセージの文字コードもロケールに応じて変化します。 +gettext が iconv() との連携を行わなければ、英語のメッセージは ASCII、 +日本語のメッセージは日本語 EUC になります。 +この関数の呼び出しによって、gettext のテキストドメインの設定は変化 +しません。 +

+ +

+未知のエラーコードを渡したときに返すメッセージは、英語では +"unknown error"、日本語では "未知のエラーです" +になります。 +

+ + +

副本

+ +

+紙に印刷された本では別々の書籍になっているものでも、電子ブックや EPWING +では 1 枚の CD-ROM にまとめることができます。 +

+ +

+たとえば、ある CD-ROM 書籍は、国語辞書、英々辞典、百科事典という 3 つ +の (印刷された本で言うところの) 「書籍」を持っていることもあり得ます。 +紛らわしさを避けるために、EB ライブラリではここで言う「書籍」のことを +副本 (subbook) と呼んでいます。 +

+ +
+
+   CD−ROM書籍
+┌─────────────┐
+│ 副本0: [国語辞典] │
+│ 副本1: [英々辞典] │
+│ 副本2: [百科事典] │
+└─────────────┘
+
+
+ +

+CD-ROM 書籍では、それぞれの副本はそれ自体が独立した書籍になっています。 +また、副本のデータも、副本毎に別々のファイルに収められています。 +したがって、EB ライブラリでも、アプリケーションプログラムの主要な処理 +である単語の検索や本文データの取得などは、すべて副本単位で行うように +なっています。 +

+ +

+本章では、EB ライブラリでの副本の扱い方について説明します。 +

+ + + +

副本コード

+ +

+EB ライブラリでは、それぞれの副本に対して 副本コード (subbook code) +を割り当てます。 +このコードは EB ライブラリが副本を識別するために用いますので、個々の +副本コードは、書籍内で同じものがないようになっています。 +

+ +

+以下のソースコードは、eb_subbook_list() という関数の +使用例です。 +この関数は、書籍内のすべての副本の副本コードを取得することができます。 +

+ +
+
+/* bookEB_Book のオブジェクトで、すでに
+ * 書籍に結び付けられていると仮定しています。*/
+EB_Subbook_Code sub_codes[EB_MAX_SUBBOOKS];
+int sub_count;
+
+if (eb_subbook_list(&book, sub_codes, &sub_count)
+    != EB_SUCCESS) {
+    printf("eb_subbook_list() failed\n");
+    return;
+}
+
+
+ +

+eb_subbook_list() が成功すると、書籍内のすべての副本コードが +配列 sub_codes[] に格納されます。 +配列の先頭の副本コードは sub_codes[0] と表され、次の +コードは sub_codes[1]、という具合になります。 +副本の個数は、sub_count に格納されます。 +

+ +

+個々の副本には、必ず題名が付けられています。 +先頭の副本 (sub_codes[0]) の題名は、次のようにして +得ることができます。 +

+ +
+
+char title[EB_MAX_TITLE_LENGTH + 1];
+
+if (eb_subbook_title2(&book, sub_codes[0], title)
+    != EB_SUCCESS) {
+    printf("eb_subbook_title2() failed\n");
+    return;
+}
+
+
+ +

+eb_subbook_title2() の呼び出しが成功すると、 +title に題名を表す文字列が格納されます。 +

+ +

+蛇足ですが、(副本ではなく) CD-ROM の題名を取得する関数はありません。 +なぜなら、題名を示すデータが CD-ROM の中には何処にもないからです。 +

+ + +

選択中の副本

+ +

+EB_Book オブジェクトは、結びつけられた CD-ROM 書籍の中の +任意の副本から一つ選んで、選択中の副本 (current subbook) +として指定することができます。 +複数の副本を、同時に選択することはできません。 +単語の検索や、本文データの取得など、ほとんどの操作は、選択中の副本に +対してだけ行えます。 +

+ +

+eb_bind()EB_Book オブジェクトを書籍に +結び付けた直後は、いずれの副本も選択されていない状態になっています。 +

+ +
+
+EB_Book         CD−ROM書籍
+オブジェクト
+┌────┐       ┌─────────────┐
+│選択中 │       │ 副本0: [国語辞典] │
+│の副本 │       │ 副本1: [英々辞典] │
+│<なし>│       │ 副本2: [百科事典] │
+└────┘       └─────────────┘
+
+
+ +

+副本の選択を行うには、関数 eb_set_subbook() を使用します。 +eb_set_subbook() は、引数として渡された副本コードに +したがって副本を選択します。 +以下は、先頭の副本 (sub_codes[0]) を選択する場合の例です。 +

+ +
+
+/* bookEB_Book のオブジェクトで、すでに
+ * 書籍に結び付けられていると仮定しています。*/
+EB_Subbook_Code sub_codes[EB_MAX_SUBBOOKS];
+int sub_count;
+
+if (eb_subbook_list(&book, sub_codes, &sub_count)
+    != EB_SUCCESS) {
+    printf("eb_subbook_list() failed\n");
+    return;
+}
+if (eb_set_subbook(&book, sub_codes[0]) != EB_SUCCESS) {
+    printf("eb_subbook_list() failed\n");
+    return;
+}
+
+
+ +

+成功すると、次のように副本が選択された状態になります。 +

+ +
+
+EB_Book         CD−ROM書籍
+オブジェクト
+┌────┐       ┌─────────────┐
+│選択中 │  ┏━━━━┿━副本0: [国語辞典] │
+│の副本 │  ┃    │ 副本1: [英々辞典] │
+│ *━━┿━━┛    │ 副本2: [百科事典] │
+└────┘       └─────────────┘
+
+
+ + +

サンプルプログラム

+ + + + +

データ型の詳細

+ +

+この節で説明しているデータ型を使うには、次のようにヘッダファイルを +読み込んで下さい。 +

+ +
+
+#include <eb/eb.h>
+
+
+ + +

EB_Subbook_Code

+ +

+データ型 EB_Subbook_Code は副本コードを表します。 +一冊の書籍の中の副本は、それぞれ一意の副本コードを持っています。 +この型は符合付き整数型の別名として定義されていますので、2 つのコードを +2 項演算子 ==!= で一致比較することが +できます。 +

+ +

+また、不正な副本コード値を表す EB_SUBBOOK_INVALID という +特別な副本コードが定義されています。 +利用可能な副本に対して、この副本コードが割り当てられることはありません。 +

+ + +

関数の詳細

+ +

+この節で説明している関数を使うには、次のようにヘッダファイルを読み込んで +下さい。 +

+ +
+
+#include <eb/eb.h>
+
+
+ + +

EB_Error_Code eb_load_all_subbooks (EB_Book *book)

+ +

+関数 eb_load_all_subbooks() は、book 内のすべての +副本を初期化します。 +通常、副本の初期化は、その副本が初めて選択されたときに自動的に行われますが、 +この関数は初期化を前倒しで行います。 +初期化の対象となるのは、この関数を呼び出した時点でまだ初期化していない +すべての副本です。 +この関数は、スタンドアロンで動作するサーバアプリケーションなどで有効です。 +クライアントからの接続を受ける前にこの関数を呼ぶことで、副本の初期化の +ためにクライアントを待たせなくて済みます。 +

+ +

+初期化の対象となったすべての副本の初期化に成功すれば、関数は +EB_SUCCESS を返します。 +一冊でも初期化に失敗した場合は、残りの副本の初期化を諦め、原因を示す +エラーコードを返します。 +

+ +

+book は、あらかじめ書籍に結び付けられていなくてはなりません。 +結びついていない場合は、EB_ERR_UNBOUND_BOOK を返します。 +

+ +

+この関数を呼び出すと、book は、副本を選択していない状態になります。 +

+ + +

EB_Error_Code eb_subbook_list (EB_Book *book, EB_Subbook_Code *subbook_list, int *subbook_count)

+ +

+関数 eb_subbook_list() は、book 内のすべて副本の +副本コードを EB_Subbook_Code 型の配列にして、 +subbook_list の指す領域に書き込みます。 +配列は、最大で EB_MAX_SUBBOOKS 個の要素を持ちます。 +加えて、書籍が収録している副本の個数を subbook_count の指す +領域に書き込みます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、subbook_count の指す領域に 0 を書き込み、原因を +示すエラーコードを返します。 +

+ +

+book は、あらかじめ書籍に結び付けられていなくてはなりません。 +結びついていない場合は、EB_ERR_UNBOUND_BOOK を返します。 +

+ + +

EB_Error_Code eb_subbook (EB_Book *book, EB_Subbook_Code *subbook_code)

+ +

+関数 eb_subbook() は、book が選択中の副本の +副本コードを subbook_code の指す領域に書き込みます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、subbook_code の指す領域に +EB_SUBBOOK_INVALID を書き込み、原因を示すエラーコードを +返します。 +

+ +

+あらかじめ、book はいずれかの副本を選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_SUB を返します。 +

+ + +

EB_Error_Code eb_subbook_title (EB_Book *book, char *title)

+ +

+関数 eb_subbook_title() は、book が選択中の副本の +題名を title の指す領域に文字列として書き込みます。 +題名の文字列の長さは、最長で EB_MAX_TITLE_LENGTH バイトです。 +この長さは、末尾のナル文字を含みません。 +

+ +

+書籍の文字コード +(「[CD-ROM 書籍と EB_Book オブジェクト] データ型の詳細」 を参照のこと) +が EB_CHARCODE_ISO8859_1 なら、題名を表す文字列は ISO 8859-1 +になり、それ以外の文字コードなら日本語 EUC になります。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、title の指す領域に空文字列を書き込み、原因を示す +エラーコードを返します。 +

+ +

+あらかじめ、book 内のいずれかの副本が選択されていなくては +なりません。 +選択していない場合は、EB_ERR_NO_CUR_SUB を返します。 +

+ + +

EB_Error_Code eb_subbook_title2 (EB_Book *book, EB_Subbook_Code subbook_code, char *title)

+ +

+eb_subbook_title() と似ていますが、選択中の副本ではなく、 +引数 subbook_code で指定された副本の題名を書き込む点が +異なります。 +

+ +

+book は副本を選択していなくても構いませんが、あらかじめ書籍 +に結び付けられていなければなりません。 +結びついていない場合は、EB_ERR_UNBOUND_BOOK を返します。 +

+ + +

EB_Error_Code eb_subbook_directory (EB_Book *book, char *directory)

+ +

+関数 eb_subbook_directory() は、book 内で現在 +選択中の副本のデータファイルを収めたディレクトリ名を、directory +の指す領域に書き込みます。 +

+ +

+ディレクトリ名の文字列の長さは、最長で +EB_MAX_DIRECTORY_NAME_LENGTH バイトです。 +この長さに、末尾のナル文字は含みません。 +ディレクトリ名は ASCII の数字、英小文字、アンダースコアで構成されます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、directory の指す領域に空文字列を書き込み、原因に +を示すエラーコードを返します。 +

+ +

+あらかじめ、book 内のいずれかの副本が選択されていなくては +なりません。 +選択していない場合は、EB_ERR_NO_CUR_SUB を返します。 +

+ + +

EB_Error_Code eb_subbook_directory2 (EB_Book *book, EB_Subbook_Code subbook_code, char *directory)

+ +

+eb_subbook_directory() と似ていますが、選択中の副本ではなく、 +引数 subbook_code で指定された副本のディレクトリ名を書き込む点 +が異なります。 +

+ +

+book は副本を選択していなくても構いませんが、あらかじめ +書籍に結び付けられていなければなりません。 +結びついていない場合は、EB_ERR_UNBOUND_BOOK を返します。 +

+ + +

EB_Error_Code eb_set_subbook (EB_Book *book, EB_Subbook_Code code)

+ +

+関数 eb_set_subbook() は、book の副本 +code を選択します。 +すでに副本を選択していた場合は、いったん未選択の状態にしてから副本 +subbook_code を選択します。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +このとき、外字は未選択の状態となり、検索、テキストデータの読み込み、 +バイナリデータの読み込みについての状態記録は、すべてリセットされます。 +失敗すると、副本を未選択の状態にして、原因を示すエラーコードを返します。 +

+ +

+あらかじめ、book は書籍に結び付けられていなければなりません。 +結びついていない場合は、EB_ERR_UNBOUND_BOOK を返します。 +

+ + +

void eb_unset_subbook (EB_Book *book)

+ +

+関数 eb_unset_subbook() は、book が選択している +副本を未選択の状態にします。 +book が書籍に結び付いていないか、副本が選択されていない場合は、 +何もしません。 +

+ + +

検索

+ +

+CD-ROM 書籍において、検索は非常に重要な機能です。 +EB ライブラリでは、次のような検索メソッドが利用できます。 +

+ +
    +
  • 前方一致検索 (word search) +
  • 後方一致検索 (end-word search) +
  • 完全一致検索 (exact-word search) +
  • 条件検索 (keyword search) +
  • クロス検索 (cross search) +
  • 複合検索 (multi search) +
+ +

+ただし、すべての CD-ROM 書籍、すべての副本で、ここに挙げたすべての +検索メソッドが利用可能なわけではありません。 +副本の中には、いずれの検索メソッドも提供しないものも存在します。 +

+ +

+EB ライブラリでは、検索を行うことができるのは、選択中の副本に対して +だけです。 +

+ +

+この章では、それぞれの検索メソッドの簡単な説明と、EB ライブラリでの +扱い方について説明します。 +

+ + + +

前方一致、後方一致、完全一致検索

+ +

+前方一致、後方一致、完全一致検索は、いずれも一個の入力語に一致する +エントリを探し出す検索メソッドです。 +

+ +

+前方一致検索は、入力語と先頭部分が一致するエントリを検索します。 +たとえば、「江戸」という語は、「江戸」「江戸時代」「江戸っ子」といった +エントリに一致します。 +

+ +

+後方一致検索は、入力語と末尾が一致するエントリを検索します。 +たとえば、`bye' という語は、`bye'、`good bye'、`bye bye' といった +エントリに一致します。 +

+ +

+完全一致検索は、一個の検索語と完全に一致するエントリだけを検索します。 +

+ +

+以下は、前方一致検索のプログラムの例です。 +選択中の副本の中から、先頭が librar で始まるエントリを探して +います。 +

+ +
+
+/* bookEB_Book のオブジェクトで、すでに
+ * 書籍に結び付けられ、副本を選択中だと仮定しています。*/
+#define MAX_HITS 50
+EB_Hit hits[MAX_HITS];
+int hit_count;
+
+if (eb_search_word(&book, "librar") != EB_SUCCESS) {
+    printf("eb_search_word() failed\n");
+    return;
+}
+if (eb_hit_list(&book, MAX_HITS, hits, &hit_count)
+    != EB_SUCCESS) {
+    printf("eb_hit_list() failed\n");
+    return;
+}
+
+
+ +

+eb_search_word() は前方一致検索をリクエストする関数です。 +この例では、librar という検索文字列を与えています。 +ただし、この関数は一致したエントリを返すことはしません。 +

+ +

+一致したエントリの取得は、続く eb_hit_list() 関数を +呼び出した際に行われます。 +eb_hit_list() は一致したエントリの一覧を配列 +hits[] の指す領域に書き込み、見つかった一致エントリの個数 +を &hit_count の指す領域に書き込みます。 +この例では、eb_hit_list() は最大で MAX_HITS +(= 50) 個 のエントリを探します。 +(つまり、50 個見つかったら検索を止めます。) +

+ +

+もし、選択中の副本が英々辞典だとすると、少なくとも library +と librarian という 2 つのエントリに関する情報が得られる +でしょう。 +このとき、配列 hits[] は次のようになっています。 +(ただし、librarylibrarian エントリの +順序は、下の絵とは異なっているかも知れません。) +

+ +
+
+┌───────────┬───────────┬─
+│ librarian │  library  │
+└───────────┴───────────┴─
+   hits[0]     hits[1]
+
+
+ +

+hits[] の中身については、本章の後ろの節でもう少し詳しく +説明します。 +

+ +

+ここまでは前方一致検索を例にとりましたが、後方一致の場合は +eb_search_word() の代わりに eb_search_endword() +を呼ぶようにします。 +他はすべて同じです。 +

+ +
+
+if (eb_search_endword(&book, "nalization") != EB_SUCCESS) {
+    printf("eb_search_endword() failed\n");
+    return;
+}
+
+
+ +

+完全一致の場合も同様です。 +eb_search_exactword() を呼ぶようにする以外は、すべて同じ +です。 +

+ +
+
+if (eb_search_exactword(&book, "library") != EB_SUCCESS) {
+    printf("eb_search_exactword() failed\n");
+    return;
+}
+
+
+ + +

条件検索

+ +

+条件検索は、複数個の入力語にすべて一致するエントリを検索します。 +たとえば、英々辞典の条件検索では、入力語をすべて含んだ例文を検索する +ようになっているかも知れません。 +

+ +

+以下は、条件検索で make, with という語の双方と +一致するエントリを、選択中の副本の中から探し出すプログラムの断片です。 +

+ +
+
+/* bookEB_Book のオブジェクトで、すでに
+ * 書籍に結び付けられ、副本を選択中だと仮定しています。*/
+static const char *keywords[3] = {"make", "with", NULL};
+
+if (eb_search_word(&book, keywords) != EB_SUCCESS) {
+    printf("eb_search_word() failed\n");
+    return;
+}
+
+
+ +

+条件検索を行う関数は、eb_search_keyword() です。 +前方一致、後方一致、完全一致検索の関数と基本的に扱い方は一緒ですが、 +複数の入力語を受け付けるようになっています。 +関数には、入力語の文字列 (へのポインタ) を配列にしたものを渡します。 +配列の最後には NULL を置き、配列の終端を明示する必要が +ある点に注意して下さい。 +

+ +

+前方一致、後方一致、完全一致検索と同様に、eb_search_keyword() +も検索のリクエストを行うだけで、一致したエントリの取得は行いません。 +エントリの取得には、やはり同様に eb_hit_list() 関数を +使います。 +

+ +
+
+EB_Hit hits[MAX_HITS];
+int hit_count;
+
+if (eb_hit_list(&book, MAX_HITS, hits, &hit_count)
+    != EB_SUCCESS) {
+    printf("eb_hit_list() failed\n");
+    return;
+}
+
+
+ + +

クロス検索

+ +

+クロス検索は、条件検索の亜種とも言うべき検索メソッドです。 +EPWING や電子ブックをみても、どういうルールで使い分けがなされているのか +分からない程、両者は実によく似ています。 +

+ +

+EB ライブラリでクロス検索を行う関数は eb_search_cross() +ですが、使い方は条件検索の関数 eb_search_keyword() と +まったく同じです。 +使い方の詳細は、「条件検索」 をご覧下さい。 +

+ + +

複合検索

+ +

+複合検索は、条件検索と同じく、複数個の入力語にすべて一致するエントリを +検索しますが、個々の入力語にあらかじめ題目が付けられています。 +

+ +

+また、前方一致、後方一致、完全一致、条件検索はすべて、各副本につき +一種類しかありませんが、複合検索だけは一つの副本の中で複数の種類が用意 +されていることがあります。 +たとえば、ある世界人名事典には、次のように人名検索用と頻出用語の検索用 +の 2 種類の複合検索が用意されているかも知れません。 +

+ +
+
+(複合検索その 1: 人名を検索する)
+    入力語 0: 国・地域
+    入力語 1: 時代
+    入力語 2: 性別
+    入力語 3: キーワード
+    入力語 4: キーワード
+
+
+ +
+
+(複合検索その 2: 頻出用語を検索する)
+    入力語 0: 用語
+    入力語 1: キーワード
+    入力語 2: キーワード
+
+
+ +

+この例のように、個々の複合検索は、入力語の題目だけでなく、入力語の数も +まちまちです。 +また、検索する際はすべての入力語を埋める必要はなく、少なくとも一個の +入力語が空でなければ、検索は成功します。 +

+ +

+副本内の複合検索は、種類毎に 複合検索コード (multi search code) +によって識別されます。 +関数 eb_multi_search_list() を使うと、選択中の副本で利用可能 +な複合検索の一覧が得られます。 +

+ +
+
+/* bookEB_Book のオブジェクトで、すでに
+ * 書籍に結び付けられ、副本を選択中だと仮定しています。*/
+EB_Multi_Search_Code multi_codes[EB_MAX_MULTI_SEARCHES];
+int multi_count;
+
+if (eb_multi_search_list(&book, multi_codes, &multi_count)
+    != EB_SUCCESS) {
+    printf("eb_multi_search_list() failed\n");
+    return;
+}
+
+
+ +

+この複合検索コードは、複合検索のための関数で必要となります。 +たとえば、eb_multi_title() は、指定した複合検索の題名 +(例:「人名検索」「頻出用語検索」) を取得する関数ですが、このときの +複合検索の指定には、複合検索コードを用います。 +以下の例では、一覧の先頭に載っている複合検索 (multi_codes[0]) +を指定しています。 +

+ +
+
+char title[EB_MAX_MULTI_TITLE_LENGTH + 1];
+
+if (eb_multi_title(&book, multi_codes[0], title)
+    != EB_SUCCESS) {
+    printf("eb_multi_title() failed\n");
+    return;
+}
+
+
+ +

+さらに関数によっては、複合検索コードに加えて、何番目の入力語かも指定 +してやる必要があります。 +たとえば、特定の入力語の題目を得る関数 eb_multi_entry_label() +が、これに該当します。 +0 番目の入力語 (つまり先頭の入力語) の題目を取得するには、次のように +します。 +

+ +
+
+char label[EB_MAX_MULTI_LABEL_LENGTH + 1];
+
+if (eb_multi_entry_label(&book, multi_code[0], 0, label)
+    != EB_SUCCESS) {
+    printf("eb_multi_entry_label() failed\n");
+    return;
+}
+
+
+ +

+複合検索を行う関数は、eb_search_multi() です。 +使い方は条件検索とほぼ同じで、入力語の文字列を配列にしたものを引数 +として渡し、配列の最後には NULL を置いて下さい。 +埋められていない入力語のところには、空文字列を置きます。 +

+ +

+eb_search_multi() も検索のリクエストを行うだけで、一致した +エントリの取得は行いません。 +取得するには eb_hit_list() を使います。 +

+ +
+
+EB_Hit hits[MAX_HITS];
+int hit_count;
+
+if (eb_hit_list(&book, MAX_HITS, hits, &hit_count)
+    != EB_SUCCESS) {
+    fprintf(stderr, "an error occurs.\n");
+    return;
+}
+
+
+ +

+なお、複合検索の入力語によっては +候補一覧 (candidates) があらじめ用意されていることがあります。 +これは、入力語として有効な語をあらかじめ列挙しておき、 +アプリケーションプログラムのユーザに選択させる仕組みです。 +候補一覧については、この章ではなく「テキストデータ」の章で説明します +(「複合検索の候補一覧」 を参照のこと)。 +

+ + +

一致エントリの情報

+ +

+eb_hit_list() は、リクエストされた検索 (前方一致、後方一致、 +完全一致、条件、複合) に一致したエントリの情報と見つかったエントリの +個数を、それぞれ EB_Hit 型の配列領域および int 型の +領域に書き込みます。 +

+ +
+
+/* bookEB_Book のオブジェクトで、すでに書籍に結び付け
+ * られ、副本を選択中だと仮定しています。*/
+EB_Hit hits[MAX_HITS];
+int hit_count;
+
+if (eb_hit_list(&book, MAX_HITS, hits, &hit_count)
+    != EB_SUCCESS) {
+    fprintf(stderr, "an error occurs.\n");
+    return;
+}
+
+
+ +

+EB_Hit 配列の個々の要素には、一致したエントリの +見出し (heading)本文 (text) の開始位置が +書き込まれています。 +

+ +
+
+             見出し
+            ┌────────────┐
+ EB_Hit   ┏━┿librarian n.│
+┌───────┐ ┃ └────────────┘
+│heading┿━┛  本文
+│       │   ┌────────────────────┐
+│   text┿━━━┿librarian           │
+└───────┘   │n.(1)A person who is│
+            │a specialist in     │
+            │library work.(2)... │
+            └────────────────────┘
+
+
+ +

+見出しと本文についてのより詳しい解説と取得方法については、 +「テキストデータ」 を参照のこと。 +

+ + +

残っているエントリの取得

+ +

+前に述べたように、eb_hit_list() を呼び出すときは、一致する +エントリを最大で何個まで探すのかを引数で指定します。 +また、eb_hit_list() は処理が成功すると、実際に見つかった +エントリの数をアプリケーションプログラムに教えます。 +

+ +
+
+error_code = eb_hit_list(&book, MAX_HITS, hits, &hit_count);
+if (error_code == EB_SUCCESS)
+    printf("%d entries found\n", hit_count);
+
+
+ +

+指定した最大個数よりも多くの一致エントリが副本に存在している場合は、 +eb_hit_list() を繰り返し呼び出すことで、残りのエントリを +取得することができます。 +

+ +
+
+for (;;) {
+    if (eb_hit_list(&book, MAX_HITS, hits, &hit_count)
+        != EB_SUCCESS) {
+        fprintf(stderr, "an error occurs.\n");
+        return;
+    }
+    if (hit_count == 0)
+        break;
+    /* 取得した一致エントリの処理 */
+}
+
+
+ +

+一致エントリがもう残っていなければ、eb_hit_list() は +&hit_count の指す領域に 0 を書き込んで、 +EB_SUCCESS を返します。 +

+ +

+ただし、途中で eb_hit_list() が失敗すると +(EB_SUCCESS 以外の値を返すと)、検索リクエストに関する +状態記録はリセットされるため、一致エントリの取得をそれ以上続けることは +できません。 +

+ + +

重複エントリの削除

+ +

+eb_hit_list() を用いて一致したエントリを取得すると、中身が +実質的に変わらないエントリが複数含まれていることがあります。 +EB ライブラリは、こうした重複エントリの削除は行いません。 +必要なら、アプリケーション側で行うことになります。 +

+ +

+重複を完璧に取り除くなら、以下のすべての条件に一致するエントリを +重複エントリとみなし、二度目以降に出現したエントリを削除します。 +

+ +
    +
  • エントリの指す本文の位置が同じ +
  • エントリの指す見出しの文字列 (位置ではなく文字列そのもの) が同じ +
+ +

+(見出し文字列の取得方法については、 +「テキストデータ」 を参照のこと。) +

+ +

+重複は、直前のエントリに対してのみ起こるとは限りません。 +たとえば、eb_hit_list() で一致エントリが 50 個得られた場合、 +最後の 50 個目は前方の 49 個と重複検査を行う必要があります。 +したがって、全体ではエントリ同士の比較を 1 + 2 + ... + 49 = 1225 回 +行うことになります。 +

+ +

+書籍によっては重複エントリが取りきれない可能性もありますが、もう少し +簡単な方法もいくつかあります。 +処理を簡単にする第一の方法は、重複エントリの判定条件を次のように変える +ことです。 +

+ +
    +
  • エントリの指す本文の位置が同じ +
  • エントリの指す見出しの文字列の位置が同じ +
+ +

+さらに処理を簡単にするには、直前の 1個のエントリに対してだけ重複検査を +行うという方法もあります。 +これなら、50 個の一致エントリに対して、比較は 49 回で済みます。 +ただしこの方法は、書籍によってはまったく効果がありません。 +

+ + +

サンプルプログラム

+ + + + +

データ型の詳細

+ +

+この節で説明しているデータ型を使うには、次のようにヘッダファイルを +読み込んで下さい。 +

+ +
+
+#include <eb/eb.h>
+
+
+ + +

EB_Hit

+ +

+EB_Hit は、検索に一致したエントリの情報を格納するための +データ型です。 +内部構造は、次のように定義されています。 +

+ +
+
+typedef struct EB_Hit_Struct EB_Hit;
+
+struct EB_Hit_Struct {
+    EB_Position heading;  /* 見出しの位置 */
+    EB_Position text;     /* 本文の位置   */
+};
+
+
+ +

+アプリケーションプログラムは、直接 EB_Hit オブジェクトの +メンバを参照したり、セットしたりしても構いません。 +

+ + +

EB_Position

+ +

+データ型 EB_Position は、副本のデータの位置を表します。 +内部構造は、次のように定義されています。 +

+ +
+
+typedef struct EB_Position_Struct EB_Position;
+
+struct EB_Position_Struct {
+    int page;     /* ページ番号 */
+    int offset;   /* ページ内のオフセット */
+};
+
+
+ +

+ページ番号は 1 から始まり、ページ内のオフセットは 0 〜 2047 の範囲と +なります。 +ただし、アプリケーションプログラムを作成する上で、このことを覚えておく +必要はありません。 +

+ +

+アプリケーションプログラムは、直接 EB_Position オブジェクト +のメンバを参照したり、セットしたりしても構いません。 +

+ + +

EB_Multi_Search_Code

+ +

+データ型 EB_Multi_Search_Code は複合検索コードを表します。 +副本に用意されている複合検索は、それぞれ一意の複合検索コードを +持っています。 +この型は符合付き整数型の別名として定義されていますので、2 つのコードを +2 項演算子 ==!= で一致比較することが +できます。 +

+ +

+また、不正な複合検索コード値を表す EB_MULTI_INVALID という +特別な副本コードが定義されています。 +利用可能な複合検索に対して、この複合検索コードが割り当てられることは +ありません。 +

+ + +

関数の詳細

+ +

+この節で説明している関数を使うには、次のようにヘッダファイルを読み込んで +下さい。 +

+ +
+
+#include <eb/eb.h>
+
+
+ + +

int eb_have_word_search (EB_Book *book)

+ +

int eb_have_endword_search (EB_Book *book)

+ +

int eb_have_exactword_search (EB_Book *book)

+ +

+関数 eb_have_word_search() は、book が選択中の +副本で前方一致検索メソッドが利用可能どうかを調べます。 +同様に eb_have_endword_search() は後方一致検索メソッドに +ついて、eb_have_exactword_search() は完全一致検索メソッドに +ついて利用可能どうかを調べます。 +

+ +

+利用可能なら 1 を返します。 +メソッドを持っていないか、そもそも副本が選択されていない場合は 0 を +返します。 +

+ + +

int eb_have_keyword_search (EB_Book *book)

+ +

+関数 eb_have_keyword_search() は、book が選択中の +副本で条件検索メソッドが利用可能どうかを調べます。 +

+ +

+利用可能なら 1 を返します。 +メソッドを持っていないか、そもそも副本が選択されていない場合は 0 を +返します。 +

+ + +

int eb_have_multi_search (EB_Book *book)

+ +

+関数 eb_have_multi_search() は、book が選択中の +副本で複合検索メソッドが利用可能どうかを調べます。 +

+ +

+最低 1 種類でも利用可能なら 1 を返します。 +メソッドを持っていないか、そもそも副本が選択されていない場合は 0 を +返します。 +

+ + +

EB_Error_Code eb_multi_search_list (EB_Book *book, EB_Multi_Search_Code *multi_list, int *multi_count)

+ +

+関数 eb_multi_search_list() は、book が選択中の +副本に用意されている複合検索を調べ、複合検索コードの一覧を +EB_Multi_Search_Code 型の配列にして、multi_list +の指す領域に書き込みます。 +配列は、最大で EB_MAX_MULTI_SEARCHES 個の要素を持ちます。 +加えて、複合検索の種類数を multi_count の指す領域に書き込みます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、subbook_count の指す領域に 0 を書き込み、原因を示す +エラーコードを返します。 +

+ +

+あらかじめ、book はいずれかの副本を選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_SUB を返します。 +

+ + +

EB_Error_Code eb_multi_entry_count (EB_Book *book, EB_Multi_Search_Code multi_id, int *entry_count)

+ +

+関数 eb_multi_search_list() は、book が選択中の +副本に用意されている複合検索 multi_id について調べ、入力語の +個数を entry_count の指す領域に書き込みます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +このとき書き込まれる入力語の個数は、1 以上 EB_MAX_MULTI_ENTRIES +以下になります。 +失敗すると、entry_count の指す領域には 0 を書き込み、原因を示す +エラーコードを返します。 +

+ +

+あらかじめ、book はいずれかの副本を選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_SUB を返します。 +

+ + +

EB_Error_Code eb_multi_title (EB_Book *book, EB_Multi_Search_Code multi_id, char *title)

+ +

+関数 eb_multi_search_list() は、book が選択中の +副本に用意されている複合検索 multi_id の題名を title +の指す領域に書き込みます。 +題目は最長で EB_MAX_MULTI_TITLE_LENGTH バイトになります。 +この長さに、ナル文字は含みません。 +

+ +

+書籍の文字コード +(「[CD-ROM 書籍と EB_Book オブジェクト] データ型の詳細」 を参照のこと) +が EB_CHARCODE_ISO8859_1 なら、題目を表す文字列は ISO 8859-1 +になり、それ以外の文字コードなら日本語 EUC になります。 +

+ +

+書籍によっては、複合検索は用意していても、複合検索の題名データを持って +いないことがあります。 +その場合、EB ライブラリが代わりに付けた題名が title に +書き込まれます。 +

+ +

+書籍の文字コードが EB_CHARCODE_ISO8859_1 なら、 +EB ライブラリが付ける題名は、"Multi Search 1", "Multi Search 2", ... +になります。 +それ以外の文字コードであれば、題名は日本語 EUC で書かれた「複合検索 1」 +「複合検索 2」... という文字列になります。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、label の指す領域には空文字列を書き込み、原因を示す +エラーコードを返します。 +

+ +

+あらかじめ、book はいずれかの副本を選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_SUB を返します。 +

+ + +

EB_Error_Code eb_multi_entry_label (EB_Book *book, EB_Multi_Search_Code multi_id, int entry_index, char *label)

+ +

+関数 eb_multi_search_list() は、book が選択中の +副本に用意されている複合検索 multi_id について調べ、 +entry_index 番目の検索語の題目を label の指す領域に +書き込みます。 +entry_index は、先頭の検索語を 0 番目と数えます。 +題目は最長で EB_MAX_MULTI_LABEL_LENGTH バイトになります。 +この長さに、ナル文字は含みません。 +

+ +

+書籍の文字コード +(「[CD-ROM 書籍と EB_Book オブジェクト] データ型の詳細」 を参照のこと) +が EB_CHARCODE_ISO8859_1 なら、題目を表す文字列は ISO 8859-1 +になり、それ以外の文字コードなら日本語 EUC になります。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、label の指す領域には空文字列を書き込み、原因を示す +エラーコードを返します。 +

+ +

+あらかじめ、book はいずれかの副本を選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_SUB を返します。 +

+ + +

int eb_multi_entry_have_candidates (EB_Book *book, EB_Multi_Search_Code multi_id, int entry_index)

+ +

+関数 eb_multi_search_list() は、book が選択中の +副本に用意されている複合検索 multi_id について調べ、 +entry_index 番目の検索語が候補一覧を持っているかどうか調べます。 +entry_index は、先頭の検索語を 0 番目と数えます。 +

+ +

+持っていれば 1 を返します。 +持っていないか、そもそも副本が選択されていない場合、あるいは +multi_id, や entry_index が不正な値だった場合は +0 を返します。 +

+ + +

EB_Error_Code eb_multi_entry_candidates (EB_Book *book, EB_Multi_Search_Code multi_id, int entry_index, EB_Position *position)

+ +

+関数 eb_multi_search_list() は、book が選択中の +副本に用意されている複合検索 multi_id について調べ、 +entry_index 番目の検索語の候補一覧の位置を position +の指す領域に書き込みます。 +先頭の検索語が 0 番目になります。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、positin の指す領域には eb_seek_text() +が必ず失敗する位置情報を書き込み、原因を示すエラーコードを返します。 +

+ +

+あらかじめ、book はいずれかの副本を選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_SUB を返します。 +

+ + +

EB_Error_Code eb_search_word (EB_Book *book, const char *input_word)

+ +

EB_Error_Code eb_search_endword (EB_Book *book, const char *input_word)

+ +

EB_Error_Code eb_search_exactword (EB_Book *book, const char *input_word)

+ +

+関数 eb_search_word() は、book が選択中の副本に +対する前方一致検索をリクエストします。 +同様に eb_search_endword() は後方一致検索を、 +eb_search_exactword() は完全一致検索をリクエストします。 +

+ +

+検索する語は、引数 input_word で指定します。 +ただし、これらの関数は検索をリクエストするだけで、一致したエントリの +情報を返すことはしません。 +一致したエントリの取得には eb_hit_list() を使います。 +関数は、成功すると EB_SUCCESS を返します。 +失敗すると、原因を示すエラーコードを返します。 +失敗すると、関数を呼び出す前にリクエストしていた検索の状態記録はリセット +されますので、その状態のまま eb_hit_list() を呼び出しても、 +やはり失敗に終わります。 +

+ +

+書籍の文字コード +(「[CD-ROM 書籍と EB_Book オブジェクト] データ型の詳細」 を参照のこと) +が EB_CHARCODE_ISO8859_1 なら、関数に渡す検索語は ISO 8859-1 +で書かれていなければなりません。 +それ以外の文字コードの場合は、日本語 EUC で書かれていなければなりません。 +不正な文字番号を含んでいた場合、関数は EB_ERR_BAD_WORD を +返します。 +

+ +

+加えて、検索語は 1 バイト以上、EB_MAX_WORD_LENGTH (= 255) +バイト以下でなければなりません。 +この長さに、ナル文字は含みません。 +長すぎる場合は、EB_ERR_TOO_LONG_WORD を、 +長さが 0 (空文字列) の場合は EB_ERR_EMPTY_WORD を返します。 +

+ +

+あらかじめ、book はいずれかの副本を選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_SUB を返します。 +なお、一致するエントリが最低 1 個あるかどうかは、戻り値には影響しません。 +

+ + +

EB_Error_Code eb_search_keyword (EB_Book *book, const char * const input_words[])

+ +

EB_Error_Code eb_search_cross (EB_Book *book, const char * const input_words[])

+ +

EB_Error_Code eb_search_multi (EB_Book *book, EB_Multi_Search_Code multi_id, const char * const input_words[])

+ +

+関数 eb_search_keyword() は、book が選択中の +副本に対する条件検索をリクエストします。 +同様に eb_search_cross() はクロス検索を、 +eb_search_multi() は複合検索をそれぞれリクエストします。 +

+ +

+検索する語は、引数 input_words で指定します。 +条件検索と複合検索はいずれも複数個の検索語を受け付けますので、検索語を +配列にして渡します。 +このとき、配列の末尾の要素には NULL を置き、配列の終端を +明示します。 +

+ +

+いずれの関数も検索をリクエストするだけで、一致したエントリの情報を +返すことはしません。 +一致したエントリの取得には eb_hit_list() を使います。 +関数は、成功すると EB_SUCCESS を返します。 +失敗すると、原因を示すエラーコードを返します。 +失敗すると、関数を呼び出す前にリクエストしていた検索の状態記録はリセット +されますので、その状態のまま eb_hit_list() を呼び出しても、 +やはり失敗に終わります。 +

+ +

+書籍の文字コード +(「[CD-ROM 書籍と EB_Book オブジェクト] データ型の詳細」 を参照のこと) +が EB_CHARCODE_ISO8859_1 なら、関数に渡す検索語は ISO 8859-1 +で書かれていなければなりません。 +それ以外の文字コードの場合は、日本語 EUC で書かれていなければなりません。 +不正な文字番号を含んでいた場合、関数は EB_ERR_BAD_WORD を +返します。 +

+ +

+加えて、個々の検索語は EB_MAX_WORD_LENGTH (= 255) バイト以下 +でなければなりません。 +この長さに、ナル文字は含みません。 +長すぎる場合は、EB_ERR_TOO_LONG_WORD を返します。 +長さが 0 バイトの検索語は無視されますが、少なくとも 1 個の検索語は長さ +が 1 以上ないといけません。 +長さが 1 以上の検索語が 1 つもないときは、EB_ERR_NO_WORD を +返します。 +

+ +

+末尾の NULL を除いた配列の要素数は、条件検索では EB_MAX_KEYWORDS +以下、クロス検索では EB_MAX_CROSS_ENTRIES 以下、 +複合検索では EB_MAX_MULTI_ENTRIES 以下でなくては +なりません。 +個数が多すぎると EB_ERRO_TOO_MANY_WORDS を返します。 +空文字列の要素を差し引いた個数ではなく、単純に渡された要素数が上限を +超えているとエラーになりますので、注意が必要です。 +

+ +

+あらかじめ、book はいずれかの副本を選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_SUB を返します。 +なお、一致するエントリが最低 1 個あるかどうかは、戻り値には影響しません。 +

+ + +

EB_Error_Code eb_hit_list (EB_Book *book, int max_hit_count, EB_Hit *hit_list, int *hit_count)

+ +

+関数 eb_hit_list() は、あらかじめ以下のいずれかの関数で +リクエストされた検索を実行し、一致したエントリを取得します。 +

+ +
    +
  • eb_search_word() (前方一致検索) +
  • eb_search_endword() (後方一致検索) +
  • eb_search_exactword() (完全一致検索) +
  • eb_search_keyword() (条件検索) +
  • eb_search_cross() (クロス検索) +
  • eb_search_multi() (複合検索) +
+ +

+したがって、この関数を呼ぶ前に、上記のいずれかの関数の呼び出しに成功して +いなくてはなりません。 +

+ +

+eb_hit_list() は最大で max_hit_count 個の +一致エントリを hit_list に書き込みます。 +そして、書き込んだ一致エントリの数を hit_count が指す領域に +書き込みます。 +それ以上の個数の一致エントリが存在する場合、残ったエントリの情報は、 +この関数を繰り返し呼び出すことで得ることができます。 +

+ +

+ただし、以下に挙げた関数を呼び出すと、リクエストした検索に関する状態記録 +がリセットされますので、一致したエントリの取得は継続できなくなります。 +

+ +
    +
  • eb_set_subbook() +
  • eb_unset_subbook() +
  • eb_load_all_subbooks() +
  • eb_bind() +
  • eb_finalize_book() +
  • eb_search_word() +
  • eb_search_endword() +
  • eb_search_exactword() +
  • eb_search_keyword() +
  • eb_search_cross() +
  • eb_search_multi() +
+ +

+繰り返し呼んだ場合も、一致したエントリの情報はその都度 hit_list +の先頭から書き込み、hit_count が指す領域に書き込む値も、その回 +の eb_hit_list() の呼び出しで書き込んだ一致エントリの数に +なります。 +

+ +

+成功すると、この関数は EB_SUCCESS を返します。 +たとえ一致したエントリがなくても、処理が正常に終了すれば、関数は +EB_SUCCESS を返します。 +

+ +

+失敗すると、hit_count が指す領域に 0 を書き込み、原因を示す +エラーコードを返します。 +この場合、リクエストしていた検索の状態記録はリセットされますので、 +これ以上 eb_hit_list() を呼んで、残った一致エントリを取得 +することはできなくなります。 +

+ +

+あらかじめ、book はいずれかの副本を選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_SUB を返します。 +また、先に挙げた検索のリクエストが成功していない状態でこの関数を呼ぶと、 +EB_ERR_NO_PREV_SEARCH を返します。 +

+ + +

テキストデータ

+ +

+テキストデータの取得は、検索と並ぶ重要な機能です。 +

+ +

+ここで言う テキストデータ (text data) は、 +本文 (text body) という意味ではありません。 +CD-ROM 書籍には確かに本文も存在しますが、本文と同じデータ形式を用いて +書かれたデータが数種類あります。 +本書では、これらのデータをまとめてテキストデータと呼んでいます。 +EB ライブラリが扱えるテキストデータの種類には、次のものがあります。 +

+ +
    +
  • 見出し +
  • 本文 +
  • メニュー +
  • 著作権表示 +
  • 複合検索の入力語の候補一覧 +
+ +

+本章では、これらのテキストデータの取得と加工方法について説明します。 +

+ + + +

テキストデータのシークと読み込み

+ +

+UNIX でプログラムを組んだ経験のある方には、ファイルからデータを読み込む +際に用いる lseek(), read() というシステムコール +をご存じの方も多いでしょう。 +

+ +

+EB ライブラリでも、テキストデータの取得には、シーク (seek) と +読み込み (read) という 2 つの操作で行います。 +ただし、EB ライブラリではファイルポインタやディスクリプタはなく、 +EB_Book オブジェクトを通じてシークや読み込みの操作を行います。 +

+ +

+また、シーク時に指定する位置も off_t 型ではなく、 +EB_Position 型 (「[検索] データ型の詳細」 を参照のこと) +のオブジェクトを用います。 +たとえば、本文の先頭位置は、eb_text() という関数を使って +次のように取得できますが、このときも位置データは EB_Position +型オブジェクトに書き込まれます。 +

+ +
+
+EB_Position position;
+
+/* 関数の処理が成功すると、position に本文の開始位置が
+ * 書き込まれます。 */
+if (eb_text(&book, &position) != EB_SUCCESS) {
+    fprintf(stderr, "an error occurs.\n");
+    return;
+}
+
+
+ +

+参考までに、EB_Position 型の内部構造は、次のようになっています。 +

+ +
+
+typedef struct EB_Position_Struct EB_Position;
+
+struct EB_Position_Struct {
+    int page;     /* ページ番号 */
+    int offset;   /* ページ内のオフセット */
+};
+
+
+ +

+検索して見つかった一致エントリの見出しや本文を読み込む際にも、位置情報 +の指定には EB_Position 型が使われます。 +一致したエントリの情報は、関数 eb_hit_list() によって +EB_Hit という型のオブジェクトに書き込まれますが、 +EB_Hit 型は次のように定義されています。 +(詳しくは 「[検索] データ型の詳細」 を参照のこと。) +

+ +
+
+typedef struct {
+    EB_Position heading;   /* 見出しの位置 */
+    EB_Position text;      /* 本文の位置   */
+} EB_Hit;
+
+
+ +

+つまり、このときの見出しと本文の位置も、EB_Position 型で +表現されているのです。 +

+ +

+では、実際のプログラムを例にして、シークと読み込みを行ってみます。 +まずは、シークからです。 +これには関数 eb_seek_text() を用います。 +ここでもやはり、位置は EB_Position 型で渡します。 +

+ +
+
+if (eb_seek_text(&book, &position) != EB_SUCCESS) {
+    fprintf(stderr, "an error occurs.\n");
+    return;
+}
+
+
+ +

+データの種類 (見出し、本文 ...) によらず、テキストデータのシークは +すべて eb_seek_text() で行います。 +

+ +

+ただし、EB_Book オブジェクトは、テキストデータの種類別に +読み込み位置を覚えているわけではなく、全種類のテキストデータで共有する +位置情報を一つ覚えているだけです。 +たとえば、本文を読み込んだ後で、別の位置にシークして見出しを読み込むと、 +EB_Book は本文の読み込み位置のことは忘れてしまいます。 +

+ +

+さて、シークが終わったら、データを読み込みます。 +読み込もうとするテキストデータの種類によって、使用する関数が異なります。 +見出しだけは eb_read_heading() を使いますが、それ以外では +eb_read_text() を使います。 +

+ +

+以下は、eb_read_text() の使用例です。 +

+ +
+
+#define MAX_LENGTH 1000
+char buffer[MAX_LENGTH + 1];
+ssize_t text_length;
+
+if (eb_read_text(&book, NULL, NULL, NULL, MAX_LENGTH,
+    text, &text_length) != EB_SUCCESS) {
+    fprintf(stderr, "an error occurs.\n");
+    return;
+}
+
+
+ +

+成功すると、text にはテキストデータが、 +text_length には実際に読み込んだバイト数が書き込まれます。 +テキストは最大で MAX_LENGTH バイト書き込まれます。 +テキストデータはさらにナル文字で終端されますので、buffer には +もう 1 バイト分の領域が必要になります。 +

+ +

+eb_read_heading() の呼び出し方も、eb_read_text() +とまったく変わりません。 +

+ +
+
+if (eb_read_heading(&book, NULL, NULL, NULL, MAX_LENGTH,
+    text, &text_length) != EB_SUCCESS) {
+    fprintf(stderr, "an error occurs.\n");
+    return;
+}
+
+
+ +

+eb_read_text()eb_read_heading() で読み込んだ +テキストデータは平文のテキストになっていて、ナル文字で終端されています。 +

+ +
+
+printf("%s\n", text);   /* 出力してみる */
+
+
+ +

+読み込みたいテキストデータが長すぎて、eb_read_text() +あるいは eb_read_heading() を一回呼び出しただけでは全部 +読み込めなかった場合は、再度呼び出すことで続きのデータを読み込むことが +できます。 +

+ + +

テキストデータの内部形式

+ +

+前節の例では、読み込んだテキストデータは、平文テキストになっていました。 +けれども、CD-ROM 書籍内に平文テキストのデータが、そのまま収録されている +わけではありません。 +

+ +

+実際のテキストデータの例を、以下に示します。 +左側のブロックは 16 進数でダンプした様子で、右側はそれを基に JIS X 0208 +(日本語のかな漢字) の文字を表している部分を [ ] という形に +直したものです。 +

+ +
+
+     (16進数によるダンプ)            (可能な部分をかな漢字に変換)
+1f0900011f41010026321f611f042121   1f0900011f410100[Σ]1f611f04[ ]
+212721211f053e704a734a541f0a1f04   [:][ ]1f05[情][報][編]1f0a1f04
+214e1f0525372530255e1f04214f2121   [[]1f05[シ][グ][マ]1f04[]][ ]
+214a237323692367236d236121212370   [(][s][i][g][m][a][ ][p]
+2372236f236a236523632374214b1f05   [r][o][j][e][c][t][)]1f05
+
+
+ +

+右側のブロックを見ると、おおよそ平文に近い形でテキストデータが収められて +いることが分かりますが、ところどころに「文字」ではないデータも含まれて +います。 +

+ +

+文字ではない部分は、すべて「エスケープシーケンス」と呼ばれるものです。 +エスケープシーケンスとは、テキストデータを出力する際に、改行の禁止や +強調修飾といった制御情報を伝えるための仕組みです。 +16 進数の 1f が、エスケープシーケンスの開始を意味します。 +

+ +

+参考までに、上のテキストデータで使われているエスケープシーケンスを +すべて列挙すると、次のようになります。 +

+ +
+
1f09 0001
+
+字下げ (インデント) の量を指定。 +(引数が 0001 なので、字下げ量は 1。) +
1f41 0100
+
+検索キーの開始。 +(引数 0100 の意味については、JIS X 4081 に記述がないため不明。) +
1f61
+
+検索キーの終了。 +
1f04
+
+半角表示の開始。 +
1f05
+
+半角表示の終了。 +
1f0a
+
+改行 +
+ +

+前節のプログラムで、読み込んだデータが平文テキストになっていたのは、 +実は EB ライブラリが加工処理をしたからです。 +つまり、「改行」のように平文テキストでも表現可能なエスケープシーケンス +については処理し、「検索キーの開始」のように表現できないものについては +無視するようにして、平文テキストになるように加工していたのです。 +

+ +

+しかし、平文テキストは表現力が乏しいので、元のデータには含まれている +エスケープシーケンスの多くを無視することになってしまいます。 +HTML のように、もっと表現力のある形式で出力するなら、無視せずに済む +シーケンスを増やせそうです。 +では、HTML 形式でテキストデータを取得する関数が EB ライブラリに用意されて +いるかというと、残念ながらありません。 +

+ +

+その代わりに、かなり手間はかかりますが、自由にテキストデータを加工できる +ための仕組みが用意されています。 +それが、次の節で説明する フック (hook) です。 +フックを使うことで、テキストデータを柔軟に加工することができます。 +

+ + +

フック

+ +

+特に何も指定しなければ、eb_read_text(), +eb_read_heading() が返すテキストデータの加工は、あらかじめ +決められた通りの方法で行われます。 +たとえば、「改行」のエスケープシーケンスに対しては、\n を +書き込むようになっています。 +

+ +

+フック (hook) を使うと、こうした加工方法を変えることができます。 +フックは、あらかじめ決められたフック設定位置に対して、フック関数を登録 +することで有効になります。 +フック関数が登録されていると、eb_read_text() や +eb_read_heading() は、あらかじめ決まったやり方でデータを +書き込む代わりに、フック関数を呼び出します。 +呼び出されたフック関数がデータの書き込み処理を行うことで、 +eb_read_text()eb_read_heading() から返る +テキストデータが変化するというわけです。 +

+ +

+EB ライブラリには、多数のフック設定位置が用意されています。 +各エスケープシーケンスには、それぞれ専用にフックが用意されており、 +それ以外にも文字のためのフックが存在します。 +(どのようなフック設定位置があるか、詳しくは +「フックコードの一覧」 を参照のこと。) +

+ +

+それぞれのフック設定位置は、フックコード (hook code) と +呼ばれるコード値で識別されます。 +たとえば、前述の「改行」のエスケープシーケンスに対応するフックコード +は EB_HOOK_NEWLINE になります。 +

+ +

+アプリケーションプログラムがフックを扱うには、フックの集合である +フックセット (hook set) を用意します。 +これは、EB ライブラリで利用可能なすべてのフック設定位置に対して、どの +フック関数を使うのかを記録するためのオブジェクトです。 +

+ +

+では、実際にどうやってフックセットを扱うのか、説明していきましょう。 +フックセットは EB_Hookset 型のオブジェクトで表しますので、 +まず EB_Hookset オブジェクトを用意します。 +

+ +
+
+EB_Hookset hookset;
+
+
+ +

+EB_Hookset オブジェクトは、EB_Book オブジェクト +と同様に、使用前に必ず初期化する必要があります。 +

+ +
+
+eb_initialize_hookset(&hookset);
+
+
+ +

+実際のフック関数は、次のようなものになります。 +この例では、フック関数の中で eb_write_text_string() という +関数を呼び出して、<br> という文字列をテキストデータ +として書き込んでいます。 +

+ +
+
+EB_Error_Code
+hook_newline(EB_Book *book, EB_Appendix *appendix, void *container,
+    EB_Hook_Code code, int argc, const unsigned int *argv) {
+    eb_write_text_string(book, "<br>");
+    return 0;
+}
+
+
+ +

+関数 eb_set_hook() を用いることで、このフック関数を +フックセットに登録することができます。 +ただし、まず EB_Hook という型のオブジェクトにいったん +フックコードとフック関数を設定し、それを eb_set_hook() を +渡してやる必要があります。 +ここでは、「改行」を表すエスケープシーケンスに対して、上記のフック関数 +を登録してみます。 +

+ +
+
+EB_Hook hook;
+
+hook.code = EB_HOOK_NEWLINE;   # フックコードをセット
+hook.function = hook_newline;  # フック関数をセット
+eb_set_hook(&hookset, &hook);
+
+
+ +

+なお、同じフック設定位置 (フックコード) に複数回フック関数を登録しても、 +有効になるのは最後に登録したものだけですので、注意して下さい。 +フック関数として NULL を指定すると、登録されているフックが +解除されます。 +

+ +

+関数 eb_set_hooks() (最後に s が付く) を使えば、 +複数のフック関数を一度に登録できます。 +

+ +
+
+static const EB_Hook hooks[] = {
+    {EB_HOOK_NEWLINE,        hook_newline},
+    {EB_HOOK_SET_INDENT,     hook_set_indent},
+    {EB_HOOK_WIDE_JISX0208,  hook_set_jisx0208},
+    {EB_HOOK_NULL,           NULL}
+};
+
+eb_set_hooks(&hookset, &hooks);
+
+
+ +

+配列の末尾を明示するために、EB_HOOK_NULL という特殊な +フックコードを置きます。 +この点も注意して下さい。 +

+ +

+こうしてフック関数を登録したフックセットを、eb_raed_text(), +eb_raed_heading() への引数として渡します。 +前節までの例では、NULL を渡していましたが、代わりに +&hookset を渡してみます。 +

+ +
+
+if (eb_read_text(&book, NULL, &hookset, NULL, MAX_LENGTH,
+    text, &text_length) != EB_SUCCESS) {
+    fprintf(stderr, "an error occurs.\n");
+    return;
+}
+
+
+ +

+これによって、テキストデータ中に改行を表すエスケープシーケンスがあると、 +\n の代わりに <br> という文字列が +書き込まれるようになります。 +

+ +

+EB_Hookset オブジェクトを使い終わったら、 +eb_finalize_hookset() を呼んで後始末をします。 +

+ +
+
+eb_finalize_hookset(&hookset);
+
+
+ + +

フックと文字コードの関係

+ +

+前節では、エスケープシーケンスに対するフックを例にとりましたが、この他 +にも、EB ライブラリには文字に対するフックが用意されています。 +

+ +
+
EB_HOOK_ISO8859_1
+
+ISO 8859-1 (ラテン文字 1) 文字へのフック。ただし制御文字を除きます。 +引数として、ISO 8859-1 の文字番号がフック関数に渡されます。 + +
EB_HOOK_NARROW_JISX0208
+
+半角の JIS X 0208 (日本語のかな漢字) 文字へのフック。 +引数として、日本語 EUC で表現した場合の文字番号が、フック関数に渡されます。 + +
EB_HOOK_WIDE_JISX0208
+
+全角の JIS X 0208 (日本語のかな漢字) 文字へのフック。 +引数として、日本語 EUC で表現した場合の文字番号が、フック関数に渡されます。 + +
EB_HOOK_GB2312
+
+GB 2312 (中国語の簡体字) 文字へのフック。 +引数として、中国語 EUC で表現した場合の文字番号が、フック関数に渡されます。 + +
EB_HOOK_NARROW_FONT
+
+半角の外字へのフック。 +引数として、外字の文字番号が、フック関数に渡されます。 + +
EB_HOOK_WIDE_FONT
+
+半角の外字へのフック。 +引数として、外字の文字番号が、フック関数に渡されます。 +
+ +

+いずれも、その文字がテキストデータ中に現れる度に、フック関数が呼び出され +ます。 +

+ +

+上の記述を見ても分かるように、フック関数に渡される文字番号は、書籍の文字 +コードに応じて、ISO 8859-1, 日本語 EUC、中国語 EUC のいずれかの文字コード +で表現されたものになります。 +

+ +

+フック関数を登録しなければ、その文字番号がテキストデータとしてそのまま +書き込まれます。 +

+ +

+もし、アプリケーションプログラムが、EB ライブラリの内部コードとは異なる +文字コードを使用したい場合は、これらのフックのフック関数を登録して、 +コード変換処理をするのも手です。 +ただし、一文字毎にフック関数が呼び出されるので、相応の負荷がかかります。 +

+ +

+また、EBXA-C を扱うには、特別な処理が必要です。 +EBXA-C では、文字コードとして GB 2312 と JIS X 0208 が使われますが +(「文字コード」 を参照のこと)、EB ライブラリによる標準の処理 +では、どちらも 0xa1a1 〜 0xfefe にマッピングされて衝突するため、最低 +でもどちらか一方をフックして文字の表現方法を変えないと、正しく出力 +できません。 +

+ + +

クロス検索の検索結果

+ +

+すでに 「検索」 の章で述べたように、CD-ROM 書籍 +には前方一致検索、後方一致検索といった複数の検索メソッドがあります。 +EB ライブラリで検索を行うと、どの検索メソッドでも、一致したエントリの +情報は、以下のような EB_Hit 型のオブジェクトとして +受け取ります。 +

+ +
+
+typedef struct {
+    EB_Position heading;   /* 見出しの位置 */
+    EB_Position text;      /* 本文の位置   */
+} EB_Hit;
+
+
+ +

+しかしクロス検索では、EB_Hit の見出しと本文の位置は +まったく同じになります。 +したがって、見出しと本文のテキストデータを読み込むには、他の検索メソッド +のようにそれぞれの位置にシークして読み込むというやり方ではうまく +いきません。 +

+ +

+以下に、クロス検索の見出しと本文を読み込むプログラム例を示します。 +

+ +
+
+/* 見出し位置へのシークを行う */
+if (eb_seek_text(&book, &hits[0].heading) != EB_SUCCESS) {
+    fprintf(stderr, "an error occurs.\n");
+    return;
+}
+/* 見出しの読み込みを行う */
+if (eb_read_heading(&book, NULL, NULL, NULL, MAX_LENGTH,
+    heading, &heading_length) != EB_SUCCESS) {
+    fprintf(stderr, "an error occurs.\n");
+    return;
+}
+/* 先ほど読み込んだ見出しの、次の部分へ飛ぶ */
+if (eb_forward_heading(&book) != EB_SUCCESS) {
+    fprintf(stderr, "an error occurs.\n");
+    return;
+}
+/* 本文の読み込みを行う */
+if (eb_read_heading(&book, NULL, NULL, NULL, MAX_LENGTH,
+    text, &text_length) != EB_SUCCESS) {
+    fprintf(stderr, "an error occurs.\n");
+    return;
+}
+
+
+ +

+クロス検索でも、見出しの内容を読み込む方法は他の検索メソッドと変わり +はなく、eb_read_heading() を使います。 +変わっているのは、本文の読み込みです。 +eb_read_text() ではなく、eb_read_heading() +を使います。 +見出しを読み込むための関数 eb_read_heading() を、本文を +読み込むために呼ぶというのは奇妙な話ですが、これはクロス検索の本文が +見出しと同じ形式になっているためです。 +通常、見出しは一行程度しか書かれていませんが、実際のところクロス検索 +の本文も一行程度しかありません。 +

+ +

+また、本文は見出しのすぐ後に書かれているため、上記のように見出しを +読み込んだ後で eb_forward_heading() という関数を呼び、 +その後で本文を読み込むためにもう一度 eb_read_heading() を +呼ぶという変わった手順を踏みます。 +

+ +

+本文だけが必要で見出しが要らなければ、シーク直後に +eb_forward_heading() を呼ぶようにします。 +その後で eb_read_heading() を呼ぶと、本文を読み込みます。 +

+ + +

著作権表示

+ +

+先に記したように、テキストデータには何種類かあり、その中に +著作権表示 (copyright notice) というものがあります。 +名前の通り、著作権表示に関するテキストデータを収めたものです。 +

+ +

+一般に、著作権表示は本文とはまったく独立したデータとして用意されます。 +したがって、本文を先頭から末尾まで読んでみても、著作権表示はどこにも +見つかりません。 +

+ +

+選択中の副本について、著作権表示の開始位置を知るには +eb_copyright() を使います。 +この関数は、副本が著作権表示を持っていなければ +EB_ERR_NO_SUCH_SEARCH を返しますので、著作権表示の有無も +同時に分かります。 +(開始位置は取得せずに、有無だけを調べたいときは、 +eb_have_copyright() という関数が使えます。) +

+ +
+
+EB_Position position;
+EB_Error_Code err;
+
+err = eb_copyright(&book, &position);
+if (err == EB_ERR_NO_SUCH_SEARCH) {
+    /* 著作権表示はない */
+} else if (err != EB_SUCCESS) {
+    /* それ以外のエラー */
+   return;
+}
+
+
+ +

+後は、得られた位置 (position) にシークして、 +eb_read_text() でテキストデータを読み込みます。 +

+ + +

メニュー

+ +

+本文とは独立したテキストデータとしては、著作権表示の他に +メニュー (menu) というものがあります。 +メニューは、主に本文の補助となるデータを収録しています。 +代表的なものでは、「前書き (序)」「凡例」といったものが挙げられます。 +

+ +

+メニューでは「別項目参照」というエスケープシーケンスを多用して、階層的 +な構造になっているのが一般的です。 +このエスケープシーケンスには、参照先のテキストの位置が記録されています。 +

+ +

+たとえば、ある CD-ROM 書籍のメニューが次のようになっていたとします。 +この例では、メニューには 3 つの項目があります。 +

+ +
+
+ * 序文
+ * 表記について
+ * 奥付
+
+
+ +

+メニューのそれぞれの項目には、参照先があります。 +テキストデータの内部表現では、「序文」「表記について」「奥付」の +それぞれの文字列の前後に別項目参照開始および終了エスケープシーケンスが +付いた形になっています。 +視覚的に分かるように記すと、次のような形になっています。 +

+ +
+
+ * <別項目参照開始シーケンス> "序文" <別項目参照終了シーケンス>
+ * <別項目参照開始シーケンス> "表記" <別項目参照終了シーケンス>
+ * <別項目参照開始シーケンス> "奥付" <別項目参照終了シーケンス>
+
+
+ +

+HTML の書き方を知っているなら、a タグと言えば分かるのでは +ないかと思います。 +

+ +
+
+<a href="./index.html">EB ライブラリのホームページ</a>
+
+
+ +

+ただし、参照先の位置情報は終了シーケンス側に記載されますので、この点は +HTML とは逆になります。 +蛇足ですが、別位置参照はメニューだけでなく、本文でも一般的に使用されます。 +

+ +

+別項目参照開始および終了シーケンスに対して、それぞれフック +EB_HOOK_BEGIN_REFERENCEEB_HOOK_END_REFERENCE +が用意されています。 +参照先の位置情報は、終了シーケンスへのフック関数に対して、引数として +渡されます。 +たとえば、EB_HOOK_END_REFERENCE へのフック関数の冒頭では、 +次のようにすると良いかも知れません。 +

+ +
+
+EB_Error_Code
+hook_end_ref(EB_Book *book, EB_Appendix *appendix, void *container,
+    EB_Hook_Code code, int argc, const unsigned int *argv)
+{
+    EB_Position position;
+
+    position.page = argv[1];    # 参照先のページ番号
+    position.offset = argv[2];  # 参照先のオフセット
+
+
+ +

+参照先は、メニューの第 2 層となります。 +この書籍の「奥付」の参照先を辿ったら、次のような表記になっていました。 +

+ +
+
+○○堂出版社 新国語辞典 第 2 版 (EPWING 版)
+第 1 版 発行 1988年 2月
+第 2 版 発行 1999年 11月
+第 2 版 (EPWING 版) 発行 2000年 2月
+
+
+ +

+同様に「序文」「表記に付いて」の参照先についても、こうした文章データ +が用意されていました。 +図示すると、メニューの階層は次のようになります。 +

+ +
+
+            ┌─────┐
+第1層         │メニュー │
+            └──┰──┘
+               ┃
+       ┏━━━━━━━╋━━━━━━━┓
+       ┃       ┃       ┃
+    ┌──┸──┐ ┌──┸──┐ ┌──┸──┐
+第2層 │メニュー │ │メニュー │ │メニュー │
+    └─────┘ └─────┘ └─────┘
+
+
+ +

+この辞書の例では、メニューはここで終わりになっていますが、書籍によっては +さらに第 3 層、第 4 層と続く場合もあります。 +また、メニュー全体が均一の階層数になっているとは限りません。 +メニューの参照先が本文や著作権表示になっていることもあります。 +

+ +

+選択中の副本について、(第 1 層の) メニューの開始位置 を知るには +eb_menu() を使います。 +この関数は、副本がメニューを持っていなければ +EB_ERR_NO_SUCH_SEARCH を返しますので、メニューの有無も同時に +分かります。 +(開始位置は取得せずに、有無だけを調べたいときは、 +eb_have_menu() という関数が使えます。) +

+ +
+
+EB_Position position;
+EB_Error_Code err;
+
+err = eb_menu(&book, &position);
+if (err == EB_ERR_NO_SUCH_SEARCH) {
+    /* メニューはない */
+} else if (err != EB_SUCCESS) {
+    /* それ以外のエラー */
+   return;
+}
+
+
+ +

+後は、得られた位置 (position) にシークして、 +eb_read_text() でテキストデータを読み込みます。 +

+ + +

複合検索の候補一覧

+ +

+「複合検索」(「複合検索」 を参照のこと) のところで述べたように、 +複合検索では、入力語に 候補一覧 (candidates) が用意されている +ことがあります。 +これは、入力語として有効な語をあらかじめ列挙しておき、 +アプリケーションプログラムのユーザに選択させる仕組みです。 +

+ +

+たとえば、人名を検索するのために、次のような複合検索があったとします。 +

+ +
+
+入力語 0: 国・地域
+入力語 1: 時代
+入力語 2: 性別
+入力語 3: キーワード
+入力語 4: キーワード
+
+
+ +

+このうち、入力語 3 の「性別」には、入力語として有効な語は「男」と「女」 +の 2 つしかないでしょう。 +このように、入力語として有効な語が限られている場合に、候補一覧が用意 +されていることがあります。 +

+ +

+候補一覧は検索のためのデータではありますが、内部構造はテキストデータ +そのものです。 +ユーザに対して候補を列記した示したテキストを示し、その中の一つを選択 +してもらうようになっています。 +

+ +

+しかも、候補一覧のデータ構造はメニューと非常に似ており、メニューの +ような階層構造を持っています +(「メニュー」 を参照のこと)。 +たとえば、上の複合検索の入力語 2 「国・地域」にも候補の一覧を設けると +したら、最初の階層は次のようになるかも知れません。 +

+ +
+
+* 日本 (→選択)
+* 日本以外のアジア (→詳細)
+* ヨーロッパ (→詳細)
+* 北アメリカ (→詳細)
+* その他 (→詳細)
+
+
+ +

+「日本」を選ぶと、そこで入力語が決定されたことになります。しかし、 +それ以外の項目についてはさらに細かく分類された選択肢が用意されて +います。 +ここでは、「北アメリカ」を選んでみましょう。 +すると、さらに次のような候補一覧のデータが提示されます。 +

+ +
+
+* アメリカ (→選択)
+* カナダ (→選択)
+
+
+ +

+ここで、「アメリカ」「カナダ」を選ぶと、入力語が決定されます。 +

+ +

+次に実際に、EB ライブラリを使ってこうした候補一覧を扱う方法について +説明します。 +まず、アプリケーションプログラムは、複合検索の入力語が候補一覧を持って +いるかどうかを、確認する必要があるでしょう。 +eb_multi_entry_candidates() を使うと、候補一覧データの開始位置 +を取得することができます。 +この関数は、候補一覧を持っていなければ EB_ERR_NO_CANDIDATES を +返しますので、候補一覧の有無も分かります。 +(開始位置は取得せずに、有無だけを調べたいときは、 +eb_multi_entry_have_candidates() という関数が使えます。) +

+ +
+
+EB_Position position;
+EB_Error_Code err;
+
+/* mulit_id, entry_id で、どの複合検索の
+ * 何番目の入力語について確認するのかを指定します。*/
+err = eb_multi_entry_candidates(&book, multi_id, entry_id, &position);
+if (err == EB_ERR_NO_CANDIDATES) {
+    /* この入力語には、候補一覧が用意されていない */
+   return;
+} else if (err != EB_SUCCESS) {
+    /* それ以外のエラー */
+   return;
+}
+
+
+ +

+後は、得られた位置 (position) にシークして、 +eb_read_text() でテキストデータを読み込みます。 +読み込んだテキストでは、候補となる語のそれぞれが候補開始と終了を表す +エスケープシーケンスに挟まれた形になっています。 +

+ +
+
+* <候補開始シーケンス> "日本" <候補終了シーケンス>
+* <候補開始シーケンス> "日本以外のアジア" <候補終了シーケンス>
+* <候補開始シーケンス> "ヨーロッパ" <候補終了シーケンス>
+* <候補開始シーケンス> "北アメリカ" <候補終了シーケンス>
+* <候補開始シーケンス> "その他" <候補終了シーケンス>
+
+
+ +

+候補開始シーケンスに対しては、フックとして +EB_HOOK_BEGIN_CANDIDATE が用意されています。 +終了シーケンスに対するフックは 2 種類あって、さらに次の階層へ続く場合 +に呼ばれる EB_HOOK_END_CANDIDATE_GROUP と、その語がそのまま +入力語の候補となる場合に呼ばれる EB_HOOK_END_GROUP_LEAF に +分かれています。 +

+ +

+次の階層のデータの開始位置は、終了シーケンスのフック関数に、引数として +渡ってきます。 +(この点もメニューと同様なので、メニューの解説を参考にして下さい。) +

+ +

+終了シーケンスに対するフック関数の中では、eb_current_candidate() +という関数が使えます。 +この関数は、開始シーケンスと終了シーケンスの間に挟まれた「候補」の文字列 +(ポインタ) を返します。 +

+ +
+
+const char *candidate;
+
+candidate = eb_current_candidate(book);
+
+
+ + +

区切りコードの問題

+ +

+本文は、先頭から末尾まで一本の繋がったデータ列になっています。 +英語辞典なら、最初の単語 `A' から最後の `zzz' までの説明が、すべて一つの +「本文」の中に書かれることになります。 +

+ +

+一般に、アプリケーションプログラムがある単語を検索した際は、本文の中から +その単語を説明した部分だけを抜き出して出力することになるでしょう。 +たとえば、`dictionary' という単語を引いた場合、次のような文章が出力される +事が期待されます。 +その次や、次の次の単語の説明まで延々と表示されることを、おそらく大半の +ユーザは望まない筈です。 +

+ +
+
+dictionary [名] (複: dictionaries)
+辞典、事典
+[類義] lexicon, glossary (用語辞典), encyclopedia (百科事典)
+
+
+ +

+しかし、困ったことに CD-ROM 書籍には、単語の説明の終わりを示す印 +(エスケープシーケンス) が定義されていません。 +つまり、ある語の説明部分を正確に抜き出すことは、電子ブックや EPWING では +不可能なのです。 +

+ +

+しかしながら、幸いにも市販の書籍の多くには、単語の説明の終了位置にだけ +出現する、特有のエスケープシーケンスが存在します。 +もちろん、このエスケープシーケンスは本来「単語の説明の終了」を示すもの +ではなく別の用途として用いるのですが、「終了位置」として代用できる +という意味です。 +

+ +

+EB ライブラリでは、この「終了位置」の印に使えるエスケープシーケンスの +ことを、区切りコード (stop code) と呼んでいます。 +EB ライブラリは区切りコードを自動判定する機能を持っていますが、判定は +完璧ではないので外れることもあります。 +外れると本文が途中で途切れたり、本文の続きが延々と出力されたりします。 +

+ +

+その場合は、明示的に appendix +(詳しくは ebappendix コマンドのマニュアル +の「appendix (付録) とは」を参照のこと) +で区切りコードを指定することによって回避できる書籍もありますが、 +残念ながら区切りコードがまったく存在しない書籍も少数ながら存在します。 +区切りコードを持たない書籍に対して、有効な対処方法は今のところありません。 +

+ +

+eb_read_text() による本文の取得では、区切りコードが検出された +時点で読み込みを止めます。 +さらに繰り返し eb_read_text() を呼んでも、区切りコードより先の +本文は読み込めません。 +

+ +

+区切りコードを検出したかどうかの判定には、eb_is_text_stopped() +を使います。 +この関数は、最後に読み込みを行ったテキストデータの中に、区切りコードを +検出していれば 1 を返します。 +

+ +

+本文以外のテキストデータにも区切りコードの概念は存在しますので、 +eb_is_text_stopped() を使って区切りコードを検出できます。 +しかし、本文以外では EB ライブラリが確実に区切りを判別できますので、 +誤判定の問題は起きません。 +

+ +

+見出しにおける区切りは、それぞれの単語の見出しの終了位置となります。 +メニューおよび複合検索の候補一覧では、階層化された個々のメニューデータ +の終了位置で区切りと判定されます。 +(同一階層に複数個のメニューデータがあっても、個々のメニューデータで +区切られます。) +著作権表示では、全文の終了位置で区切りと判定されます。 +

+ + +

サンプルプログラム

+ + + + +

データ型の詳細

+ +

+この節で説明しているデータ型を使うには、次のようにヘッダファイルを +読み込んで下さい。 +

+ +
+
+#include <eb/eb.h>
+
+
+ + +

EB_Hook_Code

+ +

+データ型 EB_Hook_Hook は、フックの設定位置コードを表します。 +

+ +

+この型は符合付き整数型の別名として定義されていますので、2 つのコードを +2 項演算子 ==!= で一致比較することができます。 +

+ +

+EB ライブラリでは、全部で EB_NUMBER_OF_HOOKS 個のフックコード +を定義しています。 +定義されている設定位置コードの一覧については、 +次の節 (「フックコードの一覧」 を参照のこと) +を参照して下さい。 +

+ + +

EB_Hook

+ +

+データ型 EB_Hook は、フックコードとそれに対応するフック関数 +の組を表します。 +内部構造は、次のように定義されています。 +

+ +
+
+typedef struct EB_Hook_Struct EB_Hook;
+
+struct EB_Hook_Struct {
+    EB_Hook_Code code;
+    EB_Error_Code (*FUNC)(EB_Book *, EB_Appendix *, void *,
+        EB_Hook_Code, int, const unsigned int *);
+};
+
+
+ +

+アプリケーションプログラムは、直接 EB_Hook オブジェクトの +メンバを参照したり、セットしたりしても構いません。 +

+ + +

EB_Hookset

+ +

+データ型 EB_Hookset は、フック一式を表します。 +EB ライブラリで利用可能なすべてのフック設定位置に対して、どのような +フック関数を指定するのかを記録するための型です。 +

+ +

+EB_Hookiset オブジェクトの操作は、すべて EB ライブラリが用意 +している関数で行います。 +アプリケーションプログラムは、直接 EB_Hookset オブジェクトの +メンバを参照したり、セットしたりすべきではありません。 +

+ +

+EB_Hookset オブジェクトを使用する際は、まずそのオブジェクトに +対して eb_initialize_hookset() を呼んで初期化しなくては +なりません。 +

+ + +

フック関数の詳細

+ +

+この節では、フック関数の仕様について記します。 +

+ +

+まず、フック関数を呼び出す eb_read_text() および +eb_read_heading() のプロトタイプは次のようになっています。 +

+ +
+
+EB_Error_Code
+eb_read_text(EB_Book *book, EB_Appendix *appendix,
+    EB_Hookset *hookset, void *container, size_t text_max_length,
+    char *text, ssize_t *text_length)
+
+
+ +

+一方、フック関数のプロトタイプは、次のようになっています。 +

+ +
+
+EB_Error_Code
+hook_function(EB_Book *book, EB_Appendix *appendix, void *container,
+    EB_Hook_Code code, int argc, const unsigned int *argv);
+
+
+ +

+引数 book, appendix, container は、 +eb_read_text() あるいは eb_read_heading() に +渡された値がそのままフック関数にも渡ってきます。 +

+ +

+appendix というのは、書籍に対する補助データを提供するオブジェクト +です +(appendix (付録) について詳しくは +ebappendix コマンドのマニュアル +の「appendix (付録) とは」を参照のこと)。 + +

+引数 container は、アプリケーションプログラムからフック関数に +何かデータを渡したいときに使います。 +

+ +

+最後の argcargv には、加工前のテキストデータが +渡されます。 +文字に対するフックでは、文字コード番号が渡ってきます。 +エスケープシーケンスに対するフックでは、そのシーケンス自体のコード +(1f で始まるコード) と、もしあればエスケープシーケンスへの +引数をが渡ってきます。 +個々のフックにおいて、argcargv にどうような値が +渡ってくるのか、詳しくは 「フックコードの一覧」 を参照のこと。 +

+ +

+フック関数の中から次に挙げる関数を呼び出すことで、テキストデータへの +書き込みを行うことができます。 +

+ +
    +
  • eb_write_text() +
  • eb_write_text_string() +
  • eb_write_text_byte1() +
  • eb_write_text_byte2() +
+ +

+これらの関数の仕様に関して詳しくは +「[テキストデータ] 関数の詳細」 を参照のこと。 +

+ +

+フック関数が EB_SUCCESS 以外の値を返すと、フック関数を +呼び出した eb_read_text(), eb_read_heading() +はエラーが発生したものと見なし、そのエラーコードをそのまま +アプリケーションプログラムに返します。 +

+ +

+フック関数の中では、book に対して以下の関数を呼び出しては +いけません。 +呼び出したときの動作は、未定義です。 +

+ +
    +
  • eb_seek_text() +
  • eb_read_text() +
  • eb_read_heading() +
  • eb_read_rawtext() +
  • eb_forward_text() +
  • eb_backward_text() +
  • eb_set_subbook() +
  • eb_unset_subbook() +
  • eb_load_all_subbook() +
  • eb_bind() +
  • eb_finalize_book() +
  • eb_finalize_library() +
+ + +

フックコードの一覧

+ +

+この節で説明しているフックコードを使うには、次のようにヘッダファイルを +読み込んで下さい。 +

+ +
+
+#include <eb/text.h>
+
+
+ + +

定数 EB_HOOK_NULL

+ +

+EB_HOOK_NULL は厳密にはフックではなく、 +eb_set_hooks() で複数のフック関数を登録する際に、 +EB_Hook 配列の末尾の要素を示すために用います。 +このフックコードに対して、フック関数は登録できません。 +

+ +

+詳しくは、「[テキストデータ] フック関数の詳細」 を参照のこと。 +

+ + +

定数 EB_HOOK_INITIALIZE

+ +

+EB_HOOK_INITIALIZE は、eb_seek_text() を +呼び出した直後の最初の eb_read_text(), +eb_read_heading() の呼び出し時に処理されます。 +何か初期化処理をしたいときに、使うと良いでしょう。 +

+ +

+このフックが、フック関数に渡す argc は 0 です。 +フック関数を登録していない状態では、このフックはテキストデータに何も +書き込みません。 +

+ + +

定数 EB_HOOK_BEGIN_NARROW

+ +

定数 EB_HOOK_END_NARROW

+ +

+EB_HOOK_BEGIN_NARROW および EB_HOOK_END_NARROW +は、半角表示の開始と終了を表すエスケープシーケンスに対するフックです。 +

+ +

+どちらのフックも、フック関数に渡す argc は 1 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +EB_HOOK_BEGIN_NARROW なら 0x1f04、 +EB_HOOK_END_NARROW なら 0x1f05 になります。 +

+ +

+フック関数を登録していない状態では、これらのフックはテキストデータに何も +書き込みません。 +

+ + +

定数 EB_HOOK_BEGIN_SUBSCRIPT

+ +

定数 EB_HOOK_END_SUBSCRIPT

+ +

+EB_HOOK_BEGIN_SUBSCRIPT および +EB_HOOK_END_SUBSCRIPT は、下付き表示の開始と終了を表す +エスケープシーケンスに対するフックです。 +

+ +

+どちらのフックも、フック関数に渡す argc は 1 です。 +argv[0] の値はエスケープシーケンスのコードそのもので、 +EB_HOOK_BEGIN_SUBSCRIPT なら 0x1f06、 +EB_HOOK_END_SUBSCRIPT なら 0x1f07 になります。 +

+ +

+フック関数を登録していない状態では、これらのフックはテキストデータに +何も書き込みません。 +

+ + +

定数 EB_HOOK_SET_INDENT

+ +

+EB_HOOK_SET_INDENT は、テキストデータの行頭の字下げ指定を +表すエスケープシーケンスに対するフックです。 +

+ +

+このフックが、フック関数に渡す argc は 2 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f09 になります。 +argv[1] が、字下げの量を表します。 +

+ +

+字下げの量の単位が、何であるのかは不明です。 +また、字下げ量の最小値は、0 の場合と 1 の場合の二通りがあります。 +いずれにしろ、字下げは 1 ずつ増えたり減ったりします。 +

+ +

+フック関数を登録していない状態では、このフックはテキストデータに何も +書き込みません。 +

+ + +

定数 EB_HOOK_NEWLINE

+ +

+EB_HOOK_SET_NEWLINE は、改行を表すエスケープシーケンスに +対するフックです。 +

+ +

+ただし、eb_read_heading() (見出しの読み込み) による処理では、 +改行を表すエスケープシーケンスは区切りコードとしても扱われます。 +そのため、エスケープシーケンスが見つかってもこのフックの処理は行われず、 +ただちに読み込み処理は終了します。 +

+ +

+このフックが、フック関数に渡す argc は 1 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f0a になります。 +

+ +

+フック関数を登録していない状態では、このフックはテキストデータに何も +書き込みませんが、eb_initialize_hookset() で +EB_Hook オブジェクトを初期化すると、フック関数として +eb_hook_newline() が自動的に登録されます。 +

+ + +

定数 EB_HOOK_BEGIN_SUPERSCRIPT

+ +

定数 EB_HOOK_END_SUPERSCRIPT

+ +

+EB_HOOK_BEGIN_SUPERSCRIPT および +EB_HOOK_END_SUPERSCRIPT は、上付き表示の開始と終了を表す +エスケープシーケンスに対するフックです。 +

+ +

+どちらのフックも、フック関数に渡す argc は 1 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +EB_HOOK_BEGIN_SUPERSCRIPT なら 0x1f0e、 +EB_HOOK_END_SUPERSCRIPT なら 0x1f0f になります。 +

+ +

+フック関数を登録していない状態では、これらのフックはテキストデータに何も +書き込みません。 +

+ + +

定数 EB_HOOK_BEGIN_NO_NEWLINE

+ +

定数 EB_HOOK_END_NO_NEWLINE

+ +

+EB_HOOK_BEGIN_NO_NEWLINE および +EB_HOOK_END_NO_NEWLINE は、改行禁止の開始と終了を表す +エスケープシーケンスに対するフックです。 +

+ +

+どちらのフックも、フック関数に渡す argc は 1 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +EB_HOOK_BEGIN_NO_NEWLINE なら 0x1f10、 +EB_HOOK_END_NO_NEWLINE なら 0x1f11 になります。 +

+ +

+フック関数を登録していない状態では、これらのフックはテキストデータに何も +書き込みません。 +

+ + +

定数 EB_HOOK_BEGIN_EMPHASIS

+ +

定数 EB_HOOK_END_EMPHASIS

+ +

+EB_HOOK_BEGIN_EMPHASIS および EB_HOOK_END_EMPHASIS +は、強調表示の開始と終了を表すエスケープシーケンスに対するフックです。 +

+ +

+どちらのフックも、フック関数に渡す argc は 1 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +EB_HOOK_BEGIN_EMPHASIS なら 0x1f12、 +EB_HOOK_END_EMPHASIS なら 0x1f13 になります。 +

+ +

+フック関数を登録していない状態では、これらのフックはテキストデータに何も +書き込みません。 +

+ + +

定数 EB_HOOK_BEGIN_CANDIDATE

+ +

定数 EB_HOOK_END_CANDIDATE_LEAF

+ +

定数 EB_HOOK_END_CANDIDATE_GROUP

+ +

+EB_HOOK_BEGIN_CANDIDATE は、複合検索の候補となる語の開始を +表すエスケープシーケンスに対するフックです。 +

+ +

+それに対して、終了を表すエスケープシーケンスに対するフックは 2 種類 +あります。 +一つは EB_HOOK_END_CANDIDATE_LEAF で、候補となる語が実際に +検索の入力語として使えるものであることを示します。 +もう一つは EB_HOOK_END_CANDIDATE_GROUP で、候補となる語は +さらに細かい選択肢に分かれていることを示します。 +(したがって、候補となる語を検索の入力語として使うことはできません。) +

+ +

+フック EB_HOOK_BEGIN_CANDIDATES が、フック関数に渡す +argc は 1 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f43 になります。 +

+ +

+フック EB_HOOK_END_CANDIDATE_LEAF および +EB_HOOK_END_CANDIDATE_GROUP が、フック関数に渡す +argc は 3 です。 +どちらのフックも、argv[0] はエスケープシーケンスのコード +そのもので、0x1f63 になります。 +フック EB_HOOK_END_CANDIDATE_GROUPargv[1] +と argv[2] は、次の階層の候補一覧データの開始ページ番号と +オフセットです。 +これは、EB_Position オブジェクト +(「[検索] データ型の詳細」 を参照のこと) +の page および offset メンバの値に相当します。 +フック EB_HOOK_END_CANDIDATE_LEAF では、argv[1], +argv[2] は 2 つとも 0 になっています。 +

+ +

+フック関数を登録していない状態では、これらのフックはテキストデータに何も +書き込みません。 +

+ + +

定数 EB_HOOK_BEGIN_REFERENCE

+ +

定数 EB_HOOK_END_REFERENCE

+ +

+EB_HOOK_BEGIN_REFERENCE および +EB_HOOK_END_REFERENCE は、別位置のテキストデータの参照開始と +終了を表すエスケープシーケンスに対するフックです。 +

+ +

+フック EB_HOOK_BEGIN_REFERENCE が、フック関数に渡す +argc は 2 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f42 になります。 +argv[1] の意味は不明です。 +

+ +

+EB_HOOK_END_REFERENCE が、フック関数に渡す argc +は 3 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f62 になります。 +argv[1]argv[2] は、参照先のページ番号と +オフセットです。 +これは、EB_Position オブジェクト +(「[検索] データ型の詳細」 を参照のこと) +の page および offset メンバの値に相当します。 +

+ +

+フック関数を登録していない状態では、これらのフックはテキストデータに何も +書き込みません。 +

+ + +

定数 EB_HOOK_BEGIN_KEYWORD

+ +

定数 EB_HOOK_END_KEYWORD

+ +

+EB_HOOK_BEGIN_KEYWORD および EB_HOOK_END_KEYWORD は、 +検索キーの開始と終了を表すエスケープシーケンスに対するフックです。 +

+ +

+フック EB_HOOK_BEGIN_KEYWORD が、フック関数に渡す +argc は 2 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f41 になります。 +argv[1] の意味は不明です。 +

+ +

+EB_HOOK_END_KEYWORD は、フック関数に 1 個の引数を渡します。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f61 になります。 +

+ +

+フック関数を登録していない状態では、これらのフックはテキストデータに何も +書き込みません。 +

+ + +

定数 EB_HOOK_BEGIN_DECORATION

+ +

定数 EB_HOOK_END_DECORATION

+ +

+EB_HOOK_BEGIN_DECORATION および +EB_HOOK_END_DECORATION は、文字修飾の開始と終了を表す +エスケープシーケンスに対するフックです。 +

+ +

+フック EB_HOOK_BEGIN_DECORATION が、フック関数に渡す +argc は 2 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1fe0 になります。 +argv[1] の意味は不明です。 +

+ +

+EB_HOOK_END_KEYWORD は、フック関数に 1 個の引数を渡します。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1fe1 になります。 +

+ +

+フック関数を登録していない状態では、これらのフックはテキストデータに何も +書き込みません。 +

+ + +

定数 EB_HOOK_NARROW_FONT

+ +

定数 EB_HOOK_WIDE_FONT

+ +

+EB_HOOK_NARROW_FONT および EB_HOOK_WIDE_FONT は、 +それぞれ半角外字と全角外字に対するフックです。 +

+ +

+どちらのフックも、フック関数に渡す argc は 1 です。 +argv[0] は、外字の文字番号を表します。 +

+ +

+フック関数を登録していない状態では、このフックはテキストデータに何も +書き込みませんが、eb_initialize_hookset() で +EB_Hook オブジェクトを初期化すると、フック関数として +eb_hook_narrow_character_text() および +eb_hook_wide_character_text() が自動的に登録されます。 +

+ + +

定数 EB_HOOK_ISO8859_1

+ +

+EB_HOOK_ISO8859_1 は、ISO 8859-1 (ラテン文字 1) 文字に対する +フックです。 +

+ +

+このフックが、フック関数に渡す argc は 1 です。 +argv[0] は、ISO 8859-1 の文字番号を表します。 +

+ +

+フック関数を登録していない状態では、argv[0] の値をそのまま +テキストデータに書き込みます。 +つまり、文字はそのまま ISO 8859-1 として、1 バイト書き込まれます。 +

+ +

+このフックが利用されるのは、処理中の書籍の文字コードが +EB_CHARCODE_ISO8859_1 の場合だけです。 +

+ + +

定数 EB_HOOK_NARROW_JISX0208

+ +

定数 EB_HOOK_WIDE_JISX0208

+ +

+EB_HOOK_NARROW_JISX0208EB_HOOK_WIDE_JISX0208 +は、半角および全角の JIS X 0208 (日本語のかな漢字) 文字に対するフックです。 +

+ +

+どちらのフックも、フック関数に渡す argc は 1 です。 +argv[0] は、JIS X 0208 の文字を日本語 EUC で表現したときの +文字番号を表します。 +

+ +

+フック関数を登録していない状態では、argv[0] の値をそのまま +テキストデータに書き込みます。 +つまり、文字はそのまま日本語 EUC として、2 バイト書き込まれます。 +

+ +

+このフックが利用されるのは、 +処理中の書籍の文字コードが EB_CHARCODE_JISX0208 か +EB_CHARCODE_JISX0208_GB2312 の場合だけです。 +

+ + +

定数 EB_HOOK_GB2312

+ +

+EB_HOOK_GB2312 は、GB 2312 (中国語の簡体字) 文字に対する +フックです。 +

+ +

+このフックが、フック関数に渡す argc は 1 です。 +argv[0] は、GB 2312 の文字を中国語 EUC で表現したときの +文字番号を表します。 +

+ +

+フック関数を登録していない状態では、argv[0] の値をそのまま +テキストデータに書き込みます。 +つまり、文字はそのまま中国語 EUC として、2 バイト書き込まれます。 +

+ +

+このフックが利用されるのは、処理中の書籍の文字コードが +EB_CHARCODE_JISX0208_GB2312 の場合だけです。 +

+ + +

定数 EB_HOOK_BEGIN_MONO_GRAPHIC

+ +

定数 EB_HOOK_END_MONO_GRAPHIC

+ +

+EB_HOOK_BEGIN_MONO_GRAPHIC および +EB_HOOK_END_MONO_GRAPIHC は、モノクロ図版の開始と終了を +表すエスケープシーケンスに対するフックです。 +

+ +

+フック EB_HOOK_BEGIN_MONO_GRAPHIC が、フック関数に渡す +argc は 4 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f320x1f44 のいずれかになります。 +argv[2]argv[3] は、図版の高さと幅 +(ピクセル数) を意味します。 +ただし、電子ブックのモノクロ図版 (最初の引数が 0x1f32 の +場合) には、図版の高さと幅の情報が欠けているので、値はどちらも 0 に +なります。 +argv[1] の意味は不明です。 +

+ +

+EB_HOOK_END_MONO_GRAPHIC が、フック関数に渡す +argc は 3 です。 +argv[0] は、エスケープシーケンスのコードそのものです。 +EB_HOOK_BEGIN_MONO_GRAPHICargv[0] が +0x1f32 なら、EB_HOOK_END_MONO_GRAPHIC の +argv[0]0x1f52 になり、0x1f44 +なら 0x1f64 になります。 +argv[1]argv[2] は、図版データのページ番号 +とオフセットです。 +これは、EB_Position オブジェクト +(「[検索] データ型の詳細」 を参照のこと) +の page および offset メンバの値に相当します。 +

+ +

+図版データの取り出し方については、「モノクロ図版」 +を参照してください。 +

+ +

+フック関数を登録していない状態では、これらのフックはテキストデータに何も +書き込みません。 +

+ + +

定数 EB_HOOK_BEGIN_GRAY_GRAPHIC

+ +

定数 EB_HOOK_END_GRAY_GRAPHIC

+ +

+これらのフック名称は、グレースケール図版のために予約されていますが、 +本バージョンの EB ライブラリではまだ対応していません。 +

+ + +

定数 EB_HOOK_BEGIN_COLOR_BMP

+ +

定数 EB_HOOK_BEGIN_COLOR_JPEG

+ +

定数 EB_HOOK_END_COLOR_GRAPHIC

+ +

+EB_HOOK_BEGIN_COLOR_BMPEB_HOOK_COLOR_JPEG +は、それぞれ BMP 形式と JPEG 形式のカラー図版の開始を表す +エスケープシーケンスに対するフックです。 +開始のフックは BMP と JPEG とでフックが分かれていますが、終了の +フックは共通で、EB_HOOK_END_COLOR_GRAPIHC になります。 +

+ +

+フック EB_HOOK_BEGIN_COLOR_BMP と +EB_HOOK_COLOR_JPEG が、フック関数に渡す argc は +4 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f4d になります。 +argv[2]argv[3] は、図版の幅と高さ +(ピクセル数) を意味します。 +argv[1] の意味は不明です。 +

+ +

+フック EB_HOOK_END_COLOR_BMP が、フック関数に渡す +argc は 3 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f6d になります。 +argv[1]argv[2] は、図版データのページ番号 +とオフセットです。 +これは、EB_Position オブジェクト +(「[検索] データ型の詳細」 を参照のこと) +の page および offset メンバの値に相当します。 +

+ +

+図版データの取り出し方については、「カラー図版」 +を参照してください。 +

+ +

+フック関数を登録していない状態では、これらのフックはテキストデータに何も +書き込みません。 +

+ + +

定数 EB_HOOK_BEGIN_IN_COLOR_BMP

+ +

定数 EB_HOOK_BEGIN_IN_COLOR_JPEG

+ +

定数 EB_HOOK_END_IN_COLOR_GRAPHIC

+ +

+EB_HOOK_BEGIN_IN_COLOR_BMPEB_HOOK_IN_COLOR_JPEG は、 +それぞれ BMP 形式と JPEG 形式のインラインカラー図版の開始を表す +エスケープシーケンスに対するフックです。 +開始のフックは BMP と JPEG とでフックが分かれていますが、終了の +フックは共通で、EB_HOOK_END_IN_COLOR_GRAPIHC になります。 +

+ +

+フック EB_HOOK_BEGIN_IN_COLOR_BMP と +EB_HOOK_IN_COLOR_JPEG が、フック関数に渡す argc +は 4 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f3c になります。 +argv[2]argv[3] は、図版の幅と高さ +(ピクセル数) を意味します。 +argv[1] の意味は不明です。 +

+ +

+フック EB_HOOK_END_IN_COLOR_BMP が、フック関数に渡す +argc は 3 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f5c になります。 +argv[1]argv[2] は、図版データのページ番号と +オフセットです。 +これは、EB_Position オブジェクト +(「[検索] データ型の詳細」 を参照のこと) +の page および offset メンバの値に相当します。 +

+ +

+図版データの取り出し方については、「カラー図版」 +を参照してください。 +

+ +

+フック関数を登録していない状態では、これらのフックはテキストデータに何も +書き込みません。 +

+ + +

定数 EB_HOOK_BEGIN_CLICKABLE_AREA

+ +

定数 EB_HOOK_END_CLICKABLE_AREA

+ +

+EB_HOOK_BEGIN_CLICKABLE_AREA は、カラー図版およびインラインカラー図版内の特定矩形領域に対して、参照先情報を表現した開始エスケープシーケンスに対するフックです。 +同様に、EB_HOOK_END_CLICKABLE_AREA は終了エスケープシーケンスに対するフックです。 +

+ +

+フック EB_HOOK_BEGIN_CLICKABLE_AREA が、フック関数に渡す +argc は 7 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f4f になります。 +argv[1]argv[2] は、それぞれ矩形領域の開始 +x, y 座標を表します。 +それぞれ矩形領域の開始 x, y 座標を表します。 +カラー図版の左上の座標が (0, 0) です。 +同様に、argv[3]argv[4] が図版の右方向への +幅と、下方向への高さを表します。 +最後の argv[5]argv[6] が参照先のページ番号 +とオフセットとなります。 +

+ +
+
+         参照先付きカラー図版
+(0,0)
+  ┌─────────────────────┐
+  │                     │
+  │(x,y)                │
+  │  ┌ ─ ─ ─ ─ ─ ─ ┐    │
+  │  │         高さ↑ │    │
+  │              │      │
+  │  │  矩形領域     │ │    │
+  │              │      │
+  │  │           │ │    │
+  │       幅      │      │
+  │  │←──────────┼→│    │
+  │              ↓      │
+  │  └ ─ ─ ─ ─ ─ ─ ┘    │
+  │                     │
+  └─────────────────────┘
+
+
+ +

+EB_HOOK_END_CLICKABLE_AREA が、フック関数に渡す +argc は 1 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f6f になります。 +

+ +

+参照先情報の取り出し方については、 +「参照先付きカラー図版」 +を参照して下さい。 +

+ +

+フック関数を登録していない状態では、これらのフックはテキストデータに何も +書き込みません。 +

+ + +

定数 EB_HOOK_BEGIN_WAVE

+ +

定数 EB_HOOK_END_WAVE

+ +

+EB_HOOK_BEGIN_WAVE および EB_HOOK_END_WAVE は、 +WAVE (PCM) 形式の音声データの開始と終了を表すエスケープシーケンスに対する +フックです。 +

+ +

+フック EB_HOOK_BEGIN_WAVE が、フック関数に渡す +argc は 6 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f4a になります。 +argv[2]argv[3] は音声データの開始位置の +ページ番号とオフセット、argv[4]argv[5] は +終了位置のページ番号とオフセットをそれぞれ表します。 +argv[1] の意味は不明です。 +

+ +

+EB_HOOK_END_WAVE が、フック関数に渡す argc は +1 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f6a になります。 +

+ +

+音声データの取り出し方については、「WAVE 音声」 +を参照して下さい。 +

+ +

+フック関数を登録していない状態では、これらのフックはテキストデータに何も +書き込みません。 +

+ + +

定数 EB_HOOK_BEGIN_MPEG

+ +

定数 EB_HOOK_END_MPEG

+ +

+EB_HOOK_BEGIN_MPEG および EB_HOOK_END_MPEG は、 +MPEG 形式の動画データの開始と終了を表すエスケープシーケンスに対するフック +です。 +

+ +

+フック EB_HOOK_BEGIN_MPEG が、フック関数に渡す +argc は 6 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f39 になります。 +argv[2]argv[5] は、動画データのファイル名を +エンコードした数値列になります。 +argv[1] の意味は不明です。 +

+ +

+EB_HOOK_END_MPEG が、フック関数に渡す argc は +1 です。 +argv[0] はエスケープシーケンスのコードそのもので、 +0x1f59 になります。 +

+ +

+動画データの取り出し方については、「MPEG 動画」 +を参照して下さい。 +

+ +

+フック関数を登録していない状態では、これらのフックはテキストデータに何も +書き込みません。 +

+ + +

フックセット操作関数の詳細

+ +

+この節で説明している関数を使うには、次のようにヘッダファイルを読み込んで +下さい。 +

+ +
+
+#include <eb/text.h>
+
+
+ + +

void eb_initialize_hookset (EB_Hookset *hookset)

+ +

+関数 initialize_hookset() は、hookset の指す +EB_Hookset オブジェクトを初期化します。 +EB_Hookiset オブジェクトに対して EB ライブラリの他の関数を +呼ぶ前に、 +必ずそのオブジェクトを初期化しなくてはなりません。 +初期化していないオブジェクトに対して、EB ライブラリの他の関数を呼んだ +場合の動作は未定義です。 +また、すでに初期化したオブジェクトに対して、再度 +eb_initialize_hookset() を呼んではいけません。 +呼んだ場合の動作は未定義です。 +

+ +

+この関数は、各フックの初期値を次のようにセットします。 +

+ + + + + + + + + + + + + + +
フック + フック関数 +
EB_HOOK_NARROW_JISX0208 + eb_hook_euc_to_ascii() +
EB_HOOK_NARROW_FONT + eb_hook_narrow_character_text() +
EB_HOOK_WIDE_FONT + eb_hook_wide_character_text() +
EB_HOOK_NEWLINE + eb_hook_newline() +
上記以外のフック + NULL (フック関数なし) +
+ + +

EB_Error_Code eb_finalize_hookset (EB_Hookset *hookset)

+ +

+関数 eb_finalize_hookset() は、hookset が指す +EB_Hooksest オブジェクトの後始末を行います。 +

+ +

+オブジェクトが割り当てて管理していたメモリは、すべて解放されます。 +すべてのフックには、フック関数として NULL がセットされます。 +

+ +

+後始末をしたオブジェクトに対して eb_set_hook(), eb_set_hooks() +を呼ぶことで、オブジェクトを再利用することができます。 +

+ + +

EB_Error_Code eb_set_hook (EB_Hookset *hookset, const EB_Hook *hook)

+ +

+関数 eb_set_hook() は、hookset が指す EB_Hooksest +オブジェクトに、フック関数を一つ登録します。 +登録するフックの種類とフック関数は、hook で指定します。 +

+ +

+同じフックコードに複数回フック関数を登録しても、有効になるのは最後に +登録したものだけですので、注意して下さい。 +フック関数として NULL を指定すると、登録されているフックが +解除されます。 +

+ +

+成功すると、この関数は EB_SUCCESS を返します。 +失敗すると、原因を示すエラーコードを返します。 +

+ + +

EB_Error_Code eb_set_hooks (EB_Hookset *hookset, const EB_Hook *hooks)

+ +

+この関数は eb_set_hook() に似ていますが、任意の個数の +フック関数を一度に登録できる点が異なります。 +

+ +

+登録するフックの種類とフック関数は、hooks で指定します。 +hooksEB_Hook オブジェクトの配列 (の先頭) を +指していなければなりません。 +また、この配列の末尾には、フックコード EB_HOOK_NULL をセット +した EB_Hook オブジェクトを配列要素として置く必要があります。 +

+ +

+eb_set_hooks() は、配列の先頭から順番に、指定されたフックコード +に対してフック関数を登録していきます。 +エラーが発生すると、残りのフックの登録はせずに、原因を示すエラーコード +をただちに返します。 +すべてのフック関数の登録に成功すると、EB_SUCCESS を返します。 +

+ + +

組み込みフック関数の詳細

+ +

+EB ライブラリは、基本的なフック関数をいくつか用意しています。 +本節では、これらのフック関数についての仕様を解説します。 +

+ +

+この節で説明している関数を使うには、次のようにヘッダファイルを読み込んで +下さい。 +

+ +
+
+#include <eb/text.h>
+
+
+ +

+いずれのフック関数も、引数 appendixcontainer に +NULL を渡されても、動作に支障はないようになっています。 +

+ + +

EB_Error_Code eb_hook_euc_to_ascii (EB_Book *book, EB_Appendix *appendix, void *container, EB_Hook_Code code, int argc, const unsigned int *argv)

+ +

+eb_hook_euc_to_ascii() は、フックコード +EB_HOOK_NARROW_JISX0208 (半角 JIS X 0208 文字) のための +フック関数です。 +

+ +

+EB_Hookset オブジェクトを関数 +eb_initialiez_hookset() で初期化すると、この関数が自動的に +登録されます。 +

+ +

+このフック関数は、argv[0] として渡された JIS X 0208 の文字 +(エンコーディングは日本語 EUC) を調べ、対応する ASCII 文字が存在すれば +その ASCII 文字をテキストデータとして書き込み、なければ JIS X 0208 の +文字をそのまま書き込みます。 +

+ +

+常に EB_SUCCESS を返します。 +

+ + +

EB_Error_Code eb_hook_narrow_character_text (EB_Book *book, EB_Appendix *appendix, void *container, EB_Hook_Code code, int argc, const unsigned int *argv)

+ +

EB_Error_Code eb_hook_wide_character_text (EB_Book *book, EB_Appendix *appendix, void *container, EB_Hook_Code code, int argc, const unsigned int *argv)

+ +

+eb_hook_narrow_character_text() は、フックコード +EB_HOOK_NARROW_FONT (半角外字) のためのフック関数です。 +同様に eb_hook_wide_character_text() は、フックコード +EB_HOOK_WIDE_FONT (全角外字) のためのフック関数です。 +

+ +

+EB_Hookset オブジェクトを関数 +eb_initialiez_hookset() で初期化すると、これらの関数が自動的 +に登録されます。 +

+ +

+この関数は、appendix の選択中している副本が、 +argv[0] として渡された外字の代替文字列を持っているかどうか +調べます。 +持っていればその文字列をテキストデータとして書き込み、持っていなければ +<?> という文字列を書き込みます。 +

+ +

+appendixNULL の場合や、付録が副本を選択中で +ない場合も、代替文字列を持っていないものとして扱います。 +

+ +

+この関数は、常に EB_SUCCESS を返します。 +

+ + +

EB_Error_Code eb_hook_newline (EB_Book *book, EB_Appendix *appendix, void *container, EB_Hook_Code code, int argc, const unsigned int *argv)

+ +

+eb_hook_narrow_newline() は、フックコード +EB_HOOK_NEWLINE (改行) のためのフック関数です。 +

+ +

+EB_Hookset オブジェクトを関数 +eb_initialiez_hookset() で初期化すると、これらの関数が自動的 +に登録されます。 +

+ +

+この関数は、テキストデータに \n を書き込みます。 +常に EB_SUCCESS を返します。 +

+ + +

EB_Error_Code eb_hook_empty (EB_Book *book, EB_Appendix *appendix, void *container, EB_Hook_Code code, int argc, const unsigned int *argv)

+ +

+eb_hook_empty() は、何もしないフック関数です。 +常に EB_SUCCESS を返します。 +

+ + +

テキストデータ操作関数の詳細

+ +

+この節で説明している関数を使うには、次のようにヘッダファイルを読み込んで +下さい。 +

+ +
+
+#include <eb/text.h>
+
+
+ + +

int eb_have_text (EB_Book *book)

+ +

int eb_have_menu (EB_Book *book)

+ +

int eb_have_copyright (EB_Book *book)

+ +

+関数 eb_have_text() は、book の選択している副本が、 +本文を持っているかどうかを調べます。 +同様に、eb_have_menu() はメニューを持っているかどうか、 +eb_have_copyright() は著作権表示を持っているかどうか調べます。 +

+ +

+いずれの関数も、持っていれば 1 を返し、持っていなければ 0 を返します。 +book が副本を選択していない場合も 0 を返します。 +

+ + +

EB_Error_Code eb_text (EB_Book *book, EB_Position *position)

+ +

EB_Error_Code eb_menu (EB_Book *book, EB_Position *position)

+ +

EB_Error_Code eb_copyright (EB_Book *book, EB_Position *position)

+ +

+関数 eb_text() は、book が選択している副本の本文 +の開始位置を position の指す領域に書き込みます。 +同様に、eb_menu() はメニューの開始位置を、 +eb_have_copyright() は著作権表示の開始位置を書き込みます。 +

+ +

+成功すると、これらの関数は EB_SUCCESS を返します。 +失敗すると、position に必ずシークが失敗する位置を書き込んで、 +原因を示すエラーコードを返します。 +

+ +

+あらかじめ、book 内のいずれかの副本が選択されていなくては +なりません。 +book が副本を選択していなければ、EB_ERR_NO_CUR_SUB +を返します。 +選択中の副本が、対象となるテキストデータを持っていなければ、 +EB_ERR_NO_SUCH_SEARCH を返します。 +

+ + +

EB_Error_Code eb_seek_text (EB_Book *book, const EB_Position *position)

+ +

+関数 eb_seek_text() は、book が選択している副本の +テキストデータファイルをシークします。 +シーク位置は position で指定します。 +このとき、position は常にファイルの先頭からの位置として解釈 +されます。 +(相対位置へのシーク機能は、EB ライブラリにはありません。) +

+ +

+シークを行うと、それまでに行った読み込みの状態記録がリセットされます。 +eb_read_text(), eb_read_heading(), +eb_read_rawtext() を用いてテキストデータを読み込むには、 +前もってこの関数を呼び出しておく必要があります。 +

+ +

+成功すると、この関数は EB_SUCCESS を返します。 +失敗すると、原因を示すエラーコードを返します。 +

+ +

+あらかじめ、book 内のいずれかの副本が選択されていなくては +なりません。 +book が副本を選択していなければ、EB_ERR_NO_CUR_SUB +を返します。 +選択中の副本にテキストデータが存在しないときは、EB_ERR_NO_TEXT +を返します。 +

+ +

+なお、書籍によっては、テキストデータを収めたファイルには他のデータも +一緒に格納されていることがありますが、テキスト以外のデータにアクセス +しても、テキストデータの現在位置、読み込みに関する状態記録は変化しません。 +

+ + +

EB_Error_Code eb_tell_text (EB_Book *book, EB_Position *position)

+ +

+関数 eb_seek_text() は、book が選択している副本の +テキストデータファイルの現在のアクセス位置を返します。 +

+ +

+成功すると、position の指す領域に現在のアクセス位置を書き込み、 +EB_SUCCESS を返します。 +失敗すると、シークが必ず失敗する位置を書き込み、原因を示すエラーコード +を返します。 +

+ +

+あらかじめ、book 内のいずれかの副本が選択されていなくては +なりません。 +book が副本を選択していなければ、EB_ERR_NO_CUR_SUB +を返します。 +選択中の副本にテキストデータが存在しないときは、EB_ERR_NO_TEXT +を返します。 +

+ + +

EB_Error_Code eb_read_text (EB_Book *book, EB_Appendix *appendix, EB_Hookset *hookset, void *container, size_t text_max_length, char *text, ssize_t *text_length)

+ +

EB_Error_Code eb_read_heading (EB_Book *book, EB_Appendix *appendix, EB_Hookset *hookset, void *container, size_t text_max_length, char *text, ssize_t *text_length)

+ +

+関数 eb_read_text()eb_read_heading() は、 +book +が選択している副本のテキストデータファイルの現在のアクセス位置からデータ +を読み込みます。 +eb_read_heading() は見出しの読み込みに用い、 +eb_read_text() はそれ以外のテキストデータの読み込みに用います。 +

+ +

+読み込まれたテキストデータは、必要に応じて文字コードの変換 +(「文字コード」 を参照のこと) が行われた後に、hookset +の指すフックセットにしたがって加工されます。 +hooksetNULL のときは、代わりに EB ライブラリ側 +で用意している 標準のフックセット (default hookset) が +用いられます。 +このフックセットは、eb_initialize_hookset() によって +初期化しただけのフックセットと等価です。 +

+ +

+フックセットによって加工された後に、テキストデータは text の +指す領域に書き込まれ、書き込んだバイト数が text_length の指す +領域に書き込まれます。 +text はナル文字で終端されますが、text_length には +ナル文字の分は勘定に入れません。 +テキストデータは、text_max_length で指定されたバイト数を超えて +書き込むことはありません。 +ただし、text_max_length にもナル文字の分は勘定に入っていません +ので、texttext_max_length + 1 バイト分のデータ +を格納できる大きさが必要です。 +

+ +

+どちらの関数も、成功すれば EB_SUCCESS を返し、失敗すれば +text_length の指す領域に 0 を書き込んで原因を示すエラーコード +を返します。 +

+ +

+あらかじめ、book 内のいずれかの副本が選択されていなくては +なりません。 +book が副本を選択していなければ、EB_ERR_NO_CUR_SUB +を返します。 +

+ +

+また、eb_read_text()eb_read_heading() を +呼び出すには、 +あらかじめ eb_seek_text() の呼び出しを成功させ、テキストデータ +のアクセス位置がセットされた状態にしておかなくてはなりません。 +シークをせずに呼び出すと、EB_ERR_NO_PREV_SEEK を返します。 +

+ +

+逆に一度シークすれば、区切りコードが検出されるまでの間なら、関数を +繰り返し呼ぶことでテキストデータの続きを読み込むことができます。 +区切りコードが検出されると、関数を呼び出しても読み込みは行われません。 +その場合でも、他にエラーが発生しなければ EB_SUCCESS が返り、 +text には空文字列が書き込まれます。 +

+ +

+ただし、一度 eb_read_text() を呼び出してテキストデータを +読み込み始めたら、繰り返し呼び出す際も、eb_read_text() を +使わなければなりません。 +途中から eb_read_heading() および後述の +eb_read_rawtext() に切り替えて呼び出すと +EB_ERR_DIFF_CONTENT エラーが返ります。 +関数 eb_read_heading() についても同様です。 +この制限は、再度 eb_seek_text() を呼び出すか、 +eb_set_subbook() で副本を選択し直すまで続きます。 +

+ +

+渡された appendix が区切りコードの情報を持った副本を選択中 +であれば、本文の区切りコードとしてその値を使用します。 +それ以外の場合は、eb_read_text() が区切りコードを自動判別を +試みます。 +ただし、この判定は完璧なものではないので、書籍によっては変な位置で本文 +が切れてしまうかも知れません。 +(本文以外のテキストデータに関しては、このような問題は起きません。) +

+ +

+引数 container は、アプリケーションプログラムからフック関数に +データを渡すためのものです。 +eb_read_text(), eb_read_heading() では、直接 +この引数の値を参照することはありません。 +

+ +

+引数 appendix, container は、そのままフック関数に +渡されます。 +これらの引数は NULL でも構いません。 +(呼び出されるフック関数で支障がなければ。) +

+ +

+なお、フック関数や eb_read_text(), eb_read_heading() +自身が文字ないしエスケープシーケンス一個分に対するデータを書き込もうと +したときに、text に十分な空き領域がないということが起こり +得ます。 +その場合、関数は途中まで text に書き込むことはせずに、 +いったん処理を終えて戻ります。 +したがって、マルチバイト文字のデータが途中で切れたりすることはありません。 +

+ +

+書き込めなかった分は、当然ながら text_length の勘定には +入りません。 +書き込めなかったデータは book 内部に保存されているので、 +もう一度 eb_read_text(), eb_read_heading() を +呼び出すと、前回の呼び出しで書き込めなかったデータがまず text +の先頭に書き込まれます。 +書き込んだデータは text_length の勘定に入ります。 +

+ +

+ただし、book が保存しているデータの長さが +text_max_length を超えていると、何も書き込まずに関数は終了 +します。 +このとき、書き込めなかったデータは引き続き保存されます。 +つまり、text_max_length があまりに小さく、かつ保持している +データのほうが長いと、何度呼び出しても text への書き込みが +進みませんので、注意が必要です。 +

+ +

+eb_seek_text() を呼び出すか、eb_set_subbook() +で副本を選択し直すと、保存していたデータは破棄されます。 +

+ + +

EB_Error_Code eb_read_rawtext (EB_Book *book, size_t text_max_length, char *text, ssize_t *text_length)

+ +

+関数 eb_read_rawtext() は、book が選択している +副本のテキストデータファイルの現在のアクセス位置からデータを読み込みます。 +

+ +

+eb_read_text() と似ていますが、この関数はフックセットによる +データの加工や文字コードの変換を一切行わず、データを内部表現のまま返します。 +読み込むテキストデータの種類は、何であっても構いません。 +

+ +

+読み込んだテキストデータは text の指す領域に書き込まれ、 +書き込んだバイト数が text_length の指す領域に書き込まれます。 +テキストデータは、text_max_length で指定されたバイト数を超えて +書き込むことはありません。 +ただし、eb_read_text() と異なり、text はナル文字 +で終端されません。 +マルチバイト文字やエスケープシーケンスの途中で text の残り領域 +が足りなくなった場合も、途中までは書き込みます。 +

+ +

+処理が成功すれば EB_SUCCESS を返し、失敗すれば +text_length の指す領域に 0 を書き込んで原因を示すエラーコード +を返します。 +

+ +

+あらかじめ、book 内のいずれかの副本が選択されていなくては +なりません。 +book が副本を選択していなければ、EB_ERR_NO_CUR_SUB +を返します。 +

+ +

+また、この関数を呼び出すには、あらかじめ eb_seek_text() の +呼び出しを成功させ、テキストデータのアクセス位置がセットされた状態にして +おかなくてはなりません。 +シークをせずに呼び出すと、EB_ERR_NO_PREV_SEEK を返します。 +

+ +

+この関数は、繰り返し呼び出すことで、前回読み込んだテキストデータの続き +を読み込むことができます。 +ただし、区切りコードの検出を行いませんので、ひたすら呼び出しを続けると、 +テキストデータファイルの末尾まで行ってしまいます。 +

+ +

+一度 eb_read_rawtext() を呼び出してテキストデータを読み込み +始めたら、繰り返し呼び出す際も、eb_read_rawtext() を +使わなければなりません。 +途中から、eb_read_text()eb_read_heading() に +切り替えると、 +EB_ERR_DIFF_CONTENT エラーが返ります。 +この制限は、再度 eb_seek_text() を呼び出すか、 +eb_set_subbook() で副本を選択し直すまで続きます。 +

+ + +

int eb_is_text_stopped (EB_Book *book)

+ +

+関数 eb_is_text_stopped() は、最後に読み込んだテキストデータ +が末尾に達したかどうかを判定します。 +

+ +

+book が選択中の副本で、最後に eb_read_text() +または eb_read_heading() でテキストデータを読み込んだ際に、 +区切りコードを検出したか、テキストデータ全体の一番後ろの位置に達して +読み込みを終えていれば、この関数は 1 を返します。 +それ以外のときは、0 を返します。 +

+ +

+book が副本を選択していない場合や、選択中の副本にテキストデータ +が存在しない場合も 0 が返ります。 +

+ +

+eb_read_text() または eb_read_heading() で +テキストデータを読み込んでいない場合も、同様に 0 が返ります。 +テキストデータを読み込んだ後であっても、テキストデータの読み込みに関する +状態記録をリセットする関数 (eb_read_text() の項を参照) を呼んでしまうと、 +読み込んでいないと見なされますので、注意して下さい。 +

+ +

+通常はこの関数を使わなくても、eb_read_text() や +eb_read_heading() が 0 を返したら、テキストデータの末尾に +達したとみなして差し支えないでしょう。 +ただしその際は、引数 text_max_length の値を十分大きく取って +下さい。 +

+ + + +

EB_Error_Code eb_write_text_byte1 (EB_Book *book, int byte1)

+ +

EB_Error_Code eb_write_text_byte2 (EB_Book *book, int byte1, int byte2)

+ +

EB_Error_Code eb_write_text_string (EB_Book *book, const char *string)

+ +

EB_Error_Code eb_write_text (EB_Book *book, const char *stream, size_t stream_length)

+ +

+これらの関数は、いずれもフック関数の中から、テキストデータを書き込む +ために用います。 +書き込むデータの種類によって、使い分けて下さい。 +

+ +

+eb_write_text_byte1() は、byte1 で指定した +1 バイトの値を書き込みます。 +eb_write_text_byte2() は、byte1, byte2 +で指定した 2 バイトを書き込みます。 +eb_write_text_string() は、string で指定した +文字列を書き込みます。 +eb_write_text() は、stream から始まる長さ +stream_length バイトのバイト列を書き込みます。 +

+ +

+どの関数も、成功すると EB_SUCCESS を返し、失敗すると原因を +示すエラーコードを返します。 +

+ +

+最終的に、書き込んだテキストデータは、フック関数の呼び出し元である +eb_read_text(), eb_read_heading() から +アプリケーションプログラムに渡されます。 +

+ +

+フック関数として呼び出されていないときに、これらの関数を呼び出した場合 +の動作は未定義です。 +

+ + +

const char *eb_current_candidate (EB_Book *book)

+ +

+関数 eb_current_candidate() は、アクセス中のテキストデータの +現在位置に書かれている、複合検索の候補となる語を返します。 +

+ +

+返す文字列の長さは、最長で EB_MAX_WORD_LENGTH バイトになります。 +ただし、この長さにナル文字は含みません。 +

+ +

+この関数は非常に特殊で、複合検索の候補となる語の終了を意味する +エスケープシーケンスへのフックである EB_HOOK_END_CANDIDATE_LEAF +および EB_HOOK_END_CANDIDATE_GROUP に対するフック関数の中で +のみ呼び出すことができます。 +それ以外の場所で呼び出したときの動作は、未定義です。 +

+ +

+この関数の呼び出し方ですが、フック関数に渡ってきた EB_Book +オブジェクト (へのポインタ) を、そのままこの関数に引数として渡して +やります。 +

+ +

+book の文字コード +(「[CD-ROM 書籍と EB_Book オブジェクト] データ型の詳細」 を参照のこと) +が EB_CHARCODE_ISO8859_1 なら、関数の返す文字列は ISO 8859-1 +になり、それ以外の文字コードの場合は日本語 EUC になります。 +関数の返す文字列は、他のフックによる加工処理の影響を受けません。 +文字コードの変換を行う以外は、内部データをそのまま返します。 +

+ +

+なお、この関数が返した文字列を参照できるのは、フック関数から戻るまでの +間だけですので、注意して下さい。 +

+ + +

EB_Error_Code eb_forward_text (EB_Book *book, EB_Appendix *appendix)

+ +

EB_Error_Code eb_backward_text (EB_Book *book, EB_Appendix *appendix)

+ +

+関数 eb_forward_text()eb_backward_text() は、 +book が選択している副本の本文のアクセス位置を前後に移動させ、 +本文の区切りコードを単位とした頭出しを行います。 +ちょうど、音楽 CD の曲の頭出しと同じです。 +

+ +

+eb_forward_text() は本文の末尾方向に向かってアクセス位置を +進め、eb_backward_text() は先頭方向に向かってアクセス位置を +戻します。 +

+ +

+eb_forward_text() の呼び出しでは、アクセス位置は必ず次の語の +説明の開始位置まで移動します。 +それに対して eb_backward_text() の呼び出しでは、移動先が状態 +によって異なります。 +もし、現在のアクセス位置がその単語の説明の先頭にあるときは、 +eb_backward_text() の呼び出しによって、一つ前の単語の説明の +先頭にアクセス位置が移動します。 +アクセス位置が単語の説明の途中や末尾にあるときは、その単語の説明の +先頭に移動します。 +

+ +

+この関数は、成功すると EB_SUCCESS を返し、失敗すると原因を示す +エラーコードを返します。 +

+ +

+あらかじめ、book 内のいずれかの副本が選択されていなくては +なりません。 +book が副本を選択していなければ、EB_ERR_NO_CUR_SUB +を返します。 +

+ +

+加えて、これらの関数を呼び出すには、あらかじめ eb_seek_text() +か eb_read_text() を呼び出しが成功していないといけません。 +(eb_read_text() の呼び出しを成功させるには、さらに前もって +eb_seek_text() の呼び出しを成功させることが条件となります。) +

+ +

+eb_read_text() ではなく、eb_read_heading() や +eb_read_rawtext() の呼び出しに成功した後でこの関数を +呼び出すと、EB_ERR_DIFF_CONTENT を返します。 +また、前もって eb_seek_text() でシークせずにこの関数を +呼び出すと、EB_ERR_NO_PREV_SEEK を返します。 +

+ +

+本文データの末尾や先頭に達してしまって、その方向にもう本文がないときは、 +EB_ERR_END_OF_CONTENT を返します。 +

+ +

+appendixNULL ではなく、区切りコードの情報を +持った副本を選択中であれば、本文の区切りコードとしてその値を使用します。 +それ以外の場合は、eb_read_text() と同じ方法で区切りコードの +自動判別を試みます。 +

+ +

+アクセス位置上にあるのがメニューや著作権表示のように、本文以外の +テキストデータであっても構いません。 +ただし、本文以外のテキストデータの内部には、頭出し位置がデータの +先頭位置にしかありませんので、この関数が役に立つ状況はほとんど +ありません。 +

+ +

+(メニューでは、個々の階層のメニューデータが、それぞれ独立した +テキストデータになっているため、頭出しを行っても前後のメニューデータへは +移動できません。 +複合検索の候補一覧も同様です。) +

+ + +

EB_Error_Code eb_forward_heading (EB_Book *book)

+ +

+関数 eb_forward_heading() は、book が選択している +副本の見出しのアクセス位置を後に移動させ、見出しの区切りを単位とした頭出し +を行います。 +

+ +

+本文の頭出しを行う関数 eb_forward_text() の見出し版です。 +ただし、見出しで頭出しを行う機会は、クロス検索の本文取得に限られるため、 +eb_backward_heading() という関数は用意していません。 +

+ +

+この関数を呼ぶと、アクセス位置が次の見出しの開始位置まで移動します。 +(クロス検索では、見出し領域の中に「見出し」と「本文」が交互に書かれて +いますが、データ構造上「本文」と「見出し」は区別が付きません。 +アクセス位置がクロス検索の見出し領域内の場合、この関数を呼ぶと最も近い +「見出し」もしくは「本文」の開始位置まで移動します。) +

+ +

+eb_read_heading() ではなく、eb_read_text() や +eb_read_rawtext() の呼び出しに成功した後でこの関数を +呼び出すと、EB_ERR_DIFF_CONTENT を返します。 +また、前もって eb_seek_text() でシークせずにこの関数を +呼び出すと、EB_ERR_NO_PREV_SEEK を返します。 +

+ +

+この関数は、成功すると EB_SUCCESS を返し、失敗すると原因を示す +エラーコードを返します。 +

+ +

+クロス検索以外の検索メソッドの見出しの格納位置に対して、この関数を +呼ぶことも可能ですが、そのような必要に迫られる機会はないでしょう。 +

+ + +

外字

+ +

+文字コードに収録されていない、私的に定義した文字のことを、俗に「外字」 +と言います。 +外字として定義した個々の文字を識別するために、文字コードに収録された +文字とは重複しない位置に、各文字の文字番号に割り振るのが普通です。 +(割り当てる文字番号の詳細については、「文字コード」 を参照のこと。) +

+ +

+市販の電子ブック、EPWING でも、ほとんどが外字を使っています。 +外字の定義状況は書籍同士でバラバラで、まったく統一感はありません。 +つまり、同じ文字番号を使っていても、定義されている外字は書籍によって +違います。 +外字は副本毎に定義することが可能ですが、一つの CD-ROM 書籍内でも副本に +よって定義が異なることも珍しくありません。 +副本によっては、数百から数千の外字を定義していることもあります。 +

+ +

+CD-ROM 書籍では、定義した外字の字形データ (つまりフォント) を用意して +います。 +フォントはビットマップデータであり、書籍によっては大きさの異なる数種類 +のフォントを用意しています。 +

+ +

+逆に言えば、外字に対して提供されるデータは、フォントだけです。 +ある文字番号を割り当てられた外字が、漢字なのか、発音記号なのか、 +そういった補助的な情報は用意されていません。 +アプリケーションプログラムが外字をサポートするためには、外字のフォント +をそのまま表示する以外に方法はないでしょう。 +

+ + + +

半角外字と全角外字

+ +

+CD-ROM 書籍における外字には、「全角外字」「半角外字」の二種類があります。 +全角外字は用意されているフォントの横と縦の長さがおよそ 1:1 になっており、 +半角外字では 1:2 になっています。 +

+ +
+
+      全角外字          半角外字  
+    (16×16)        (8×16)
+□□□□□□□□□□□□□□□□  □□□□□□□□
+□□□□□□□□□□□□□□□□  □□■■□■□□
+□□□■■■■■■□□□■□□□  □□□□■□□□
+□□□□□□□□■□■□■□□□  □□□■■□□□
+□□□□■□□■□□■□■□□□  □□■□□■□□
+□□□□■□□■■■■■■□□□  □■□□□■□□
+□□■■■■■□□□■□■□□□  □□□■□■□□
+□□□□□□□□□□■□■□□□  □□■□■■□□
+□□□■□□□□□□□□■□□□  □■□□□■□□
+□□□■□□□□□□□□■□□□  □■□□□■□□
+□□□■■■■■■■■■■□□□  □■□□□■□□
+□□□■□□□□□□□□■□□□  □■□□□■□□
+□□□■□□□□□□□□■□□□  □■□□□■□□
+□□□■■■■■■■■■■□□□  □■□□□■□□
+□□□□□□□□□□□□□□□□  □□■■■□□□
+□□□□□□□□□□□□□□□□  □□□□□□□□
+
+
+ +

+テキストデータには、半角表示の開始と終了を表すエスケープシーケンスが +あり (「テキストデータの内部形式」 を参照のこと)、 +開始と終了の間に置かれたものは半角外字、それ以外のところなら全角外字に +なります。 +

+ +

+文字番号は同じでも、字形が全角と半角ではまったく異なることもあります +ので、外字の文字番号だけから、全角と半角のどちらかを判断することは +できません。 +かならず、前方に半角開始のエスケープシーケンスが出現していたかどうか +という情報に基づいて判断しないといけません。 +

+ +

+ただし、全角か半角かの判定は EB ライブラリ側で行いますので、 +アプリケーションプログラムが文脈の解析を行う必要はありません。 +

+ +

+CD-ROM 書籍の副本には、半角外字あるいは全角外字のどちらか一方だけを +定義しているものもありますし、両方とも定義しているものもあります。 +

+ + +

外字の大きさと外字コード

+ +

+各副本には、定義している外字のフォントがビットマップ形式で収録されて +います。 +フォントの大きさは、縦のピクセル数を基準にすると 16, 24, 30, 48 の +4 種類があり、全角外字、半角外字それぞれのフォントの大きさ +(横のピクセル数×縦のピクセル数) は次の通りになります。 +

+ + + + + + + +
縦のピクセル数 全角全角 半角外字
16 16x16 8x16
24 24x24 16x24
30 32x30 16x30
48 48x48 24x48
+ +

+ただし、すべての副本でこれら 4 種類のフォントを用意しているわけでは +ありません。 +縦が 16 ピクセルのものは必ず用意されていますが、それ以外はないことも +珍しくありません。 +(外字がまったく定義されていなければ、16 ピクセルのフォントも用意され +ません。) +

+ +

+EB ライブラリでは、このように縦方向のピクセル数、つまり +フォントの高さ (font height) を基準に、外字フォントの大きさを +区別しています。 +そして、それぞれのフォントの高さ (16, 24, 30, 48) に対して、 +外字コード (font code) というものを割り当てています。 +フォントの高さを指定する際は、必ずこの外字コードを使います。 +

+ + + + + + + +
縦のピクセル数 外字コード
16 EB_FONT_16
24 EB_FONT_24
30 EB_FONT_30
48 EB_FONT_48
+ + +

選択中の外字フォントの高さ

+ +

+EB_Book オブジェクトで選択中の副本が用意している外字フォント +の高さの中から一つ選んで、 +選択中の外字フォントの高さ (current font height) として指定する +ことができます。 +EB ライブラリで外字のフォントデータ (ビットマップデータ) を取り出すには、 +外字フォントの高さをあらかじめ選択しておく必要があります。 +

+ +

+選択するには、関数 eb_set_font() を使います。 +以下のプログラムは、高さ 24 ピクセルのフォントを選択する場合の例です。 +

+ +
+
+/* bookEB_Book のオブジェクトで、すでに
+ * 書籍に結び付けられ、副本を選択中だと仮定しています。*/
+if (eb_set_font(&book, EB_FONT_24) != EB_SUCCESS) {
+    printf("eb_set_font_() failed\n");
+    return;
+}
+
+
+ +

+このプログラムでは、高さ 24 ピクセルのフォントを選択中の副本が用意して +いるものと仮定していますが、実際には用意していない副本も珍しくありません。 +もし、副本が高さ 24 ピクセルのフォントを用意していなければ、 +eb_set_font()EB_ERR_NO_SUCH_FONT を返します。 +

+ +

+しかし、外字を選択する前に、前もってその副本が用意しているフォントを +知りたいときもあります。 +これには、2 通りの方法があります。 +

+ +

+まず 1 つ目は、選択中の副本が用意しているフォントの高さの一覧を +eb_font_list() で取得する方法です。 +これは、副本コードの一覧を取得する eb_subbook_list() と +使い方が良く似ています。 +

+ +
+
+EB_Font_Code font_list[EB_MAX_FONTS];
+int font_count;
+int i;
+
+if (eb_font_list(&book, font_list, &font_count) != EB_SUCCESS) {
+    printf("eb_font_list() failed\n");
+    return;
+}
+
+for (i = 0; i < font_count; i++) {
+    if (font_list[i] == EB_FONT_24)
+        printf("this subbook has EB_FONT_24\n");
+}
+
+
+ +

+2 つ目は、eb_have_font() を使うやり方です。 +この関数は、特定の高さのフォントを、選択中の副本が用意しているかどうか +調べることができます。 +

+ +
+
+if (eb_have_font(&book, EB_FONT_24)) {
+    printf("this subbook has EB_FONT_24\n");
+}
+
+
+ +

+また、選択中の副本が半角外字、全角外字を定義しているかどうかは、それぞれ +eb_have_narrow_font(), eb_have_wide_font() +を使って調べることができます。 +

+ +
+
+if (eb_have_narrow_font(&book))
+    printf("this subbook has narrow font\n");
+if (eb_have_wide_font(&book))
+    printf("this subbook has wide font\n");
+
+
+ +

+なお、あらかじめ副本を選択しておかないと、外字の高さは選択できないので +注意して下さい。 +eb_set_subbook() で選択中の副本を切り替えると、外字フォント +の高さは常に未選択の状態に戻ります。 +

+ + +

外字フォントの取り出し

+ +

+外字の高さを選択した状態であれば、外字のフォントデータ +(ビットマップデータ) を取り出すことができます。 +

+ +

+フォントデータを取り出す関数は、 +全角外字なら eb_wide_font_character_bitmap()、 +半角外字なら eb_narrow_font_character_bitmap() です。 +

+ +

+全角外字 0xa121 のフォントデータを取り出すプログラムは、 +次のようになります。 +半角外字の場合は、呼び出す関数名が変わるだけです。 +

+ +
+
+/* bookEB_Book のオブジェクトで、すでに
+ * 書籍に結び付けられ、副本と外字の高さを選択中だと仮定しています。*/
+char bitmap[EB_SIZE_WIDE_FONT_48];
+
+if (eb_wide_font_character_bitmap(book, 0xa121, bitmap)
+    != EB_SUCCESS) {
+    return;
+}
+
+
+ +

+ここでは、bitmap にフォントデータを格納しています。 +bitmap の領域として EB_SIZE_WIDE_FONT_48 +バイトを確保していますが、これは高さ 48 ピクセルの外字データを格納する +ために必要なサイズを表します。 +

+ +

+フォントデータのサイズは、外字の高さに応じて一定です。 +高さ 48 ピクセルは外字の中でも最大のサイズなので、このサイズの領域を +用意すれば、どの高さの外字でも格納できます。 +

+ +

+外字データは、ビットマップ形式のデータになっています。 +背景色をビット値 0, 前景色をビット値 1 として、各ピクセルの値を並べて +あります。 +並び方ですが、左上からまずは右に向かってピクセルを拾っていき、左端まで +来たら一つ下の段に降りて、また右方向にピクセルを拾います。 +以下、一番下の段までこれを繰り返します。 +

+ +

+ただし、バイト内では、128, 64, 32, ...1 の桁の順にビット値を格納して +います。 +つまり、128 の桁は一番左のピクセル、1 の桁は一番右のピクセルに対応 +します。 +

+ +

+以下に、16x16 の全角外字のビットマップの例と、そのバイト列を記します。 +背景色が□、前景色が■です。 +

+ +
+
+□□□□□□□□□□□□□□□□  0x00, 0x00,
+□□□□□□□□□□□□□□□□  0x00, 0x00,
+□□□■■■■■■□□□■□□□  0x1f, 0x88,
+□□□□□□□□■□■□■□□□  0x00, 0xc8,
+□□□□■□□■□□■□■□□□  0x09, 0x28,
+□□□□■□□■■■■■■□□□  0x09, 0xf8,
+□□■■■■■□□□■□■□□□  0x3e, 0x28,
+□□□□□□□□□□■□■□□□  0x00, 0x28,
+□□□■□□□□□□□□■□□□  0x10, 0x08,
+□□□■□□□□□□□□■□□□  0x10, 0x08,
+□□□■■■■■■■■■■□□□  0x1f, 0xf8,
+□□□■□□□□□□□□■□□□  0x18, 0x08,
+□□□■□□□□□□□□■□□□  0x18, 0x08,
+□□□■■■■■■■■■■□□□  0x1f, 0xf8,
+□□□□□□□□□□□□□□□□  0x00, 0x00,
+□□□□□□□□□□□□□□□□  0x00, 0x00,
+
+
+ + +

外字フォントの変換

+ +

+EB ライブラリには、外字のビットマップデータを XBM, XPM, GIF, BMP, PNG +の各画像形式に変換する関数が用意されています。 +変換を行う関数は、次の 5 つです。 +

+ + + + + + + +
eb_bitmap_to_xbm() XBM への変換
eb_bitmap_to_xpm() XPM への変換
eb_bitmap_to_gif() GIF への変換
eb_bitmap_to_bmp() BMP への変換
eb_bitmap_to_png() PNG への変換
+ +

+どの関数も呼び出し方は同じですが、ここでは XBM への変換のプログラム例 +を示します。 +

+ +
+
+/* bitmap に高さ 16 の全角外字のビットマップデータが格納
+ * されていると仮定しています。*/
+char bitmap[EB_SIZE_WIDE_FONT_16];
+char xbm[EB_SIZE_WIDE_FONT_16_XBM];
+size_t xbmsize;
+
+if (eb_wide_font_character_bitmap(bitmap, EB_WIDTH_WIDE_FONT_16,
+    EB_HEIGHT_FONT_16, xbm, &xbmsize) != EB_SUCCESS) {
+    return;
+}
+
+
+ +

+XPM, GIF, PNG への変換では、前景色は黒、背景色は透明になります。 +BMP への変換では、前景色は黒、背景色は白になります。 +XBM はモノクロ図版用のデータ形式なので、色の設定はありません。 +

+ + +

テキスト中の外字

+ +

+外字はテキストデータ (本文、メニューなど) の中で使われています。 +

+ +

+アプリケーションプログラムが、テキストデータ中に出現する外字を識別して +処理を行うには、外字に対するフックを設定して、フック関数の中で処理する +ことになります。 +

+ +

+外字に対するフックは、全角外字に対する EB_HOOK_WIDE_FONT と +半角外字に対する EB_HOOK_NARROW_FONT の二種類があります。 +いずれも、外字が一字出現する度に、設定したフック関数を呼び出します。 +

+ +

+フックの扱い方については、「フックコードの一覧」 を参照のこと。 +

+ + +

データ型の詳細

+ +

+この節で説明しているデータ型を使うには、次のようにヘッダファイルを +読み込んで下さい。 +

+ +
+
+#include <eb/eb.h>
+
+
+ + +

EB_Font_Code

+ +

+外字コードは、外字の高さ (ピクセル数) を表します。 +現在のところ、定義されている高さは次の通りです。 +

+ +
    +
  • EB_FONT_16 +
  • EB_FONT_24 +
  • EB_FONT_30 +
  • EB_FONT_48 +
  • EB_FONT_INVALID +
+ +

+外字コードの実体は整数値ですが、EB_FONT_16 の値は 16 では +ありません。 +他も同様ですので、注意して下さい。 +

+ +

+EB_FONT_INVALID は特別な外字コードで、不正な外字コード値を +表すために用います。 +

+ + +

定数の詳細

+ +

+この節で説明している定数を使うには、次のようにヘッダファイルを +読み込んで下さい。 +

+ +
+
+#include <eb/font.h>
+
+
+ + +

定数 EB_WIDTH_NARROW_FONT_16

+ +

定数 EB_WIDTH_NARROW_FONT_24

+ +

定数 EB_WIDTH_NARROW_FONT_30

+ +

定数 EB_WIDTH_NARROW_FONT_48

+ +

定数 EB_WIDTH_WIDE_FONT_16

+ +

定数 EB_WIDTH_WIDE_FONT_24

+ +

定数 EB_WIDTH_WIDE_FONT_30

+ +

定数 EB_WIDTH_WIDE_FONT_48

+ +

+これらの定数は、半角、全角およびそれぞれの高さ (外字コード) の外字一個 +分の幅 (横方向のピクセル数) を int 型で表しています。 +

+ + +

定数 EB_HEIGHT_NARROW_FONT_16

+ +

定数 EB_HEIGHT_NARROW_FONT_24

+ +

定数 EB_HEIGHT_NARROW_FONT_30

+ +

定数 EB_HEIGHT_NARROW_FONT_48

+ +

定数 EB_HEIGHT_WIDE_FONT_16

+ +

定数 EB_HEIGHT_WIDE_FONT_24

+ +

定数 EB_HEIGHT_WIDE_FONT_30

+ +

定数 EB_HEIGHT_WIDE_FONT_48

+ +

+これらの定数は、半角、全角およびそれぞれの高さ (外字コード) の外字一個分 +の縦方向のピクセル数を int 型で表しています。 +

+ +

+EB_HEIGHT_NARROW_FONT_16 および +EB_HEIGHT_WIDE_FONT_16 の実際の値は 16 です。 +(外字コード EB_FONT_16 の実際の値は 16 ではありませんので、 +注意して下さい。) +

+ + +

定数 EB_SIZE_NARROW_FONT_16

+ +

定数 EB_SIZE_NARROW_FONT_24

+ +

定数 EB_SIZE_NARROW_FONT_30

+ +

定数 EB_SIZE_NARROW_FONT_48

+ +

定数 EB_SIZE_WIDE_FONT_16

+ +

定数 EB_SIZE_WIDE_FONT_24

+ +

定数 EB_SIZE_WIDE_FONT_30

+ +

定数 EB_SIZE_WIDE_FONT_48

+ +

+これらの定数は、半角、全角およびそれぞれの高さ (外字コード) の外字一個分 +のビットマップデータを格納するのに必要な領域の大きさを表しています。 +値は int 型で、単位はバイトです。 +

+ + +

定数 EB_SIZE_NARROW_FONT_16_XBM

+ +

定数 EB_SIZE_NARROW_FONT_24_XBM

+ +

定数 EB_SIZE_NARROW_FONT_30_XBM

+ +

定数 EB_SIZE_NARROW_FONT_48_XBM

+ +

定数 EB_SIZE_WIDE_FONT_16_XBM

+ +

定数 EB_SIZE_WIDE_FONT_24_XBM

+ +

定数 EB_SIZE_WIDE_FONT_30_XBM

+ +

定数 EB_SIZE_WIDE_FONT_48_XBM

+ +

+これらの定数は、半角、全角およびそれぞれの高さ (外字コード) の外字一個分 +のビットマップデータを eb_bitmap_to_xbm() を用いて XBM 形式 +に変換する際に、変換後の XBM 形式のデータの大きさを表しています。 +値は int 型で、単位はバイトです。 +

+ + +

定数 EB_SIZE_NARROW_FONT_16_XPM

+ +

定数 EB_SIZE_NARROW_FONT_24_XPM

+ +

定数 EB_SIZE_NARROW_FONT_30_XPM

+ +

定数 EB_SIZE_NARROW_FONT_48_XPM

+ +

定数 EB_SIZE_WIDE_FONT_16_XPM

+ +

定数 EB_SIZE_WIDE_FONT_24_XPM

+ +

定数 EB_SIZE_WIDE_FONT_30_XPM

+ +

定数 EB_SIZE_WIDE_FONT_48_XPM

+ +

+これらの定数は、半角、全角およびそれぞれの高さ (外字コード) の外字一個分 +のビットマップデータを eb_bitmap_to_xpm() を用いて XPM 形式 +に変換する際に、変換後の XPM 形式のデータの大きさを表しています。 +値は int 型で、単位はバイトです。 +

+ + +

定数 EB_SIZE_NARROW_FONT_16_GIF

+ +

定数 EB_SIZE_NARROW_FONT_24_GIF

+ +

定数 EB_SIZE_NARROW_FONT_30_GIF

+ +

定数 EB_SIZE_NARROW_FONT_48_GIF

+ +

定数 EB_SIZE_WIDE_FONT_16_GIF

+ +

定数 EB_SIZE_WIDE_FONT_24_GIF

+ +

定数 EB_SIZE_WIDE_FONT_30_GIF

+ +

定数 EB_SIZE_WIDE_FONT_48_GIF

+ +

+これらの定数は、半角、全角およびそれぞれの高さ (外字コード) の外字一個分 +のビットマップデータを eb_bitmap_to_gif() を用いて GIF 形式 +に変換する際に、変換後の GIF 形式のデータの大きさを表しています。 +値は int 型で、単位はバイトです。 +

+ + +

定数 EB_SIZE_NARROW_FONT_16_BMP

+ +

定数 EB_SIZE_NARROW_FONT_24_BMP

+ +

定数 EB_SIZE_NARROW_FONT_30_BMP

+ +

定数 EB_SIZE_NARROW_FONT_48_BMP

+ +

定数 EB_SIZE_WIDE_FONT_16_BMP

+ +

定数 EB_SIZE_WIDE_FONT_24_BMP

+ +

定数 EB_SIZE_WIDE_FONT_30_BMP

+ +

定数 EB_SIZE_WIDE_FONT_48_BMP

+ +

+これらの定数は、半角、全角およびそれぞれの高さ (外字コード) の外字一個分 +のビットマップデータを eb_bitmap_to_bmp() を用いて BMP 形式 +に変換する際に、変換後の BMP 形式のデータの大きさを表しています。 +値は int 型で、単位はバイトです。 +

+ + +

定数 EB_SIZE_NARROW_FONT_16_PNG

+ +

定数 EB_SIZE_NARROW_FONT_24_PNG

+ +

定数 EB_SIZE_NARROW_FONT_30_PNG

+ +

定数 EB_SIZE_NARROW_FONT_48_PNG

+ +

定数 EB_SIZE_WIDE_FONT_16_PNG

+ +

定数 EB_SIZE_WIDE_FONT_24_PNG

+ +

定数 EB_SIZE_WIDE_FONT_30_PNG

+ +

定数 EB_SIZE_WIDE_FONT_48_PNG

+ +

+これらの定数は、半角、全角およびそれぞれの高さ (外字コード) の外字一個分 +のビットマップデータを eb_bitmap_to_png() を用いて PNG 形式 +に変換する際に、変換後の PNG 形式のデータの大きさを表しています。 +値は int 型で、単位はバイトです。 +

+ + +

関数の詳細

+ +

+この節で説明している関数を使うには、次のようにヘッダファイルを読み込んで +下さい。 +

+ +
+
+#include <eb/font.h>
+
+
+ + +

EB_Error_Code eb_font (EB_Book *book, EB_Font_Code *font_code)

+ +

+関数 eb_font() は、選択している副本において、選択中の +外字フォントの高さを表す外字コードを font_code の指す領域に +書き込みます。 +

+ +

+成功すると関数は EB_SUCCESS を返します。 +失敗すると font_code の指す領域に EB_FONT_INVALID +を書き込み、原因を示すエラーコードを返します。 +

+ +

+あらかじめ、外字フォントの高さが選択されていなければなりません。 +外字が選択されていなければ、EB_ERR_NO_CUR_FONT を返します。 +副本そのものを選択していない場合も、同様です。 +

+ + +

EB_Error_Code eb_set_font (EB_Book *book, EB_Font_Code font_code)

+ +

+関数 eb_set_font() は、選択中の副本における外字フォントの +高さをセットします。 +セットする外字フォントの「高さ」は、対応する外字コードを引数 +font_code で指定します。 +

+ +

+この関数は、成功すると EB_SUCCESS を返し、指定した「高さ」が +「選択中の外字フォントの高さ」となります。 +すでに外字フォントの高さを選択していた場合は、いったん未選択の状態に +してからあらためて font_code を選択します。 +

+ +

+失敗すると原因を示すエラーコードを返し、外字フォントの高さは未選択の +状態になります。 +

+ +

+あらかじめ、book 内のいずれかの副本が選択されていなくては +なりません。 +book が副本を選択していなければ、EB_ERR_NO_CUR_SUB +を返します。 +また、その副本が持っていない外字フォントの高さが指定されると、 +EB_ERR_NO_SUCH_FONT を返します。 +

+ + +

void eb_unset_font (EB_Book *book)

+ +

+関数 eb_unset_font() は、選択中の外字フォントの高さを未選択 +の状態に戻します。 +book が書籍に結び付いていない場合や副本が選択されていない場合、 +もしくは外字フォントの高さが選択されていない場合は何もしません。 +

+ + +

EB_Error_Code eb_font_list (EB_Book *book, EB_Font_Code *font_list, int *font_count)

+ +

+関数 eb_font_list() は、選択中の副本が定義している外字の +高さの一覧を EB_Font_Code 型の配列にして、font_list +の指す領域に書き込みます。 +

+ +

+配列は、最大で EB_MAX_FONTS 個の要素を持ちます。 +加えて、書籍が収録している副本の個数を font_count の指す領域に +書き込みます。 +(現在のバージョンでは 、EB_MAX_FONTS の値は 4 になっています。 +高さ 16, 24, 30, 48 ピクセルの 4 種類です。) +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、font_count の指す領域に 0 を書き込み、原因を示す +エラーコードを返します。 +

+ +

+あらかじめ、book 内のいずれかの副本が選択されていなくては +なりません。 +book が副本を選択していなければ、EB_ERR_NO_CUR_SUB +を返します。 +

+ + +

int eb_have_font (EB_Book *book, EB_Font_Code font_code)

+ +

+関数 eb_font() は、font_code で指定した高さの +外字フォントを、選択中の副本が持っているかどうかを調べます。 +

+ +

+持っていれば 1 を返し、持っていなければ 0 を返します。 +book が副本を選択していない場合も 0 を返します。 +

+ + +

EB_Error_Code eb_font_height (EB_Book *book, int *height)

+ +

+関数 eb_font_height() は、book が選択中の +外字フォントの高さ (縦方向のピクセル数) を height の指す領域に +書き込みます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、height の指す領域に 0 を書き込み、原因を示す +エラーコードを返します。 +

+ +

+あらかじめ、book は外字フォントの高さを選択していなくては +なりません。 +選択していない場合は、EB_ERR_NO_CUR_FONT を返します。 +

+ + +

EB_Error_Code eb_font_height2 (EB_Font_Code font_code, int *height)

+ +

+eb_font_height() と似ていますが、選択中の副本ではなく、引数 +font_height で指定された外字コードの高さ (縦方向のピクセル数) +を書き込む点が異なります。 +

+ + +

int eb_have_narrow_font (EB_Book *book)

+ +

int eb_have_wide_font (EB_Book *book)

+ +

+関数 eb_have_narrow_font() は、選択中の副本が半角外字を定義 +しているかどうかを調べます。 +同様に、関数 eb_have_wide_font() は、全角外字を定義しているか +どうかを調べます。 +

+ +

+定義していれば 1 を、定義していなければ 0 を返します。 +book が副本を選択していない場合も 0 を返します。 +

+ + +

EB_Error_Code eb_narrow_font_width (EB_Book *book, int *width)

+ +

EB_Error_Code eb_wide_font_width (EB_Book *book, int *width)

+ +

+関数 eb_narrow_font_width() は、book が選択中の +外字フォントの高さにおける半角外字の幅 (横方向のピクセル数) を、 +height の指す領域に書き込みます。 +同様に、eb_wide_font_width() は全角外字の幅を書き込みます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、width の指す領域に 0 を書き込み、原因を示す +エラーコードを返します。 +

+ +

+あらかじめ、book は外字の高さを選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_FONT を返します。 +

+ + +

EB_Error_Code eb_narrow_font_width2 (EB_Font_Code font_code, int *width)

+ +

EB_Error_Code eb_wide_font_width2 (EB_Font_Code font_code, int *width)

+ +

+eb_narrow_font_width(), eb_wide_font_width() と +似ていますが、選択中の副本ではなく、引数font_height で指定された +外字コードの幅 (横方向のピクセル数) を書き込む点が異なります。 +

+ + +

EB_Error_Code eb_narrow_font_size (EB_Book *book, size_t *size)

+ +

EB_Error_Code eb_wide_font_size (EB_Book *book, size_t *size)

+ +

+関数 eb_narrow_font_size() は、book が選択中の +外字フォントの高さにおける半角外字一個分のデータサイズ (バイト数) を、 +size の指す領域に書き込みます。 +同様に、eb_wide_font_size() は全角外字のサイズを書き込みます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、size の指す領域に 0 を書き込み、原因を示す +エラーコードを返します。 +

+ +

+あらかじめ、book は外字フォントの高さを選択していなくては +なりません。 +選択していない場合は、EB_ERR_NO_CUR_FONT を返します。 +

+ + +

EB_Error_Code eb_narrow_font_size2 (EB_Font_Code font_code, size_t *size)

+ +

EB_Error_Code eb_wide_font_size2 (EB_Font_Code font_code, size_t *size)

+ +

+eb_narrow_font_size(), eb_wide_font_size() と +似ていますが、選択中の副本ではなく、引数 font_height で指定 +された外字コードの外字一個分のデータサイズを書き込む点が異なります。 +

+ + +

EB_Error_Code eb_narrow_font_start (EB_Book *book, int *start)

+ +

EB_Error_Code eb_wide_font_start (EB_Book *book, int *start)

+ +

+関数 eb_narrow_font_start() は、book が選択中の +副本における半角外字の先頭の文字番号 (半角外字の文字番号の中で最小のもの) +を、start の指す領域に書き込みます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、原因を示すエラーコードを返します。 +

+ +

+あらかじめ、book は副本を選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_SUB を返します。 +副本が半角外字を定義していない場合は、EB_ERR_NO_CUR_FONT を +返します。 +

+ +

+関数 eb_wide_font_start() は、半角外字ではなく全角外字に +ついて調べるという点を除いて、eb_narrow_font_start() と同じ +です。 +

+ + +

EB_Error_Code eb_narrow_font_end (EB_Book *book, int *end)

+ +

EB_Error_Code eb_wide_font_end (EB_Book *book, int *end)

+ +

+関数 eb_narrow_font_end() は、book が選択中の副本 +における半角外字の最後の文字番号 (半角外字の文字番号の中で最大のもの) を、 +start の指す領域に書き込みます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、原因を示すエラーコードを返します。 +

+ +

+あらかじめ、book は副本を選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_SUB を返します。 +副本が半角外字を定義していない場合は、EB_ERR_NO_CUR_FONT を +返します。 +

+ +

+関数 eb_wide_font_end() は、半角外字ではなく全角外字について +調べるという点を除いて、eb_narrow_font_end() と同じです。 +

+ + +

EB_Error_Code eb_narrow_font_character_bitmap (EB_Book *book, int character_number, char *bitmap)

+ +

EB_Error_Code eb_wide_font_character_bitmap (EB_Book *book, int character_number, char *bitmap)

+ +

+関数 eb_narrow_font_character_bitmap() は、book +が選択中の副本で定義している、半角外字のビットマップデータを取り出します。 +取り出す外字の文字番号を、character_number で指定します。 +

+ +

+成功すると、関数はビットマップデータを bitmap の指す領域に +書き込み、EB_SUCCESS を返します。 +失敗すると、bitmap の指す領域に空文字列を書き込み、原因を示す +エラーコードを返します。 +

+ +

+あらかじめ、book は外字フォントの高さを選択していなくては +なりません。 +選択していない場合は、EB_ERR_NO_CUR_FONT を返します。 +副本が半角外字を定義していない場合も、やはり EB_ERR_NO_CUR_FONT +を返します。 +文字番号 character_number が外字の定義範囲外にある場合は、 +EB_ERR_NO_SUCH_CHAR_BMP を返します。 +

+ +

+関数 eb_wide_font_character_bitmap() は、半角外字ではなく +全角外字のビットマップデータを取り出すという点を除いて、 +eb_narrow_font_character_bitmap() と同じです。 +

+ +

+ビットマップデータの形式については、 +「外字フォントの取り出し」 を参照のこと。 +

+ + +

EB_Error_Code eb_forward_narrow_font_character (EB_Book *book, int n, int *character_number)

+ +

EB_Error_Code eb_forward_wide_font_character (EB_Book *book, int n, int *character_number)

+ +

+関数 eb_forward_narrow_font_character() は、book +が選択中の副本で定義されている半角外字の文字番号 character_number +のn 個後ろに位置する外字の文字番号を取得します。 +

+ +

+まず、関数を呼び出す際に、character_number の指す領域に +文字番号を書き込んでおきます。 +関数の処理が成功すると、戻ったときに n 個分だけ後方の文字番号 +に書き換わっています。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、原因を示すエラーコードを返します。 +

+ +

+あらかじめ、book は副本を選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_SUB を返します。 +副本が半角外字を持っていない場合は、EB_ERR_NO_CUR_FONT を +返します。 +

+ +

+n 個後ろにもう外字がない場合や、呼び出した際に +character_number の指す領域に書き込んであった文字番号が外字の +定義範囲外にある場合は EB_ERR_NO_SUCH_CHAR_BMP を返します。 +

+ +

+n には負の数を指定することもできます。 +この場合、次の呼び出しと等価になります。 +

+ +
+
+/* n < 0 とする */
+eb_backward_narrow_font_character (book, -n, character_number);
+
+
+ +

+関数 eb_forward_wide_font_character() は、半角外字ではなく +全角外字について操作するという点を除いて、 +eb_forward_narrow_font_character() と同じです。 +

+ + +

EB_Error_Code eb_backward_narrow_font_character (EB_Book *book, int n, int *character_number)

+ +

EB_Error_Code eb_backward_wide_font_character (EB_Book *book, int n, int *character_number)

+ +

+関数 eb_backward_narrow_font_character() は +eb_forward_narrow_font_character() とはちょうど逆の関数です。 +book が選択中の副本で定義されている半角外字の文字番号 +character_numbern 個前方に位置する外字の +文字番号を取得します。 +

+ +

+同様に、eb_backward_wide_font_character() は、全角外字に +ついて n 個前方の外字の文字番号を取得する関数で、 +eb_forward_wide_font_character() と反対の関数です。 +

+ +

+n には負の数を指定することも可能で、それぞれ次の呼び出しと +等価になります。 +

+ +
+
+/* 半角外字の場合 (n < 0) */
+eb_forward_narrow_font_character (book, -n, character_number);
+
+/* 全角外字の場合 (n < 0) */
+eb_forward_wide_font_character (book, -n, character_number);
+
+
+ + +

EB_Error_Code eb_narrow_font_xbm_size (EB_Font_Code height, size_t *size)

+ +

EB_Error_Code eb_narrow_font_xpm_size (EB_Font_Code height, size_t *size)

+ +

EB_Error_Code eb_narrow_font_gif_size (EB_Font_Code height, size_t *size)

+ +

EB_Error_Code eb_narrow_font_bmp_size (EB_Font_Code height, size_t *size)

+ +

EB_Error_Code eb_narrow_font_png_size (EB_Font_Code height, size_t *size)

+ +

EB_Error_Code eb_wide_font_xbm_size (EB_Font_Code height, size_t *size)

+ +

EB_Error_Code eb_wide_font_xpm_size (EB_Font_Code height, size_t *size)

+ +

EB_Error_Code eb_wide_font_gif_size (EB_Font_Code height, size_t *size)

+ +

EB_Error_Code eb_wide_font_bmp_size (EB_Font_Code height, size_t *size)

+ +

EB_Error_Code eb_wide_font_png_size (EB_Font_Code height, size_t *size)

+ +

+最初の 5 つの関数 +(eb_narrow_font_xbm_size() 〜 +eb_narrow_font_png_size()) は、外字コード height +の半角外字一個のビットマップを XBM, XPM, GIF, BMP, PNG 形式にそれぞれ変換 +したときのデータサイズを size の指す領域に書き込みます。 +

+ +

+同様に、後ろの 5 つの関数 +(eb_wide_font_xbm_size() 〜 +eb_wide_font_png_size()) は、全角外字を変換したときの +データサイズを書き込みます。 +

+ +

+いずれの関数も、成功すると EB_SUCCESS を返します。 +失敗すると、size の指す領域に 0 を書き込み、原因を示す +エラーコードを返します。 +

+ + +

EB_Error_Code eb_bitmap_to_xbm (const char *bitmap, int width, int height, char *image, size_t *image_length)

+ +

EB_Error_Code eb_bitmap_to_xpm (const char *bitmap, int width, int height, char *image, size_t *image_length)

+ +

EB_Error_Code eb_bitmap_to_gif (const char *bitmap, int width, int height, char *image, size_t *image_length)

+ +

EB_Error_Code eb_bitmap_to_bmp (const char *bitmap, int width, int height, char *image, size_t *image_length)

+ +

EB_Error_Code eb_bitmap_to_png (const char *bitmap, int width, int height, char *image, size_t *image_length)

+ +

+これら 5 つの関数は、eb_narrow_font_character() または +eb_wide_font_character() で取り出した外字のビットマップを +XBM, XPM, GIF, BMP, PNG 形式にそれぞれ変換します。 +

+ +

+ビットマップデータの指す領域を bitmap で指定し、ビットマップの +高さと幅を width, height で渡します。 +

+ +

+関数の呼び出しから戻ると、image の指す領域に変換後のデータが +書き込まれ、image_length の指す領域に変換後のデータの大きさが +書き込まれます。 +

+ +

+XPM, GIF, PNG への変換では、前景色は黒、背景色は透明になります。 +BMP への変換では、前景色は黒、背景色は白になります。 +XBM はモノクロ図版用のデータ形式なので、色の設定はありません。 +

+ + +

サンプルプログラム

+ + + + +

バイナリデータ

+ +

+バイナリデータ (binary data) とは、 +図版や動画、音声といったマルチメディアデータのことを指します。 +バイナリデータは、必ずテキストデータ +(「テキストデータ」 を参照のこと) +から参照される形で利用されます。 +

+ +

+今のところ EB ライブラリでは、全種類のバイナリデータを取り扱うことが +できるわけではありません。 +電子ブックで扱えるのは、2 階調のモノクロ図版と、カラー図版 (JPEG) だけ +です。 +EPWING では、モノクロ図版、カラー図版 (BMP および JPEG) に加えて、 +WAVE (PCM) 音声、MPEG 動画を扱うことができます。 +

+ +

+ただし、EB ライブラリが提供しているのは、こうしたバイナリデータを +CD-ROM 書籍から取得する機能だけです。 +表示したり再生したりする機能は用意していませんので、注意して下さい。 +

+ +

+アプリケーションは、英和辞書や国語辞書といった辞書だけを対象にするなら、 +バイナリデータの表示や再生には対応しなくても支障はありません。 +しかし一方では、図鑑や数式の表現にモノクロ図版を使っている数学辞典の +ように、対応しないと不便なものもあります。 +バイナリデータの表示や再生の機能を実装するかどうかは、アプリケーション +の対象辞書をどの範囲までにするのかによって決めると良いでしょう。 +

+ +

+以下、この章では種類別にバイナリデータの扱い方について説明します。 +

+ +

+バイナリデータの種類毎にデータの取り出し方は微妙に異なりますが (これは +データの収録方法が微妙に異なっているからに他なりません)、おおよそ手順 +は、次のようなものになります。 +

+ +
    +
  1. +テキストデータのフックを用いて、バイナリデータの参照情報を取得する。 + +
  2. +eb_binary_set_...() 関数を呼び出して、指定した位置の +バイナリデータをこれから読み込む旨を EB ライブラリに伝える。 + +
  3. +eb_read_binary() で実際にデータを読み込む。 +
+ +

+テキストデータと同様に、バイナリデータも副本に属するデータ +ですので、副本を選択していないと取得することはできません。 +バイナリデータの読み込みには、テキストデータとは別の +ファイルディスクリプタが割り当てられます。 +したがって、双方を交互に読み込んでも、動作には影響はありません。 +

+ + + +

モノクロ図版

+ +

+2 階調のモノクロ図版は、電子ブック、EPWING 双方に存在し、EB ライブラリ +ではどちらも扱うことができます。 +(電子ブックに存在する 16 階調のモノクロ図版は、今のところ EB ライブラリ +では対応していません。) +

+ +

+モノクロ図版データの内部形式は外字と同じですが、EB ライブラリでは、 +1 ピクセルに 1bit を割り当てた BMP 形式に変換してアプリケーションに +渡すようにしています。 +したがって、アプリケーションからは、あたかも BMP の図版データが収録 +されているようにみえます。 +

+ +

+テキストデータ内からは、バイナリデータであるモノクロ図版を参照する形 +をとります。 +モノクロ図版を取り出すには、この参照情報が必要です。 +参照情報の取得は、テキストデータ処理時に、モノクロ図版の開始と終了を +表すエスケープシーケンスへのフック EB_HOOK_BEGIN_MONO_GRAPHIC +と EB_HOOK_END_MONO_GRAPHIC を用いて行います。 +

+ +

+フック EB_HOOK_BEGIN_MONO_GRAPHIC がフック関数に渡す引数 +(argv) は 4 つあり、このうちの argv[2] と +argv[3] が図版の幅と高さ (ピクセル数) を意味します。 +

+ +

+また、フック EB_HOOK_END_MONO_GRAPHIC がフック関数に渡す +引数は 3 つで、argv[1]argv[2] が、 +図版データのページ番号とオフセットになります。 +

+ +

+モノクロ図版を取得するには、上記のフックから得た図版のページ番号と +オフセット、および幅と高さを記憶しておきます。 +

+ +

+次に、eb_set_binary_mono_graphic() を呼び出して、これから +モノクロ図版のデータを取得することを EB ライブラリに伝えます。 +eb_set_binary_mono_graphic() への引数には、 +EB_Book オブジェクトと、先ほど得た図版へのページ番号、 +オフセット、幅、高さを渡します。 +EB_Book オブジェクトは、これから取り出そうとしている図版を +収録している副本をあらかじめ選択しておく必要があります。 +

+ +
+
+/* eb_set_binary_mono_graphic() の関数プロトタイプ */
+EB_Error_Code
+eb_set_binary_mono_graphic(EB_Book *book, EB_Position *position,
+    int width, int height);
+
+
+ +

+電子ブックでは、フック関数に渡される幅と高さの値は 0 になっていますが、 +そのまま eb_set_binary_mono_graphic() に渡します。 +(EPWING では 0 を渡してはいけません。) +

+ +

+以上で図版データの取得準備ができたので、データを読み込みます。 +これには、eb_read_binary() を使います。 +

+ +
+
+#define MAX_LENGTH 1000
+char bitmap[MAX_LENGTH];
+ssize_t bitmap_length;
+
+if (eb_read_binary(&book, MAX_LENGTH, bitmap, &bitmap_length)
+    != EB_SUCCESS) {
+    fprintf(stderr, "an error occurs.\n");
+    return;
+}
+
+
+ +

+成功すると、読み込んだ図版データが bitmap に書き込まれ、 +何バイト書き込んだのかが bitmap_length に書き込まれます。 +書き込まれるバイト数は、最大で MAX_LENGTH バイトです。 +

+ +

+必ずしも一回の eb_read_binary() の呼び出しで図版データを +終端まで読み込む必要はなく、関数を繰り返し呼び出せば、前回の続きを +読み込むことができます。 +eb_read_binary() は、図版データの終端まで来るとそれ以上 +データは読み込みませんので、eb_read_binary() が 0 を返した +時点で図版データが終端したことを認識できます。 +

+ + +

カラー図版

+ +

+カラー図版は、電子ブックでは JPEG 形式、EPWING では JPEG と BMP (DIB) +形式のものが使用されています。 +EB ライブラリはこれらをすべて扱うことができますが、電子ブックへの対応 +は限定的なものになっています。(詳しくは後述します。) +

+ +

+カラー図版のデータを取り出すには、モノクロ図版と同様にテキストデータ +からカラー図版への参照情報をフックを通じて取得し、続いて実際に +カラー図版のデータを読み込むという手順になります。 +

+ +

+eb_set_binary_color_graphic() を呼び出して、これから +アプリケーションがカラー図版のデータを取得しようとしていることを +EB ライブラリに伝えます。 +eb_set_binary_color_graphic() への引数には、 +EB_Book オブジェクトに加えて、カラー図版のページ番号と +オフセットを渡します。 +

+ +
+
+/* eb_set_binary_color_graphic() の関数プロトタイプ */
+EB_Error_Code
+eb_set_binary_color_graphic(EB_Book *book, EB_Position *position);
+
+
+ +

+EB_Book オブジェクトは、これから取り出そうとしている図版を +収録している副本をあらかじめ選択しておきます。 + +カラー図版のページ番号とオフセットの情報は、カラー図版の開始と終了を表す +エスケープシーケンスへのフックから得ます。 +フックは、インライン表示用と非インライン用の 2 種類があり、さらに +それぞれ開始フックが JPEG 用と BMP 用に分かれています。 +

+ +
+
EB_HOOK_BEGIN_COLOR_BMP
+
EB_HOOK_BEGIN_COLOR_JPEG
+
+非インライン用 BMP, JPEG の開始フック + +
EB_HOOK_END_COLOR_GRAPHIC
+
+非インライン用カラー図版 (BMP, JPEG 共通) の終了フック + +
EB_HOOK_BEGIN_IN_COLOR_BMP
+
EB_HOOK_BEGIN_IN_COLOR_JPEG
+
+インライン用 BMP, JPEG の開始フック + +
EB_HOOK_END_IN_COLOR_GRAPHIC
+
+非インライン用カラー図版 (BMP, JPEG 共通) の終了フック +
+ +

+非インライン用の終了フック EB_HOOK_END_GRAPHIC では、 +フック関数に渡す引数の argv[2]argv[3] が、 +図版データのページ番号とオフセットになりますので、これを +eb_set_binary_color_graphic() に渡してやります。 +同様に、インライン用の終了フック EB_HOOK_END_IN_GRAPHIC +では、argv[2]argv[3] がページ番号と +オフセットですので、これを渡します。 +

+ +

+後は、実際にカラー図版のデータを取り出します。 +これには、モノクロ図版と同様に eb_read_binary() を用います。 +使い方はまったく一緒ですので、詳しくは +「モノクロ図版」 を参照してください。 +

+ +

+ただし、電子ブックのカラー図版については、データの終了位置が来ても +EB ライブラリは読み込みを止めないという制限事項があります。 +これは、データの大きさに関する情報が記されていないためで、データの +終端位置は、アプリケーションが JPEG のデータをデコードして割り出すしか +ありません。 +

+ + +

参照先付きカラー図版

+ +

+カラー図版には、画像内の特定の矩形領域に参照先の情報を付け加えたものが +あります。 +HTML におけるクリッカブル・イメージ (clickable image) とほぼ同じで、その +矩形領域内にマウスポインタがある間にマウスをクリックすると、あらかじめ +決められたリンク先に画面が遷移するという仕掛けです。 +リンク先となる矩形領域は、画像一つに対して複数個登録できます。 +

+ +
+
+       参照先付きカラー図版の例
+┌────────────────────────┐
+│┌ ─ ─ ─ ─ ┐  ┌ ─ ─ ─ ─ ┐│
+│                        │
+││  矩形領域1  │  │  矩形領域2  ││
+│                        │
+│└ ─ ─ ─ ─ ┘  └ ─ ─ ─ ─ ┘│
+│                        │
+│┌ ─ ─ ─ ─ ┐             │
+│                        │
+││  矩形領域3  │      図版     │
+│                        │
+│└ ─ ─ ─ ─ ┘             │
+└────────────────────────┘
+
+
+ +

+参照先付きカラー図版の取り扱い方は、通常のカラー図版を拡張した形と +なります。通常のカラー図版の場合では、たとえば JPEG の非インライン +画像では、次のような順番でフックが呼び出されます。 +

+ +
    +
  1. EB_HOOK_BEGIN_COLOR_JPEG (非インライン用 JPEG 開始) +
  2. EB_HOOK_END_COLOR_GRAPHIC (非インライン用 JPEG 終了) +
+ +

+これに対して参照先付きのカラー図版では、この2つのフックの間に、矩形領域 +情報に関するフックが挿入されます。 +

+ +
    +
  1. EB_HOOK_BEGIN_COLOR_JPEG (非インライン用 JPEG 開始) +
  2. EB_HOOK_BEGIN_CLICKABLE_AREA (矩形領域1 開始) +
  3. EB_HOOK_END_CLICKABLE_AREA (矩形領域1 終了) +
  4. EB_HOOK_BEGIN_CLICKABLE_AREA (矩形領域2 開始) +
  5. EB_HOOK_END_CLICKABLE_AREA (矩形領域2 終了)
    + 以下、矩形領域3、矩形領域4 ... と矩形領域の個数分だけ続く。 +
  6. EB_HOOK_END_COLOR_GRAPHIC (非インライン用 JPEG 終了) +
+ +

+矩形領域に関する具体的な情報は、EB_HOOK_BEGIN_CLICKABLE_AREA +(開始フック) のほうで取得します。 +フック関数に渡す引数の argv[1]argv[2] が、 +それぞれ矩形領域の開始 x, y 座標を表します。 +カラー図版の左上の座標が (0, 0) です。 +同様に、argv[3]argv[4] が矩形領域の右方向 +への幅と、下方向への高さを表します。 +最後の argv[5]argv[6] が参照先のページ番号 +とオフセットとなります。 +

+ +

+アプリケーションが参照先付きカラー図版に対応しない場合は、矩形領域の +開始情報と終了情報を無視することになります。 +これにより、図版は通常の (参照先を持たない) カラー図版とまったく同じく +扱われます。 +

+ + +

WAVE (PCM) 音声

+ +

+WAVE (PCM) 形式の音声データは EPWING にだけ存在します。 +(代わりに電子ブックには CD-DA 形式の音声データがありますが、EB ライブラリ +では対応していません。) +

+ +

+WAVE 形式の音声データを取り出すには、まずテキストデータ中から WAVE 音声 +の参照情報を得ます。 +参照開始と終了を表すエスケープシーケンスへのフック +EB_HOOK_BEGIN_WAVEEB_HOOK_END_WAVE が +それぞれありますので、これを用います。 +

+ +

+フック EB_HOOK_BEGIN_WAVE がフック関数に渡す引数のうち、 +argv[2]argv[3] が音声データの開始位置の +ページ番号とオフセット、argv[4]argv[5] が +終了位置のページ番号とオフセットとなります。 +

+ +

+この開始位置と終了位置を関数 eb_set_binary_wave() に渡して、 +その位置にある音声データをこれから取り出すことを EB ライブラリに伝えます。 +

+ +
+
+/* eb_set_binary_wave() の関数プロトタイプ */
+EB_Error_Code
+eb_set_binary_wave(EB_Book *book, EB_Position *start_position,
+EB_Position *end_position);
+
+
+ +

+そして後は、実際に音声データを取り出します。 +これには、他のバイナリデータと同様に eb_read_binary() を +用います。 +eb_read_binary() の使い方は、 +「モノクロ図版」 を参照のこと を参照してください。 +

+ + +

MPEG1 動画

+ +

+MPEG1 形式の動画データは EPWING にだけ存在します。 +動画データは EPWING の CD-ROM の movie というディレクトリの下に、 +動画毎に一個のファイルにした形で収められています。 +

+ +

+テキストデータ中に存在する、MPEG データの参照開始と終了を表す +エスケープシーケンスへのフック EB_HOOK_BEGIN_MPEG と +EB_HOOK_END_MPEG を使用することで、参照先の MPEG の +ファイル名を取得できます。 +

+ +

+具体的には、フック EB_HOOK_BEGIN_MPEG がフック関数に渡す +引数のうち、argv[2]argv[5] が合わせて一つ +のファイル名を表すようになっています。 +

+ +

+MPEG 動画のデータを得るには、このファイル名を +eb_set_binary_mpeg() に渡して、そのファイルの動画データを +これから取り出す旨を EB ライブラリに伝えます。 +ファイル名は、次のようにして argv + 2 +(&argv[2] でも同じ) を渡します。 +

+ +
+
+if (eb_set_binary_mpeg(&book, argv + 2) != EB_SUCCESS) {
+    fprintf(stderr, "an error occurs.\n");
+    return;
+}
+
+
+ +

+後は、実際に動画データを取り出します。 +これには、やはり他のバイナリデータと同様に eb_read_binary() +を用います。 +eb_read_binary() の使い方については、 +「モノクロ図版」 を参照のこと を参照してください。 +

+ + +

関数の詳細

+ +

+この節で説明している関数を使うには、次のようにヘッダファイルを読み込んで +下さい。 +

+ +
+
+#include <eb/binary.h>
+
+
+ + +

EB_Error_Code eb_set_binary_mono_graphic (EB_Book *book, const EB_Position *position, int width, height)

+ +

+関数 eb_set_binary_mono_graphic() は、モノクロ図版のデータを +これから取得しようとしていることを EB ライブラリに伝えます。 +引数 position は図版の位置、width, height +には図版の幅と高さを渡します。 +これらの情報は、図版の参照元であるテキストデータに記載されており、通常は +フック関数を通じて得るようにします。 +ただし、電子ブックでは幅と高さの値の情報がテキストデータに記されていない +ため、0 を渡すことになります。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、原因に応じたエラーコードを返します。 +

+ +

+あらかじめ、図版を取り出そうとしている副本を選択しておかなければ +なりません。 +book が副本を選択していなければ、EB_ERR_NO_CUR_SUB +を返します。 +図版の位置、幅、高さの値が明らかにおかしいと EB ライブラリが判断した +ときは、EB_ERR_NO_SUCH_BINARY を返します。 +

+ +

+この関数は、実際に図版データを読み込むことはしません。 +読み込みには、eb_read_binary() を用います。 +モノクロ図版のデータは、1 ピクセルに 1bit を割り当てた BMP 形式になって +います。 +

+ + +

EB_Error_Code eb_set_binary_color_graphic (EB_Book *book, const EB_Position *position)

+ +

+関数 eb_set_binary_color_graphic() は、EPWING のカラー図版の +データをこれから取得しようとしていることを EB ライブラリに伝えます。 +引数 position は図版の位置を渡します。 +位置の情報は、図版の参照元であるテキストデータに記載されており、通常は +フック関数を通じて得るようにします。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +

+ +

+あらかじめ、図版を取り出そうとしている副本を選択しておかなければ +なりません。 +book が副本を選択していなければ、EB_ERR_NO_CUR_SUB +を返します。 +図版の位置が明らかにおかしいと EB ライブラリが判断したときは、 +EB_ERR_NO_SUCH_BINARY を返します。 +

+ +

+この関数は、実際に図版データを読み込むことはしません。 +読み込みには、eb_read_binary() を用います。 +カラー図版データは、JPEG か BMP (DIB) のいずかの形式になっています。 +

+ + +

EB_Error_Code eb_set_binary_wave (EB_Book *book, const EB_Position *start_position, EB_Position *end_position)

+ +

+関数 eb_set_binary_wave() は、WAVE (PCM) 形式の音声のデータ +をこれから取得しようとしていることを EB ライブラリに伝えます。 +引数 start_positionend_position には音声データ +の開始位置を渡します。 +位置の情報は、音声データの参照元であるテキストデータに記載されており、 +通常はフック関数を通じて得るようにします。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、原因に応じたエラーコードを返します。 +

+ +

+あらかじめ、音声データを取り出そうとしている副本を選択しておかなければ +なりません。 +book が副本を選択していなければ、EB_ERR_NO_CUR_SUB を +返します。 +音声データの位置が明らかにおかしいと EB ライブラリが判断したときは、 +EB_ERR_NO_SUCH_BINARY を返します。 +

+ +

+この関数は、実際に音声データを読み込むことはしません。 +読み込みには、eb_read_binary() を用います。 +

+ + +

EB_Error_Code eb_set_binary_mpeg (EB_Book *book, const unsigned int *argv)

+ +

+関数 eb_set_binary_mpeg() は、MPEG1 形式の動画のデータを +これから取得しようとしていることを EB ライブラリに伝えます。 +引数 argv には動画データのファイル名を渡します。 +ただし、このファイル名は文字列ではなく、フック関数 +EB_HOOK_BEGIN_MPEG に渡された引数 argv[2] +〜 argv[5] の部分を渡します。 +つまり、フック関数の引数 argv + 2 を、 +eb_set_binary_mpeg() への引数 argv として +渡します。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、原因に応じたエラーコードを返します。 +

+ +

+あらかじめ、動画データを取り出そうとしている副本を選択しておかなければ +なりません。 +book が副本を選択していなければ、EB_ERR_NO_CUR_SUB +を返します。 +存在しない動画ファイル名を EB ライブラリが判断したときは、 +EB_ERR_NO_SUCH_BINARY を返します。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +

+ +

+この関数は、実際に動画データを読み込むことはしません。 +読み込みには、eb_read_binary() を用います。 +

+ + +

EB_Error_Code eb_read_binary (EB_Book *book, size_t binary_max_length, char *binary, ssize_t *binary_length)

+ +

+関数 eb_read_binary() は、バイナリデータを読み込みます。 +読み込もうとしているバイナリデータは、事前に +

+ +
    +
  • eb_set_binary_mono_graphic() +
  • eb_set_binary_color_graphic() +
  • eb_set_binary_wave() +
  • eb_set_binary_mpeg() +
+ +

+のいずれかの関数で、EB ライブラリに通知しておく必要があります。 +

+ +

+読み込んだデータは引数 binary の指す先の領域に書き込まれます。 +また、このとき書き込まれたバイト数は、binary_length の指す +先の領域にセットされます。 +ただし、書き込まれるバイト数は、最長でも引数 binary_max_length +に指定した値までとなります。 +

+ +

+この関数は、特に読み込んだデータの終端にナル文字を付加するような事は +しません。 +読み込まれるデータもバイナリ形式なので、途中にナル文字が出現する事も +あります。 +

+ +

+この関数を一回呼び出しだだけで、バイナリデータ全体を一気に取得する +必要はありません。 +繰り返し呼び出せば、前回の続きからデータが読み込まれます。 +

+ +

+ただし、以下に挙げた関数を呼び出すと、バイナリデータの読み込みに関する +状態記録がリセットされますので、それ以上の読み込みはできなくなります。 +

+ +
    +
  • eb_set_subbook() +
  • eb_unset_subbook() +
  • eb_load_all_subbooks() +
  • eb_bind() +
  • eb_finalize_book() +
  • eb_set_binary_mono_graphic() +
  • eb_set_binary_color_graphic() +
  • eb_set_binary_wave() +
  • eb_set_binary_mpeg() +
+ +

+eb_read_binary() を繰り返し呼んだ場合、バイナリデータは +その都度 binary の先頭から書き込まれ、*binary_length +の値も、その回の eb_read_binary() の呼び出しで書き込まれた +バイト数になります。 +

+ +

+データの終端に来ると、それ以上この関数を呼んでも関数は binary +には何も書き込まず、*binary_length に 0 を書き込み、 +EB_SUCCESS を返します。 +

+ +

+成功すると、この関数は EB_SUCCESS を返します。 +失敗すると、binary_length が指す領域に -1 を書き込み、原因を +示すエラーコードを返します。 +この場合、バイナリデータの読み込み状態の記録がリセットされますので、 +データの続きを読み込むことはできなくなります。 +

+ +

+あらかじめ、book はいずれかの副本を選択していなくては +なりません。 +選択していない場合は、EB_ERR_NO_CUR_SUB を返します。 +また、冒頭に挙げた関数の呼び出しが成功していない状態でこの関数を呼ぶと、 +EB_ERR_NO_CUR_BINARY を返します。 +

+ + +

EB_Error_Code eb_compose_movie_file_name (const unsigned int *argv, char *composed_file_name)

+ +

+関数 eb_compose_movie_file_name() は、動画データのファイル名 +を通常の文字列に変換します。 +

+ +

+EB ライブラリでは、動画データのファイル名はフック関数 +EB_HOOK_BEGIN_MPEG に渡された 4 つの int 型引数 +(argv[2]argv[5]) によって表現されます。 +

+ +

+動画データを読み込む際は、これをそのまま eb_set_binary_mpeg() +に渡せば良いのですが、ファイル名を通常の文字列で得たい場合は、この関数を +用います。 +たとえば、個々の動画に一意の ID のようなものを振りたい場合は、ファイル +名を ID として使うと良いかも知れません。 +なお、この関数で変換して得られるファイル名にはパスが含まれていません。 +

+ +

+フック関数の引数 argv + 2 をこの関数への引数 argv +として渡すと、composed_file_name が指す先の領域に、文字列形式 +に変換されたファイル名が格納されます。 +ファイル名は最長で EB_MAX_DIRECTORY_NAME_LENGTH (= 8) バイト +になります。 +この長さには終端のナル文字の分を含んでいませんので、格納領域にはもう +1 バイト余裕が要ります。 +

+ +

+なお、格納されたファイル名は、実際に存在するファイル名とは若干異なって +いる可能性があります。 +たとえば、英字の大文字と小文字、接尾子の有無などの違いがこれに当たります。 +この関数は、あくまで文字列に機械的に変換するだけなので、ファイルが実在 +するかどうかのチェックはしません。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +

+ + +

EB_Error_Code eb_compose_movie_path_name (EB_Book *book, const unsigned int *argv, char *composed_path_name)

+ +

+関数 eb_compose_movie_path_name() は、動画データのファイル名 +を通常の文字列に変換します。 +働きは、前述の関数 eb_compose_movie_file_name() に良く +似ていますが、eb_compose_movie_path_name() が返すファイル名 +は、絶対パスの形式になっている点が異なります。 +

+ +

+また、eb_compose_movie_path_name() では、ファイル名が実在 +するかどうかのチェックを行うという点も、大きな違いです。 +ファイル名を文字列に変換した上で、英字の大文字と小文字の違いや接尾子の +有無は、実在のファイルに合わせて調整したものを返します。 +したがって、パスを除いた部分で比較しても、 +eb_compose_movie_file_name() が返すファイル名とは必ずしも +一致しません。 +

+ +

+引数 book は、動画ファイルを収録している副本を選択して +おかなければなりません。 +副本を選択していなければ、EB_ERR_NO_CUR_SUB を返します。 +

+ +

+引数 argv の意味は、eb_compose_movie_file_name() +と同じです。 +

+ +

+ファイル名の変換が成功すると、関数は composed_path_name が +指す先の領域に、文字列形式に変換された動画ファイル名を格納し、 +EB_SUCCESS を返します。 +ファイル名は最長で EB_MAX_PATH_LENGTH バイトになります。 +この長さには終端のナル文字の分を含んでいませんので、格納領域にはもう +1 バイト余裕が要ります。 +

+ +

+ファイル名が実在しないと、EB_ERR_BAD_FILE_NAME を返します。 +

+ + +

EB_Error_Code eb_decompose_movie_file_name (unsigned int *argv, const char *composed_file_name)

+ +

+関数 eb_compose_movie_file_name() は、 +eb_compose_movie_file_name() とちょうど逆の働きをします。 +つまり、通常の文字列に変換された動画データのファイル名 +composed_file_name を、4 つの int 型引数 argv に +戻します。 +したがって、argv の指す領域は、少なくとも int 型の値を 4 つ +格納できる大きさが必要です。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +

+ + +

appendix データ

+ +

+appendix (付録) とは CD-ROM 書籍の補助データの +ことです。 +appendix は CD-ROM 書籍の出版社から提供されているものではなく、 +EB ライブラリに固有のものです。 +ebappendix コマンドを用いて生成します +(詳しくは ebappendix コマンドのマニュアル +の「appendix (付録) とは」を参照のこと)。 +

+ +

+appendix は以下のデータを CD-ROM 書籍に対して提供します。 +

+ +
    +
  • 本文の区切りコード +
  • 外字の代替文字列 +
+ +

+appendix のレイアウトは CD-ROM 書籍のものとよく似ています。 +トップディレクトリには catalog もしくは +catalogs ファイルが存在し、各副本のデータは対応する +サブディレクトリに配置されています。 +

+ +

+アプリケーションは appendix に対応し、本文の区切りコードの情報を使える +ようにすることをお薦めします。 +外字の代替文字列については、外字のフォントをそのまま表示できるので +あれば、対応する必要性はかなり乏しいですが、本文の区切りコードは、 +扱えないと正しく本文を表示できない書籍に対応できません +(区切りコードについては、「区切りコードの問題」 を参照のこと)。 +

+ + + +

EB_Appendix オブジェクト

+ +

+CD-ROM 書籍本体を扱うには EB_Book オブジェクトを +用いましたが、appendix を扱うには EB_Appendix オブジェクト +を使います。 +EB_Appendix オブジェクトを操作するための関数は、 +EB_Book のものとは異なりますが、操作手順はよく似ています。 +

+ +

+EB_Appendix オブジェクトは、個々の appendix に対して 1 個 +ずつ作る必要があります。 +

+ +
+
+EB_Appendix app;
+
+
+ +

+もちろん、オブジェクトの領域は、malloc() で確保しても +構いません。 +

+ +
+
+EB_Appendix *app_pointer;
+
+app_pointer = (EB_Appendix *) malloc(sizeof(EB_Appendix));
+
+
+ +

+オブジェクトは、使う前に必ず eb_initialize_appendix() +という関数で中身を初期化しなくてはなりません。 +EB_Book オブジェクトでも eb_initialize_book() +で初期化する必要がありましたが、それと同じです。 +

+ +
+
+eb_initialize_appendix(&app);
+eb_initialize_appendix(app_pointer);
+
+
+ +

+続いて、オブジェクトを appendix の実体に結び付けるために、 +eb_bind_appendix() を呼び出します。 +これは、EB_Book オブジェクトの eb_bind() に +相当します。 +

+ +
+
+EB_Appendix          appendix
+オブジェクト            ┌────────────┐
+┌───┐             │            │
+│   ┝━━━━━━━━━━━━━┥ /mnt/dict  │
+└───┘ eb_bind     │            │
+      _appendix() └────────────┘
+
+
+ +

+実際のプログラムでは、次のようにします。 +

+ +
+
+if (eb_bind_appendix(&app, "/mnt/dict") != EB_SUCCESS) {
+    printf("eb_bind_appendix() failed\n");
+    return;
+}
+
+
+ +

+eb_bind_appendix() に渡す appendix のパス +(この例では /mnt/dict) は appendix のトップディレクトリ、 +つまり catalog または catalogs ファイルのある +ディレクトリを指定します。 +パスには、遠隔アクセス識別子 (例: ebnet://localhost/dict.app) +を指定することも可能です。 +

+ +

+EB_Appendix オブジェクトを使い終わったら、 +eb_finalize_appendix() を呼んで後始末をします。 +オブジェクトは appendix との結び付きを解かれた状態に戻り、 +内部で割り当てられたメモリは解放され、開いていたファイルもすべて +閉じられます。 +

+ +
+
+eb_finalize_appendix(&app);
+eb_finalize_appendix(app_pointer);
+
+
+ +

+オブジェクトの領域を malloc() で確保した場合は、 +eb_finalize_appendix() を呼んだ後ならば、オブジェクトの +領域を安全に解放することができます。 +

+ +
+
+free(app_pointer);
+
+
+ + +

副本

+ +

+CD-ROM と同様に、appendix にも副本が存在します。 +appendix の副本も、副本コードを使って識別します。 +個々の副本コードは、appendix 内で同じものがないようになっています。 +

+ +

+CD-ROM 書籍内のすべての副本の副本コードを取得する関数として +eb_subbook_list() がありましたが、appendix にも +eb_appendix_subbook_list() という同様の関数があります。 +

+ +
+
+/* appEB_Appendix のオブジェクトで、
+ * すでに書籍に結び付けられていると仮定しています。*/
+EB_Subbook_Code sub_codes[EB_MAX_SUBBOOKS];
+int sub_count;
+
+if (eb_appendix_subbook_list(&app, sub_codes, &sub_count)
+    != EB_SUCCESS) {
+    printf("eb_appendix_subbook_list() failed\n");
+    return;
+}
+
+
+ +

+eb_appendix_subbook_list() が成功すると、書籍内のすべての +副本コードが 配列 sub_codes[] に格納されます。 +配列の先頭の副本コードは sub_codes[0] と表され、次の +コードは sub_codes[1]、という具合になります。 +副本の個数は、sub_count に格納されます。 +

+ +

+EB_Book と同様に EB_Appendix オブジェクト +でも、結びつけられた CD-ROM 書籍の中の任意の副本から一つ選んで、 +選択中の副本 (current subbook) として指定することができます。 +複数の副本を、同時に選択することはできません。 +区切りコードや外字の代替文字列といった appendix 内のデータへのアクセス +は、選択中の副本に対してだけ行えます。 +

+ +

+以下は、先頭の副本 (sub_codes[0]) を選択する場合の例です。 +

+ +
+
+/* appEB_Appendix のオブジェクトで、
+ * すでに書籍に結び付けられていると仮定しています。*/
+if (eb_set_appendix_subbook(&app, sub_codes[0]) != EB_SUCCESS) {
+    printf("eb_subbook_list() failed\n");
+    return;
+}
+
+
+ +

+eb_bind_appendix()EB_Appendix オブジェクト +を appendix に結び付けた直後は、いずれの副本も選択されていない状態に +なっています。 +

+ + +

本文の区切りコード

+ +

+CD-ROM 書籍によっては、EB ライブラリが本文の表示を正しい位置で +止められないことがあります +(詳しくは、「区切りコードの問題」 を参照のこと)。 +これは、本文の区切りコードの推測を EB ライブラリが誤ったために起こる +のですが、appendix データを使うことで、正しい区切りコードを EB ライブラリ +に教えてやることができます。 +

+ +

+CD-ROM 書籍の本文を取得する関数 eb_read_text() は +第 2 引数に EB_Appendix * をとるのですが、ここに appendix +オブジェクトを渡してやるようにします。 +

+ +
+
+/* book, app は、それぞれ EB_Book
+ * および EB_Appendix のオブジェクトで、どちらもすでに
+ * 副本を選択中と仮定しています。*/
+#define MAX_LENGTH 1000
+char buffer[MAX_LENGTH + 1];
+ssize_t text_length;
+
+if (eb_read_text(&book, &app, NULL, NULL, MAX_LENGTH,
+    text, &text_length) != EB_SUCCESS) {
+    fprintf(stderr, "an error occurs.\n");
+    return;
+}
+
+
+ +

+eb_read_text() は、渡された appendix オブジェクトが副本を +選択済みで、かつ区切りコードの情報を持っていれば、その区切りコードを +使用します。 +

+ + +

外字の代替文字列

+ +

+CD-ROM 書籍は、定義している外字の情報としてフォントのデータしか用意して +いません。 +つまり、その外字がどのような文字なのかをユーザに分かるようにするには、 +アプリケーションがフォントを表示するしかありません。 +しかしこれでは、テキストインターフェースを用いたアプリケーションでは、 +本文中の外字の部分がまったく分かりません。 +外字を多用している書籍では、本文が解読不能に近い状態になるかも知れません。 +

+ +

+そこで EB ライブラリでは、外字の代替となる文字列を appendix 内で定義 +できるようにしています。 +appendix が用意されている場合に限り、アプリケーションは外字のフォント +を描画する代わりにその代替文字列を出力することにすれば、 +テキストインターフェースを用いたアプリケーションでも書籍が読み易く +なります。 +

+ +

+appendix に定義されている代替文字列を取り出す関数は、2 つあります。 +半角外字用の eb_narrow_alt_character_text() と全角外字用の +eb_wide_alt_character_text() です。 +どちらも、使い方は変わりません。 +

+ +

+以下の例では、半角外字の文字番号 0xa121 に対する代替文字列を +buffer に格納しています。 +

+ +
+
+/* appEB_Appendix のオブジェクトで、
+ * すでに副本を選択中であると仮定しています。*/
+char buffer[EB_MAX_ALTERNATION_TEXT_LENGTH + 1];
+
+if (eb_narrow_alt_character_text(&app, buffer, 0xa121)
+    != EB_SUCCESS) {
+    printf("eb_narrow_alt_character_text() failed\n");
+    return;
+}
+
+
+ +

+外字は個々の副本に対して定義されているので、代替文字列を取り出すには、 +あらかじめ副本を選択しておく必要があります。 +外字のフォントを取り出す際は、これに加えて外字の「高さ」も選択しておく +必要がありましたが、代替文字列には高さの概念がないので必要ありません。 +

+ +

+代替文字列は最長で EB_MAX_ALTERNATION_TEXT_LENGTH バイト +(= 31 バイト) です。 +ただし、この長さにはナル文字の分は含んでいないので、buffer +はもう 1 バイト分余裕を持たせています。 +

+ + +

データ型の詳細

+ +

+この節で説明しているデータ型を使うには、次のようにヘッダファイルを +読み込んで下さい。 +

+ +
+
+#include <eb/appendix.h>
+
+
+ + +

EB_Appendix

+ +

+EB_Appendix 型は、一冊の CD-ROM 書籍を表します。 +CD-ROM 書籍へのアクセスは、すべてこの型のオブジェクトを介して行います。 +同時に複数の CD-ROM 書籍にアクセスする際は、書籍一冊毎にオブジェクトを +作る必要があります。 +

+ +

+EB_Appendix オブジェクトの操作は、すべて EB ライブラリが +用意している関数で行います。 +アプリケーションプログラムは、直接 EB_Appendix オブジェクト +のメンバを参照したり、セットしたりすべきではありません。 +

+ +

+EB_Appendix オブジェクトを使用する際は、まずそのオブジェクト +に対して eb_initialize_book() を呼んで初期化しなくては +なりません。 +

+ + +

関数の詳細

+ +

+この節で説明している関数を使うには、次のようにヘッダファイルを読み込んで +下さい。 +

+ +
+
+#include <eb/appendix.h>
+
+
+ + +

void eb_initialize_appendix (EB_Appendix *app)

+ +

+関数 eb_initialize_appendix() は、app の指す +EB_Appendix オブジェクトを初期化します。 +EB_Appendix オブジェクトに対して EB ライブラリの他の関数を +呼ぶ前に、必ずそのオブジェクトを初期化しなくてはなりません。 +初期化していないオブジェクトに対して、EB ライブラリの他の関数を呼んだ +場合の動作は未定義です。 +また、すでに初期化したオブジェクトに対して、 +再度 eb_initialize_appendix() を呼んではいけません。 +呼んだ場合の動作は未定義です。 +

+ + +

void eb_finalize_appendix (EB_Appendix *app)

+ +

+関数 eb_finalize_appendix() は、app が指す +EB_Appendix オブジェクトの後始末を行います。 +

+ +

+オブジェクトが割り当てて管理していたメモリはすべて解放され、 +ファイルディスクリプタもすべて閉じられます。 +オブジェクトが appendix と結び付いていた場合は、結び付きが解かれます。 +

+ +

+後始末をしたオブジェクトに対して eb_bind_appendix() を呼ぶことで、 +オブジェクトを再利用することができます。 +

+ + +

EB_Error_Code eb_bind_appendix (EB_Appendix *app, const char *path)

+ +

+関数 eb_bind_appendix() は、app の指す +EB_Appendix オブジェクトを、パス path にある +appendix に結び付けます。 +パスには、appendix のトップディレクトリか遠隔アクセス識別子を指定します。 +appendix のトップディレクトリとは、catalog あるいは +catalogs ファイルの存在するディレクトリを指します。 +

+ +

+オブジェクトがすでにappendix に結び付いていた場合、その appendix との +結び付きを解いてから、path にある appendix に結び付けます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +このとき、副本は未選択の状態になります。 +失敗すると、オブジェクトを appendix との結び付きを解かれた状態にして、 +原因を示すエラーコードを返します。 +

+ +

+path は、EB_MAX_PATH_LENGTH バイトに収まて +いなくてはなりません。 +さらに、path が相対パスのときは、絶対パスに変換した結果が +この長さに収まっていなくてはなりません。 +これを超えると、EB_ERR_TOO_LONG_FILE_NAME を返します。 +

+ + +

int eb_is_appendix_bound (EB_Appendix *app)

+ +

+関数 eb_is_appendix_bound() は、app が appendix に +結び付いているかどうかを調べます。 +結び付いていれば 1 を返し、そうでなければ 0 を返します。 +

+ + +

EB_Error_Code eb_appendix_path (EB_Appendix *app, char *path)

+ +

+関数 eb_appendix_path() は、app に結び付いている +appendix のパスもしくは遠隔アクセス識別子を、path の指す領域 +に書き込みます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、path の指す領域に空文字列を書き込み、原因を示す +エラーコードを返します。 +

+ +

+app は、あらかじめ書籍に結び付いている必要があります。 +結びついていない場合は、EB_ERR_UNBOUND_BOOK を返します。 +

+ +

+path に書き込むパス名のバイト数は、最長で +EB_MAX_PATH_LENGTH になります。 +この長さは、末尾のナル文字を含みません。 +関数が返すパスは正規化された形になっているので、 +eb_bind_appendix() に渡したときのものと同じとは限りません。 +たとえば、相対パスだった場合は、絶対パスに変換されます。 +

+ + +

EB_Error_Code eb_load_all_appendix_subbooks (EB_Appendix *app)

+ +

+関数 eb_load_all_appendix_subbooks() は、app 内 +のすべての副本を初期化します。 +通常、副本の初期化は、その副本が初めて選択されたときに自動的に +行われますが、この関数は初期化を前倒しで行います。 +初期化の対象となるのは、この関数を呼び出した時点でまだ初期化していない +すべての副本です。 +この関数は、スタンドアロンで動作するサーバアプリケーションなどで有効です。 +クライアントからの接続を受ける前にこの関数を呼ぶことで、副本の初期化の +ためにクライアントを待たせなくて済みます。 +

+ +

+初期化の対象となったすべての副本の初期化に成功すれば、関数は +EB_SUCCESS を返します。 +一冊でも初期化に失敗した場合は、残りの副本の初期化を諦め、原因を示す +エラーコードを返します。 +

+ +

+app は、あらかじめ appendix に結び付けられていなくては +なりません。 +結びついていない場合は、EB_ERR_UNBOUND_APP を返します。 +

+ +

+この関数を呼び出すと、app は、副本を選択していない状態に +なります。 +

+ + +

EB_Error_Code eb_appendix_subbook_list (EB_Book *app, EB_Subbook_Code *subbook_list, int *subbook_count)

+ +

+関数 eb_appendix_subbook_list() は、app 内の +すべて副本の副本コードを EB_Subbook_Code 型の配列にして、 +subbook_list の指す領域に書き込みます。 +配列は、最大で EB_MAX_SUBBOOKS 個の要素を持ちます。 +加えて、appendix が収録している副本の個数を subbook_count の +指す領域に書き込みます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、subbook_count の指す領域に 0 を書き込み、原因を +示すエラーコードを返します。 +

+ +

+app は、あらかじめ appendix に結び付けられていなくては +なりません。 +結びついていない場合は、EB_ERR_UNBOUND_APP を返します。 +

+ + +

EB_Error_Code eb_appendix_subbook (EB_Book *app, EB_Subbook_Code *subbook_code)

+ +

+関数 eb_appendix_subbook() は、app が選択中の +副本の副本コードを subbook_code の指す領域に書き込みます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、subbook_code の指す領域に +EB_SUBBOOK_INVALID を書き込み、原因を示すエラーコードを +返します。 +

+ +

+あらかじめ、app はいずれかの副本を選択していなくては +なりません。 +選択していない場合は、EB_ERR_NO_CUR_APPSUB を返します。 +

+ + +

EB_Error_Code eb_appendix_subbook_directory (EB_Book *app, char *directory)

+ +

+関数 eb_appendix_subbook_directory() は、app 内 +で現在選択中の副本のデータファイルを収めたディレクトリ名を、 +directory の指す領域に書き込みます。 +

+ +

+ディレクトリ名の文字列の長さは、最長で +EB_MAX_DIRECTORY_NAME_LENGTH バイトです。 +この長さに、末尾のナル文字は含みません。 +ディレクトリ名は ASCII の数字、英小文字、アンダースコアで構成されます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、directory の指す領域に空文字列を書き込み、原因に +を示すエラーコードを返します。 +

+ +

+あらかじめ、app 内のいずれかの副本が選択されていなくては +なりません。 +選択していない場合は、EB_ERR_NO_CUR_APPSUB を返します。 +

+ + +

EB_Error_Code eb_appendix_subbook_directory2 (EB_Book *app, EB_Subbook_Code subbook_code, char *directory)

+ +

+eb_appendix_subbook_directory() と似ていますが、選択中の +副本ではなく、引数 subbook_code で指定された副本の +ディレクトリ名を書き込む点が異なります。 +

+ +

+app は副本を選択していなくても構いませんが、あらかじめ +appendix に結び付けられていなければなりません。 +結びついていない場合は、EB_ERR_UNBOUND_APP を返します。 +

+ + +

EB_Error_Code eb_set_appendix_subbook (EB_Book *app, EB_Subbook_Code code)

+ +

+関数 eb_set_appendix_subbook() は、app の副本 +code を選択します。 +すでに副本を選択していた場合は、いったん未選択の状態にしてから副本 +subbook_code を選択します。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +このとき、外字は未選択の状態となり、検索、テキストデータの読み込み、 +バイナリデータの読み込みについての状態記録は、すべてリセットされます。 +失敗すると、副本を未選択の状態にして、原因を示すエラーコードを返します。 +

+ +

+あらかじめ、app は appendix に結び付けられていなければ +なりません。 +結びついていない場合は、EB_ERR_UNBOUND_APP を返します。 +

+ + +

void eb_unset_appendix_subbook (EB_Book *app)

+ +

+関数 eb_unset_appendix_subbook() は、app が選択 +している副本を未選択の状態にします。 +app が appendix に結び付いていないか、副本が選択されていない +場合は、何もしません。 +

+ + +

int eb_have_stop_code (EB_Book *app)

+ +

+関数 eb_have_stop_code() は、app が選択中の副本で +区切りコードが定義されているかどうかを調べます。 +

+ +

+定義していれば 1 を返します。 +定義していないか、そもそも副本が選択されていない場合は 0 を返します。 +

+ + +

EB_Error_Code eb_stop_code (EB_Book *app, int *stop_code)

+ +

+関数 eb_stop_code() は、app が選択中の副本で定義 +している区切りコードを stop_code の指す領域に書き込みます。 +stop_code[0], stop_code[1] に、区切りコードの値 +としてそれぞれ 0x00000xffff が書き込まれます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、関数は stop_code[0]stop_code[1] +に -1 を書き込み、原因を示すエラーコードを返します。 +

+ +

+あらかじめ、app は副本を選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_APPSUB を返します。 +副本が区切りコードを定義していない場合は、EB_ERR_NO_STOPCODE +を返します。 +

+ + +

int eb_have_narrow_alt (EB_Book *app)

+ +

int eb_have_wide_alt (EB_Book *app)

+ +

+関数 eb_have_narrow_alt() は、選択中の副本が半角外字に対する +代替文字列を定義しているかどうかを調べます。 +同様に、関数 eb_have_wide_alt() は、全角外字に対する +代替文字列を定義しているかどうかを調べます。 +

+ +

+定義していれば 1 を、定義していなければ 0 を返します。 +app が副本を選択していない場合も 0 を返します。 +

+ + +

EB_Error_Code eb_narrow_alt_start (EB_Book *app, int *start)

+ +

EB_Error_Code eb_wide_alt_start (EB_Book *app, int *start)

+ +

+関数 eb_narrow_alt_start() は、app が選択中の副本 +における半角外字に対する代替文字列の定義範囲を調べ、先頭の文字番号 +(半角外字の文字番号の中で最小のもの) を start の指す領域に +書き込みます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、原因を示すエラーコードを返します。 +

+ +

+あらかじめ、app は副本を選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_APPSUB を返します。 +副本が半角外字に対する代替文字列を定義していない場合は、 +EB_ERR_NO_ALT を返します。 +

+ +

+関数 eb_wide_font_start() は、半角外字ではなく全角外字に +ついて調べるという点を除いて、eb_narrow_font_start() と同じ +です。 +

+ + +

EB_Error_Code eb_narrow_alt_end (EB_Book *app, int *end)

+ +

EB_Error_Code eb_wide_alt_end (EB_Book *app, int *end)

+ +

+関数 eb_narrow_alt_end() は、app が選択中の副本 +における半角外字に対する代替文字列の定義範囲を調べ、最後の文字番号 +(半角外字の文字番号の中で最大のもの) を start の指す領域に +書き込みます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、原因を示すエラーコードを返します。 +

+ +

+あらかじめ、app は副本を選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_APPSUB を返します。 +副本が半角外字に対する代替文字列を定義していない場合は、 +EB_ERR_NO_ALT を返します。 +

+ +

+関数 eb_wide_font_start() は、半角外字ではなく全角外字に +ついて調べるという点を除いて、eb_narrow_font_start() と同じ +です。 +

+ + +

EB_Error_Code eb_narrow_alt_character_text (EB_Book *app, int character_number, char *text)

+ +

EB_Error_Code eb_wide_alt_character_text (EB_Book *app, int character_number, char *text)

+ +

+関数 eb_narrow_alt_character_text() は、book が +選択中の副本で定義している、半角外字の代替文字列を取り出します。 +外字の文字番号を、character_number で指定します。 +

+ +

+成功すると、関数は代替文字列を text の指す領域に書き込み、 +EB_SUCCESS を返します。 +失敗すると、text の指す領域に空文字列を書き込み、原因を示す +エラーコードを返します。 +

+ +

+代替文字列は最長で EB_MAX_ALTERNATION_TEXT_LENGTH バイト +(= 31 バイト) です。 +ただし、この長さにはナル文字の分は含んでいないので、text の +領域にはもう 1 バイト分必要です。 +

+ +

+代替文字列がどの文字コードで書かれているかは、appendix の中には +記録されていません。 +しかし、appendix は必ず特定の書籍に対応して作成されるものなので、書籍の +文字コードから次のように判断すれば、問題ないでしょう。 +

+ +
    +
  • 書籍が ISO 8859-1 で書かれている場合は、代替文字列も ISO 8859-1 +
  • それ以外の場合、代替文字列は日本語 EUC +
+ +

+あらかじめ、app は副本を選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_APPSUB を返します。 +文字番号 character_number が外字の定義範囲外にある場合は、 +EB_ERR_NO_SUCH_CHAR_TEXT を返します。 +

+ +

+副本が半角外字に対する代替文字列を (character_number に限らず +まったく) 定義していない場合は、EB_ERR_NO_ALT を返します。 +そうではなく、一部の文字番号については半角外字に対する代替文字列を +定義しているものの、character_number に対する代替文字列は +存在しない場合、関数は EB_SUCCESS を返し、text +の指す領域には空文字列が書き込まれます。 +

+ +

+関数 eb_wide_alt_character_text() は、半角外字ではなく +全角外字に対する代替文字列を取り出すという点を除いて、 +eb_narrow_alt_character_text() と同じです。 +

+ + +

EB_Error_Code eb_backward_narrow_alt_character (EB_Book *book, int n, int *character_number)

+ +

EB_Error_Code eb_backward_wide_alt_character (EB_Book *book, int n, int *character_number)

+ +

+関数 eb_forward_narrow_alt_character() は、app +が選択中の副本において定義されている、半角外字に対する代替文字列の +文字番号 character_numbern 個後ろに位置する +文字の文字番号を取得します。 +

+ +

+まず、関数を呼び出す際に、character_number の指す領域に +文字番号を書き込んでおきます。 +関数の処理が成功すると、戻ったときに n 個分だけ後方の文字番号 +に書き換わっています。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、原因を示すエラーコードを返します。 +

+ +

+あらかじめ、app は副本を選択していなくてはなりません。 +選択していない場合は、EB_ERR_NO_CUR_APPSUB を返します。 +副本が半角外字に対する代替文字列を定義していない場合は、 +EB_ERR_NO_ALT を返します。 +

+ +

+n 個後ろにもう外字がない場合や、呼び出した際に +character_number の指す領域に書き込んであった文字番号が外字の +定義範囲外にある場合は EB_ERR_NO_SUCH_CHAR_TEXT を返します。 +

+ +

+n には負の数を指定することもできます。 +この場合、次の呼び出しと等価になります。 +

+ +
+
+/* n < 0 とする */
+eb_backward_narrow_font_character (book, -n, character_number);
+
+
+ +

+関数 eb_forward_wide_alt_character() は、半角外字ではなく +全角外字について操作するという点を除いて、 +eb_forward_narrow_alt_character() と同じです。 +

+ + +

サンプルプログラム

+ + + + +

サーバ上の書籍一覧

+ +

+EBNET サーバから遠隔アクセスを行う際、サーバがそのクライアントに対して +アクセスを許可している書籍や appendix データの一覧を取得することが +できます。 +

+ +

+このとき、EBNET サーバを指定する遠隔アクセス記述子には、特定の書籍や +appendix データに対するアクセスとは異なり、書籍名は指定しません。 +すなわち、一般形は次のようになります。 +

+ +
+
+ebnet://ホスト:ポート/
+
+
+ +

+末尾の `/' はなくても構いません。 +: とそれに続くポート番号は省略可能で、その場合は +22010 番ポートを利用することを意味します。 +

+ +

+ebinfo コマンドの --book-list オプション指定時の挙動は、EB ライブラリ +のこの機能によって実装されています。 +(ebinfo についての詳細は、 +@pxref{Book list on EBNET server, , EBNET サーバの書籍一覧, ebinfo-ja, ebinfo-ja}。) +

+ +
+
+% ebinfo --book-list ebnet://localhost
+名前             題名
+encycl           ブラウンコンサイス百科事典
+encycl.app       ブラウンコンサイス百科事典 (appendix)
+crossword        クロスワードパズル辞典
+travel           ワールドトラベルガイド
+
+
+ +

+名前の末尾が .app になっているものは appendix データで、 +その他は書籍本体です。 +この例の書籍 encycl に対してアクセスするなら、 +遠隔アクセス識別子は ebnet://localhost/encycl になります。 +

+ +

+なお、クライアントに対してアクセスを許可していない書籍や appendix データ +は、サーが側で一覧から除外されます。 +

+ + + +

EB_BookList オブジェクト

+ +

+EBNET サーバの提供する書籍および appendix データの一覧を取得するには、 +まず EB_BookList 型のオブジェクトを用意する必要があります。 +

+ +
+
+EB_BookList bl;
+
+
+ +

+オブジェクトの領域は、malloc() で確保しても構いません。 +

+ +
+
+EB_BookList *bl_pointer;
+
+bl_pointer = (EB_BookList *) malloc(sizeof(EB_BookList));
+
+
+ +

+EB_Book オブジェクトと同様に、EB_BookList +オブジェクトも使う前に中身を初期化する必要があります。 +これは、eb_initialize_booklist() という関数で行います。 +

+ +
+
+eb_initialize_booklist(&bl);
+eb_initialize_booklist(bl_pointer);
+
+
+ +

+初期化が完了したら、特定のサーバとオブジェクトを結びつけます。 +たとえば、ebnet://localhost で表されるサーバに対して、 +オブジェクトを結びつけるには次のようにします。 +

+ +
+
+if (eb_bind_booklist(&bl, "ebnet://localhost") != EB_SUCCESS) {
+    printf("eb_bind_booklist() failed\n");
+    return;
+}
+
+
+ +

+これはちょうど、EB_Book オブジェクトに対して +eb_bind() を呼ぶのと同じです。 +

+ +

+こうして、ようやく書籍一覧の情報を取り出すことができます。 +これには eb_booklist_book_count(), +eb_booklist_book_name(), eb_booklist_book_title() +という 3 つの関数を使用します。 +これらの関数はそれぞれ、クライアントがアクセス可能な書籍の数、各書籍 +および appendix データの名称 (アクセス識別子として指定する名前)、各書籍 +と appendix データの題名を得ることができます。 +

+ +
+
+char *name, *title;
+int count, i;
+
+count = eb_booklist_book_count(&bl);
+for (i = 0; i < count; i++) {
+    if (eb_booklist_book_name(&bl, i, &name) != EB_SUCCESS) {
+        printf("eb_booklist_book_name(%d) failed\n", i);
+        return;
+    }
+    if (eb_booklist_book_title(&bl, i, &title) != EB_SUCCESS) {
+        printf("eb_booklist_book_title(%d) failed\n", i);
+        return;
+    }
+    printf("name = %s, title = %s\n", name, title);
+}
+
+
+ +

+EB_BookList オブジェクトを使い終わったら、必ず後始末を +行います。 +

+ +
+
+eb_finalize_booklist(&bl);
+eb_finalize_booklist(bl_pointer);
+
+
+ +

+オブジェクトの領域を malloc() で確保した場合は、 +eb_finalize_booklist() を呼んだ後ならば、オブジェクトの領域 +を安全に解放することができます。 +

+ +
+
+free(bl_pointer);
+
+
+ + +

データ型の詳細

+ +

+この節で説明しているデータ型を使うには、次のようにヘッダファイルを +読み込んで下さい。 +

+ +
+
+#include <eb/booklist.h>
+
+
+ + +

EB_BookList

+ +

+EB_BookList 型は、EBNET サーバ上が使っている書籍および +appendix の一覧を取得する際に用いるオクジェクトの型です。 +

+ +

+EB_BookList オブジェクトを使用する際は、まずそのオブジェクト +に対して eb_initialize_booklist() を呼んで初期化する必要が +あります。 +

+ + +

関数の詳細

+ +

+この節で説明している関数を使うには、次のようにヘッダファイルを読み込んで +下さい。 +

+ +
+
+#include <eb/booklist.h>
+
+
+ + +

void eb_initialize_booklist (EB_BookList *bl)

+ +

+関数 eb_initialize_booklist() は、bl の指す +EB_BookList オブジェクトを初期化します。 +EB_BookList オブジェクトに対して EB ライブラリの他の関数を +呼ぶ前に、必ずそのオブジェクトを初期化しなくてはなりません。 +初期化していないオブジェクトに対して、EB ライブラリの他の関数を呼んだ +場合の動作は未定義です。 +また、すでに初期化したオブジェクトに対して、 +再度 eb_initialize_booklist() を呼んではいけません。 +呼んだ場合の動作は未定義です。 +

+ + +

EB_Error_Code eb_bind_booklist (EB_BookList *bl, const char *path)

+ +

+関数 eb_bind_booklist() は、app の指す +EB_BookList オブジェクトを、遠隔アクセス記述子 path +で指定された EBNET サーバに結び付けます。 +

+ +

+オブジェクトがすでにサーバに結び付いていた場合、そのサーバとの結び付き +を解いてから、path にあるサーバに結び付けます。 +

+ +

+成功すると、関数は EB_SUCCESS を返します。 +失敗すると、オブジェクトをサーバとの結び付きを解かれた状態にして、原因 +を示すエラーコードを返します。 +

+ +

+path は、EB_MAX_PATH_LENGTH バイトに収まて +いなくてはなりません。 +これを超えると、EB_ERR_TOO_LONG_FILE_NAME を返します。 +また、書籍名を指定していない遠隔アクセス記述子でなければなりません。 +それ以外の形式だと、EB_ERR_BAD_FILE_NAME を返します。 +

+ +

+使用している EB ライブラリのバイナリが、遠隔アクセスに非対応のもので +ある場合、EB_ERR_EBNET_UNSUPPORTED が返ります。 +

+ + +

void eb_finalize_booklist (EB_BookList *bl)

+ +

+関数 eb_finalize_booklist() は、bl が指す +EB_BookList オブジェクトの後始末を行います。 +

+ +

+オブジェクトが割り当てて管理していたメモリはすべて解放され、 +ファイルディスクリプタもすべて閉じられます。 +オブジェクトが EBNET サーバと結び付いていた場合は、結び付きが解かれます。 +

+ +

+後始末をしたオブジェクトに対して eb_bind_booklist() を呼ぶ +ことで、オブジェクトを再利用することができます。 +

+ + +

int eb_booklist_book_count (EB_BookList *bl)

+ +

+関数 eb_booklist_book_count() は、EBNET サーバがこの +クライアントに対してアクセスを許可している書籍および appendix データの数 +を取得します。 +

+ +

+オブジェクト bl の指す EB_BookList オブジェクトは、 +あらかじめ EBNET サーバに結びついている必要があります。 +結びついていない場合は、EB_ERR_UNBOUND_BOOKLIST を返します。 +

+ + +

EB_Error_Code eb_booklist_book_name (EB_BookList *bl, int i, char **name)

+ +

EB_Error_Code eb_booklist_book_title (EB_BookList *bl, int i, char **title)

+ +

+関数 eb_booklist_book_name() は、EBNET サーバの書籍や +appendix データの名称を取得します。 +ここで言う「名称」とは、遠隔アクセス識別子で指定する書籍名のことです。 +つまり、ebnet://localhost/dictdict の部分 +を指します。 +同様に、関数 eb_booklist_book_title() は、書籍や appendix +の題名を取得します。 +

+ +

+いずれの関数も、EBNET サーバ上の何番目の書籍もしくは appendix の情報を +取得するのかを、引数 i で指定します。 +先頭は 1 番目ではなく 0 番目になります。 +

+ +

+成功すると、関数は書籍の名称、題名へのポインタを *name, +*title に書き込み、EB_SUCCESS を返します。 +なお、このポインタ値は オブジェクト bl が保持している +文字列を指すようになっています。 +bl に対して eb_finalize_booklist() を呼んで +しまうと、この文字列も参照不可能になってしまいますので、注意して下さい。 +

+ +

+オブジェクト bl の指す EB_BookList オブジェクト +は、あらかじめ EBNET サーバに結びついている必要があります。 +結びついていない場合は、EB_ERR_UNBOUND_BOOKLIST を返します。 +また、i は 0 以上かつサーバが提供している書籍および appendix +の総数未満でなければなりません。 +これ以外の値のときは、EB_ERR_NO_SUCH_BOOK が返ります。 +

+ + +

サンプルプログラム

+ + + + +

索引

+ + +

データ型の索引

+ +

+型名の先頭の EB_ は省略しています。 +

+ + + + +

関数の索引

+ +

+関数名の先頭の eb_ は省略しています。 +

+ + + + +

定数の索引

+ +

+定数名の先頭の EB_ は省略しています。 +

+ + + + + diff --git a/doc/ebappendix.html.in b/doc/ebappendix.html.in new file mode 100644 index 0000000..5e680c4 --- /dev/null +++ b/doc/ebappendix.html.in @@ -0,0 +1,729 @@ + + + + + + +ebappendix コマンド + + + +

ebappendix コマンド

+

+この文書は EB ライブラリバージョン + +に対応しています。 +

+ +

+目次: +

+ + + +

+Copyright (c) 2003-2006 Motoyuki Kasahara +

+ + +

appendix (付録) とは

+ +

+appendix (付録) とは CD-ROM 書籍の補助データのことです。 +appendix は CD-ROM 書籍の出版社から提供されているものではなく、 +EB ライブラリに固有のものです。 +

+ +

+appendix は以下のデータを CD-ROM 書籍に対して提供します。 +

+ +
+
本文の区切りコード
+
+あなたが EB ライブラリを使って CD-ROM 辞書の中のある単語を引く際、その +単語の説明が終了する箇所で、EB ライブラリが本文の出力を止めることを +あなたは期待するのではないでしょうか。 +しかし、EB ライブラリはそのような動作を保証することができません。 +なぜなら、CD-ROM 書籍の本文には、項目の終わりを示す印が存在しないから +です。 + +幸いにも、多くの CD-ROM 書籍には、項目の終わりを示す印の代替として +使える、区切りコード (stop code) というものを持って +います。 +通常、EB ライブラリはこの区切りコードを自動的に推測するようになって +いるのですが、時々誤った区切りコードを導き出すことがあります。 +appendix の区切りコードは、その書籍の正しい区切りコードを EB ライブラリ +に教えてやるために用います。 + +
外字の代替文字列
+
+多くの CD-ROM 書籍は、外字 (独自に定義した文字) を持っており、本文中で +その外字を使っています。 +CD-ROM 書籍では外字のビットマップフォントを用意しており、 +クライアントアプリケーションが外字を出力するには、そのフォントを描画 +しなくてはなりません。 + +appendix では、外字の 代替文字列 (alternation text) +を定義することができます。 +アプリケーションは、ビットマップフォントを描画する代わりに、その +代替文字列を出力することにしても良いでしょう。 +
+ +

+appendix のレイアウトは CD-ROM 書籍のものとよく似ています。 +トップディレクトリには catalog もしくは catalogs +ファイルが存在し、各副本のデータは対応するサブディレクトリに配置されて +います。 +

+ + +

ebappendix コマンドとは

+ +

+appendix はバイナリ形式のデータファイルで構成されますので、手で直接 +編集するのは容易ではありません。 +そこで、EB ライブラリでは ebappendix コマンドを用意しています。 +ebappendix コマンドは、テキスト形式で書かれたデータを読み込み、 +バイナリ形式の appendix を生成します。 +

+ +

+EB ライブラリの公式な FTP サイト +ftp://ftp.sra.co.jp/pub/misc/eb/appendix/ +には、既にいくつかの書籍用の appendix が置いてあります。 +ここに載っていない CD-ROM 書籍用の appendix を用意したい場合は、 +ebappendix コマンドを使いましょう。 +

+ + +

appendix のソースデータの書き方

+ +

+この章では、appendix のソースデータの書き方を説明します。 +ここで、「ソースデータ」と言っているのは、ebappendix が読み込む +テキスト形式で書かれたデータのことです。 +

+ +

+appendix を生成するためには、次に挙げるソースデータファイルが必要です。 +これらのファイルをすべて、同じディレクトリ上に用意するようにします。 +

+ +
+
catalog.app または catalogs.app
+
+appendix には必ず、catalog または catalogs という +名前のファイルが必要です。 +catalog.app, catalogs.app はその生成元となる +ファイルです。 +appendix に収録されている 副本 (subbook) +(詳しくは +catalog(s).app の書き方」 +を参照) の一覧を記します。 + +
副本.app
+
+appendix が収録している副本それぞれに対して、一つずつ用意する必要が +あります (副本 の部分は、実際は個々の副本の名前になります)。 +appendix のメインデータである、本文の区切りコードや外字の代替文字列は、 +このファイルに記します。 +
+ + + +

catalog(s).app とは

+ +

+CD-ROM 書籍と同様に、appendix パッケージにも必ず catalog +もしくは catalogs という名前のファイルのどちらか一方が +必要です。 +catalog.app, catalogs.app ファイルは、その +生成元となります。 +

+ +

+ebappendix コマンドに appendix を生成させる際には、 +catalog.appcatalogs.app のどちらかを必ず +用意しておく必要があります。 +

+ +

+ebappendix の標準の動作では、catalog.app という +ファイル名にしておくと、生成するファイル名も catalog に +なります。 +また、appendix 全体のディレクトリ構造が、電子ブックに似た形式になります。 +

+ +

+反対に、catalogs.app というファイル名にしておくと、生成する +ファイル名も catalogs になります。 +また、appendix 全体のディレクトリ構造が、EPWING に似た形式になります。 +

+ +

+ただし、EPWING の書籍に対して電子ブック形式の appendix を使用しても、 +動作そのものには支障がありません。 +逆も同様です。 +

+ + +

catalog(s).app の書き方

+ +

+catalog(s).app には、書籍に収録されている副本のディレクトリ名を +1 行に 1 つずつ書き並べます。 +副本のディレクトリ名は、ebinfo コマンドを使うと容易に分かります。 +

+ +

+以下は、ebinfo の実行例です。 +

+ +
+
+% ebinfo /mnt/cdrom
+ディスクの形式: EB/EBG/EBXA/EBXA-C/S-EBXA
+文字コード: JIS X 0208
+副本の数: 2
+
+副本  1:
+  題名: 新英和辞典(第三版)
+  ディレクトリ: ejdict
+  検索方式: 前方一致 後方一致 条件 メニュー 
+  フォントの大きさ: 16 24 30 48
+  半角フォントの文字: 0xa121 -- 0xa24e
+  全角フォントの文字: 0xa321 -- 0xa27e
+
+副本  2:
+  題名: この書籍の使い方
+  ディレクトリ: howto
+  検索方式: 前方一致 後方一致 条件 メニュー 
+  フォントの大きさ: 16 24 30 48
+  半角フォントの文字: 
+  全角フォントの文字: 0xa321 -- 0xa27e
+
+
+ +

+この辞書用の appendix を作成する場合、catalog(s).app には次の +ように記します。 +

+ +
+
+ejdict
+howto
+
+
+ +

+(ebinfo コマンドに関しての詳細は、 +ebinfo コマンドのマニュアル を参照のこと。) +

+ +

+ディレクトリ名の大文字、小文字は、同じものとして扱われます。 +また、空行およびおよび空白以外の最初の文字がハッシュ記号 (#) +である行は無視されます。 +

+ +

+必ずもとの書籍の副本すべてを、同じ順序で catalog(s).app に +記すようにして下さい。 +

+ + +

副本.app とは

+ +

+appendix が収録している副本それぞれに対して、ソースデータファイル +副本.app を用意する必要があります。 +副本 の部分は、実際には個々の副本の使用する +ディレクトリ名になります。 +

+ +

+たとえば、前節の例では、書籍が ejdicthowto +というディレクトリ名を持った副本を持っていました。 +この場合、用意するファイルは ejdict.apphowto.app +になります。 +

+ +

+副本.app ファイルは appendix のメインデータである、 +本文の区切りコードや外字の代替文字列を収録した appendix や +furoku といったファイルの生成元になります。 +(appendix を電子ブック形式で生成すると appendix、EPWING 形式 +で生成すると furoku というファイル名になります。) +

+ + +

副本.app の文法

+ +

+各副本のソースデータを記したファイル「副本.app」 +の中では、空行、および空白以外の最初の文字がハッシュ記号 (#) +である行は無視されます。 +

+ +

+他の行はすべて、単独指示子 (single directive) か +複合指示子 (group directive) のいずれかでなくてはなりません。 +単独指示子と複合指示子は、どのような順序で定義しても差し支えありません。 +

+ +

+単独指示子とは、1 行で完結する指示子です。 +単独指示子の一般形は次の通りです。 +

+ +
+
+指示子の名前    指示子の値
+
+
+ +

+以下の例では、stop-code が指示子の名前、 +0x1f09 0x0001 がその値です。 +

+ +
+
+stop-code          0x1f09 0x0001
+
+
+ +

+指示子名の大文字と小文字は区別されますので、stop-code を +Stop-Code と書くことはできません。 +指示子の名前と値の区切りには、空白かタブを用います。 +連続した空白とタブが、行頭および行末にあった場合、それらは無視されます。 +

+ +

+複合指示子とは、記述が設定ファイル内の複数行に渡る指示子です。 +複合指示子の一般形は次の通りです。 +

+ +
+
+begin 複合指示子の名前
+    副指示子の名前    副指示子の値
+             : 
+             : (繰り返し)
+             : 
+end
+
+
+ +

+キーワード begin が、複合指示子の開始を表します。 +begin は後ろに 複合指示子の名前 を引数として +取ります。 +begin複合指示子の名前 は空白かタブで区切り、 +両方とも同じ行の中に置きます。 +キーワード end は、複合指示子の終了を表します。 +end は、単独で 1 行にして置きます。 +

+ +

+今のところ 副本.app で使用できる複合指示子の名前は、 +narrowwide の 2 つだけです。 +それぞれの 副指示子 は、beginend +の行の間に置きます。 +副指示子に関する記述の一般的な規則は、単独指示子と変わりません +(たとえば、副指示子の名前副指示子の値 は空白か +タブで区切ることなど)。 +

+ +

+以下は、 narrow 複合指示子の記述例です。 +

+ +
+
+begin narrow
+    range-start     0xa121
+    range-end       0xa123
+    0xa121          [→参照]
+    0xa122          [→音声]
+    0xa123          [→図解]
+end
+
+
+ + +

副本.app の単独指示子

+ +

+単独指示子には次のようなものがあります。 +

+ +
+
character-code
+
+appendix の文字コードを指定します。 +文字コードは必ず、CD-ROM 書籍に合わせるようにします。 +CD-ROM 書籍の文字コードは、ebinfo コマンドの出力を見れば確認 +できます。 + +CD-ROM 書籍が ISO 8859-1 で書かれている場合は、指示子の値として +ISO8859-1 を指定します。 +それ以外の場合は、JISX0208 を指定して下さい。 + +
+
+character-code          JISX0208
+
+
+ +この指示子は、副本.app ファイル内で必ず一回定義 +されなければなりません。 +定義しなかったり、二度以上定義するとエラーになります。 + +
stop-code
+
+副本の本文の区切りコードを指定します。 +指示子の値は、区切りコードの文字番号を 2 つ書き並べたものになります。 + +
+
+stop-code          0x1f09 0x0001
+
+
+ +文字番号は、0x ないし 0X に続けて 16進数 4 桁 +で記します。 +ただし、1つ目の文字番号は、0x1f090x1f41 で +なければなりません。 +それ以外だとエラーになります。 + +ebstopcode コマンドを使うと、副本に適切な区切りコードを +特定することができます (詳しくは +ebstopcode コマンドのマニュアル を参照の +こと)。 + +この指示子は定義しなくても構いませんが、二度以上定義するとエラーになります。 +
+ + +

副本.app の複合指示子

+ +

+narrow および wide 複合指示子は、それぞれ副本に +対する半角外字および全角外字に対する代替文字列を定義するために用います。 +ただし、副本が外字を定義していても、代替文字列を利用する必要がなければ、 +narrow, wide 複合指示子を記述する必要はありません。 +

+ +

+narrowwide 複合指示子内で定義できる副指示子は、 +まったく同じです。 +副指示子には次のようなものがあります。 +

+ +
+
range-start
+
+外字の定義範囲を記します。 +開始位置の文字番号を range-start で、終了位置の文字番号を +range-end で指定します。 +文字番号は、0x ないし 0X に続けて 16進数 4 桁で +記します。 +以下は記述例です。 + +
+
+    range-start     0xa121
+    range-end       0xa123
+
+
+ +定義範囲は、ebinfo コマンドの出力結果の +「半角フォントの文字 (narrow font characters)」 +「全角フォントの文字 (wide font characters)」 +で記された範囲と一致させるようにして下さい。 + +narrow および wide 複合指示子内では、 +必ず一回ずつ range-start および range-end を +定義しなければなりません。 +定義しなかったり、二度以上定義したりするとエラーになります。 + +
0xhhhh
+
+hhhh は、4 桁 の 16進数です。 +文字番号 0xhhhh の全角外字ないし半角外字に対して、 +代替文字列を定義します。 + +
+
+    0xa121          [名]
+
+
+ +appendix が ISO 8859-1 で書かれている場合は、代替文字列も ISO 8859-1 +で定義します。 +それ以外の場合は、代替文字列を日本語 EUC で定義します。 +いずれも、代替文字列は最長で 31 バイトまでで、それを超えるとエラーに +なります。 + +range-start, range-end で指定した定義範囲内の +外字すべてについて、代替文字列を設定する必要はありません。 +ただし、同一の複合指示子内で、一つの文字番号の外字に対して代替文字列を +定義できるのは一回までです。 +複数回設定しようとすると、エラーになります。 +また、範囲外の文字番号の代替文字列を定義しようとしても、やはりエラーに +なります。 + +CD-ROM 書籍がどのような外字を定義しているのかは、ebfont コマンド +で調べることができます (詳しくは +ebfont コマンドのマニュアル を参照のこと)。 +
+ + +

appendix の生成

+ +

+appendix のソースデータが書けたら、ebappendix コマンドを用いて +実際の (バイナリ形式の) appendix を生成します。 +

+ +

+以下、この章では ebappendix の実行方法について詳しく説明します。 +

+ + + +

ebappendix の実行

+ +

+ebappendix の一般的な起動方法は次の通りです。 +

+ +
+
+% ebappendix 入力ディレクトリのパス
+
+
+ +

+入力ディレクトリのパス には、読み込む appendix ソースデータの +ディレクトリ、つまり catalog.app または catalogs.app +ファイルが存在するディレクトリを指定します。 +省略した場合は、カレントディレクトリを指定したとみなされます。 +

+ +

+標準では、出力ファイルはカレントディレクトリに作成されます。 +

+ +

+--output-directory オプションを指定することで、 +ebappendix はカレントディレクトリ以外の場所に出力することが +できます。 +

+ +
+
+% ebappendix --output-directory 出力ディレクトリのパス \
+  入力ディレクトリのパス
+
+
+ +

+もし出力ディレクトリが存在していなければ、自動的に ebappendix +が生成します。 +

+ +

+実行すると、ebappendix は出力ディレクトリの下にサブディレクトリ +を作り、いくつかのファイルを生成します。 +

+ + +

appendix と CD-ROM 書籍の重ね合わせ

+ +

+HDD 上にコピーした CD-ROM 書籍と同じディレクトリに、appendix を重ねて +置くことができます。 +

+ +

+これには、ebappendix--output-directory と +--no-catalog オプションを使います。 +--output-directory オプションには、CD-ROM 書籍の +トップディレクトリを指定します。 +

+ +
+
+% ebappendix --no-catalog --output-directory 出力ディレクトリのパス \
+  入力ディレクトリのパス
+
+
+ +

+なお、appendix の形式 (電子ブックか EPWING か) は CD-ROM 書籍に合わせる +ようにします +(詳しくは +catalog(s).app の書き方」 +を参照)。 +

+ +

+ebappendix の実行前後で CD-ROM 書籍のディレクトリ構成が +どのように変化するのか、例を記してみます。 +まず電子ブックの場合ですが、実行前のディレクトリ構成が次のように +なっていたとします。 +

+ +
+
+catalog
+ejdict/start
+howto/start
+
+
+ +

+ebappendix で appendix を重ね合わせると、次のような構成に +なります。 +

+ +
+
+catalog
+ejdict/start
+ejdict/appendix  ← appendix のファイル
+howto/start
+howto/appendix   ← appendix のファイル
+
+
+ +

+同様に、EPWING で実行前のディレクトリ構成が次のようになっていたと +すると、 +

+ +
+
+catalogs
+ejdict/data/honmon
+howto/data/honmon
+
+
+ +

+実行後は、次のような構成になります。 +

+ +
+
+catalogs
+ejdict/data/honmon
+ejdict/data/furoku  ← appendix のファイル
+howto/data/honmon
+howto/data/furoku   ← appendix のファイル
+
+
+ +

+CD-ROM 書籍によっては、ディレクトリ名に大文字が混じっていることが +ありますが、ebappendix はそれを検出しますので、名前を小文字に +変えたディレクトリを別途作ってしまうことはありません。 +

+ +

+--no-catalog オプションを指定すると、ebappendix は +カタログファイル catalogcatalogs ファイルを +生成しなくなります。 +この appendix を EB ライブラリのアプリケーションから使う際は、 +CD-ROM 書籍に最初から用意されている catalog や +catalogs ファイルを CD-ROM 書籍、appendix 共用の +カタログファイルとして流用することになります。 +

+ +

+appendix のカタログファイルは、CD-ROM 書籍のカタログファイルの部分集合 +となっているため、こうした事が可能となっています。 +--no-catalog オプションを指定し忘れると、 +ebappendix は CD-ROM 書籍のカタログファイルを上書き +してしまいますので、注意して下さい。 +

+ + +

ebappendix のオプション

+ +

+ebappendix コマンドは、伝統的な一文字オプション名と覚えやすい +長いオプション名の両方を扱うことができます。 +長いオプション名を表すには、- ではなく -- を +用います。 +オプション名が一意に決まる範囲内で、名前の後方部分を省略することができま +す。 +

+ +
+
-b 書籍の形式
+
--booktype 書籍の形式
+
+appendix を電子ブック、EPWING のどちらの形式のレイアウトに似せて作る +のかを指定します。 +電子ブック形式なら eb、EPWING 形式なら epwing +と指定します。 + +このオプションを指定しなかった場合、次の要領でどちらの形式で生成する +のかがが決定されます。 +まず、入力ディレクトリに catalog.app ファイルが存在すれば +それが読み込まれ、電子ブック形式の appendix が生成されます。 +catalog.app がなく、代わりに catalogs.app が +存在すればそれが読み込まれ、EPWING 形式の appendix が生成されます。 +(catalogs.appcatalog.app なければ、エラー +になります。) + +
-d
+
--debug
+
--verbose
+
+デバッグ用のメッセージを、標準エラー出力に出力します。 + +
-h
+
--help
+
+ヘルプメッセージを標準出力に出力して、終了します。 + +
-n
+
--no-catalog
+
+カタログファイル (catalog および catalogs) を +生成しません。 +このオプションは、書籍と appendix を同じディレクトリに重ね合わせる際に +有効です +(詳しくは +「appendix と CD-ROM 書籍の重ね合わせ」 +を参照のこと)。 + +
-o ディレクトリ
+
--output-directory ディレクトリ
+
+出力先のディレクトリを指定します。 +このオプションを省略すると、カレントディレクトリ (.) に +出力します。 +ディレクトリが存在しなければ、自動的に生成されます。 + +
-t
+
--test
+
+ファイルを出力しません。 +入力ファイルを読み込んで、内容のチェックだけを行います。 + +
-v
+
--version
+
+バージョン番号を標準出力に出力して、終了します。 +
+ + + diff --git a/doc/ebfont.html.in b/doc/ebfont.html.in new file mode 100644 index 0000000..6eb4c92 --- /dev/null +++ b/doc/ebfont.html.in @@ -0,0 +1,387 @@ + + + + + + +ebfont コマンド + + + +

ebfont コマンド

+

+この文書は EB ライブラリバージョン + +に対応しています。 +

+ +

+目次: +

+ + + +

+Copyright (c) 1998-2006 Motoyuki Kasahara +

+ + +

はじめに

+ +

+ebfont コマンドは、CD-ROM 書籍の外字のビットマップデータを +読み込み、それを指定された画像形式に変換し、ファイルに書き出します。 +ebfont は EB ライブラリを使用しており、ライブラリと一緒に +配布されています。 +

+ + +

外字とは

+ +

+CD-ROM 書籍の多くは、書籍固有の文字、外字 (local characters) を定義して +います。 +たとえば、CD-ROM 書籍に使われる文字セットは発音記号を持っていないため、 +英和辞書の中には発音記号を定義しているものがあります。 +

+ +

+CD-ROM 書籍は、外字のビットマップデータも持っています。 +ebfont コマンドは、CD-ROM 書籍のビットマップデータを読み、 +それを指定された画像形式に変換し、ファイルに書き出します。 +ebfont は、XBM、XPM、GIF、BMP、PNG のうちのいずれか、 +または複数の画像ファイルを生成することができます。 +特に指定がなければ、XBM 形式が選択されます。 +

+ +

+外字は、半角 (narrow) と 全角 +(wide) の 2 種類に分類されます。 +半角の文字のビットマップデータでは、高さは幅の約半分です。 +全角の文字のビットマップデータでは、高さと幅はほぼ同じです。 +CD-ROM 書籍は、一冊の中に両方の種類の外字を定義することが可能で、 +ebfont は両方の種類の画像ファイルを生成します。 +

+ +

+CD-ROM 書籍の内部形式の仕様書では、半角と全角の両方の外字に対して +4 種類のサイズを定義しています。 +外字の幅、高さ、サイズは次の通りです。 +

+ + + + + + + +
高さ 半角 全角
16 8x16 16x16
24 16x24 24x24
30 16x30 32x30
48 24x48 48x48
+ +

+特に指定がなければ、ebfont は高さが 16 ピクセルのフォントの +画像ファイルを生成します。 +

+ + +

ebfont の実行

+ +

+ebfont の一般的な起動方法は次の通りです。 +

+ +
+
+% ebfont 書籍へのパス
+
+
+ +

+書籍へのパス には、CD-ROM 書籍のトップディレクトリ、つまり +catalog または catalogs ファイルが存在する +ディレクトリを指定します。 +パスは、ローカルなパス (例: /mnt/dict) でも遠隔アクセス識別子 +(例: ebnet://localhost/dict) でも構いません。 +複数のパスを書くことはできませんが、以下のように、パスの指定を省くことは +できます。 +

+ +
+
+% ebfont
+
+
+ +

+この場合、ebfont はカレントディレクトリの下に画像ファイルを +生成します。 +このとき、ファイル名の一般形式は次の通りです。 +

+ +
+
+副本/高さ/narrow/文字番号.拡張子
+副本/高さ/wide/文字番号.拡張子
+
+
+ +

+拡張子xbmxpmgif、 +bmp png のいずれかで、文字番号 は +16 進数 4 桁 (0 から 9a から +f) で、次のようになります。 +

+ +
+
+ejdict/16/narrow/a121.xbm
+ejdict/16/wide/a321.xbm
+
+
+ +

+ejdict/16/xbm/narrow などの中間のディレクトリは、もし +無ければ ebfont が生成します。 +

+ +

+--output-directory オプションを指定することで、 +ebfont はカレントディレクトリ以外のディレクトリに +画像ファイルを出力することができます。 +そのトップディレクトリは、ebfont を実行する前に作成されて +いなければなりません。 +

+ +
+
+% ebfont --output-directory ディレクトリ 書籍へのパス
+
+
+ + + +

画像形式

+ +

+ebfont は XBM, XPM, GIF89a, BMP, PNG 形式の画像ファイルを +生成することができます。 +画像形式は --image-format (-i) オプションで +指定します。 +--image-format オプションは引数を一つ取り、そこにカンマ +(,) で区切って、画像形式の名前を並べて書きます。 +たとえば、以下のコマンドを実行すると、ebfont は XPM 形式と +GIF 形式の画像ファイルを生成します。 +

+ +
+
+% ebfont --image-format xpm,gif 書籍へのパス
+
+
+ +

+--image-format の引数は、次のように分けて書くこともできます。 +

+ +
+
+% ebfont --image-format xpm --image-format gif 書籍へのパス
+
+
+ +

+XPM, GIF, PNG 形式では、前景色は黒 (RGB の #000000) に、 +背景色は透明になります。 +BMP 形式では、前景色は黒に、背景色は白 (RGB の #ffffff) に +なります。 +

+ +

+ebzip は GIF の画像を生成する際に LZW 圧縮アルゴリズムを +使わないため、ファイルのサイズは相当大きくなります。 +

+ + +

高さ

+ +

+特に指定がなければ、ebfont は、半角と全角それぞれについて、 +高さ 16 ピクセルのフォントの画像ファイルを生成します。 +--font-height (-f) オプションを使用することで、 +他の高さのフォントの画像ファイルを生成することができます。 +--font-height オプションは引数を一つ取り、そこにカンマ +(,) で区切って、フォントの高さを並べて書きます。 +フォントの高さは、162430、 +48 のいずれかでなくてはいけません。 +たとえば、以下のコマンドを実行すると、ebfont は高さ +16 ピクセルと 24 ピクセルのフォントの画像ファイルを生成します。 +

+ +
+
+% ebfont --font-height 16,24 書籍へのパス
+
+
+ +

+--font-height の引数は、次のように分けて書くこともできます。 +

+ +
+
+% ebfont --font-height 16 --font-height 24 書籍へのパス
+
+
+ + +

副本

+ +

+なにも設定しないと、ebzip はすべての副本 (subbook) を対象に +して画像ファイルを生成しますが、--subbook (-S) +オプションを使うと、指定した副本の画像ファイルだけを生成することができます。 +

+ +

+--subbook オプションは引数を一つ取り、そこにカンマ +(,) で区切って、副本のディレクトリ名を並べて書きます。 +ebinfo コマンドを用いると、あなたの所有している書籍に +どのような副本が含まれているのかを知ることができます。 +

+ +
+
+% ebinfo /mnt/cdrom
+ディスクの形式: EB/EBG/EBXA/EBXA-C/S-EBXA
+文字コード: JIS X 0208
+副本の数: 3
+
+副本 1:
+  題名: 新英和辞典(第四版)
+  ディレクトリ: english
+  検索方式: 前方一致 後方一致 条件 メニュー
+  フォントの大きさ: 16 24 30 48
+  半角フォントの文字: 0xa121 -- 0xa24e
+  全角フォントの文字: 0xa321 -- 0xa27e
+
+副本 2:
+  題名: CD-ROM 仏和辞典(第三版)
+  ディレクトリ: french
+  検索方式: 前方一致 後方一致 条件 メニュー
+  フォントの大きさ: 16 24 30 48
+  半角フォントの文字: 
+  全角フォントの文字: 0xa321 -- 0xa27e
+
+副本 3:
+  題名: ポケット独和辞典(第三版)
+  ディレクトリ: german
+  検索方式: メニュー
+  フォントの大きさ: 16 24 30 48
+  半角フォントの文字: 
+  全角フォントの文字: 0xa321 -- 0xa27e
+
+
+ +

+(ebinfo コマンドに関しての詳細は、 +ebinfo コマンドのマニュアル を参照のこと。) +この例では、3 つの副本が書籍には含まれており、そのディレクトリ名は +english, french, german +だということが分かります。 +

+ +

+次のコマンドを実行すると, ebfontenglish と +french の画像ファイルだけを生成します。 +

+ +
+
+% ebfont --subbook english,french /mnt/cdrom
+
+
+ +

+ディレクトリ名の大文字・小文字の違いは、区別されません。 +--subbook の引数は、次のように分けて書くこともできます。 +

+ +
+
+% ebfont --subbook english --subbook french /mnt/cdrom
+
+
+ + +

ebfont のオプション一覧

+ +

+ebzip コマンドは、伝統的な一文字オプション名と覚えやすい長い +オプション名の両方を扱うことができます。 +長いオプション名を表すには、- ではなく -- を +用います。 +オプション名が一意に決まる範囲内で、名前の後方部分を省略することができます。 +

+ +
+
-d
+
--debug
+
--verbose
+
+デバッグ用の情報を、標準エラー出力に出力します。 + +
-f 高さ
+
--font-height 高さ
+
+高さが 高さ の外字の画像ファイルを生成します。 +高さ は、高さをカンマ (,) で区切って並べたもので +なくてはなりません。 +高さの指定として許されるのは、1624、 +3048 です。 +指定がなければ、ebfont は高さが 16 ピクセルのフォントのものを +生成します。 +(詳しくは、「高さ」を参照のこと。) + +
-h
+
--help
+
+ヘルプメッセージを標準出力に出力して、終了します。 + +
-i 画像形式
+
--image-format 画像形式
+
+画像形式 形式の画像ファイルを生成します。 +画像形式 は、画像形式名をカンマ (,) で区切って +並べたものでなくてはなりません。 +対応している画像形式の名前は xbmxpm、 +gifbmpgifpng +です。 +指定しなかったときは、ebfont は XBM 形式の画像ファイルを +生成します。 +(詳しくは、「画像形式」を参照のこと。) + +
-o ディレクトリ
+
--output-directory ディレクトリ
+
+画像ファイルを ディレクトリ 以下に出力します。 +指定しなかったときは、ebfont はカレントディレクトリ +(.) の下に画像ファイルを生成します。 +(詳しくは、ebfont の実行」 +を参照のこと。) + +
-S 副本
+
--subbook 副本
+
+ebfont に、どの副本の外字を生成させるのかを指定します。 +副本 は、副本のディレクトリ名をカンマ (,) で +区切って並べたものでなくてはなりません。 +指定しなかったときは、すべての副本が生成の対象になります。 +(詳しくは、「副本」を参照のこと。) + +
-v
+
--version
+
+バージョン番号を標準出力に出力して、終了します。 +
+ + + diff --git a/doc/ebinfo.html.in b/doc/ebinfo.html.in new file mode 100644 index 0000000..a8144d2 --- /dev/null +++ b/doc/ebinfo.html.in @@ -0,0 +1,319 @@ + + + + + + +ebinfo コマンド + + + +

ebinfo コマンド

+

+この文書は EB ライブラリバージョン + +に対応しています。 +

+ +

+目次: +

+ + + +

+Copyright (c) 1997-2006 Motoyuki Kasahara +

+ + +

はじめに

+ +

+ebinfo コマンドは CD-ROM 書籍に関する様々な情報を出力します。 +ebinfo は EB ライブラリを使用しており、ライブラリと一緒に配布 +されています。 +

+ + +

ebinfo の実行

+ +

+ebinfo の一般的な起動方法は次の通りです。 +

+ +
+
+% ebinfo 書籍へのパス
+
+
+ +

+書籍へのパス には、CD-ROM 書籍のトップディレクトリ、つまり +catalog または catalogs ファイルが存在する +ディレクトリを指定します。 +パスは、ローカルなパス (例: /mnt/dict) でも遠隔アクセス識別子 +(例: ebnet://localhost/dict) でも構いません。 +複数のパスを書くことはできませんが、以下のように、パスの指定を省くことは +できます。 +

+ +
+
+% ebinfo
+
+
+ +

+この場合、ebinfo はカレントディレクトリ (.) が +指定されたものと判断します。 +ebinfo は指定された書籍に関する情報を、次のような感じで出力 +します。 +

+ +
+
+% ebinfo /mnt/cdrom
+ディスクの形式: EB/EBG/EBXA/EBXA-C/S-EBXA
+文字コード: JIS X 0208
+副本の数: 2
+
+副本  1:
+  題名: 新英和辞典(第三版)
+  ディレクトリ: ejdict
+  検索方式: 前方一致 後方一致 条件 メニュー 
+  フォントの大きさ: 16 24 30 48
+  半角フォントの文字: 0xa121 -- 0xa24e
+  全角フォントの文字: 0xa321 -- 0xa27e
+
+副本  2:
+  題名: この書籍の使い方
+  ディレクトリ: howto
+  検索方式: 前方一致 後方一致 条件 メニュー 
+  フォントの大きさ: 16 24 30 48
+  半角フォントの文字: 
+  全角フォントの文字: 0xa321 -- 0xa27e
+
+
+ +

+副本 (subbook) が複合検索 (multi-search) に対応している場合、 +--multi-search (または -m) オプションを指定すると、 +ebinfo は複合検索に関する詳細な情報も合わせて出力します。 +複合検索に関する情報は、次のような感じになります。 +

+ +
+
+  複合検索 1:
+    ラベル 1: 国または地域
+    候補: 有
+    ラベル 2: 時期
+      候補: 無
+    ラベル 3: カテゴリ
+      候補: 有
+    ラベル 4: 出典
+      候補: 無
+  複合検索 2:
+    ラベル 1: 著者
+      候補: 無
+    ラベル 2: 題名
+      候補: 無
+    ラベル 3: 日付
+      候補: 無
+    ラベル 4: 出版社
+      候補: 無
+
+
+ + +

出力される情報の詳細ついて

+ +

+この節では、ebinfo が出力する情報の詳細について説明します。 +

+ +
+
disc type:
+
+その書籍の形式。EB/EBG/EBXA/EBXA-C/S-EBXA または EPWING です。 + +
character code:
+
+その書籍で使用されている文字コー。ISO 8859-1 または JIS X 0208 です。 + +
the number of subbooks:
+
+その書籍に収録されている副本 (subbbok) の数。 +
+ +

+加えて、その書籍のそれぞれの副本について、以下の情報が出力されます。 +

+ +
+
title:
+
+副本の題名。 +書籍が JIS X 0208 に書かれているときは、題名は EUC (Extended UNIX Code) +で表示されます。 + +
directory:
+
+その副本に関連するファイルが置かれるディレクトリの名前。 +英小文字は大文字に変換されます。 + +
search methods:
+
+副本が対応している検索方法の一覧。 +この一覧は、以下に記した検索方法の一部、もしくは全部から構成されます。 + +
+
copyright
+
+著作権表示 (copyright notice)。 +厳密に言えば、これは検索方法ではないのですが、CD-ROM 書籍の内部形式の +関係から、表示するようにしています。 + +
word
+
+前方一致検索 (Word search)。 + +
endword
+
+後方一致検索 (Endword search)。 + +
keyword
+
+条件検索 (Keyword search)。 + +
cross
+
+クロス検索 (Keyword search)。 + +
multi
+
+複合検索 (Multi search)。 + +
menu
+
+メニュー検索 (Menu search). + +
graphic
+
+グラフィック検索 (Graphic search). + +
+ +

+副本が持つ、フォントのサイズの一覧。 +この一覧には、16, 24, 30, 48 という 4 つのサイズの一部、もしくは全部から +構成されます。 +

+ +

+副本が定義している半角文字の文字番号の範囲。 +

+ +

+副本が定義している全角文字の文字番号の範囲。 +

+ +
+ + +

EBNET サーバの書籍一覧

+ +

+通常の出力の代わりに、ebinfo は EBNET サーバが公開している +書籍の一覧を出力することもできます。 +この場合のコマンド行の概要は、次のようになります。 +

+ +
+
+% ebinfo --book-list 遠隔サーバ識別子
+
+
+ +

+ここで、遠隔サーバ識別子 は、書籍名を含まない遠隔アクセス識別子 +になります。 +たとえば、 +

+ +
+
+% ebinfo --book-list ebnet://dict.example.com
+名前             題名
+encycl           ブラウンコンサイス百科事典
+encycl.app       ブラウンコンサイス百科事典 (appendix)
+crossword        クロスワードパズル辞典
+travel           ワールドトラベルガイド
+
+
+ +

+「名前」の末尾に .app が付いているものは appendix (付録)、 +それ以外は書籍本体です。 +ただし、そのクライアントに対してアクセスを許可しない書籍や appendix は +出力されません。 +

+ +

+続けて、この中の encycl という書籍の情報を見るには、次の +ようにします。 +

+ +
+
+% ebinfo ebnet://dict.example.com/cncyclopedia
+ディスクの形式: EB/EBG/EBXA/EBXA-C/S-EBXA
+文字コード: JIS X 0208
+副本の数: 1
+
+副本 1:
+  題名: ブラウンコンサイス百科事典
+  ディレクトリ: brown
+  検索方式: 前方一致 後方一致 条件 複合 メニュー
+  フォントの大きさ: 16 24
+  半角フォントの文字: 0xa121 -- 0xa452
+  全角フォントの文字: 0xa321 -- 0xa452
+
+
+ + +

ebinfo のオプション

+ +

+ebinfo コマンドは、伝統的な一文字オプション名と覚えやすい長い +オプション名の両方を扱うことができます。 +長いオプション名を表すには、- ではなく -- を +用います。 +オプション名が一意に決まる範囲内で、名前の後方部分を省略することができます。 +

+ +
+
-h
+
--help
+
+ヘルプメッセージを標準出力に出力して、終了します。 + +
-l
+
--book-list
+
+通常の出力の代わりに、EBNET サーバが公開している書籍の一覧を出力します。 +コマンド行引数 book-path は遠隔アクセス識別子でなければなりません。 + +
-m
+
--multi-search
+
+複合検索 (multi search) に関する情報も、合わせて出力します。 + +
-v
+
--version
+
+バージョン番号を標準出力に出力して、終了します。 +
+ + + diff --git a/doc/ebrefile.html.in b/doc/ebrefile.html.in new file mode 100644 index 0000000..b30032a --- /dev/null +++ b/doc/ebrefile.html.in @@ -0,0 +1,355 @@ + + + + + + +ebrefile コマンド + + + +

ebrefile コマンド

+

+この文書は EB ライブラリバージョン + +に対応しています。 +

+ +

+目次: +

+ + + +

+Copyright (c) 1998-2006 Motoyuki Kasahara +

+ + +

はじめに

+ +

+一冊の CD-ROM 書籍は、大抵複数の 副本 (subbook) を +持っています。 +たとえばある CD-ROM 書籍は国語辞典、英和辞典、和英辞典の 3 つの副本を +収めています。 +個々の副本は、それ自体が独立した「書籍」になっています。 +

+ +
+
+     (CD-ROM 書籍)
++-----------------------+
+|   [国語辞典] (副本)   |
+|   [英和辞典] (副本)   |
+|   [和英辞典] (副本)   |
++-----------------------+
+
+
+ +

+EB/EBG/EBXA/EBXA-C/S-EBXA 形式の CD-ROM 書籍は catalog +というファイルを、EPWING 形式の CD-ROM 書籍は catalogs +というファイルを持っています。 +これらのファイルは、その CD-ROM 書籍にはどんな副本が収められているのかを +定義しています。 +これらのファイルは、CD-ROM 書籍のトップディレクトリに置かれています。 +

+ +

+ebrefile は元のカタログファイルを読み、ユーザから指定された +副本だけを取り込んだ新しいカタログファイルを生成します。 +言い換えれば、ebrefile は特定の副本の定義を、カタログファイル +から削除します。 +CD-ROM 書籍が 3 つの副本を持っている場合、ebrefile は +そのうちの任意の 1 つまたは 2 つの副本を、新しいカタログファイルに +取り込むことができます。 +ハードディスクに CD-ROM 書籍の一部だけをコピーしたいときに、 +ebrefile は便利です。 +ebrefile は EB ライブラリと一緒に配布されています。 +

+ +

+あなたは、自分の所有する CD-ROM 書籍の使用許諾を守らなくてはいけません。 +ebrefile はフリーソフトウェアですが、あなたの書籍が自由に +使えるものであるとは限りません。 +ebrefile は、CD-ROM 書籍のあるファイルの内容に変更を加えます。 +ご注意下さい。 +

+ + +

ebrefile の実行

+ +

+ebrefile の一般的な起動方法は次の通りです。 +

+ +
+
+% ebrefile 書籍へのパス
+
+
+ +

+書籍へのパス には、CD-ROM 書籍のトップディレクトリ、つまり +catalog または catalogs ファイルが存在する +ディレクトリを指定します。 +複数のパスを書くことはできませんが、以下のように、パスの指定を省くことは +できます。 +

+ +
+
+% ebrefile
+
+
+ +

+この場合、ebrefile はカレントディレクトリ (.) +が指定されたものと判断します。 +

+ +

+遠隔アクセスには対応していませんので、遠隔アクセス識別子は使用できません。 +

+ +
+
+% ebrefile ebnet://localhost/cdrom
+ebrefile: ebnet には対応していません。
+
+
+ + + +

副本の選択

+ +

+特に指定がないと、ebrefile は、元のカタログファイルで定義 +されているすべての副本を新しい副本に取り込みます。 +つまり、新しいカタログファイルは、単に元のファイルのコピーになります。 +この振る舞いは、役に立ちません。 +ebrefile は、通常 --subbook (-S) +オプションを指定して起動します。 +

+ +

+--subbook (-S) オプションは引数を一つ取り、 +そこにカンマ (,) で区切って、新しいカタログファイルに +取り込みたい副本のディレクトリ名を並べて書きます。 +ebinfo コマンドを用いると、あなたの所有している書籍に +どのような副本が含まれているのかを知ることができます。 +

+ +
+
+% ebinfo /mnt/cdrom
+ディスクの形式: EB/EBG/EBXA/EBXA-C/S-EBXA
+文字コード: JIS X 0208
+副本の数: 3
+
+副本 1:
+  題名: 新英和辞典(第四版)
+  ディレクトリ: english
+  検索方式: 前方一致 後方一致 条件 メニュー
+  フォントの大きさ: 16 24 30 48
+  半角フォントの文字: 0xa121 -- 0xa24e
+  全角フォントの文字: 0xa321 -- 0xa27e
+
+副本 2:
+  題名: CD-ROM 仏和辞典(第三版)
+  ディレクトリ: french
+  検索方式: 前方一致 後方一致 条件 メニュー
+  フォントの大きさ: 16 24 30 48
+  半角フォントの文字: 
+  全角フォントの文字: 0xa321 -- 0xa27e
+
+副本 3:
+  題名: ポケット独和辞典(第三版)
+  ディレクトリ: german
+  検索方式: メニュー
+  フォントの大きさ: 16 24 30 48
+  半角フォントの文字: 
+  全角フォントの文字: 0xa321 -- 0xa27e
+
+
+ +

+(ebinfo コマンドに関しての詳細は、 +ebinfo コマンドのマニュアル を参照のこと。) +この例では、3 つの副本が書籍には含まれており、その名前は english +french, german だということが分かります。 +

+ +

+次のコマンドを実行すると、ebrefile は副本として +englishfrench だけを定義した新しいカタログ +を生成します。 +

+ +
+
+% ebrefile --subbook english,french
+
+
+ +

+ディレクトリ名の大文字・小文字の違いは、区別されません。 +--subbook の引数は、次のように分けて書くこともできます。 +

+ +
+
+% ebrefile --subbook english --subbook french
+
+
+ +

+ebrefile は副本の定義順序を変えることはできませんので、 +--subbook に与える引数の順序は任意です。 +

+ +

+これで再構成は完了です。 +もういちど ebinfo を起動してみましょう。 +副本 german が消えています。 +

+ +
+
+% ebinfo /mnt/cdrom
+ディスクの形式: EB/EBG/EBXA/EBXA-C/S-EBXA
+文字コード: JIS X 0208
+副本の数: 2
+
+副本 1:
+  題名: 新英和辞典(第四版)
+  ディレクトリ: english
+  検索方式: 前方一致 後方一致 条件 メニュー
+  フォントの大きさ: 16 24 30 48
+  半角フォントの文字: 0xa121 -- 0xa24e
+  全角フォントの文字: 0xa321 -- 0xa27e
+
+副本 2:
+  題名: CD-ROM 仏和辞典(第三版)
+  ディレクトリ: french
+  検索方式: 前方一致 後方一致 条件 メニュー
+  フォントの大きさ: 16 24 30 48
+  半角フォントの文字: 
+  全角フォントの文字: 0xa321 -- 0xa27e
+
+
+ +

+もし、CD-ROM 書籍全体をすでにハードディスクにコピーしているなら、 +副本 german のファイルは削除しても構いません。 +ディレクトリ名が小文字で構成されているなら、次のようにします。 +

+ +
+
+% rm -r german
+
+
+ +

+ebrefile は、読み込んだカタログファイルにそのまま上書きして +新たなカタログファイルを生成しますが、元のカタログファイルの複製が、 +catalog(s).old というファイル名で保存されます。 +副本の選択を間違えてしまった場合は、いったん元に戻しましょう。 +(以下では、カタログファイルが catalogs だと仮定しています。) +

+ +
+
+% mv catalogs.old catalogs
+
+
+ +

+ただし 実行時に catalog(s).old が既に存在していると、上書き +せずに残します。 +この場合、カタログファイルの複製は新たに作られませんので、注意して下さい。 +

+ + +

ebzip との連携

+ +

+ebrefile は、ebzip という CD-ROM 書籍を圧縮する +コマンドと併用することができます +(ebzip コマンドに関しての詳細は、 +ebzip コマンドのマニュアル を参照のこと。) +通常、 ebzipebrefile にはコマンド行で同じ +引数を与えます。 +

+ +

+CD-ROM 書籍が /cdrom にマウントされ、この書籍には +englishfrenchgerman という +3 つの副本が収められているとします。 +以下に記した操作によって、副本 englishfrench +は圧縮されてカレントディレクトリの下に置かれ、副本 german は +副本のリストから削除されます。 +

+ +
+
+% ebzip --subbook english,french /cdrom
+% ebrefile --subbook english,french /cdrom
+
+
+ +

+圧縮したファイルをカレントディレクトリ以外に置くには、次のようにします。 +

+ +
+
+% ebzip --output-directory /dict --subbook english,french /cdrom
+% ebrefile --output-directory /dict --subbook english,french /cdrom
+
+
+ + +

ebrefile のオプション一覧

+ +

+ebrefile コマンドは、伝統的な一文字オプション名と覚えやすい +長いオプション名の両方を扱うことができます。 +長いオプション名を表すには、- ではなく -- を +用います。 +オプション名が一意に決まる範囲内で、名前の後方部分を省略することができます。 +

+ +
+
-h
+
--help
+
+ヘルプメッセージを標準出力に出力して、終了します。 + +
-o ディレクトリ
+
--output-directory ディレクトリ
+
+新しいカタログファイルを置くディレクトリを指定します。 +指定しなかったときは、カレントディレクトリ (.) になります +(詳しくは、ebrefile の実行」 +を参照のこと)。 + +
-S 副本
+
--subbook 副本
+
+ebrefile が新しいカタログファイルに取り込むべき副本を指定します。 +副本 は、副本のディレクトリ名をカンマ (,) で区切って +並べたものでなくてはいけません。 +指定しなかったときは、すべての副本が対象になります +(詳しくは、「副本の選択」 を参照のこと)。 + +
-v
+
--version
+
+バージョン番号を標準出力に出力して、終了します。 +
+ + + diff --git a/doc/ebstopcode.html.in b/doc/ebstopcode.html.in new file mode 100644 index 0000000..f9968f9 --- /dev/null +++ b/doc/ebstopcode.html.in @@ -0,0 +1,234 @@ + + + + + + +ebstopcode コマンド + + + +

ebstopcode コマンド

+

+この文書は EB ライブラリバージョン + +に対応しています。 +

+ +

+目次: +

+ + + +

+Copyright (c) 2003-2006 Motoyuki Kasahara +

+ + +

はじめに

+ +

+あなたが EB ライブラリのアプリケーションを使って CD-ROM 書籍の中のある +単語を引く際、その単語の説明が終了する箇所で、アプリケーションが本文の +出力を止めることをあなたは期待するのではないでしょうか。 +しかし、EB ライブラリはそのような動作を保証することができません。 +なぜなら、CD-ROM 書籍の本文には、項目の終わりを示す印が存在しないから +です。 +

+ +

+幸いにも、多くの CD-ROM 書籍には、項目の終わりを示す印の代替として +使える、本文の区切りコード (text stop code) というものを持って +います。 +通常、EB ライブラリはこの区切りコードを自動的に推測するようになって +いるのですが、時々誤った区切りコードを導き出すことがあります。 +その場合は、appendix (付録) というものを用いて、EB ライブラリに +正しい区切りコードを教えてやらなくてはなりません。 +

+ +

+ebstopcode コマンドは、CD-ROM 書籍の本文の区切りコードを解析 +するためのツールです。 +

+ + +

ebstopcode の実行

+ +

+ebstopcode の一般的な起動方法は次の通りです。 +

+ +
+
+% ebstopcode 書籍へのパス 副本
+
+
+ +

+書籍へのパス には、CD-ROM 書籍のトップディレクトリ、つまり +catalog または catalogs ファイルが存在する +ディレクトリを指定します。 +遠隔アクセス用の識別子 (ebnet://...) を指定することも可能です。 +書籍へのパス が省略された場合は、カレントディレクトリが指定された +ものと見なされます。 +

+ +

+副本 には、処理の対象とする副本のディレクトリ名を指定します。 +ebinfo コマンドを用いると、CD-ROM 書籍にどのような副本が +含まれているのかを知ることができます。 +

+ +
+
+% ebinfo /cdrom
+ディスクの形式: EB/EBG/EBXA/EBXA-C/S-EBXA
+文字コード: JIS X 0208
+副本の数: 2
+
+副本 1:
+  題名: 新英和辞典(第四版)
+  ディレクトリ: english
+  検索方式: 前方一致 後方一致 条件 メニュー
+  フォントの大きさ: 16 24 30 48
+  半角フォントの文字: 0xa121 -- 0xa24e
+  全角フォントの文字: 0xa321 -- 0xa27e
+
+副本 2:
+  題名: CD-ROM 仏和辞典(第三版)
+  ディレクトリ: french
+  検索方式: 前方一致 後方一致 条件 メニュー
+  フォントの大きさ: 16 24 30 48
+  半角フォントの文字: 
+  全角フォントの文字: 0xa321 -- 0xa27e
+
+
+
+ +

+(ebinfo コマンドに関しての詳細は、 +ebinfo コマンドのマニュアル を参照のこと。) +この例では、2 つの副本が書籍には含まれており、その名前は english +と french だということが分かります。 +

+ +

+副本 english の区切りコードを解析するには、以下を実行します。 +

+ +
+
+% ebstopcode /cdrom english
+
+
+ +

+ebstopcode は、副本の本文と区切りコードの候補を次のように +出力します。 +

+ +
+
+=== stop-code?: 0x1f09 0x0001 ===
+
+=== stop-code?: 0x1f41 0x0100 ===
+A
+
+=== stop-code?: 0x1f09 0x0001 ===
+[名] 1: A 抗原を有する赤血球を持つ血液型
+
+=== stop-code?: 0x1f09 0x0001 ===
+2: メートル基準の長さの単位。10億分の 1 メートル。
+
+=== stop-code?: 0x1f09 0x0001 ===
+3: アンペア。電流の基本単位で、SI単位系の一つ。
+
+=== stop-code?: 0x1f09 0x0001 ===
+
+=== stop-code?: 0x1f41 0x0100 ===
+(以下略)
+
+
+ +

+stop-code?: と書かれた行はそれぞれ、区切りコードの候補を +示しています。 +これを区切りコードとして指定すると、EB ライブラリはその地点で本文の +出力を停止します。 +

+ +

+この english という副本の適切な区切りコードは、"0x1f41 0x0100" +になります。 +--no-candidate--code オプションを使用して、この +区切りコードを試してみます。 +

+ +
+
+% ebstopcode --no-candidate --code "0x1f41 0x0100" /cdrom english
+A
+[名] 1: A 抗原を有する赤血球を持つ血液型。
+2: メートル基準の長さの単位。10億分の 1 メートル。
+3: アンペア。電流の基本単位で、SI単位系の一つ。
+
+
+ + +

ebstopcode のオプション一覧

+ +

+ebstopcode コマンドは、伝統的な一文字オプション名と覚えやすい長い +オプション名の両方を扱うことができます。 +長いオプション名を表すには、- ではなく -- を +用います。 +オプション名が一意に決まる範囲内で、名前の後方部分を省略することが +できます。 +

+ +
+
-c コード
+
--code コード
+
+コード を区切りコードに指定します (例: "0x1f09 0x0001")。 +ebstopcode は、コード を見つけるまで本文を出力します。 + +
-h
+
--help
+
+ヘルプメッセージを標準出力に出力して、終了します。 + +
-l 長さ
+
--length 長さ
+
+本文データを最長で 長さ バイトまで出力します。 +長さ を 0 にすると、ebstopcode は本文全体を出力します。 +このオプションを指定しなかったときは、2048 になります。 + +
-n
+
--no-candidates
+
+区切りコードの候補を出力しないようにします。 + +
-p ページ:オフセット
+
--text-position ページ:オフセット
+
+本文データの出力をこの位置から開始します。 +ページ には 0 より大きい 16進整数を、オフセット には、 +0〜0x7FF の間の 16進整数をそれぞれ指定します。 +このオプションを指定しなかったときは、本文データの先頭位置から出力します。 + +
-v
+
--version
+
+バージョン番号を標準出力に出力して、終了します。 +
+ +

+--code (-c) と --length +(-l) オプションは、互いにもう一方のオプションを打ち消します。 +

+ + + diff --git a/doc/ebutils.css b/doc/ebutils.css new file mode 100644 index 0000000..8c529a3 --- /dev/null +++ b/doc/ebutils.css @@ -0,0 +1,37 @@ +body { + color: #000000; + background-color: #ffffff; +} + +td { + border-style: solid; + border-width: 1px; +} + +table { + border-style: solid; + border-width: 2px; +} + +h2 { + font-size: x-large; + background-color: #cfcfcf; + padding: 3px; + border-style: solid; + border-width: 1px; +} + +h3 { + font-size: large; + background-color: #cfcfcf; + padding: 3px; + border-style: solid; + border-width: 1px; +} + +h4 { + font-size: medium; + border-style: solid; + border-width: 2px; + padding: 8px; +} diff --git a/doc/ebzip.html.in b/doc/ebzip.html.in new file mode 100644 index 0000000..ccbccc1 --- /dev/null +++ b/doc/ebzip.html.in @@ -0,0 +1,1314 @@ + + + + + + +ebzip コマンド + + + +

ebzip コマンド

+

+この文書は EB ライブラリバージョン + +に対応しています。 +

+ +

+目次: +

+ + + +

+Copyright (c) 1998-2006 Motoyuki Kasahara +

+ + +

はじめに

+ +

+ebzip は EB ライブラリのアプリケーション用に、CD-ROM 書籍の +圧縮・伸長を行います。 +EB ライブラリのアプリケーションは、機能的には何の制限もなく圧縮された +CD-ROM 書籍にアクセスできます (ただし、処理速度はもとの書籍に比べて遅 +くなるかも知れません)。 +圧縮データ形式は、CPU の種類や、OS、ファイルシステムには依存していませ +んので、ebzip で圧縮したファイルは共用が可能です。 +ebzip は EB ライブラリと一緒に配布されています。 +

+ +

+あなたは、自分の所有する CD-ROM 書籍の使用許諾を守らなくてはいけません。 +ebzip はフリーソフトウェアですが、あなたの書籍が自由に使える +ものであるとは限りません。 +CD-ROM 書籍の出版社がハードディスク (および他の補助記憶装置) に書籍を +コピーすることを許可していないのであれば、その書籍の圧縮は諦めて下さい。 +

+ + +

動作とコマンド名

+ +

+ebzip は三つの 動作 (action) モードを +備えています。 +圧縮 (compression)、伸長 (uncompression) と情報出力 (information) です。 +

+ +
    +
  • 圧縮 (compression)
    +一冊の CD-ROM 書籍を圧縮します。 + +
  • 伸長 (uncompression)
    +ebzip で圧縮された、一冊の CD-ROM 書籍を伸長します。 + +
  • 情報出力 (information)
    +ebzip で圧縮された、一冊の CD-ROM 書籍の圧縮状態に関する +情報を出力します。 + +
+ +

+ebzip は起動時に、起動時に使用されたコマンド名と +コマンドラインオプションから動作モードを決定します。 +ebzip の一回の実行の間で、動作モードが変わることは +ありません。 +

+ +

+ebzipebzipebunzip, +ebzipinfo という異なる 3 つのコマンド名でインストール +されます。 +(一部の環境では、ebzipinfoebzipinf +という名前になっています。) + +

+ebunzip という名前で起動された場合は、伸長を行います。 +ebzipinfo という名前で起動された場合、情報出力を行います。 +それ以外の場合は、圧縮を行います。 +

+ +

+コマンドラインオプションでも、動作モードを決定することができます。 +--compress (-z) で圧縮、--uncompress +(-u) で伸長、--information (-i) +で情報出力を行います。 +オプションは、起動時のコマンド名より優先します。 +次の例では、いずれも動作モードが「伸長」になります。 +

+ +
+
+ebunzip
+ebzip --uncompress
+ebzipinfo --uncompress
+
+
+ +

+遠隔アクセスには対応していませんので、遠隔アクセス識別子は使用できません。 +

+ +
+
+% ebzip ebnet://localhost/cdrom
+ebzip: ebnet には対応していません。
+
+
+ + +

ebzip の実行

+ +

+ebinfoebunzipebzipinfo の +一般的な起動方法は次の通りです。 +

+ +
+
+% ebzip 書籍へのパス
+% ebunzip 書籍へのパス
+% ebzipinfo 書籍へのパス
+
+
+ +

+書籍へのパス には、CD-ROM 書籍のトップディレクトリ、つまり +catalog または catalogs ファイルが存在する +ディレクトリを指定します。 +複数のパスを書くことはできませんが、以下のように、パスの指定を省くことは +できます。 +

+ +
+
+% ebzip
+% ebunzip
+% ebzipinfo
+
+
+ +

+この場合は、カレントディレクトリ (.) が指定されたものと +判断されます。 +

+ + +

圧縮

+ +

+ebzip (ebunzip --compress、 +ebzipinfo --compress と等価) は CD-ROM 書籍の圧縮を行います。 +

+ + + +

圧縮の実行例 (1)

+ +

+この節では、ハードディスクにすでにコピーしてある CD-ROM 書籍を圧縮するには +どうしたらいいかを説明します。 +CD-ROM 書籍がすでに /dict にコピーされているものの、まだ圧縮 +されていないと仮定します。 +この書籍は /dict の下に、次のようなファイルを持っています。 +

+ +
+
+/dict/catalog
+/dict/language
+/dict/kanji/start
+/dict/english/start
+
+
+ +

+この書籍を圧縮するには、次のようにします。 +

+ +
+
+% cd /dict
+% ebzip
+
+
+ +

+これは次のようにしても同じです。 +

+ +
+
+% ebzip --output-directory /dict /dict
+
+
+ +

+圧縮には、しばらくかかることがあります。 +圧縮の間、ebzip は、次のように状況を知らせるメッセージを出力 +します。 +

+ +
+
+==> /dict/kanji/start を圧縮 <==
+./dict/kanji/start.ebz に出力
+ 1.0% 処理済み (2097152 / 220069888 バイト)
+ 1.9% 処理済み (4194304 / 220069888 バイト)
+ 2.9% 処理済み (6291456 / 220069888 バイト)
+        : (略)
+完了 (220069888 / 220069888 バイト)
+220069888 -> 78163751 バイト (35.5%)
+
+
+ +

+圧縮が完了すると、/dict の下のディレクトリ構成が少し変化して +いるのが分かります。 +

+ +
+
+/dict/catalog
+/dict/language.ebz
+/dict/kanji/start.ebz
+/dict/english/start.ebz
+
+
+ +

+拡張子 .ebz がいくつかのファイル +(/dict/language.ebz/dict/kanji/start.ebz、 +/dict/english/start.ebz) に付いています。 +これらが圧縮されたファイルです。 +他のファイルは変化していません。 +

+ +

+ebzip が圧縮するファイルは、 +STARTHONMONHONMON2、 +HONMONSLANGUAGE ファイルと GAIJI +ディレクトリにある外字ファイルです。 +

+ + +

圧縮の実行例 (2)

+ +

+この節ではもう一つ別の例として、CD-ROM ディスクのファイルを圧縮し、それ +をハードディスクに置く方法について説明します。 +元の CD-ROM 書籍が /cdrom にマウントされ、書籍は +/cdrom の下に次のようなファイルを持っていると仮定します。 +

+ +
+
+/cdrom/catalog
+/cdrom/language
+/cdrom/german/start
+/cdrom/french/start
+/cdrom/italian/start
+
+
+ +

+この書籍を圧縮し、/dict の下に置くためには、次のコマンドを +実行します。 +

+ +
+
+% cd /dict
+% ebzip --keep /cdrom
+
+
+ +

+これは次のようにしても同じです。 +

+ +
+
+% ebzip --keep --output-directory /dict /cdrom
+
+
+ +

+出力側のディレクトリ /dict は空でも構いませんが、圧縮前に +あらかじめ作っておかなければならないので、注意して下さい。 +この例では、--keep オプションを使っています。 +特に指定しなければ、ebzip は、圧縮後に元のファイルを削除 +しますが、--keep オプションはこの振る舞いを抑制します。 +

+ +

+/dict/cdrom のディレクトリ構成はほとんど +同じですが、/dict の下の圧縮されたファイルには拡張子 +.ebz が付いています。 +

+ +
+
+/dict/catalog
+/dict/language.ebz
+/dict/german/start.ebz
+/dict/french/start.ebz
+/dict/italian/start.ebz
+
+
+ +

+中間のディレクトリ /dict/german/dict/french、 +/dict/italian は、もし無ければ ebzip によって +作成されます。 +catalogcatalogs は、出力側のディレクトリ +にコピーされます。 +EB ライブラリが対応していないファイル、ディレクトリについては、 +ebzip は無視します (圧縮もコピーもしません)。 +

+ + +

圧縮レベル

+ +

+ebzip は、0 〜 5 という 6 つの圧縮レベルを持っています。 +圧縮レベル 0 は、圧縮・伸長が最も速いですが、圧縮率は最悪です。 +圧縮レベル 5 は、圧縮率が最良ですが、圧縮・伸長は最も遅くなります。 +圧縮レベルは、--level (-l) オプションで設定します。 +

+ +
+
+% ebzip --level 2 --output-directory /dict /dict
+
+
+ +

+無指定時のレベルは 0 (最速だが圧縮率は最悪) です。 +

+ + +

テスト

+ +

+ebzip--test (-t) オプション付き +で実行すると、ebzip は圧縮したデータを実際のファイルには +書き込まなくなります。 +圧縮する前に圧縮後のファイルの大きさを知りたいときに、便利です。 +

+ +
+
+% ebzip --test /dict /dict
+
+
+ + +

一部だけの圧縮

+ +

+なにも設定しないと、ebzip は書籍一冊の全体を圧縮しますが、 +--subbook (-S) や --skip-content +(-s) オプションを使うと一部だけを圧縮できます。 +

+ +

+--subbook オプションは引数を一つ取り、そこにカンマ +(,) で区切って、圧縮したい副本のディレクトリ名を並べて +書きます。 +ebinfo コマンドを用いると、あなたの所有している書籍に +どのような副本が含まれているのかを知ることができます。 +

+ +
+
+% ebinfo /mnt/cdrom
+ディスクの形式: EB/EBG/EBXA/EBXA-C/S-EBXA
+文字コード: JIS X 0208
+副本の数: 3
+
+副本 1:
+  題名: 新英和辞典(第四版)
+  ディレクトリ: english
+  検索方式: 前方一致 後方一致 条件 メニュー
+  フォントの大きさ: 16 24 30 48
+  半角フォントの文字: 0xa121 -- 0xa24e
+  全角フォントの文字: 0xa321 -- 0xa27e
+
+副本 2:
+  題名: CD-ROM 仏和辞典(第三版)
+  ディレクトリ: french
+  検索方式: 前方一致 後方一致 条件 メニュー
+  フォントの大きさ: 16 24 30 48
+  半角フォントの文字: 
+  全角フォントの文字: 0xa321 -- 0xa27e
+
+副本 3:
+  題名: ポケット独和辞典(第三版)
+  ディレクトリ: german
+  検索方式: メニュー
+  フォントの大きさ: 16 24 30 48
+  半角フォントの文字: 
+  全角フォントの文字: 0xa321 -- 0xa27e
+
+
+ +

+(ebinfo コマンドに関しての詳細は、 +ebinfo コマンドのマニュアル を参照のこと。) +この例では、3 つの副本が書籍には含まれており、それらのディレクトリ名は +english, french, german +だということが分かります。 +

+ +

+englishgerman だけを圧縮するには、次の +ようにします。 +

+ +
+
+% ebzip --subbook english,french /dict
+
+
+ +

+ディレクトリ名の大文字、小文字の違いは無視されます。 +--subbook の引数は、次のように分けて書くこともできます。 +

+ +
+
+% ebzip --subbook english --subbook french /dict
+
+
+ +

+残りの副本 (この例では german) のファイルは圧縮されることも +コピーされることもありませんので、この時点ではまだこの書籍に対する圧縮の +作業は完了していません。 +この書籍を使用するためには、さらなる操作を行って残りの副本を圧縮するか、 +ebrefile コマンドを使って残りの副本を catalog(s) +ファイルの副本登録リストから削除しなくてはなりません +(ebrefile コマンドについて詳しくは、 +ebrefile コマンド のマニュアル +の「ebzip との連携」項を参照のこと)。 +

+ +

+副本の一部ずつを複数回に分けて圧縮する場合、すべての副本で同じ圧縮レベル +を指定する必要はありません。 +(たとえば、englishfrench はレベル 0 で圧縮し、 +german はレベル 2 で圧縮する)。 +

+ +

+--skip-content (-s) は --subbook +に似ていますが、--skip-content では無視するファイルの +データ型を指定します。 +

+ +
+
+% ebzip --skip-content sound,movie --subbook french /dict
+
+
+ +

+この例では、ebzip は音声と動画ファイルを飛ばします。 +現在のところ、ebzip によって認識されるデータ型は、 +次の通りです。 +

+ +
    +
  • font
    +外字のフォント +
  • graphic
    +画像データ +
  • sound
    +音声データ +
  • movie
    +動画データ +
+ + +

古いファイルの上書き

+ +

+書き込もうとしたファイルがすでに存在するとき、ebzip は +上書きして良いかどうかの確認を求めてきます。 +

+ +
+
+==> /dict/science/data/honmon を圧縮 <==
+/dict/science/data/honmon.ebz に出力
+
+ファイルがすでに存在します: /dict/science/data/honmon.ebz
+上書きしますか (はい:y, いいえ:n)?
+
+
+ +

+yn で答えて下さい。 +n と答えると、ebzip はそのファイルを飛ばして、 +次に進みます。 +

+ +

+--force-overwrite オプションを指定すると、ebzip +はすでに存在しているファイルを、確認なしに上書きします。 +同様に、--no-overwrite オプションを指定すると、 +ebzip は確認なしにそのファイルを飛ばして次に進みます。 +

+ + +

圧縮された書籍の圧縮

+ +

+S-EBXA および EPWING 規格においても圧縮形式を定義しており、CD-ROM 書籍 +にはこれらの圧縮形式を実際に採用しているものがあります。 +これらの圧縮形式は、ebzip の圧縮形式とは異なるものです。 +

+ +

+ebzip は S-EBXA や EPWING 圧縮形式で圧縮された CD-ROM 書籍も +伸長することができますが、圧縮することはできません。 +

+ +

+ebzip に対して、既に圧縮されている CD-ROM 書籍を圧縮するように +命じると、ebzip はいったん書籍を伸長してから、ebzip の圧縮形式で +圧縮し直します。 +

+ +

+一般に ebzip の圧縮形式の方が S-EBXA や EPWING の圧縮形式よりも圧縮率が +良好です。 +

+ + +

伸長

+ +

+ebunzip (ebzip --uncompress、 +ebzipinfo --uncompress と同じ) は、ebzip で +圧縮した CD-ROM 書籍を伸長します。 +

+ + + +

伸長の実行例

+ +

+伸長の処理手順は、圧縮とかなり似ています。 +/dict の下に圧縮された書籍が置かれているものと仮定します。 +この書籍には、/dict の下に次のようなファイルを持っています。 +

+ +
+
+/dict/catalog
+/dict/language.ebz
+/dict/kanji/start.ebz
+/dict/english/start.ebz
+
+
+ +

+この書籍を伸長するには、次のコマンドを実行します。 +

+ +
+
+% cd /dict
+% ebunzip
+
+
+ +

+これは次のようにしても同じです。 +

+ +
+
+% ebunzip --output-directory /dict /dict
+
+
+ +

+伸長には、しばらくかかることがあります。 +伸長の間、ebunzip は、次のように状況を知らせるメッセージを出力 +します。 +

+ +
+
+==> /dict/kanji/start.ebz を伸長 <==
+./kanji/start.ebz に出力
+ 5.1% 処理済み (4194304 / 82460672 バイト)
+10.2% 処理済み (8388608 / 82460672 バイト)
+15.3% 処理済み (12582912 / 82460672 バイト)
+        : (略)
+完了 (82460672 / 82460672 バイト)
+25681439 -> 82460672 バイト
+
+
+ +

+伸長の間、ebunzip は、すでに存在するファイルを上書きしても良いか +どうか確認を求めてきます。 +

+ +
+
+==> /dict/kanji/start.ebz を伸長 <==
+/dict/kanji/start に出力
+
+ファイルがすでに存在します: /dict/kanji/start
+上書きしますか (はい:y, いいえ:n)?
+
+
+ +

+伸長が完了すると、/dict の下のディレクトリ構成は少し変化して +います。 +

+ +
+
+/dict/catalog
+/dict/language
+/dict/kanji/start
+/dict/english/start
+
+
+ +

+伸長されたファイルはファイル名が変化し、 +拡張子 .ebz が取り除かれています。 +

+ + +

伸長のオプション

+ +

+多くのオプションは、圧縮時と伸長時とで同じ意味を持っています。 +

+ +

+--keep オプションを指定すると、ebunzip は、 +伸長した後に圧縮ファイルを削除しなくなります。 +

+ +

+--test オプションを指定すると、ebunzip は伸長 +したデータを実際のファイルには書き込みません。 +このオプションは、ファイルが正しく圧縮されているのかを確認するときに便利 +です +(--test オプションについての詳細は、 +「テスト」を参照のこと)。 +

+ +

+--subbook--skip-content オプションを指定 +すると、条件に合致したファイルだけしか伸長しません +(これらのオプションについての詳細は、 +「一部だけの圧縮」 を参照のこと)。 +

+ +

+--force-overwrite--no-overwrite オプション +を指定すると、ebunzip は上書きしても良いかどうかの確認なしに、 +ファイルを上書きしたり飛ばして次に進んだりします +(--force-overwrite--no-overwrite オプション +についての詳細は、 +「古いファイルの上書き」 を参照のこと)。 +

+ +

+ebunzip は、--level オプションを無視します。 +伸長時に --level オプションを指定する必要はありません。 +

+ + +

圧縮された書籍の伸長

+ +

+S-EBXA および EPWING 規格でも圧縮形式を定義しており、CD-ROM 書籍には +これらの圧縮形式を実際に採用しているものがあります。 +しかし、S-EBXA や EPWINGの圧縮形式は、ebzip の圧縮形式とは異なります。 +

+ +

+ebzip は S-EBXA や EPWING 圧縮形式で圧縮された CD-ROM 書籍も +伸長することができますが、圧縮することはできません。 +

+ +

+S-EBXA 形式で圧縮された START ファイルや、EPWING 形式で圧縮 +された HONMON2, HONMONS ファイルを伸長すると、 +伸長後のファイルには拡張子 .org が付加されます +(例: honmon2honmon2.org)。 +

+ + +

情報出力

+ +

+ebzipinfo (ebzip --information +ebunzip --information と同じ) は CD-ROM 書籍の圧縮状態を出力 +します。 +

+ + + +

情報出力の実行例

+ +

+/dict にある、圧縮された CD-ROM 書籍の情報を出力するには +次のコマンドを実行します。 +/dict に置かれている、圧縮された CD-ROM 書籍の情報を出力 +するには、次のようにします。 +

+ +
+
+% ebzipifo /dict
+
+
+ +

+ebzipinfo は標準出力に次のような情報を出力します。 +

+ +
+
+==> /dict/spanish/spanish/start.ebz <==
+154290176 -> 54881862 バイト (35.6%, ebzip 圧縮レベル 0)
+
+==> /dict/spanish/language.ebz <==
+compressed: 12288 -> 4121 バイト (33.5%, ebzip 圧縮レベル 0)
+
+==> /dict/spanish/catalog <==
+2048 バイト (非圧縮)
+
+
+ + +

情報出力のオプション

+ +

+--subbook--skip-content オプションを +指定すると、条件に合致したファイルの情報だけを出力します +(これらのオプションについての詳細は、 +「一部だけの圧縮」を参照のこと)。 +

+ +

+ebzipinfo--force-overwrite、 +--keep--level--no-overwrite、 +--output-directory--quiet--silence、 +--test オプションを無視します。 +

+ + +

書籍の削除

+ +

+ebzip は、ハードディスク上に圧縮した辞書の削除機能は持って +いません。 +代わりに rm コマンドを使って下さい。 +

+ +
+
+% rm -r /dict
+
+
+ +

+この作業は、注意して行って下さい。 +

+ + +

ebzip のオプション一覧

+ +

+ebzip コマンドは、伝統的な一文字オプション名と覚えやすい長い +オプション名の両方を扱うことができます。 +長いオプション名を表すには、- ではなく -- を +用います。 +オプション名が一意に決まる範囲内で、名前の後方部分を省略することができます。 +

+ +
+
-f
+
--force-overwrite
+
+確認を求めずに、既に存在しているファイルを上書きします。 +このオプションは、情報出力の動作のときや、--test +(-t) オプションを指定したときは無視されます +(詳しくは、「古いファイルの上書き」 を +参照のこと)。 + +
-h
+
--help
+
+ヘルプメッセージを標準出力に出力して、終了します。 + +
-i
+
--information
+
+指定された CD-ROM 書籍の圧縮状態を出力します +(詳しくは、 「情報出力」 を参照のこと)。 + +
-k
+
--keep
+
+出力側のファイルを書き込み終わっても、対応する入力側のファイルは +削除しません。 +このオプションは、情報出力の動作のときや、--test +(-t) オプションを指定したときは無視されます +(詳しくは、「圧縮の実行例 (2)」 +を参照のこと)。 + +
-l 整数
+
--level 整数
+
+圧縮レベルを指定します。 +整数 は、012、 +345 のいずれかでなくては +いけません。 +レベル 0 は、最も速いものの圧縮率は最悪です。 +レベル 3 は、最も遅いものの圧縮率は最良です。 +指定しなかったときのレベルは 0 です。 +このオプションは、圧縮以外の動作のときは無視されます。 +(詳しくは、「圧縮レベル」 を参照のこと。) + +
-n
+
--no-overwrite
+
+既に存在するファイルがあった場合、上書きの確認を求めずに、そのファイル +は飛ばして次のファイルに進みます。 +このオプションは、情報出力の動作のときや、--test +(-t) オプションを指定したときは無視されます。 +(詳しくは、「古いファイルの上書き」 +を参照のこと。) + +
-o ディレクトリ
+
--output-directory ディレクトリ
+
+出力側のファイルを置くディレクトリを指定します。 +指定しなかったときは、カレントディレクトリ (.) になります。 +このオプションは、情報出力の動作のときや、--test +(-t) オプションを指定したときは無視されます + +
-q
+
--quiet
+
--silence
+
+情報、警告メッセージを出力しません。 +ただし、圧縮・伸長時に出力側のファイルが既に存在していると、 +ebzip はその出力側のファイルを上書きして良いかどうか +訊いてきます。 +この質問を抑制するには、--force-overwrite(-f) +または --no-overwrite(-n) を指定して下さい。 +このオプションは、情報出力の動作のときは、無視されます + +
-s
+
--skip-content
+
+無視するファイルのデータ型を指定します。 + は、データ型の名前をカンマ (,) で区切って +並べたものでなくてはいけません。 +ebzip が現在のところ認識するデータ型の名前は、 +font (外字のフォント)、graphic (画像データ)、 +sound (音声データ)、movie (動画データ) です。 +指定しなかったときは、どのファイルも無視されません。 + +
-S 副本
+
--subbook 副本
+
+圧縮・伸長・情報出力の対象とする副本を指定します。 +副本 は、副本のディレクトリ名をカンマ (,) で +区切って並べたものでなくてはいけません。 +指定しなかったときは、すべての副本が対象になります。 +(詳しくは 「一部だけの圧縮」 を参照 +のこと。) + +
-t
+
--test
+
+圧縮・伸長したデータを、実際のファイルには書き込みません。 +このオプションは、情報出力の動作のときは無視されます。 +(詳しくは 「テスト」 を参照のこと。) + +
-u
+
--uncompress
+
+CD-ROM 書籍を伸長します。 +(詳しくは 「伸長」 を参照のこと。) + +
-v
+
--version
+
+バージョン番号を標準出力に出力して、終了します。 + +
-z
+
--compress
+
+CD-ROM 書籍を圧縮します。 +(詳しくは 「圧縮」 を参照のこと。) + +
+ + +

圧縮結果の例

+ +

+次の表は、ある英和・和英辞典 (EBXA) の START ファイルを +圧縮した結果: +

+ + + + + + + + + +
圧縮レベル ファイルサイズ 圧縮率
(元のファイル) 154476544 bytes 100.0%
レベル 0 54922039 bytes 35.6%
レベル 1 49615791 bytes 32.1%
レベル 2 45983464 bytes 29.8%
レベル 3 43431397 bytes 28.1%
(参考: gzip -6) 38712247 bytes 25.0%
+ +

+ある英々辞典 (EBG) の START ファイルを圧縮した結果: +

+ + + + + + + + + +
圧縮レベル ファイルサイズ 圧縮率
(元のファイル) 55511040 bytes 100.0%
レベル 0 25866491 bytes 46.6%
レベル 1 24419066 bytes 44.0%
レベル 2 23453212 bytes 42.2%
レベル 3 22748840 bytes 41.0%
(参考: gzip -6) 20930009 bytes 37.7%
+ +

+ある国語辞典 (EPWING V1) の HONMON ファイルを圧縮した結果: +

+ + + + + + + + + +
圧縮レベル ファイルサイズ 圧縮率
(元のファイル) 23642112 bytes 100.0%
レベル 0 9927048 bytes 42.0%
レベル 1 9213184 bytes 39.0%
レベル 2 8767603 bytes 37.1%
レベル 3 8495563 bytes 35.9%
(参考: gzip -6) 8114658 bytes 34.3%
+ +

+ある国語辞典 (EPWING V5) の HONMON2 ファイルを圧縮した結果: +

+ + + + + + + +
圧縮レベル ファイルサイズ 圧縮率
(非圧縮) 220069888 bytes 100.0%
(元のファイル) 149139690 bytes 67.8%
レベル 0 82973263 bytes 37.7%
レベル 1 78163751 bytes 35.5%
+ +

+ある百科事典 (S-EBXA) の START ファイルを圧縮した結果: +

+ + + + + + + +
圧縮レベル file size ratio
(非圧縮) 225140735 bytes 100.0%
(元のファイル) 176467968 bytes 78.4%
レベル 0 146045331 bytes 64.9%
レベル 1 138137218 bytes 61.4%
+ + +

圧縮ファイルの形式

+ +

+この章では、ebzip が扱っている圧縮ファイル形式の詳細について説 +明します。 +

+ + +

圧縮ファイル形式の概要

+ +

+圧縮ファイル形式は次のような特徴を持っています。 +

+ +
    +
  • CPU の種類、オペレーティングシステム、ファイルシステムに依存しません。 + +
  • 非損失圧縮です。
    +圧縮ファイルを伸長することによって、元のファイルを復元できます。 + +
  • 6 つの圧縮レベルがあります。
    +伸長の速さか圧縮率の良さの、いずれかを選ぶことができます。 +
+ +

+圧縮されたファイルは、ヘッダ部、インデックス部、およびデータ部から構成 +され、この順でファイルに配置されます。 +

+ +
+
++--------+-------------+-----------------------------+
+| ヘッダ |インデックス |          データ             |
++--------+-------------+-----------------------------+
+                                                     EOF
+
+
+ + +

データ部

+ +

+元のファイルは、次の行程で圧縮されます。 +

+ +

+まず、ebzip は元のファイルを分割します。 +個々の スライス (slice) は、末尾のものを除けば、 +同じ大きさになっています。 +

+ +
+
++---------------+---------------+--   --+----------+
+|  スライス 1   |  スライス 2   |  ...  |スライス N|
++---------------+---------------+--   --+----------+
+                                                  EOF
+
+
+ +

+スライス・サイズは、圧縮レベルから決まります +(圧縮レベルについては 「圧縮レベル」を +参照のこと)。 +

+ + + + + + + + + +
圧縮レベル スライスの大きさ
0 2048 バイト
1 4096 バイト
2 8192 バイト
3 16384 バイト
4 32768 バイト
5 65536 バイト
+ +

+次に、末尾のスライスがスライス・サイズよりも短かった場合、 +ebzip はスライス・サイズと同じになるまで伸ばし、伸ばした +部分に 0x00 を埋めます。 +

+ +
+
+                                                 伸した部分
++---------------+---------------+--   --+---------+-----+
+|  スライス 1   |  スライス 2   |  ...  |  スライス N   |
++---------------+---------------+--   --+---------+-----+
+                                                        EOF
+
+
+ +

+最後に、ebzip は個々のスライスを、RFC 1951 に記されている +DEFLATE 圧縮データ形式で圧縮します。 +おのおののスライスは、他のスライスとは独立して圧縮されます。 +圧縮されたスライスのビット数が 8 の倍数でなければ、1 〜 7 ビットを圧 +縮されたスライスの末尾に足し、8 の倍数になるようにします。 +これにより、圧縮されたそれぞれのスライスはバイトの境界から開始されます。 +足されたビットの内容は未定義ですが、このビットは決して使用されません。 +

+ +
+
++------------+----------+--   --+--------------+
+| 圧縮された |圧縮された|  ...  |  圧縮された  |
+| スライス 1 |スライス 2|  ...  |  スライス N  |
++------------+----------+--   --+--------------+
+
+
+ +

+これが圧縮ファイル形式における データ部 になり、圧縮された +スライスから構成されます。 +

+ +

+末尾のスライスの伸ばした部分は、末尾のスライスの一部として圧縮され +ます。 +ebunzip が末尾のスライスを復元するときは、スライスを伸長して +から伸ばした部分を取り除くという作業を行います。 +

+ +

+圧縮したスライスの大きさが、スライス・サイズよりも大きいか等しいときは、 +ebzip はそのスライスの圧縮データを廃棄します。 +この場合、ebzip は元のデータをそのスライスの圧縮データとして +代わりに記録します。 +

+ +

+元のファイルが空だったときは、圧縮ファイルのデータ部はありません。 +

+ + +

インデックス部

+ +

+圧縮時に、ebzip は圧縮した個々のスライスの +インデックス (index) を記録します。 +個々のインデックスは、圧縮ファイルの先頭から圧縮されたスライスの先頭 +までの距離を表します。 +距離の単位はバイトです。 +

+ +
+
++---------+---------+--           --+---------+---------+
+|インデッ |インデッ |  ...........  |インデッ |インデッ |
+|クス 1   |クス 2   |  ...........  |クス N   |クス END |
++---------+---------+--           --+---------+---------+
+     |         |                        |         |
+ +---+         +----+                   +------+  +-----------+
+ V                  V                          V              V
++------------------+------------------+--   --+--------------+
+|    圧縮された    |    圧縮された    |  ...  |  圧縮された  |
+|    スライス 1    |    スライス 2    |  ...  |  スライス N  |
++------------------+------------------+--   --+--------------+
+
+
+ +

+個々のインデックスは 2 〜 5 バイトの大きさを持ちます。 +インデックスの大きさは、元のファイルの大きさで決まります。 +

+ + + + + + + +
元のファイルの大きさ インデックスの大きさ
0 〜 65535 バイト 2 バイト
65535 〜 16777215 バイト 3 バイト
16777216 〜 4294967295 バイト 4 バイト
4294967296 〜 1099511627775 バイト 5 バイト
+ +

+インデックス内での、複数バイトからなる数値はすべて、値の大きい方の部分 +を表すバイト (most significant byte) が先に来た形で記録されます。 +たとえば、0x1234 は次のように記録されます。 +最初のバイトは 0x12 となり、次のバイトは 0x34 になります。 +

+ +
+
++---------+---------+
+|0001 0010|0011 0100|
++---------+---------+
+  (0x12)    (0x34)
+
+
+ +

+インデックス部は、圧縮されたスライス 1 のインデックスで始まり、その後ろ +に圧縮されたスライス 2 のインデックスが続きます。 +圧縮されたスライス N のインデックスの後ろには、「終端」へのインデックス +が置かれます。 +このインデックスは、圧縮されたスライス N の末尾の次のバイトへの +インデックスになります。 +また、圧縮されたファイルのサイズを示すことにもなります。 +

+ +
+
++---------+---------+--           --+---------+---------+
+|インデッ |インデッ |  ...........  |インデッ |インデッ |
+|クス 1   |クス 2   |  ...........  |クス N   |クス END |
++---------+---------+--           --+---------+---------+
+
+
+ +

+圧縮されたスライスの大きさがスライスサイズに等しいときは、そのスライス +のデータは実際には圧縮されていないことを示します。 +

+ +

+元のファイルが空だったときは、インデックス部はインデックスを一つだけ +持ちます。 +このインデックスは圧縮されたファイルの大きさを表します。 +

+ + +

ヘッダ部

+ +

+ヘッダ部は 22 バイトからなります。 +次のフィールドから構成されます。 +

+ +
+
++--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+| マジック ID  |*1| *2  |ファイルの大きさ | Adler-32  | 修正時刻  |
++--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ 0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17 18 19 20 21
+
+*1: zip モードと圧縮レベル
+*2: 予約領域
+
+
+ +
+
マジック ID (5 バイト)
+
+0x45, 0x42, 0x5a, 0x69, 0x70 (ASCII 文字列で表すと EBZip) +という固定した値を持ちます。 + +
zip モード (MSB 側の 4 ビット)
+
+圧縮モードを表します。 +元の (非圧縮時の) ファイルの大きさが 4294967295 バイト (= 4Gバイト) +以内のときは 1 (2 進数で 0001)、それより大きいときは 2 (2 進数で 0002) +をセットします。 + +

+ファイルの大きさで値が変わるのは、歴史的な事情によります。 +以前の EB Library は圧縮モード 1 しか既定しておらず、また 4GB バイト +を超えるファイルを扱えませんでした。 +4G バイトを超えるファイルを扱えるように EB Library を改良した際に、 +「4G バイトを超えたら、圧縮モードは 2 にセットする」というルールを +新たに設けました。 +これにより、以前の EB Library で 4GB バイトを超えたファイルを扱おう +とすると、非対応の圧縮モードとみなされ、エラーが発生するようになって +います。 +

+ +
圧縮レベル (LSB 側の 4 ビット)
+
+圧縮レベルを表します。 + +
予約領域 (2 バイト)
+
+予約されていますが、使われていません。 +0x0000 で埋められます。 + +
ファイルの大きさ (6 バイト)
+
+元の (非圧縮時の) ファイルの大きさを記録しています。 + +
Adler-32 (4 バイト)
+
+RFC 1950 に記されている Adler-32 というアルゴリズムを用いて計算した、 +非圧縮データのチェックサムの値です。 + +
修正時刻 (4 バイト)
+
+元のファイルの最終修正時刻です。 +グリニッジ標準時の 1970 年 1 月 1 日 0 時 0 分 0 秒からの経過秒数で +表します。 +
+ +

+zip モード圧縮レベル は、両方ともヘッダの +5 バイト目に入ります。 +zip モード は、値の最も大きい部分を表すビット +(most significant bit) を含み、圧縮レベル は最も小さい部分を +表すビット (least significant bit) を含んでいます。 +zip モード が 1 で、圧縮レベル が 2 なら、 +ヘッダの 5 バイト目は 0x12 になります。 +

+ +
+
+ MSB                         LSB
++---+---+---+---+---+---+---+---+
+| 0   0   0   1   0   0   1   0 | = 0x12
++---+---+---+---+---+---+---+---+
+  (zip モード)  |  (圧縮レベル)
+
+
+ +

+ヘッダ内での、複数バイトからなる数値はすべて、値の大きい方の部分 +を表すバイト (most significant byte) が先に来た形で記録されます。 +

+ + + diff --git a/doc/html-include b/doc/html-include new file mode 100755 index 0000000..9b95750 --- /dev/null +++ b/doc/html-include @@ -0,0 +1,211 @@ +#! /usr/bin/perl +# +# Copyright (c) 2005-2006 Motoyuki Kasahara +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +# +# html-include -- tiny file inclusion processoor for HTML. +# +# Usage: +# html-include [-o output-file] [input-file] +# +# `html-include' extracts file inclusion directives in HTML, and output +# the result. The following is file inclusion directive line that +# `html-include' recognizes: +# +# +# +# Note that "[ \t]*$|) { + # + # This is file inclusion directive line. + # + if (++$i >= $max_nest_level) { + die "$0: too deep inclusion\n"; + } + + $in_files[$i] = {'handle' => new FileHandle, + 'name' => search_file($1), + 'lineno' => 0}; + if (!$in_files[$i]->{handle}->open('<' . $in_files[$i]->{name})) { + die "$0: failed to open the file, $!: " . + $in_files[$i]->{name} . "\n"; + } + + if ($comment_mode) { + print $out_file->{handle}->printf("\n", + $in_files[$i]->{name}, + $in_files[$i]->{lineno} + 1); + } + } else { + $out_file->{handle}->print($_, "\n"); + } + + $out_file->{lineno}++; + } + + $in_files[$i]->{handle}->close(); + last if (--$i < 0); + + if ($comment_mode) { + $out_file->{handle}->printf("\n", + $in_files[$i]->{name}, + $in_files[$i]->{lineno} + 1); + } +} + + +sub search_file ($) { + my ($file) = @_; + + foreach my $dir (@search_paths) { + return "$dir/$file" if (-r "$dir/$file"); + } + + return $file; +} diff --git a/doc/html-index b/doc/html-index new file mode 100755 index 0000000..0d284d2 --- /dev/null +++ b/doc/html-index @@ -0,0 +1,157 @@ +#! /usr/bin/perl +# +# Copyright (c) 2005 Motoyuki Kasahara +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +# +# html-index -- make index page of HTML files. +# +# Usage: +# html-index [option...] input-file... +# +# `html-index' reads HTML files, and generates their indice. The indice +# are created from tags in the HTML files. Since `html-index' +# doesn't parse HTML precisely, `<' and `>' in tag must be in the same +# line and be the following form: +# +# +# +# The corresponding reference in the index looks like: +# +# name +# +# or, if two or more input files are specified: +# +# name +# +# `category' above is category name of index. It is used to generate +# more than one indice: function index and concept index, for example. +# By default, the script generates `index-.html' for each index +# category. +# +# In input HTML files, the following line has the special meaning: +# +# +# +# It sets file name in in the indice. +# +# Options: +# -p prefix set prefix of index files. +# (default: `index-') +# -s suffix set suffix of index files. +# (default: `html') +# -h do not output file name in . +# + +require 5.005; +use Getopt::Std; + +# +# Usage +# +my $usage = "Usage: $0 [-p prefix] [-s suffix] [-h] file...\n"; + +# +# Variables +# +my $out_prefix = 'index'; +my $out_suffix = 'html'; +my %indice = (); +my $fragment_only = 0; + +# +# Parse command line arguments. +# +my %options; +getopts('p:s:h', \%options) or die $usage; +die $usage if (@ARGV == 0); + +$out_prefix = $options{p} if (defined($options{p})); +$out_suffix = $options{s} if (defined($options{s})); +$fragment_only = 1 if (defined($options{h}) || @ARGV == 1); + +# +# Read HTML files. +# +for (my $i = 0; $i < @ARGV; $i++) { + my $in_file_name = $ARGV[$i]; + if (!open(IN_FILE, "< $in_file_name")) { + die "$0: failed to open the file, $!: $in_file_name\n"; + } + + while () { + chomp; + if (m|^[ \t]*$|) { + $in_file_name = $1; + } elsif (m||) { + my $name = $1; + if ($name =~ m|^([a-z_][0-9a-z_]+):(.+)$|) { + my $type = $1; + my $value = $2; + if (!defined($indice{$type})) { + $indice{$type} = {}; + } + $indice{$type}->{$value} = $in_file_name; + } + } + } + + close(IN_FILE); +} + +# +# Generate index files. +# +foreach my $i (sort {uc($a) cmp uc($b)} keys(%indice)) { + my $out_file_name = sprintf("%s-%s.%s", $out_prefix, $i, $out_suffix); + + if (!open(OUT_FILE, "> $out_file_name")) { + die "$0: failed to open the file, $!: $out_file_name\n"; + } + + print OUT_FILE "
\n"; + my $prev_head_char = ''; + + foreach my $j (sort(keys(%{$indice{$i}}))) { + my $cur_head_char = uc(substr($j, 0, 1)); + if ($cur_head_char ne $prev_head_char) { + print OUT_FILE '
', $cur_head_char, "\n"; + } + + if ($fragment_only) { + printf(OUT_FILE "
%s\n", + $i, $j, $j); + } else { + printf(OUT_FILE "
%s\n", + $indice{$i}->{$j}, $i, $j, $j); + } + $prev_head_char = $cur_head_char; + } + + print OUT_FILE "
\n"; + close(OUT_FILE); +} diff --git a/doc/html-split b/doc/html-split new file mode 100755 index 0000000..d95eeb7 --- /dev/null +++ b/doc/html-split @@ -0,0 +1,238 @@ +#! /usr/bin/perl +# +# Copyright (c) 2005-2006 Motoyuki Kasahara +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +# +# html-split -- split an HTML file. +# +# Usage: +# html-split [option...] input-file +# +# `html-split' splits an HTML file with heading tags (

...

). +# Suppose that `input-file' is `foo.html', HTML files splitted by +# `html-split' are `foo-0.html', `foo-1.html', and so on. +# +# Options: +# -Z do not add `-0' to the first split. +# -l LEVEL split with this heading level +# (default: h2) +# -p PREFIX prefix of splitted HTML files. +# -s SUFFIX suffix of splitted HTML files. +# (default: html) +# -w WIDTH minimum width of split number. +# (default: 1) +# -t TOC fragment name of `Table of Contents'. +# (default: toc) +# + +require 5.005; +use Getopt::Std; +use File::Basename; + +# +# Usage +# +my $usage = "Usage: $0 [option...] input-file\n"; + +# +# Variables +# +my $in_file; +my $out_prefix; +my $out_suffix; +my $counter_width = 1; +my $split_level = 2; +my $toc_tag = 'toc'; +my $supress_zero_flag = 0; + +my @toc = (); +my @indice = (); +my @preamble = (); +my $toc_page = 0; + +# +# Parse command line arguments. +# +my %options; +getopts('Zl:w:p:s:t:', \%options) or die $usage; +die $usage if (@ARGV != 1); + +$in_file = $ARGV[0]; +if (defined($options{l})) { + $options{l} =~ s/^h//; + $split_level = $options{l}; +} +$counter_width = $options{w} if (defined($options{w})); +$supress_zero_flag = defined($options{Z}); +$toc_tag = $options{t} if (defined($options{t})); + +if (defined($options{p})) { + $out_prefix = $options{p}; +} else { + $out_prefix = basename($in_file, '.htm', '.html'); +} + +if (defined($options{s})) { + $out_suffix = $options{s}; +} elsif ($in_file =~ m|\.htm$|) { + $out_suffix = 'htm'; +} else { + $out_suffix = 'html'; +} + +# +# Read an HTML file. +# +if (!open(IN_FILE, "< $in_file")) { + die "$0: failed to open the file, $!: $in_file\n"; +} + +my $toc_found = 0; +my $page = 0; + +while () { + last if (m|^|); + push(@preamble, $_); +} + +while () { + chomp; + last if (m|^|); + if (m|^| && $1 <= $split_level) { + $page++ if (@toc > 0); + push(@toc, $_); + } + if (m||) { + my $tag = $1; + if ($tag eq $toc_tag) { + $toc_page = $page; + $toc_found = 1; + } + push(@indice, {'tag' => $tag, 'page' => $page}); + } +} + +close(IN_FILE); + +if (!$toc_found) { + die "$0: not found\n"; +} + +# +# Generate splitted HTML files. +# +if (!open(IN_FILE, "< $in_file")) { + die "$0: failed to open the file, $!: $in_file\n"; +} + +while () { + last if (m|^|); +} + +for (my $page = 0; $page < @toc; $page++) { + my $bar = ''; + if ($page > 0) { + $bar .= sprintf("[前へ] ", + splitted_file_name($page - 1)); + } + + if ($page + 1 < @toc) { + $bar .= sprintf("[次へ] ", + splitted_file_name($page + 1)); + } + + $bar .= sprintf("[目次] ", + splitted_file_name($toc_page), $toc_tag); + + my $out_file = splitted_file_name($page); + if (!open(OUT_FILE, "> $out_file")) { + die "$0: failed to open the file, $!: $out_file\n"; + } + + foreach my $j (@preamble) { + print OUT_FILE $j; + } + + print OUT_FILE "\n"; + print OUT_FILE "

\n", $bar, "\n

\n
\n"; + print OUT_FILE $toc[$page], "\n"; + + for (;;) { + $_ = ; + chomp; + if (!defined($_) || m|^|) { + 1 while (); + last; + } + elsif (m|^| && $1 <= $split_level) { + next if ($page == 0 && $_ eq $toc[$page]); + last; + } + 1 while (s||&rewrite_href($1)|e); + print OUT_FILE $_, "\n"; + } + + print OUT_FILE "
\n

\n", $bar, "\n

\n"; + print OUT_FILE "\n"; + print OUT_FILE "\n"; + + close(OUT_FILE); +} + +close(IN_FILE); + +# +# Return n'th splitted file name. +# +sub splitted_file_name ($) { + my ($n) = @_; + + if ($n == 0 && $supress_zero_flag) { + return sprintf("%s.%s", $out_prefix, $out_suffix); + } else { + return sprintf("%s-%0${counter_width}d.%s", + $out_prefix, $n, $out_suffix); + } +} + +# +# Rewrite
. +# +sub rewrite_href ($) { + my ($tag) = @_; + + for (my $i = 0; $i < @indice; $i++) { + if ($indice[$i]->{tag} eq $tag) { + return sprintf("", + splitted_file_name($indice[$i]->{page}), $tag); + } + } + + warn "$0: unknown tag \`$tag'\n"; + return ""; +} diff --git a/doc/html-toc b/doc/html-toc new file mode 100755 index 0000000..3e5828f --- /dev/null +++ b/doc/html-toc @@ -0,0 +1,151 @@ +#! /usr/bin/perl +# +# Copyright (c) 2005-2006 Motoyuki Kasahara +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +# +# html-toc -- make `table of contents' of HTML files. +# +# Usage: +# html-index [option...] input-file... +# +# `html-toc' reads HTML files, and generates `table of contents' (TOC) +# of the HTML files. The TOC is created from

...

tags and +# tag in the HTML files. Since `html-toc' doesn't parse +# HTML precisely, the tags must be the following form: +# +# heading +# +# where `?' is 1..6. Note that and above must be in the same +# line. +# +# `html-toc' outputs TOC to standard out by default. +# +# Options: +# -o file specify output file. +# -h do not output file name in . +# -m level minimum target heading level +# (default: h1) +# -M level maximum target heading level +# (default: h6) + +require 5.005; +use Getopt::Std; + +# +# Usage +# +my $usage = "Usage: $0 [option...] input-file...\n"; + +# +# Variables +# +my $out_file = '-'; +my @preamble = (); +my $fragment_only = 0; +my $min_level = 1; +my $max_level = 6; + +# +# Parse command line arguments. +# +my %options; +getopts('o:hm:M:', \%options) or die $usage; +die $usage if (@ARGV == 0); + +$fragment_only = 1 if (defined($options{h}) || @ARGV == 1); +$out_file = $options{o} if (defined($options{o})); +if (defined($options{m})) { + $options{m} =~ s/^h//; + $min_level = $options{m}; +} +if (defined($options{M})) { + $options{M} =~ s/^h//; + $max_level = $options{M}; +} + +# +# Read an HTML file. +# +$current_level = $min_level; + +if ($out_file eq '-') { + $out_file = 'stdout'; + open(OUT_FILE, ">& STDOUT"); +} else { + if (!open(OUT_FILE, "> $out_file")) { + die "$0: failed to open the file, $!: $out_file\n"; + } +} + +print OUT_FILE "\n"; + } + while ($current_level < $level) { + print OUT_FILE ' ' x ($current_level - $min_level + 1); + print OUT_FILE "
    \n"; + $current_level++; + } + + print OUT_FILE ' ' x ($current_level - $min_level + 1); + if ($fragment_only) { + print OUT_FILE sprintf("
  • %s\n", + $tag, $heading); + } else { + print OUT_FILE sprintf("
  • %s\n", + $in_file, $tag, $heading); + } + } + } + + close(IN_FILE); +} + +while ($current_level > $min_level) { + $current_level--; + print OUT_FILE ' ' x ($current_level - $min_level + 1); + print OUT_FILE "
\n"; +} + +print OUT_FILE "\n"; + +close(OUT_FILE); diff --git a/eb.conf.in b/eb.conf.in new file mode 100644 index 0000000..e968677 --- /dev/null +++ b/eb.conf.in @@ -0,0 +1,53 @@ +# +# Installation status of EB Library. +# + +# Version. +EBCONF_VERSION="@VERSION@" + +# EB Libarry include files are in DIR. +# (--with-eb-includes) +EBCONF_EBINCS="@EBCONF_EBINCS@" + +# EB Libarry files are in DIR. +# (--with-eb-libraries) +EBCONF_EBLIBS="@EBCONF_EBLIBS@" + +# zlib include files are in DIR. +# (--with-zlib-includes) +EBCONF_ZLIBINCS="@EBCONF_ZLIBINCS@" + +# zlib libarry files are in DIR. +# (--with-zlib-libraries) +EBCONF_ZLIBLIBS="@EBCONF_ZLIBLIBS@" + +# pthread is supported or not. +# (--enable-pthread) +EBCONF_ENABLE_PTHREAD="@ENABLE_PTHREAD@" + +# additional CPPFLAGS for pthread support +# (--with-pthread-cppflags) +EBCONF_PTHREAD_CPPFLAGS="@PTHREAD_CPPFLAGS@" + +# additional CFLAGS for pthread support +# (--with-pthread-cflags) +EBCONF_PTHREAD_CFLAGS="@PTHREAD_CFLAGS@" + +# additional LDFLAGS for pthread support +# (--with-pthread-ldflags) +EBCONF_PTHREAD_LDFLAGS="@PTHREAD_LDFLAGS@" + +# native language is supported or not. +# (--enable-nls) +EBCONF_ENABLE_NLS="@ENABLE_NLS@" + +# gettext include files are in DIR. +# (--with-gettext-includes) +EBCONF_INTLINCS="@EBCONF_INTLINCS@" + +# gettext library files are in DIR. +# (--with-gettext-libraries) +EBCONF_INTLLIBS="@EBCONF_INTLLIBS@" + +# remote access is supported or not. +EBCONF_ENABLE_EBNET="@ENABLE_EBNET@" diff --git a/eb/Makefile.am b/eb/Makefile.am new file mode 100644 index 0000000..4a2738a --- /dev/null +++ b/eb/Makefile.am @@ -0,0 +1,77 @@ +lib_LTLIBRARIES = libeb.la + +if ENABLE_EBNET +libeb_ebnet_sources = ebnet.c multiplex.c linebuf.c urlparts.c getaddrinfo.c \ + dummyin6.c +else +libeb_ebnet_sources = +endif + +libeb_la_SOURCES = appendix.c appsub.c bcd.c binary.c bitmap.c book.c \ + booklist.c copyright.c cross.c eb.c endword.c error.c exactword.c \ + filename.c font.c hook.c jacode.c keyword.c lock.c log.c match.c \ + menu.c multi.c narwalt.c narwfont.c readtext.c search.c setword.c \ + stopcode.c strcasecmp.c subbook.c text.c widealt.c widefont.c word.c \ + zio.c $(libeb_ebnet_sources) +libeb_la_LDFLAGS = -no-undefined -version-info @LIBEB_VERSION_INFO@ \ + $(ZLIBLIBS) $(INTLLIBS) + +dist_pkginclude_HEADERS = appendix.h binary.h booklist.h defs.h eb.h error.h \ + font.h text.h zio.h +nodist_pkginclude_HEADERS = sysdefs.h +dist_noinst_HEADERS = build-pre.h dummyin6.h ebnet.h getaddrinfo.h linebuf.h \ + urlparts.h +nodist_noinst_HEADERS = build-post.h + +INCLUDES = -DEB_BUILD_LIBRARY $(INTLINCS) $(ZLIBINCS) + +EXTRA_DIST = stamp-widealt-h stamp-widefont-h build-post.h.in +CLEANFILES = stamp-build-post-h stamp-sysdefs-h build-post.h sysdefs.h +MAINTAINERCLEANFILES = stamp-widealt-h stamp-widefont-h widealt.c widefont.c +BUILT_SOURCES = build-post.h sysdefs.h widealt.c widefont.c + +sysdefs.h: stamp-sysdefs-h +stamp-sysdefs-h: Makefile + rm -f sysdefs.h.tmp + echo '/* automatically generated by Makefile. */' > sysdefs.h.tmp + echo '#define EB_VERSION_STRING "$(VERSION)"' >> sysdefs.h.tmp + echo '#define EB_VERSION_MAJOR $(EB_VERSION_MAJOR)' >> sysdefs.h.tmp + echo '#define EB_VERSION_MINOR $(EB_VERSION_MINOR)' >> sysdefs.h.tmp + if test X$(ENABLE_EBNET) = Xyes; then \ + echo '#define EB_ENABLE_EBNET 1' >> sysdefs.h.tmp; \ + fi + if test X$(ENABLE_PTHREAD) = Xyes; then \ + echo '#define EB_ENABLE_PTHREAD 1' >> sysdefs.h.tmp; \ + fi + $(top_srcdir)/move-if-change sysdefs.h.tmp sysdefs.h + @echo timestamp > stamp-sysdefs-h + +build-post.h: stamp-build-post-h +stamp-build-post-h: build-post.h.in Makefile + rm -f build-post.h.tmp + echo '/* automatically generated from build-post.h.in. */' \ + > build-post.h + sed -e 's;\@localedir\@;$(localedir);' \ + $(srcdir)/build-post.h.in >> build-post.h.tmp + $(top_srcdir)/move-if-change build-post.h.tmp build-post.h + @echo timestamp > stamp-build-post-h + +widealt.c: stamp-widealt-h +stamp-widealt-h: narwalt.c Makefile + rm -f widealt.c.tmp + echo '/* automatically generated from narwalt.c. */' \ + > widealt.c.tmp + sed -e s/narrow/wide/g -e s/Narrow/Wide/g -e s/NARROW/WIDE/g \ + $(srcdir)/narwalt.c >> widealt.c.tmp + $(top_srcdir)/move-if-change widealt.c.tmp widealt.c + @echo timestamp > stamp-widealt-h + +widefont.c: stamp-widefont-h +stamp-widefont-h: narwfont.c Makefile + rm -f widefont.c.tmp + echo '/* automatically generated from narwfont.c. */' \ + > widefont.c.tmp + sed -e s/narrow/wide/g -e s/Narrow/Wide/g -e s/NARROW/WIDE/g \ + $(srcdir)/narwfont.c >> widefont.c.tmp + $(top_srcdir)/move-if-change widefont.c.tmp widefont.c + @echo timestamp > stamp-widefont-h diff --git a/eb/Makefile.in b/eb/Makefile.in new file mode 100644 index 0000000..4d6b638 --- /dev/null +++ b/eb/Makefile.in @@ -0,0 +1,681 @@ +# Makefile.in generated by automake 1.10.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = eb +DIST_COMMON = $(dist_noinst_HEADERS) $(dist_pkginclude_HEADERS) \ + $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/in6addr.m4 $(top_srcdir)/m4/largefile.m4 \ + $(top_srcdir)/m4/lcmessage.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/sockaddrin6.m4 \ + $(top_srcdir)/m4/sockinttypes.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgincludedir)" \ + "$(DESTDIR)$(pkgincludedir)" +libLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(lib_LTLIBRARIES) +libeb_la_LIBADD = +am__libeb_la_SOURCES_DIST = appendix.c appsub.c bcd.c binary.c \ + bitmap.c book.c booklist.c copyright.c cross.c eb.c endword.c \ + error.c exactword.c filename.c font.c hook.c jacode.c \ + keyword.c lock.c log.c match.c menu.c multi.c narwalt.c \ + narwfont.c readtext.c search.c setword.c stopcode.c \ + strcasecmp.c subbook.c text.c widealt.c widefont.c word.c \ + zio.c ebnet.c multiplex.c linebuf.c urlparts.c getaddrinfo.c \ + dummyin6.c +@ENABLE_EBNET_TRUE@am__objects_1 = ebnet.lo multiplex.lo linebuf.lo \ +@ENABLE_EBNET_TRUE@ urlparts.lo getaddrinfo.lo dummyin6.lo +am_libeb_la_OBJECTS = appendix.lo appsub.lo bcd.lo binary.lo bitmap.lo \ + book.lo booklist.lo copyright.lo cross.lo eb.lo endword.lo \ + error.lo exactword.lo filename.lo font.lo hook.lo jacode.lo \ + keyword.lo lock.lo log.lo match.lo menu.lo multi.lo narwalt.lo \ + narwfont.lo readtext.lo search.lo setword.lo stopcode.lo \ + strcasecmp.lo subbook.lo text.lo widealt.lo widefont.lo \ + word.lo zio.lo $(am__objects_1) +libeb_la_OBJECTS = $(am_libeb_la_OBJECTS) +libeb_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(libeb_la_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libeb_la_SOURCES) +DIST_SOURCES = $(am__libeb_la_SOURCES_DIST) +dist_pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER) +nodist_pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(dist_noinst_HEADERS) $(dist_pkginclude_HEADERS) \ + $(nodist_noinst_HEADERS) $(nodist_pkginclude_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +EBCONF_EBINCS = @EBCONF_EBINCS@ +EBCONF_EBLIBS = @EBCONF_EBLIBS@ +EBCONF_INTLINCS = @EBCONF_INTLINCS@ +EBCONF_INTLLIBS = @EBCONF_INTLLIBS@ +EBCONF_ZLIBINCS = @EBCONF_ZLIBINCS@ +EBCONF_ZLIBLIBS = @EBCONF_ZLIBLIBS@ +EB_VERSION_MAJOR = @EB_VERSION_MAJOR@ +EB_VERSION_MINOR = @EB_VERSION_MINOR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_EBNET = @ENABLE_EBNET@ +ENABLE_NLS = @ENABLE_NLS@ +ENABLE_PTHREAD = @ENABLE_PTHREAD@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +ICONVINCS = @ICONVINCS@ +ICONVLIBS = @ICONVLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLINCS = @INTLINCS@ +INTLLIBS = @INTLLIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBEB_VERSION_INFO = @LIBEB_VERSION_INFO@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAILING_ADDRESS = @MAILING_ADDRESS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_CPPFLAGS = @PTHREAD_CPPFLAGS@ +PTHREAD_LDFLAGS = @PTHREAD_LDFLAGS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +ZLIBDEPS = @ZLIBDEPS@ +ZLIBINCS = @ZLIBINCS@ +ZLIBLIBS = @ZLIBLIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgdocdir = @pkgdocdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +lib_LTLIBRARIES = libeb.la +@ENABLE_EBNET_FALSE@libeb_ebnet_sources = +@ENABLE_EBNET_TRUE@libeb_ebnet_sources = ebnet.c multiplex.c linebuf.c urlparts.c getaddrinfo.c \ +@ENABLE_EBNET_TRUE@ dummyin6.c + +libeb_la_SOURCES = appendix.c appsub.c bcd.c binary.c bitmap.c book.c \ + booklist.c copyright.c cross.c eb.c endword.c error.c exactword.c \ + filename.c font.c hook.c jacode.c keyword.c lock.c log.c match.c \ + menu.c multi.c narwalt.c narwfont.c readtext.c search.c setword.c \ + stopcode.c strcasecmp.c subbook.c text.c widealt.c widefont.c word.c \ + zio.c $(libeb_ebnet_sources) + +libeb_la_LDFLAGS = -no-undefined -version-info @LIBEB_VERSION_INFO@ \ + $(ZLIBLIBS) $(INTLLIBS) + +dist_pkginclude_HEADERS = appendix.h binary.h booklist.h defs.h eb.h error.h \ + font.h text.h zio.h + +nodist_pkginclude_HEADERS = sysdefs.h +dist_noinst_HEADERS = build-pre.h dummyin6.h ebnet.h getaddrinfo.h linebuf.h \ + urlparts.h + +nodist_noinst_HEADERS = build-post.h +INCLUDES = -DEB_BUILD_LIBRARY $(INTLINCS) $(ZLIBINCS) +EXTRA_DIST = stamp-widealt-h stamp-widefont-h build-post.h.in +CLEANFILES = stamp-build-post-h stamp-sysdefs-h build-post.h sysdefs.h +MAINTAINERCLEANFILES = stamp-widealt-h stamp-widefont-h widealt.c widefont.c +BUILT_SOURCES = build-post.h sysdefs.h widealt.c widefont.c +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu eb/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu eb/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libeb.la: $(libeb_la_OBJECTS) $(libeb_la_DEPENDENCIES) + $(libeb_la_LINK) -rpath $(libdir) $(libeb_la_OBJECTS) $(libeb_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/appendix.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/appsub.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bcd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/binary.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bitmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/book.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/booklist.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copyright.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cross.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dummyin6.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eb.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ebnet.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/endword.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exactword.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filename.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/font.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getaddrinfo.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hook.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jacode.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keyword.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linebuf.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lock.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/match.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/menu.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multi.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multiplex.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/narwalt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/narwfont.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readtext.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/search.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setword.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stopcode.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strcasecmp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/subbook.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/text.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/urlparts.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/widealt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/widefont.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/word.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zio.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-dist_pkgincludeHEADERS: $(dist_pkginclude_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" + @list='$(dist_pkginclude_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(dist_pkgincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgincludedir)/$$f'"; \ + $(dist_pkgincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgincludedir)/$$f"; \ + done + +uninstall-dist_pkgincludeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(dist_pkginclude_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(pkgincludedir)/$$f'"; \ + rm -f "$(DESTDIR)$(pkgincludedir)/$$f"; \ + done +install-nodist_pkgincludeHEADERS: $(nodist_pkginclude_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" + @list='$(nodist_pkginclude_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(nodist_pkgincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgincludedir)/$$f'"; \ + $(nodist_pkgincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgincludedir)/$$f"; \ + done + +uninstall-nodist_pkgincludeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(nodist_pkginclude_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(pkgincludedir)/$$f'"; \ + rm -f "$(DESTDIR)$(pkgincludedir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgincludedir)" "$(DESTDIR)$(pkgincludedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-dist_pkgincludeHEADERS \ + install-nodist_pkgincludeHEADERS + +install-dvi: install-dvi-am + +install-exec-am: install-libLTLIBRARIES + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-dist_pkgincludeHEADERS \ + uninstall-libLTLIBRARIES uninstall-nodist_pkgincludeHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libLTLIBRARIES clean-libtool ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am \ + install-dist_pkgincludeHEADERS install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-libLTLIBRARIES \ + install-man install-nodist_pkgincludeHEADERS install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-dist_pkgincludeHEADERS \ + uninstall-libLTLIBRARIES uninstall-nodist_pkgincludeHEADERS + + +sysdefs.h: stamp-sysdefs-h +stamp-sysdefs-h: Makefile + rm -f sysdefs.h.tmp + echo '/* automatically generated by Makefile. */' > sysdefs.h.tmp + echo '#define EB_VERSION_STRING "$(VERSION)"' >> sysdefs.h.tmp + echo '#define EB_VERSION_MAJOR $(EB_VERSION_MAJOR)' >> sysdefs.h.tmp + echo '#define EB_VERSION_MINOR $(EB_VERSION_MINOR)' >> sysdefs.h.tmp + if test X$(ENABLE_EBNET) = Xyes; then \ + echo '#define EB_ENABLE_EBNET 1' >> sysdefs.h.tmp; \ + fi + if test X$(ENABLE_PTHREAD) = Xyes; then \ + echo '#define EB_ENABLE_PTHREAD 1' >> sysdefs.h.tmp; \ + fi + $(top_srcdir)/move-if-change sysdefs.h.tmp sysdefs.h + @echo timestamp > stamp-sysdefs-h + +build-post.h: stamp-build-post-h +stamp-build-post-h: build-post.h.in Makefile + rm -f build-post.h.tmp + echo '/* automatically generated from build-post.h.in. */' \ + > build-post.h + sed -e 's;\@localedir\@;$(localedir);' \ + $(srcdir)/build-post.h.in >> build-post.h.tmp + $(top_srcdir)/move-if-change build-post.h.tmp build-post.h + @echo timestamp > stamp-build-post-h + +widealt.c: stamp-widealt-h +stamp-widealt-h: narwalt.c Makefile + rm -f widealt.c.tmp + echo '/* automatically generated from narwalt.c. */' \ + > widealt.c.tmp + sed -e s/narrow/wide/g -e s/Narrow/Wide/g -e s/NARROW/WIDE/g \ + $(srcdir)/narwalt.c >> widealt.c.tmp + $(top_srcdir)/move-if-change widealt.c.tmp widealt.c + @echo timestamp > stamp-widealt-h + +widefont.c: stamp-widefont-h +stamp-widefont-h: narwfont.c Makefile + rm -f widefont.c.tmp + echo '/* automatically generated from narwfont.c. */' \ + > widefont.c.tmp + sed -e s/narrow/wide/g -e s/Narrow/Wide/g -e s/NARROW/WIDE/g \ + $(srcdir)/narwfont.c >> widefont.c.tmp + $(top_srcdir)/move-if-change widefont.c.tmp widefont.c + @echo timestamp > stamp-widefont-h +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/eb/appendix.c b/eb/appendix.c new file mode 100644 index 0000000..edcc8af --- /dev/null +++ b/eb/appendix.c @@ -0,0 +1,447 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "appendix.h" +#ifdef ENABLE_EBNET +#include "ebnet.h" +#endif +#include "build-post.h" + +/* + * Appendix ID counter. + */ +static EB_Book_Code appendix_counter = 0; + +/* + * Mutex for `appendix_counter'. + */ +#ifdef ENABLE_PTHREAD +static pthread_mutex_t appendix_counter_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif + +/* + * Unexported functions. + */ +static EB_Error_Code eb_load_appendix_catalog(EB_Appendix *appendix); + + +/* + * Initialize alternation text cache in `appendix'. + */ +void +eb_initialize_alt_caches(EB_Appendix *appendix) +{ + EB_Alternation_Cache *p; + int i; + + LOG(("in: eb_initialize_alt_caches(appendix=%d)", (int)appendix->code)); + + for (i = 0, p = appendix->narrow_cache; + i < EB_MAX_ALTERNATION_CACHE; i++, p++) + p->character_number = -1; + for (i = 0, p = appendix->wide_cache; + i < EB_MAX_ALTERNATION_CACHE; i++, p++) + p->character_number = -1; + + LOG(("out: eb_initialize_alt_caches()")); +} + + +/* + * Finalize alternation text cache in `appendix'. + */ +void +eb_finalize_alt_caches(EB_Appendix *appendix) +{ + LOG(("in+out: eb_finalize_alt_caches(appendix=%d)", (int)appendix->code)); + + /* nothing to be done */ +} + + +/* + * Initialize `appendix'. + */ +void +eb_initialize_appendix(EB_Appendix *appendix) +{ + LOG(("in: eb_initialize_appendix()")); + + appendix->code = EB_BOOK_NONE; + appendix->path = NULL; + appendix->path_length = 0; + appendix->disc_code = EB_DISC_INVALID; + appendix->subbook_count = 0; + appendix->subbooks = NULL; + appendix->subbook_current = NULL; +#ifdef ENABLE_EBNET + appendix->ebnet_file = -1; +#endif + eb_initialize_lock(&appendix->lock); + eb_initialize_alt_caches(appendix); + + LOG(("out: eb_initialize_appendix()")); +} + + +/* + * Finalize `appendix'. + */ +void +eb_finalize_appendix(EB_Appendix *appendix) +{ + LOG(("in: eb_finalize_appendix(appendix=%d)", (int)appendix->code)); + + appendix->code = EB_BOOK_NONE; + + if (appendix->path != NULL) { + free(appendix->path); + appendix->path = NULL; + } + appendix->path_length = 0; + + appendix->disc_code = EB_DISC_INVALID; + + if (appendix->subbooks != NULL) { + eb_finalize_appendix_subbooks(appendix); + free(appendix->subbooks); + appendix->subbooks = NULL; + appendix->subbook_count = 0; + } + appendix->subbook_current = NULL; + eb_finalize_lock(&appendix->lock); + eb_finalize_alt_caches(appendix); + +#ifdef ENABLE_EBNET + ebnet_finalize_appendix(appendix); +#endif + + LOG(("out: eb_finalize_appendix()")); +} + + +/* + * Bind `appendix' to `path'. + */ +EB_Error_Code +eb_bind_appendix(EB_Appendix *appendix, const char *path) +{ + EB_Error_Code error_code; + char temporary_path[EB_MAX_PATH_LENGTH + 1]; + int is_ebnet; + + eb_lock(&appendix->lock); + LOG(("in: eb_bind_appendix(path=%s)", path)); + + /* + * Reset structure members in the appendix. + */ + if (appendix->path != NULL) { + eb_finalize_appendix(appendix); + eb_initialize_appendix(appendix); + } + + /* + * Assign a book code. + */ + pthread_mutex_lock(&appendix_counter_mutex); + appendix->code = appendix_counter++; + pthread_mutex_unlock(&appendix_counter_mutex); + + /* + * Check whether `path' is URL. + */ + is_ebnet = is_ebnet_url(path); +#ifndef ENABLE_EBNET + if (is_ebnet) { + error_code = EB_ERR_EBNET_UNSUPPORTED; + goto failed; + } +#endif + + /* + * Set path of the appendix. + * The length of the file name "path/subdir/subsubdir/file.;1" must + * be EB_MAX_PATH_LENGTH maximum. + */ + if (EB_MAX_PATH_LENGTH < strlen(path)) { + error_code = EB_ERR_TOO_LONG_FILE_NAME; + goto failed; + } + strcpy(temporary_path, path); +#ifdef ENABLE_EBNET + if (is_ebnet) + error_code = ebnet_canonicalize_url(temporary_path); + else + error_code = eb_canonicalize_path_name(temporary_path); +#else + error_code = eb_canonicalize_path_name(temporary_path); +#endif + if (error_code != EB_SUCCESS) + goto failed; + appendix->path_length = strlen(temporary_path); + + if (EB_MAX_PATH_LENGTH + < appendix->path_length + 1 + EB_MAX_RELATIVE_PATH_LENGTH) { + error_code = EB_ERR_TOO_LONG_FILE_NAME; + goto failed; + } + + appendix->path = (char *)malloc(appendix->path_length + 1); + if (appendix->path == NULL) { + error_code = EB_ERR_MEMORY_EXHAUSTED; + goto failed; + } + strcpy(appendix->path, temporary_path); + + /* + * Establish a connection with a ebnet server. + */ +#ifdef ENABLE_EBNET + if (is_ebnet) { + error_code = ebnet_bind_appendix(appendix, appendix->path); + if (error_code != EB_SUCCESS) + goto failed; + } +#endif + + /* + * Read information from the catalog file. + */ + error_code = eb_load_appendix_catalog(appendix); + if (error_code != EB_SUCCESS) + goto failed; + + LOG(("out: eb_bind_appendix(appendix=%d) = %s", (int)appendix->code, + eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_finalize_appendix(appendix); + LOG(("out: eb_bind_appendix() = %s", eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + +/* + * Read information from the `CATALOG(S)' file in `appendix'. + * Return EB_SUCCESS, if it succeeds, error-code ohtherwise. + */ +static EB_Error_Code +eb_load_appendix_catalog(EB_Appendix *appendix) +{ + EB_Error_Code error_code; + char buffer[EB_SIZE_PAGE]; + char catalog_file_name[EB_MAX_FILE_NAME_LENGTH + 1]; + char catalog_path_name[EB_MAX_PATH_LENGTH + 1]; + char *space; + EB_Appendix_Subbook *subbook; + size_t catalog_size; + size_t title_size; + Zio zio; + Zio_Code zio_code; + int i; + + LOG(("in: eb_load_appendix_catalog(appendix=%d)", (int)appendix->code)); + + zio_initialize(&zio); + + /* + * Find a catalog file. + */ + if (eb_find_file_name(appendix->path, "catalog", catalog_file_name) + == EB_SUCCESS) { + appendix->disc_code = EB_DISC_EB; + catalog_size = EB_SIZE_EB_CATALOG; + title_size = EB_MAX_EB_TITLE_LENGTH; + } else if (eb_find_file_name(appendix->path, "catalogs", catalog_file_name) + == EB_SUCCESS) { + appendix->disc_code = EB_DISC_EPWING; + catalog_size = EB_SIZE_EPWING_CATALOG; + title_size = EB_MAX_EPWING_TITLE_LENGTH; + } else { + error_code = EB_ERR_FAIL_OPEN_CATAPP; + goto failed; + } + + eb_compose_path_name(appendix->path, catalog_file_name, catalog_path_name); + eb_path_name_zio_code(catalog_path_name, ZIO_PLAIN, &zio_code); + + /* + * Open the catalog file. + */ + if (zio_open(&zio, catalog_path_name, zio_code) < 0) { + error_code = EB_ERR_FAIL_OPEN_CATAPP; + goto failed; + } + + /* + * Get the number of subbooks in the appendix. + */ + if (zio_read(&zio, buffer, 16) != 16) { + error_code = EB_ERR_FAIL_READ_CATAPP; + goto failed; + } + appendix->subbook_count = eb_uint2(buffer); + if (EB_MAX_SUBBOOKS < appendix->subbook_count) + appendix->subbook_count = EB_MAX_SUBBOOKS; + if (appendix->subbook_count == 0) { + error_code = EB_ERR_UNEXP_CATAPP; + goto failed; + } + + /* + * Allocate memories for subbook entries. + */ + appendix->subbooks = (EB_Appendix_Subbook *) + malloc(sizeof(EB_Appendix_Subbook) * appendix->subbook_count); + if (appendix->subbooks == NULL) { + error_code = EB_ERR_MEMORY_EXHAUSTED; + goto failed; + } + eb_initialize_appendix_subbooks(appendix); + + /* + * Read subbook information. + */ + for (i = 0, subbook = appendix->subbooks; i < appendix->subbook_count; + i++, subbook++) { + /* + * Read data from the catalog file. + */ + if (zio_read(&zio, buffer, catalog_size) != catalog_size) { + error_code = EB_ERR_FAIL_READ_CAT; + goto failed; + } + + /* + * Set a directory name of the subbook. + */ + strncpy(subbook->directory_name, buffer + 2 + title_size, + EB_MAX_DIRECTORY_NAME_LENGTH); + subbook->directory_name[EB_MAX_DIRECTORY_NAME_LENGTH] = '\0'; + space = strchr(subbook->directory_name, ' '); + if (space != NULL) + *space = '\0'; + eb_fix_directory_name(appendix->path, subbook->directory_name); + } + + /* + * Close the catalog file. + */ + zio_close(&zio); + zio_finalize(&zio); + LOG(("out: eb_load_appendix_catalog() = %s", eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + zio_close(&zio); + zio_finalize(&zio); + if (appendix->subbooks != NULL) { + free(appendix->subbooks); + appendix->subbooks = NULL; + } + LOG(("out: eb_load_appendix_catalog() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Examine whether `appendix' is bound or not. + */ +int +eb_is_appendix_bound(EB_Appendix *appendix) +{ + int is_bound; + + eb_lock(&appendix->lock); + LOG(("in: eb_is_appendix_bound(appendix=%d)", (int)appendix->code)); + + is_bound = (appendix->path != NULL); + + LOG(("out: eb_is_appendix_bound() = %d", is_bound)); + eb_unlock(&appendix->lock); + + return is_bound; +} + + +/* + * Get the bound path of `appendix'. + */ +EB_Error_Code +eb_appendix_path(EB_Appendix *appendix, char *path) +{ + EB_Error_Code error_code; + + eb_lock(&appendix->lock); + LOG(("in: eb_appendix_path(appendix=%d)", (int)appendix->code)); + + /* + * Check for the current status. + */ + if (appendix->path == NULL) { + error_code = EB_ERR_UNBOUND_APP; + goto failed; + } + + /* + * Copy the path to `path'. + */ + strcpy(path, appendix->path); + + LOG(("out: eb_appendix_path(path=%s) = %s", + path, eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *path = '\0'; + LOG(("out: eb_appendix_path() = %s", eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + diff --git a/eb/appendix.h b/eb/appendix.h new file mode 100644 index 0000000..9cef1a5 --- /dev/null +++ b/eb/appendix.h @@ -0,0 +1,100 @@ +/* -*- C -*- + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef EB_APPENDIX_H +#define EB_APPENDIX_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef EB_BUILD_LIBRARY +#include "eb.h" +#else +#include +#endif + +/* + * Function declarations. + */ +/* appendix.c */ +void eb_initialize_appendix(EB_Appendix *appendix); +void eb_finalize_appendix(EB_Appendix *appendix); +EB_Error_Code eb_bind_appendix(EB_Appendix *appendix, const char *path); +int eb_is_appendix_bound(EB_Appendix *appendix); +EB_Error_Code eb_appendix_path(EB_Appendix *appendix, char *path); + +/* appsub.c */ +EB_Error_Code eb_load_all_appendix_subbooks(EB_Appendix *appendix); +EB_Error_Code eb_appendix_subbook_list(EB_Appendix *appendix, + EB_Subbook_Code *subbook_list, int *subbook_count); +EB_Error_Code eb_appendix_subbook(EB_Appendix *appendix, + EB_Subbook_Code *subbook_code); +EB_Error_Code eb_appendix_subbook_directory(EB_Appendix *appendix, + char *directory); +EB_Error_Code eb_appendix_subbook_directory2(EB_Appendix *appendix, + EB_Subbook_Code subbook_code, char *directory); +EB_Error_Code eb_set_appendix_subbook(EB_Appendix *appendix, + EB_Subbook_Code subbook_code); +void eb_unset_appendix_subbook(EB_Appendix *appendix); + +/* narwalt.c */ +int eb_have_narrow_alt(EB_Appendix *appendix); +EB_Error_Code eb_narrow_alt_start(EB_Appendix *appendix, int *start); +EB_Error_Code eb_narrow_alt_end(EB_Appendix *appendix, int *end); +EB_Error_Code eb_narrow_alt_character_text(EB_Appendix *appendix, + int character_number, char *text); +EB_Error_Code eb_forward_narrow_alt_character(EB_Appendix *appendix, + int n, int *character_number); +EB_Error_Code eb_backward_narrow_alt_character(EB_Appendix *appendix, + int n, int *character_number); + +/* stopcode.c */ +int eb_have_stop_code(EB_Appendix *appendix); +EB_Error_Code eb_stop_code(EB_Appendix *appendix, int *); + +/* widealt.c */ +int eb_have_wide_alt(EB_Appendix *appendix); +EB_Error_Code eb_wide_alt_start(EB_Appendix *appendix, int *start); +EB_Error_Code eb_wide_alt_end(EB_Appendix *appendix, int *end); +EB_Error_Code eb_wide_alt_character_text(EB_Appendix *appendix, + int character_number, char *text); +EB_Error_Code eb_forward_wide_alt_character(EB_Appendix *appendix, int n, + int *character_number); +EB_Error_Code eb_backward_wide_alt_character(EB_Appendix *appendix, int n, + int *character_number); + +/* for backward compatibility */ +#define eb_suspend_appendix eb_unset_appendix_subbook +#define eb_initialize_all_appendix_subbooks eb_load_all_appendix_subbooks + +#ifdef __cplusplus +} +#endif + +#endif /* not EB_APPENDIX_H */ diff --git a/eb/appsub.c b/eb/appsub.c new file mode 100644 index 0000000..769c9eb --- /dev/null +++ b/eb/appsub.c @@ -0,0 +1,750 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "appendix.h" +#include "build-post.h" + +/* + * Unexported functions. + */ +static EB_Error_Code eb_load_appendix_subbook(EB_Appendix *appendix); +static EB_Error_Code eb_set_appendix_subbook_eb(EB_Appendix *appendix, + EB_Subbook_Code subbook_code); +static EB_Error_Code eb_set_appendix_subbook_epwing(EB_Appendix *appendix, + EB_Subbook_Code subbook_code); + +/* + * Initialize all subbooks in `appendix'. + */ +void +eb_initialize_appendix_subbooks(EB_Appendix *appendix) +{ + EB_Appendix_Subbook *subbook; + int i; + + LOG(("in: eb_initialize_appendix_subbooks(appendix=%d)", + (int)appendix->code)); + + for (i = 0, subbook = appendix->subbooks; i < appendix->subbook_count; + i++, subbook++) { + subbook->initialized = 0; + subbook->code = i; + subbook->directory_name[0] = '\0'; + subbook->data_directory_name[0] = '\0'; + subbook->file_name[0] = '\0'; + subbook->character_code = EB_CHARCODE_INVALID; + subbook->narrow_start = -1; + subbook->wide_start = -1; + subbook->narrow_end = -1; + subbook->wide_end = -1; + subbook->narrow_page = 0; + subbook->wide_page = 0; + subbook->stop_code0 = 0; + subbook->stop_code1 = 0; + zio_initialize(&subbook->zio); + } + + LOG(("out: eb_initialize_appendix_subbooks()")); +} + + +/* + * Initialize subbooks in `appendix'. + */ +void +eb_finalize_appendix_subbooks(EB_Appendix *appendix) +{ + EB_Appendix_Subbook *subbook; + int i; + + LOG(("in: eb_finalize_appendix_subbooks(appendix=%d)", + (int)appendix->code)); + + for (i = 0, subbook = appendix->subbooks; i < appendix->subbook_count; + i++, subbook++) { + zio_finalize(&appendix->subbooks[i].zio); + } + + LOG(("out: eb_finalize_appendix_subbooks()")); +} + + +/* + * Load all subbooks in `appendix'. + */ +static EB_Error_Code +eb_load_appendix_subbook(EB_Appendix *appendix) +{ + EB_Error_Code error_code; + EB_Appendix_Subbook *subbook; + char buffer[16]; + int stop_code_page; + int character_count; + + LOG(("in: eb_load_appendix_subbook(appendix=%d)", (int)appendix->code)); + + subbook = appendix->subbook_current; + + /* + * Check for the current status. + */ + if (subbook == NULL) { + error_code = EB_ERR_NO_CUR_APPSUB; + goto failed; + } + + /* + * If the subbook has already initialized, return immediately. + */ + if (subbook->initialized != 0) + goto succeeded; + + /* + * Rewind the APPENDIX file. + */ + if (zio_lseek(&subbook->zio, 0, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_APP; + goto failed; + } + + /* + * Set character code used in the appendix. + */ + if (zio_read(&subbook->zio, buffer, 16) != 16) { + error_code = EB_ERR_FAIL_READ_APP; + goto failed; + } + subbook->character_code = eb_uint2(buffer + 2); + + /* + * Set information about alternation text of wide font. + */ + if (zio_read(&subbook->zio, buffer, 16) != 16) { + error_code = EB_ERR_FAIL_READ_APP; + goto failed; + } + character_count = eb_uint2(buffer + 12); + + if (0 < character_count) { + subbook->narrow_page = eb_uint4(buffer); + subbook->narrow_start = eb_uint2(buffer + 10); + + if (subbook->character_code == EB_CHARCODE_ISO8859_1) { + subbook->narrow_end = subbook->narrow_start + + ((character_count / 0xfe) << 8) + (character_count % 0xfe) + - 1; + if (0xfe < (subbook->narrow_end & 0xff)) + subbook->narrow_end += 3; + + if ((subbook->narrow_start & 0xff) < 0x01 + || 0xfe < (subbook->narrow_start & 0xff) + || subbook->narrow_start < 0x0001 + || 0x1efe < subbook->narrow_end) { + error_code = EB_ERR_UNEXP_APP; + goto failed; + } + } else { + subbook->narrow_end = subbook->narrow_start + + ((character_count / 0x5e) << 8) + (character_count % 0x5e) + - 1; + if (0x7e < (subbook->narrow_end & 0xff)) + subbook->narrow_end += 0xa3; + + if ((subbook->narrow_start & 0xff) < 0x21 + || 0x7e < (subbook->narrow_start & 0xff) + || subbook->narrow_start < 0xa121 + || 0xfe7e < subbook->narrow_end) { + error_code = EB_ERR_UNEXP_APP; + goto failed; + } + } + } + + /* + * Set information about alternation text of wide font. + */ + if (zio_read(&subbook->zio, buffer, 16) != 16) { + error_code = EB_ERR_FAIL_READ_APP; + goto failed; + } + character_count = eb_uint2(buffer + 12); + + if (0 < character_count) { + subbook->wide_page = eb_uint4(buffer); + subbook->wide_start = eb_uint2(buffer + 10); + + if (subbook->character_code == EB_CHARCODE_ISO8859_1) { + subbook->wide_end = subbook->wide_start + + ((character_count / 0xfe) << 8) + (character_count % 0xfe) + - 1; + if (0xfe < (subbook->wide_end & 0xff)) + subbook->wide_end += 3; + + if ((subbook->wide_start & 0xff) < 0x01 + || 0xfe < (subbook->wide_start & 0xff) + || subbook->wide_start < 0x0001 + || 0x1efe < subbook->wide_end) { + error_code = EB_ERR_UNEXP_APP; + goto failed; + } + } else { + subbook->wide_end = subbook->wide_start + + ((character_count / 0x5e) << 8) + (character_count % 0x5e) + - 1; + if (0x7e < (subbook->wide_end & 0xff)) + subbook->wide_end += 0xa3; + + if ((subbook->wide_start & 0xff) < 0x21 + || 0x7e < (subbook->wide_start & 0xff) + || subbook->wide_start < 0xa121 + || 0xfe7e < subbook->wide_end) { + error_code = EB_ERR_UNEXP_APP; + goto failed; + } + } + } + + /* + * Set stop-code. + */ + if (zio_read(&subbook->zio, buffer, 16) != 16) { + error_code = EB_ERR_FAIL_READ_APP; + goto failed; + } + stop_code_page = eb_uint4(buffer); + if (0 < stop_code_page) { + if (zio_lseek(&subbook->zio, ((off_t) stop_code_page - 1) * EB_SIZE_PAGE, + SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_APP; + goto failed; + } + if (zio_read(&subbook->zio, buffer, 16) != 16) { + error_code = EB_ERR_FAIL_READ_APP; + goto failed; + } + if (eb_uint2(buffer) != 0) { + subbook->stop_code0 = eb_uint2(buffer + 2); + subbook->stop_code1 = eb_uint2(buffer + 4); + } + } + + /* + * Rewind the file descriptor, again. + */ + if (zio_lseek(&subbook->zio, 0, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_APP; + goto failed; + } + + /* + * Initialize the alternation text cache. + */ + eb_initialize_alt_caches(appendix); + + succeeded: + LOG(("out: eb_load_appendix_subbook() = %s", eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_load_appendix_subbook() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Load all subbooks in the book. + */ +EB_Error_Code +eb_load_all_appendix_subbooks(EB_Appendix *appendix) +{ + EB_Error_Code error_code; + EB_Subbook_Code current_subbook_code; + EB_Appendix_Subbook *subbook; + int i; + + eb_lock(&appendix->lock); + LOG(("in: eb_load_all_appendix_subbooks(appendix=%d)", + (int)appendix->code)); + + /* + * The appendix must have been bound. + */ + if (appendix->path == NULL) { + error_code = EB_ERR_UNBOUND_APP; + goto failed; + } + + /* + * Get the current subbook. + */ + if (appendix->subbook_current != NULL) + current_subbook_code = appendix->subbook_current->code; + else + current_subbook_code = -1; + + /* + * Initialize each subbook. + */ + for (i = 0, subbook = appendix->subbooks; + i < appendix->subbook_count; i++, subbook++) { + error_code = eb_set_appendix_subbook(appendix, subbook->code); + if (error_code != EB_SUCCESS) + goto failed; + } + + /* + * Restore the current subbook. + */ + if (current_subbook_code < 0) + eb_unset_appendix_subbook(appendix); + else { + error_code = eb_set_appendix_subbook(appendix, current_subbook_code); + if (error_code != EB_SUCCESS) + goto failed; + } + + LOG(("out: eb_load_all_appendix_subbooks() = %s", + eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_load_all_appendix_subbooks() = %s", + eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + +/* + * Get a subbook list in `appendix'. + */ +EB_Error_Code +eb_appendix_subbook_list(EB_Appendix *appendix, EB_Subbook_Code *subbook_list, + int *subbook_count) +{ + EB_Error_Code error_code; + EB_Subbook_Code *list_p; + int i; + + eb_lock(&appendix->lock); + LOG(("in: eb_appendix_subbook_list(appendix=%d)", (int)appendix->code)); + + /* + * Check for the current status. + */ + if (appendix->path == NULL) { + error_code = EB_ERR_UNBOUND_APP; + goto failed; + } + + /* + * Make a subbook list. + */ + for (i = 0, list_p = subbook_list; i < appendix->subbook_count; + i++, list_p++) + *list_p = i; + *subbook_count = appendix->subbook_count; + + LOG(("out: eb_appendix_subbook_list(subbook_count=%d) = %s", + *subbook_count, eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *subbook_count = 0; + LOG(("out: eb_appendix_subbook_list() = %s", eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + +/* + * Get the subbook-code of the current subbook in `appendix'. + */ +EB_Error_Code +eb_appendix_subbook(EB_Appendix *appendix, EB_Subbook_Code *subbook_code) +{ + EB_Error_Code error_code; + + eb_lock(&appendix->lock); + LOG(("in: eb_appendix_subbook(appendix=%d)", (int)appendix->code)); + + /* + * Check for the current status. + */ + if (appendix->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_APPSUB; + goto failed; + } + + /* + * Copy the current subbook code to `subbook_code'. + */ + *subbook_code = appendix->subbook_current->code; + + LOG(("out: eb_appendix_subbook(subbook=%d) = %s", (int)*subbook_code, + eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *subbook_code = EB_SUBBOOK_INVALID; + LOG(("out: eb_appendix_subbook() = %s", eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + +/* + * Get the directory name of the current subbook in `appendix'. + */ +EB_Error_Code +eb_appendix_subbook_directory(EB_Appendix *appendix, char *directory) +{ + EB_Error_Code error_code; + + eb_lock(&appendix->lock); + LOG(("in: eb_appendix_subbook_directory(appendix=%d)", + (int)appendix->code)); + + /* + * Check for the current status. + */ + if (appendix->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_APPSUB; + goto failed; + } + + /* + * Copy the directory name to `directory'. + */ + strcpy(directory, appendix->subbook_current->directory_name); + + LOG(("out: eb_appendix_subbook_directory(directory=%s) = %s", + directory, eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *directory = '\0'; + LOG(("out: eb_appendix_subbook_directory() = %s", + eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + +/* + * Get the directory name of the subbook `subbook_code' in `appendix'. + */ +EB_Error_Code +eb_appendix_subbook_directory2(EB_Appendix *appendix, + EB_Subbook_Code subbook_code, char *directory) +{ + EB_Error_Code error_code; + + eb_lock(&appendix->lock); + LOG(("in: eb_appendix_subbook_directory2(appendix=%d, subbook=%d)", + (int)appendix->code, (int)subbook_code)); + + /* + * Check for the current status. + */ + if (appendix->path == NULL) { + error_code = EB_ERR_UNBOUND_APP; + goto failed; + } + + /* + * Check for `subbook_code'. + */ + if (subbook_code < 0 || appendix->subbook_count <= subbook_code) { + error_code = EB_ERR_NO_SUCH_APPSUB; + goto failed; + } + + /* + * Copy the directory name to `directory'. + */ + strcpy(directory, (appendix->subbooks + subbook_code)->directory_name); + + LOG(("out: eb_appendix_subbook_directory2(directory=%s) = %s", + directory, eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *directory = '\0'; + LOG(("out: eb_appendix_subbook_directory2() = %s", + eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + +/* + * Set the subbook `subbook_code' as the current subbook. + */ +EB_Error_Code +eb_set_appendix_subbook(EB_Appendix *appendix, EB_Subbook_Code subbook_code) +{ + EB_Error_Code error_code; + + eb_lock(&appendix->lock); + LOG(("in: eb_set_appendix_subbook(appendix=%d, subbook=%d)", + (int)appendix->code, (int)subbook_code)); + + /* + * Check for the current status. + */ + if (appendix->path == NULL) { + error_code = EB_ERR_UNBOUND_APP; + goto failed; + } + + /* + * Check for `subbook_code'. + */ + if (subbook_code < 0 || appendix->subbook_count <= subbook_code) { + error_code = EB_ERR_NO_SUCH_APPSUB; + goto failed; + } + + /* + * If the current subbook is `subbook_code', return immediately. + * Otherwise close the current subbook and continue. + */ + if (appendix->subbook_current != NULL) { + if (appendix->subbook_current->code == subbook_code) + goto succeeded; + eb_unset_appendix_subbook(appendix); + } + + /* + * Disc type specific section. + */ + if (appendix->disc_code == EB_DISC_EB) + error_code = eb_set_appendix_subbook_eb(appendix, subbook_code); + else + error_code = eb_set_appendix_subbook_epwing(appendix, subbook_code); + + if (error_code != EB_SUCCESS) + goto failed; + + /* + * Load the subbook. + */ + error_code = eb_load_appendix_subbook(appendix); + if (error_code != EB_SUCCESS) + goto failed; + + succeeded: + LOG(("out: eb_set_appendix_subbook() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + if (appendix->subbook_current != NULL) + zio_close(&appendix->subbook_current->zio); + appendix->subbook_current = NULL; + LOG(("out: eb_set_appendix_subbook() = %s", eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + +/* + * EB* specific section of eb_set_appendix_subbook(). + */ +static EB_Error_Code +eb_set_appendix_subbook_eb(EB_Appendix *appendix, EB_Subbook_Code subbook_code) +{ + EB_Error_Code error_code; + EB_Appendix_Subbook *subbook; + char appendix_path_name[EB_MAX_PATH_LENGTH + 1]; + Zio_Code zio_code; + + LOG(("in: eb_set_appendix_subbook_eb(appendix=%d, subbook=%d)", + (int)appendix->code, (int)subbook_code)); + + /* + * Set the current subbook. + */ + appendix->subbook_current = appendix->subbooks + subbook_code; + subbook = appendix->subbook_current; + + /* + * Open an appendix file. + */ + if (eb_find_file_name2(appendix->path, subbook->directory_name, + EB_FILE_NAME_APPENDIX, subbook->file_name) != EB_SUCCESS) { + error_code = EB_ERR_FAIL_OPEN_APP; + goto failed; + } + + eb_compose_path_name2(appendix->path, subbook->directory_name, + subbook->file_name, appendix_path_name); + eb_path_name_zio_code(appendix_path_name, ZIO_PLAIN, &zio_code); + + if (zio_open(&subbook->zio, appendix_path_name, zio_code) < 0) { + error_code = EB_ERR_FAIL_OPEN_APP; + goto failed; + } + + LOG(("out: eb_set_appendix_subbook_eb() = %s", + eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_set_appendix_subbook_eb() = %s", + eb_error_string(error_code))); + return error_code; +} + + +/* + * EPWING specific section of eb_set_appendix_subbook(). + */ +static EB_Error_Code +eb_set_appendix_subbook_epwing(EB_Appendix *appendix, + EB_Subbook_Code subbook_code) +{ + EB_Error_Code error_code; + EB_Appendix_Subbook *subbook; + char appendix_path_name[EB_MAX_PATH_LENGTH + 1]; + Zio_Code zio_code; + + LOG(("in: eb_set_appendix_subbook_epwing(appendix=%d, subbook=%d)", + (int)appendix->code, (int)subbook_code)); + + /* + * Set the current subbook. + */ + appendix->subbook_current = appendix->subbooks + subbook_code; + subbook = appendix->subbook_current; + + zio_initialize(&subbook->zio); + + /* + * Adjust a directory name. + */ + strcpy(subbook->data_directory_name, EB_DIRECTORY_NAME_DATA); + eb_fix_directory_name2(appendix->path, subbook->directory_name, + subbook->data_directory_name); + + /* + * Open an appendix file. + */ + if (eb_find_file_name3(appendix->path, subbook->directory_name, + subbook->data_directory_name, EB_FILE_NAME_FUROKU, subbook->file_name) + != EB_SUCCESS) { + error_code = EB_ERR_FAIL_OPEN_APP; + goto failed; + } + + eb_compose_path_name3(appendix->path, subbook->directory_name, + subbook->data_directory_name, subbook->file_name, + appendix_path_name); + eb_path_name_zio_code(appendix_path_name, ZIO_PLAIN, &zio_code); + + if (zio_open(&subbook->zio, appendix_path_name, zio_code) < 0) { + subbook = NULL; + error_code = EB_ERR_FAIL_OPEN_APP; + goto failed; + } + + LOG(("out: eb_set_appendix_subbook_epwing() = %s", + eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_set_appendix_subbook_epwing() = %s", + eb_error_string(error_code))); + return error_code; +} + + +/* + * Unset the current subbook. + */ +void +eb_unset_appendix_subbook(EB_Appendix *appendix) +{ + eb_lock(&appendix->lock); + LOG(("in: eb_unset_appendix_subbook(appendix=%d)", (int)appendix->code)); + + /* + * Close a file for the current subbook. + */ + if (appendix->subbook_current != NULL) { + zio_close(&appendix->subbook_current->zio); + appendix->subbook_current = NULL; + } + + LOG(("out: eb_unset_appendix_subbook()")); + eb_unlock(&appendix->lock); +} + + diff --git a/eb/bcd.c b/eb/bcd.c new file mode 100644 index 0000000..0eed583 --- /dev/null +++ b/eb/bcd.c @@ -0,0 +1,99 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "build-post.h" + +/* + * Get a BCD (binary coded decimal) packed integer with 2 bytes + * from an octet stream. + */ +unsigned +eb_bcd2(const char *stream) +{ + unsigned value; + const unsigned char *s = (const unsigned char *)stream; + + value = ((*(s ) >> 4) & 0x0f) * 1000; + value += ((*(s ) ) & 0x0f) * 100; + value += ((*(s + 1) >> 4) & 0x0f) * 10; + value += ((*(s + 1) ) & 0x0f); + + return value; +} + + +/* + * Get a BCD (binary coded decimal) packed integer with 4 bytes + * from an octet stream. + */ +unsigned +eb_bcd4(const char *stream) +{ + unsigned value; + const unsigned char *s = (const unsigned char *)stream; + + value = ((*(s ) >> 4) & 0x0f) * 10000000; + value += ((*(s ) ) & 0x0f) * 1000000; + value += ((*(s + 1) >> 4) & 0x0f) * 100000; + value += ((*(s + 1) ) & 0x0f) * 10000; + value += ((*(s + 2) >> 4) & 0x0f) * 1000; + value += ((*(s + 2) ) & 0x0f) * 100; + value += ((*(s + 3) >> 4) & 0x0f) * 10; + value += ((*(s + 3) ) & 0x0f); + + return value; +} + + +/* + * Get a BCD (binary coded decimal) packed integer with 6 bytes + * from an octet stream. + */ +unsigned +eb_bcd6(const char *stream) +{ + unsigned value; + const unsigned char *s = (const unsigned char *)stream; + + value = ((*(s + 1) ) & 0x0f); + value += ((*(s + 2) >> 4) & 0x0f) * 10; + value += ((*(s + 2) ) & 0x0f) * 100; + value += ((*(s + 3) >> 4) & 0x0f) * 1000; + value += ((*(s + 3) ) & 0x0f) * 10000; + value += ((*(s + 4) >> 4) & 0x0f) * 100000; + value += ((*(s + 4) ) & 0x0f) * 1000000; + value += ((*(s + 5) >> 4) & 0x0f) * 10000000; + value += ((*(s + 5) ) & 0x0f) * 100000000; + + return value; +} + + diff --git a/eb/binary.c b/eb/binary.c new file mode 100644 index 0000000..a258e1c --- /dev/null +++ b/eb/binary.c @@ -0,0 +1,1404 @@ +/* -*- C -*- + * Copyright (c) 2001-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "binary.h" +#include "build-post.h" + +/* + * Unexported function. + */ +static EB_Error_Code eb_read_binary_generic(EB_Book *book, + size_t binary_max_length, char *binary, ssize_t *binary_length); +static EB_Error_Code eb_read_binary_wave(EB_Book *book, + size_t binary_max_length, char *binary, ssize_t *binary_length); +static EB_Error_Code eb_read_binary_mono_graphic(EB_Book *book, + size_t binary_max_length, char *binary, ssize_t *binary_length); +static EB_Error_Code eb_read_binary_gray_graphic(EB_Book *book, + size_t binary_max_length, char *binary, ssize_t *binary_length); + + +/* + * Initialize binary context of `book'. + */ +void +eb_initialize_binary_context(EB_Book *book) +{ + LOG(("in: eb_initialize_binary_context(book=%d)", (int)book->code)); + + book->binary_context.code = EB_BINARY_INVALID; + book->binary_context.zio = NULL; + book->binary_context.location = -1; + book->binary_context.size = 0; + book->binary_context.cache_length = 0; + book->binary_context.cache_offset = 0; + book->binary_context.width = 0; + + LOG(("out: eb_initialize_binary_context()")); +} + + +/* + * Finalize binary context of `book'. + */ +void +eb_finalize_binary_context(EB_Book *book) +{ + LOG(("in+out: eb_finalize_binary_context(book=%d)", (int)book->code)); + + /* nothing to be done */ +} + + +/* + * Reset binary context of `book'. + */ +void +eb_reset_binary_context(EB_Book *book) +{ + LOG(("in: eb_reset_binary_context(book=%d)", (int)book->code)); + + eb_initialize_binary_context(book); + + LOG(("out: eb_reset_binary_context()")); +} + + +/* + * Template of BMP preamble for 2 colors monochrome graphic. + */ +#define MONO_BMP_PREAMBLE_LENGTH 62 + +static const unsigned char mono_bmp_preamble[] = { + /* Type. */ + 'B', 'M', + + /* File size. (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + + /* Reserved. */ + 0x00, 0x00, 0x00, 0x00, + + /* Offset of bitmap bits part. */ + 0x3e, 0x00, 0x00, 0x00, + + /* Size of bitmap info part. */ + 0x28, 0x00, 0x00, 0x00, + + /* Width. (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + + /* Height. (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + + /* Planes. */ + 0x01, 0x00, + + /* Bits per pixels. */ + 0x01, 0x00, + + /* Compression mode. */ + 0x00, 0x00, 0x00, 0x00, + + /* Size of bitmap bits part. (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + + /* X Pixels per meter. */ + 0x6d, 0x0b, 0x00, 0x00, + + /* Y Pixels per meter. */ + 0x6d, 0x0b, 0x00, 0x00, + + /* Colors */ + 0x02, 0x00, 0x00, 0x00, + + /* Important colors */ + 0x02, 0x00, 0x00, 0x00, + + /* RGB quad of color 0 RGB quad of color 1 */ + 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +/* + * Set monochrome bitmap picture as the current binary data. + */ +EB_Error_Code +eb_set_binary_mono_graphic(EB_Book *book, const EB_Position *position, + int width, int height) +{ + EB_Error_Code error_code; + EB_Binary_Context *context; + EB_Position real_position; + unsigned char *buffer_p; + size_t line_pad_length; + size_t data_size; + size_t file_size; + + eb_lock(&book->lock); + LOG(("in: eb_set_binary_mono_graphic(book=%d, position={%d,%d}, \ +width=%d, height=%d)", + (int)book->code, position->page, position->offset, width, height)); + + eb_reset_binary_context(book); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Current subbook must have a graphic file. + */ + if (zio_file(&book->subbook_current->text_zio) < 0) { + error_code = EB_ERR_NO_SUCH_BINARY; + goto failed; + } + + /* + * If both width and height are 0, + * we get real width, height and position of the graphic data. + */ + if (position->page <= 0 || position->offset < 0) { + error_code = EB_ERR_FAIL_SEEK_BINARY; + goto failed; + } + + if (width == 0 && height == 0) { + char buffer[22]; + + if (zio_lseek(&book->subbook_current->text_zio, + ((off_t) position->page - 1) * EB_SIZE_PAGE + position->offset, + SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_BINARY; + goto failed; + } + + if (zio_read(&book->subbook_current->text_zio, buffer, 22) != 22) { + error_code = EB_ERR_FAIL_READ_BINARY; + goto failed; + } + if (eb_uint2(buffer) != 0x1f45 || eb_uint2(buffer + 4) != 0x1f31) { + error_code = EB_ERR_UNEXP_BINARY; + goto failed; + } + width = eb_bcd2(buffer + 8); + height = eb_bcd2(buffer + 10); + + if (eb_uint2(buffer + 12) == 0x1f51) { + real_position.page = eb_bcd4(buffer + 14); + real_position.offset = eb_bcd2(buffer + 18); + } else if (eb_uint2(buffer + 14) == 0x1f51) { + real_position.page = eb_bcd4(buffer + 16); + real_position.offset = eb_bcd2(buffer + 20); + } else { + error_code = EB_ERR_UNEXP_BINARY; + goto failed; + } + + position = &real_position; + } + + if (width <= 0 || height <= 0) { + error_code = EB_ERR_NO_SUCH_BINARY; + goto failed; + } + + /* + * BMP requires that the number of bytes in a line must be multiple + * of 4. If not, 0x00 must be padded to end of each line. + * `line_pad_length' (0...3) is the number of bytes to be padded. + * + * In case of EB_BINARY_MONO_GRAPHIC, a pixel is represented with + * a bit. + */ + if (width % 32 == 0) + line_pad_length = 0; + else if (width % 32 <= 8) + line_pad_length = 3; + else if (width % 32 <= 16) + line_pad_length = 2; + else if (width % 32 <= 24) + line_pad_length = 1; + else + line_pad_length = 0; + + data_size = (width / 8 + line_pad_length) * height; + file_size = data_size + MONO_BMP_PREAMBLE_LENGTH; + + /* + * Set binary context. + */ + context = &book->binary_context; + context->code = EB_BINARY_MONO_GRAPHIC; + context->zio = &book->subbook_current->text_zio; + context->location = ((off_t) position->page - 1) * EB_SIZE_PAGE + + position->offset + (width + 7) / 8 * (height - 1); + context->size = (width + 7) / 8 * height; + context->offset = 0; + context->cache_offset = 0; + context->width = width; + + /* + * Set BMP preamble. + */ + context->cache_length = MONO_BMP_PREAMBLE_LENGTH; + memcpy(context->cache_buffer, mono_bmp_preamble, MONO_BMP_PREAMBLE_LENGTH); + + buffer_p = (unsigned char *)context->cache_buffer + 2; + *buffer_p++ = file_size & 0xff; + *buffer_p++ = (file_size >> 8) & 0xff; + *buffer_p++ = (file_size >> 16) & 0xff; + *buffer_p++ = (file_size >> 24) & 0xff; + + buffer_p = (unsigned char *)context->cache_buffer + 18; + *buffer_p++ = width & 0xff; + *buffer_p++ = (width >> 8) & 0xff; + *buffer_p++ = (width >> 16) & 0xff; + *buffer_p++ = (width >> 24) & 0xff; + + *buffer_p++ = height & 0xff; + *buffer_p++ = (height >> 8) & 0xff; + *buffer_p++ = (height >> 16) & 0xff; + *buffer_p++ = (height >> 24) & 0xff; + + buffer_p = (unsigned char *)context->cache_buffer + 34; + *buffer_p++ = data_size & 0xff; + *buffer_p++ = (data_size >> 8) & 0xff; + *buffer_p++ = (data_size >> 16) & 0xff; + *buffer_p++ = (data_size >> 24) & 0xff; + + /* + * Seek graphic file. + */ + if (zio_lseek(context->zio, context->location, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_BINARY; + goto failed; + } + + LOG(("out: eb_set_binary_mono_graphic() = %s", + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_reset_binary_context(book); + LOG(("out: eb_set_binary_mono_graphic() = %s", + eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Template of BMP preamble for gray scale graphic. + */ +#define GRAY_BMP_PREAMBLE_LENGTH 118 + +static const unsigned char gray_bmp_preamble[] = { + /* Type. */ + 'B', 'M', + + /* File size. (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + + /* Reserved. */ + 0x00, 0x00, 0x00, 0x00, + + /* Offset of bitmap bits part. */ + 0x3e, 0x00, 0x00, 0x00, + + /* Size of bitmap info part. */ + 0x28, 0x00, 0x00, 0x00, + + /* Width. (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + + /* Height. (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + + /* Planes. */ + 0x01, 0x00, + + /* Bits per pixels. */ + 0x04, 0x00, + + /* Compression mode. */ + 0x00, 0x00, 0x00, 0x00, + + /* Size of bitmap bits part. (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + + /* X Pixels per meter. */ + 0x6d, 0x0b, 0x00, 0x00, + + /* Y Pixels per meter. */ + 0x6d, 0x0b, 0x00, 0x00, + + /* Colors */ + 0x10, 0x00, 0x00, 0x00, + + /* Important colors */ + 0x10, 0x00, 0x00, 0x00, + + /* RGB quad of color 0x0 RGB quad of color 0x1 */ + 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x00, + + /* RGB quad of color 0x2 RGB quad of color 0x3 */ + 0x22, 0x22, 0x22, 0x00, 0x33, 0x33, 0x33, 0x00, + + /* RGB quad of color 0x4 RGB quad of color 0x5 */ + 0x44, 0x44, 0x44, 0x00, 0x55, 0x55, 0x55, 0x00, + + /* RGB quad of color 0x6 RGB quad of color 0x7 */ + 0x66, 0x66, 0x66, 0x00, 0x77, 0x77, 0x77, 0x00, + + /* RGB quad of color 0x8 RGB quad of color 0x9 */ + 0x88, 0x88, 0x88, 0x00, 0x99, 0x99, 0x99, 0x00, + + /* RGB quad of color 0xa RGB quad of color 0xb */ + 0xaa, 0xaa, 0xaa, 0x00, 0xbb, 0xbb, 0xbb, 0x00, + + /* RGB quad of color 0xc RGB quad of color 0xd */ + 0xcc, 0xcc, 0xcc, 0x00, 0xdd, 0xdd, 0xdd, 0x00, + + /* RGB quad of color 0xe RGB quad of color 0xf */ + 0xee, 0xee, 0xee, 0x00, 0xff, 0xff, 0xff, 0x00, +}; + +/* + * Set monochrome bitmap picture as the current binary data. + */ +EB_Error_Code +eb_set_binary_gray_graphic(EB_Book *book, const EB_Position *position, + int width, int height) +{ + EB_Error_Code error_code; + EB_Binary_Context *context; + EB_Position real_position; + unsigned char *buffer_p; + size_t line_pad_length; + size_t data_size; + size_t file_size; + + eb_lock(&book->lock); + LOG(("in: eb_set_binary_gray_graphic(book=%d, position={%d,%d}, \ +width=%d, height=%d)", + (int)book->code, position->page, position->offset, width, height)); + + eb_reset_binary_context(book); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Current subbook must have a graphic file. + */ + if (zio_file(&book->subbook_current->text_zio) < 0) { + error_code = EB_ERR_NO_SUCH_BINARY; + goto failed; + } + + /* + * If both width and height are 0, + * we get real width, height and position of the graphic data. + */ + if (position->page <= 0 || position->offset < 0) { + error_code = EB_ERR_FAIL_SEEK_BINARY; + goto failed; + } + + if (width == 0 && height == 0) { + char buffer[22]; + + if (zio_lseek(&book->subbook_current->text_zio, + ((off_t) position->page - 1) * EB_SIZE_PAGE + position->offset, + SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_BINARY; + goto failed; + } + + if (zio_read(&book->subbook_current->text_zio, buffer, 22) != 22) { + error_code = EB_ERR_FAIL_READ_BINARY; + goto failed; + } + if (eb_uint2(buffer) != 0x1f45 + || eb_uint2(buffer + 4) != 0x1f31 + || eb_uint2(buffer + 12) != 0x1f51 + || eb_uint2(buffer + 20) != 0x1f65) { + error_code = EB_ERR_UNEXP_BINARY; + goto failed; + } + + width = eb_bcd2(buffer + 8); + height = eb_bcd2(buffer + 10); + real_position.page = eb_bcd4(buffer + 14); + real_position.offset = eb_bcd2(buffer + 18); + position = &real_position; + } + + if (width <= 0 || height <= 0) { + error_code = EB_ERR_NO_SUCH_BINARY; + goto failed; + } + + /* + * BMP requires that the number of bytes in a line must be multiple + * of 4. If not, 0x00 must be padded to end of each line. + * `line_pad_length' (0...3) is the number of bytes to be padded. + * + * In case of EB_BINARY_GRAY_GRAPHIC, a pixel is represented with + * 4 bits. + */ + if (width % 8 == 0) + line_pad_length = 0; + else if (width % 8 <= 2) + line_pad_length = 3; + else if (width % 8 <= 4) + line_pad_length = 2; + else if (width % 8 <= 6) + line_pad_length = 1; + else + line_pad_length = 0; + + data_size = (width / 2 + line_pad_length) * height; + file_size = data_size + MONO_BMP_PREAMBLE_LENGTH; + + /* + * Set binary context. + */ + context = &book->binary_context; + + context->code = EB_BINARY_GRAY_GRAPHIC; + context->zio = &book->subbook_current->text_zio; + context->location = ((off_t) position->page - 1) * EB_SIZE_PAGE + + position->offset + (width + 1) / 2 * (height - 1); + context->size = (width + 1) / 2 * height; + context->offset = 0; + context->cache_offset = 0; + context->width = width; + + /* + * Set BMP preamble. + */ + context->cache_length = GRAY_BMP_PREAMBLE_LENGTH; + memcpy(context->cache_buffer, gray_bmp_preamble, + GRAY_BMP_PREAMBLE_LENGTH); + + buffer_p = (unsigned char *)context->cache_buffer + 2; + *buffer_p++ = file_size & 0xff; + *buffer_p++ = (file_size >> 8) & 0xff; + *buffer_p++ = (file_size >> 16) & 0xff; + *buffer_p++ = (file_size >> 24) & 0xff; + + buffer_p = (unsigned char *)context->cache_buffer + 18; + *buffer_p++ = width & 0xff; + *buffer_p++ = (width >> 8) & 0xff; + *buffer_p++ = (width >> 16) & 0xff; + *buffer_p++ = (width >> 24) & 0xff; + + *buffer_p++ = height & 0xff; + *buffer_p++ = (height >> 8) & 0xff; + *buffer_p++ = (height >> 16) & 0xff; + *buffer_p++ = (height >> 24) & 0xff; + + buffer_p = (unsigned char *)context->cache_buffer + 34; + *buffer_p++ = data_size & 0xff; + *buffer_p++ = (data_size >> 8) & 0xff; + *buffer_p++ = (data_size >> 16) & 0xff; + *buffer_p++ = (data_size >> 24) & 0xff; + + /* + * Seek graphic file. + */ + if (zio_lseek(context->zio, context->location, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_BINARY; + goto failed; + } + + LOG(("out: eb_set_binary_gray_graphic() = %s", + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_reset_binary_context(book); + LOG(("out: eb_set_binary_gray_graphic() = %s", + eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Set WAVE sound as the current binary data. + */ +EB_Error_Code +eb_set_binary_wave(EB_Book *book, const EB_Position *start_position, + const EB_Position *end_position) +{ + EB_Error_Code error_code; + EB_Binary_Context *context; + off_t start_location; + off_t end_location; + char temporary_buffer[4]; + + eb_lock(&book->lock); + LOG(("in: eb_set_binary_wave(book=%d, start_position={%d,%d}, \ +end_position={%d,%d})", + (int)book->code, start_position->page, start_position->offset, + end_position->page, end_position->offset)); + + eb_reset_binary_context(book); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Current subbook must have a sound file. + */ + if (zio_file(&book->subbook_current->sound_zio) < 0) { + error_code = EB_ERR_NO_SUCH_BINARY; + goto failed; + } + + /* + * Set binary context. + */ + if (start_position->page <= 0 || start_position->offset < 0) { + error_code = EB_ERR_FAIL_SEEK_BINARY; + goto failed; + } + if (end_position->page <= 0 || end_position->offset < 0) { + error_code = EB_ERR_FAIL_SEEK_BINARY; + goto failed; + } + + start_location = ((off_t) start_position->page - 1) * EB_SIZE_PAGE + + start_position->offset; + end_location = ((off_t) end_position->page - 1) * EB_SIZE_PAGE + + end_position->offset; + + context = &book->binary_context; + + context->code = EB_BINARY_WAVE; + context->zio = &book->subbook_current->sound_zio; + context->location = start_location; + if (start_location < end_location) + context->size = end_location - start_location + 1; + else { + error_code = EB_ERR_UNEXP_BINARY; + goto failed; + } + context->offset = 0; + + /* + * Read 4bytes from the sound file to check whether the sound + * data contains a header part or not. + * + * If the read data is "fmt ", the wave data has a header part. + * Otherwise, we must read a header in another location. + * + * The wave data consists of: + * + * "RIFF" wave-size(4bytes) "WAVE" header-fragment(28bytes) + * data-part-size(4bytes) data + * + * wave-size = "WAVE" + header-fragment + data-part-size + data + * = 4 + 28 + 4 + data + * = 36 + data + * data-part-size = length(data) + */ + if (zio_lseek(context->zio, context->location, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_BINARY; + goto failed; + } + if (zio_read(context->zio, temporary_buffer, 4) != 4) { + error_code = EB_ERR_FAIL_READ_BINARY; + goto failed; + } + + if (memcmp(temporary_buffer, "fmt ", 4) == 0) { + memcpy(context->cache_buffer + 12, temporary_buffer, 4); + if (zio_read(context->zio, context->cache_buffer + 16, 28) != 28) { + error_code = EB_ERR_FAIL_READ_BINARY; + goto failed; + } + if (context->size >= 32) + context->size -= 32; + else + context->size = 0; + } else { + if (zio_lseek(context->zio, + ((off_t) book->subbook_current->sound.start_page - 1) + * EB_SIZE_PAGE + 32, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_BINARY; + goto failed; + } + if (zio_read(context->zio, context->cache_buffer + 12, 28) != 28) { + error_code = EB_ERR_FAIL_SEEK_BINARY; + goto failed; + } + + *(unsigned char *)(context->cache_buffer + 40) + = (context->size) & 0xff; + *(unsigned char *)(context->cache_buffer + 41) + = (context->size >> 8) & 0xff; + *(unsigned char *)(context->cache_buffer + 42) + = (context->size >> 16) & 0xff; + *(unsigned char *)(context->cache_buffer + 43) + = (context->size >> 24) & 0xff; + + + /* + * Seek sound file, again. + */ + if (zio_lseek(context->zio, context->location, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_BINARY; + goto failed; + } + } + context->cache_length = 44; + + /* + * Read and compose a WAVE header. + */ + memcpy(context->cache_buffer, "RIFF", 4); + + *(unsigned char *)(context->cache_buffer + 4) + = (context->size + 36) & 0xff; + *(unsigned char *)(context->cache_buffer + 5) + = ((context->size + 36) >> 8) & 0xff; + *(unsigned char *)(context->cache_buffer + 6) + = ((context->size + 36) >> 16) & 0xff; + *(unsigned char *)(context->cache_buffer + 7) + = ((context->size + 36) >> 24) & 0xff; + + memcpy(context->cache_buffer + 8, "WAVE", 4); + + LOG(("out: eb_set_binary_wave() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_reset_binary_context(book); + LOG(("out: eb_set_binary_wave() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Length of the color graphic header. + */ +#define EB_COLOR_GRAPHIC_HEADER_LENGTH 8 + +/* + * Set color graphic (BMP or JPEG) as the current binary data. + */ +EB_Error_Code +eb_set_binary_color_graphic(EB_Book *book, const EB_Position *position) +{ + EB_Error_Code error_code; + EB_Binary_Context *context; + char buffer[EB_COLOR_GRAPHIC_HEADER_LENGTH]; + + eb_lock(&book->lock); + LOG(("in: eb_set_binary_color_graphic(book=%d, position={%d,%d})", + (int)book->code, position->page, position->offset)); + + eb_reset_binary_context(book); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Current subbook must have a graphic file. + */ + if (zio_file(&book->subbook_current->graphic_zio) < 0) { + error_code = EB_ERR_NO_SUCH_BINARY; + goto failed; + } + + /* + * Set binary context. + */ + if (position->page <= 0 || position->offset < 0) { + error_code = EB_ERR_FAIL_SEEK_BINARY; + goto failed; + } + + context = &book->binary_context; + context->code = EB_BINARY_COLOR_GRAPHIC; + context->zio = &book->subbook_current->graphic_zio; + context->location = ((off_t) position->page - 1) * EB_SIZE_PAGE + + position->offset; + context->offset = 0; + context->cache_length = 0; + context->cache_offset = 0; + + /* + * Seek graphic file. + */ + if (zio_lseek(context->zio, context->location, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_BINARY; + goto failed; + } + + /* + * Read header of the graphic data. + * Note that EB* JPEG file lacks the header. + */ + if (zio_read(context->zio, buffer, EB_COLOR_GRAPHIC_HEADER_LENGTH) + != EB_COLOR_GRAPHIC_HEADER_LENGTH) { + error_code = EB_ERR_FAIL_READ_BINARY; + goto failed; + } + + if (memcmp(buffer, "data", 4) == 0) { + context->size = eb_uint4_le(buffer + 4); + context->location += EB_COLOR_GRAPHIC_HEADER_LENGTH; + } else { + context->size = 0; + if (zio_lseek(context->zio, context->location, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_BINARY; + goto failed; + } + } + + LOG(("out: eb_set_binary_color_graphic() = %s", + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_reset_binary_context(book); + LOG(("out: eb_set_binary_color_graphic() = %s", + eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Set MPEG movie as the current binary data. + */ +EB_Error_Code +eb_set_binary_mpeg(EB_Book *book, const unsigned int *argv) +{ + /* + * `movie_file_name' is base name, and `movie_path_name' is absolute + * path of the movie. + */ + char movie_file_name[EB_MAX_FILE_NAME_LENGTH + 1]; + char movie_path_name[EB_MAX_PATH_LENGTH + 1]; + EB_Error_Code error_code; + EB_Subbook *subbook; + Zio_Code zio_code; + + eb_lock(&book->lock); + LOG(("in: eb_set_binary_mpeg(book=%d)", (int)book->code)); + + eb_reset_binary_context(book); + + /* + * Current subbook must have been set. + */ + subbook = book->subbook_current; + if (subbook == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Open the movie file and set binary context. + */ + if (eb_compose_movie_file_name(argv, movie_file_name) != EB_SUCCESS) { + error_code = EB_ERR_NO_SUCH_BINARY; + goto failed; + } + LOG(("aux: eb_set_binary_mpeg(): movie_file_name=%s", movie_file_name)); + + if (eb_find_file_name3(book->path, subbook->directory_name, + subbook->movie_directory_name, movie_file_name, movie_file_name) + != EB_SUCCESS) { + error_code = EB_ERR_NO_SUCH_BINARY; + goto failed; + } + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->movie_directory_name, movie_file_name, movie_path_name); + eb_path_name_zio_code(movie_path_name, ZIO_PLAIN, &zio_code); + + if (zio_open(&subbook->movie_zio, movie_path_name, zio_code) < 0) { + subbook = NULL; + error_code = EB_ERR_FAIL_OPEN_BINARY; + goto failed; + } + + book->binary_context.code = EB_BINARY_MPEG; + book->binary_context.zio = &book->subbook_current->movie_zio; + book->binary_context.location = 0; + book->binary_context.size = 0; + book->binary_context.offset = 0; + book->binary_context.cache_length = 0; + book->binary_context.cache_offset = 0; + + LOG(("out: eb_set_binary_mpeg() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_reset_binary_context(book); + LOG(("out: eb_set_binary_mpeg() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Read binary data. + */ +EB_Error_Code +eb_read_binary(book, binary_max_length, binary, binary_length) + EB_Book *book; + size_t binary_max_length; + char *binary; + ssize_t *binary_length; + +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_read_binary(book=%d, binary_max_length=%ld)", + (int)book->code, (long)binary_max_length)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Return immediately if `binary_max_length' is 0. + */ + *binary_length = 0; + + switch (book->binary_context.code) { + case EB_BINARY_COLOR_GRAPHIC: + case EB_BINARY_MPEG: + error_code = eb_read_binary_generic(book, binary_max_length, binary, + binary_length); + break; + case EB_BINARY_WAVE: + error_code = eb_read_binary_wave(book, binary_max_length, + binary, binary_length); + break; + case EB_BINARY_MONO_GRAPHIC: + error_code = eb_read_binary_mono_graphic(book, binary_max_length, + binary, binary_length); + break; + case EB_BINARY_GRAY_GRAPHIC: + error_code = eb_read_binary_gray_graphic(book, binary_max_length, + binary, binary_length); + break; + default: + error_code = EB_ERR_NO_CUR_BINARY; + goto failed; + } + if (error_code != EB_SUCCESS) + goto failed; + + LOG(("out: eb_read_binary(binary_length=%ld) = %s", (long)*binary_length, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *binary_length = -1; + eb_reset_binary_context(book); + LOG(("out: eb_read_binary() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Read generic binary data. + * This function is used for reading JPEG or BMP picture, and data part + * of WAVE sound. + */ +static EB_Error_Code +eb_read_binary_generic(EB_Book *book, size_t binary_max_length, + char *binary, ssize_t *binary_length) +{ + EB_Error_Code error_code; + EB_Binary_Context *context; + char *binary_p = binary; + size_t read_length = 0; + ssize_t read_result; + + LOG(("in: eb_read_binary_generic(book=%d, binary_max_length=%ld)", + (int)book->code, (long)binary_max_length)); + + *binary_length = 0; + context = &book->binary_context; + + /* + * Return immediately if `binary_max_length' is 0. + */ + if (binary_max_length == 0) + goto succeeded; + + /* + * Read binary data if it is remained. + * If context->size is 0, the binary data size is unknown. + */ + if (0 < context->size && context->size <= context->offset) + goto succeeded; + + if (context->size == 0) + read_length = binary_max_length - *binary_length; + else if (binary_max_length - *binary_length + < context->size - context->offset) + read_length = binary_max_length - *binary_length; + else + read_length = context->size - context->offset; + + read_result = zio_read(context->zio, binary_p, read_length); + if ((0 < context->size && read_result != read_length) || read_result < 0) { + error_code = EB_ERR_FAIL_READ_BINARY; + goto failed; + } + + *binary_length += read_result; + context->offset += read_result; + + succeeded: + LOG(("out: eb_read_binary_generic(binary_length=%ld) = %s", + (long)*binary_length, eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_read_binary_generic() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Read WAVE sound data. + */ +static EB_Error_Code +eb_read_binary_wave(EB_Book *book, size_t binary_max_length, char *binary, + ssize_t *binary_length) +{ + EB_Error_Code error_code; + EB_Binary_Context *context; + char *binary_p = binary; + size_t copy_length = 0; + + LOG(("in: eb_read_binary_wave(book=%d, binary_max_length=%ld)", + (int)book->code, (long)binary_max_length)); + + *binary_length = 0; + context = &book->binary_context; + + /* + * Return immediately if `binary_max_length' is 0. + */ + if (binary_max_length == 0) + goto succeeded; + + /* + * Copy cached data (header part) to `binary' if exists. + */ + if (0 < context->cache_length) { + if (binary_max_length < context->cache_length - context->cache_offset) + copy_length = binary_max_length; + else + copy_length = context->cache_length - context->cache_offset; + + memcpy(binary_p, context->cache_buffer + context->cache_offset, + copy_length); + binary_p += copy_length; + context->cache_offset += copy_length; + + if (context->cache_length <= context->cache_offset) + context->cache_length = 0; + + if (binary_max_length <= *binary_length) + goto succeeded; + } + + error_code = eb_read_binary_generic(book, binary_max_length - copy_length, + binary_p, binary_length); + if (error_code !=EB_SUCCESS) + goto failed; + *binary_length += copy_length; + + succeeded: + LOG(("out: eb_read_binary_wave(binary_length=%ld) = %s", + (long)*binary_length, eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_read_binary_wave() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Read monochrome graphic data. + * The function also convert the graphic data to BMP. + */ +static EB_Error_Code +eb_read_binary_mono_graphic(EB_Book *book, size_t binary_max_length, + char *binary, ssize_t *binary_length) +{ + EB_Error_Code error_code; + EB_Binary_Context *context; + unsigned char *binary_p = (unsigned char *)binary; + size_t copy_length = 0; + size_t read_length = 0; + size_t line_length; + size_t line_pad_length; + + LOG(("in: eb_read_binary_mono_graphic(book=%d, binary_max_length=%ld)", + (int)book->code, (long)binary_max_length)); + + *binary_length = 0; + context = &book->binary_context; + + line_length = (context->width + 7) / 8; + + if (context->width % 32 == 0) + line_pad_length = 0; + else if (context->width % 32 <= 8) + line_pad_length = 3; + else if (context->width % 32 <= 16) + line_pad_length = 2; + else if (context->width % 32 <= 24) + line_pad_length = 1; + else + line_pad_length = 0; + + /* + * Return immediately if `binary_max_length' is 0. + */ + if (binary_max_length == 0) + goto succeeded; + + for (;;) { + /* + * Copy cached data to `binary' if exists. + */ + if (0 < context->cache_length) { + if (binary_max_length - *binary_length + < context->cache_length - context->cache_offset) + copy_length = binary_max_length - *binary_length; + else + copy_length = context->cache_length - context->cache_offset; + + memcpy(binary_p, context->cache_buffer + context->cache_offset, + copy_length); + binary_p += copy_length; + *binary_length += copy_length; + context->cache_offset += copy_length; + + if (context->cache_length <= context->cache_offset) + context->cache_length = 0; + + if (binary_max_length <= *binary_length) + goto succeeded; + } + + /* + * Read binary data if it is remained. + * If padding is needed, read each line. + */ + read_length = line_length - context->offset % line_length; + if (context->size - context->offset < read_length) + read_length = context->size - context->offset; + if (binary_max_length - *binary_length < read_length) + read_length = binary_max_length - *binary_length; + if (read_length == 0) + goto succeeded; + + /* + * Read binary data. + */ + if (context->offset != 0 + && context->offset % line_length == 0 + && zio_lseek(context->zio, (off_t) line_length * -2, SEEK_CUR) + < 0) { + error_code = EB_ERR_FAIL_SEEK_BINARY; + goto failed; + } + if (zio_read(context->zio, (char *)binary_p, read_length) + != read_length) { + error_code = EB_ERR_FAIL_READ_BINARY; + goto failed; + } + + *binary_length += read_length; + context->offset += read_length; + binary_p += read_length; + + /* + * Pad 0x00 to BMP if needed. + */ + if (context->offset % line_length == 0) { + if (0 < line_pad_length) { + if (binary_max_length - *binary_length < line_pad_length) { + memset(context->cache_buffer, 0, line_pad_length); + context->cache_length = line_pad_length; + context->cache_offset = 0; + } else { + memset(binary_p, 0, line_pad_length); + binary_p += line_pad_length; + *binary_length += line_pad_length; + } + } + } + } + + succeeded: + LOG(("out: eb_read_binary_mono_graphic(binary_length=%ld) = %s", + (long)*binary_length, eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_read_binary_mono_graphic() = %s", + eb_error_string(error_code))); + return error_code; +} + + +/* + * Read gray scale graphic data. + * The function also convert the graphic data to BMP. + */ +static EB_Error_Code +eb_read_binary_gray_graphic(EB_Book *book, size_t binary_max_length, + char *binary, ssize_t *binary_length) +{ + EB_Error_Code error_code; + EB_Binary_Context *context; + unsigned char *binary_p = (unsigned char *)binary; + size_t copy_length = 0; + size_t read_length = 0; + size_t line_length; + size_t line_pad_length; + + LOG(("in: eb_read_binary_gray_graphic(book=%d, binary_max_length=%ld)", + (int)book->code, (long)binary_max_length)); + + *binary_length = 0; + context = &book->binary_context; + + line_length = (context->width + 1) / 2; + + if (context->width % 8 == 0) + line_pad_length = 0; + else if (context->width % 8 <= 2) + line_pad_length = 3; + else if (context->width % 8 <= 4) + line_pad_length = 2; + else if (context->width % 8 <= 6) + line_pad_length = 1; + else + line_pad_length = 0; + + /* + * Return immediately if `binary_max_length' is 0. + */ + if (binary_max_length == 0) + goto succeeded; + + for (;;) { + /* + * Copy cached data to `binary' if exists. + */ + if (0 < context->cache_length) { + if (binary_max_length - *binary_length + < context->cache_length - context->cache_offset) + copy_length = binary_max_length - *binary_length; + else + copy_length = context->cache_length - context->cache_offset; + + memcpy(binary_p, context->cache_buffer + context->cache_offset, + copy_length); + binary_p += copy_length; + *binary_length += copy_length; + context->cache_offset += copy_length; + + if (context->cache_length <= context->cache_offset) + context->cache_length = 0; + + if (binary_max_length <= *binary_length) + goto succeeded; + } + + /* + * Read binary data if it is remained. + * If padding is needed, read each line. + */ + read_length = line_length - context->offset % line_length; + if (context->size - context->offset < read_length) + read_length = context->size - context->offset; + if (binary_max_length - *binary_length < read_length) + read_length = binary_max_length - *binary_length; + if (read_length == 0) + goto succeeded; + + /* + * Read binary data. + */ + if (context->offset != 0 + && context->offset % line_length == 0 + && zio_lseek(context->zio, (off_t) line_length * -2, SEEK_CUR) + < 0) { + error_code = EB_ERR_FAIL_SEEK_BINARY; + goto failed; + } + if (zio_read(context->zio, (char *)binary_p, read_length) + != read_length) { + error_code = EB_ERR_FAIL_READ_BINARY; + goto failed; + } + + *binary_length += read_length; + context->offset += read_length; + binary_p += read_length; + + /* + * Pad 0x00 to BMP if needed. + */ + if (context->offset % line_length == 0) { + if (0 < line_pad_length) { + if (binary_max_length - *binary_length < line_pad_length) { + memset(context->cache_buffer, 0, line_pad_length); + context->cache_length = line_pad_length; + context->cache_offset = 0; + } else { + memset(binary_p, 0, line_pad_length); + binary_p += line_pad_length; + *binary_length += line_pad_length; + } + } + } + } + + succeeded: + LOG(("out: eb_read_binary_gray_graphic(binary_length=%ld) = %s", + (long)*binary_length, eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_read_binary_gray_graphic() = %s", + eb_error_string(error_code))); + return error_code; +} + + +/* + * Unset current binary. + */ +void +eb_unset_binary(EB_Book *book) +{ + eb_lock(&book->lock); + LOG(("in: eb_unset_binary(book=%d)", (int)book->code)); + + eb_reset_binary_context(book); + + LOG(("out: eb_unset_binary()")); + eb_unlock(&book->lock); +} + + diff --git a/eb/binary.h b/eb/binary.h new file mode 100644 index 0000000..031ca46 --- /dev/null +++ b/eb/binary.h @@ -0,0 +1,73 @@ +/* -*- C -*- + * Copyright (c) 2001-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef EB_BINARY_H +#define EB_BINARY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef EB_BUILD_LIBRARY +#include "defs.h" +#else +#include +#endif + +/* + * Function declarations. + */ +/* binary.c */ +EB_Error_Code eb_set_binary_mono_graphic(EB_Book *book, + const EB_Position *position, int width, int height); +EB_Error_Code eb_set_binary_gray_graphic(EB_Book *book, + const EB_Position *position, int width, int height); +EB_Error_Code eb_set_binary_wave(EB_Book *book, + const EB_Position *start_position, const EB_Position *end_position); +EB_Error_Code eb_set_binary_color_graphic(EB_Book *book, + const EB_Position *position); +EB_Error_Code eb_set_binary_mpeg(EB_Book *book, const unsigned int *argv); +EB_Error_Code eb_read_binary(EB_Book *book, size_t binary_max_length, + char *binary, ssize_t *binary_length); +void eb_unset_binary(EB_Book *book); + +/* filename.c */ +EB_Error_Code eb_compose_movie_file_name(const unsigned int *argv, + char *composed_file_name); +EB_Error_Code eb_compose_movie_path_name(EB_Book *book, + const unsigned int *argv, char *composed_path_name); +EB_Error_Code eb_decompose_movie_file_name(unsigned int *argv, + const char *composed_file_name); + +#ifdef __cplusplus +} +#endif + +#endif /* not EB_BINARY_H */ diff --git a/eb/bitmap.c b/eb/bitmap.c new file mode 100644 index 0000000..793f11b --- /dev/null +++ b/eb/bitmap.c @@ -0,0 +1,1362 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "font.h" +#include "build-post.h" + +#include + +/* + * Unexported functions. + */ +static unsigned long png_crc(const char *buf, size_t len); +static int png_compress(const char *src, int width, int height, char *dest, + size_t *dest_len); + + +/* + * Return required buffer size for a narrow font character converted + * to XBM image format. + */ +EB_Error_Code +eb_narrow_font_xbm_size(EB_Font_Code height, size_t *size) +{ + EB_Error_Code error_code; + + LOG(("in: eb_narrow_font_xbm_size(height=%d)", (int)height)); + + switch (height) { + case EB_FONT_16: + *size = EB_SIZE_NARROW_FONT_16_XBM; + break; + case EB_FONT_24: + *size = EB_SIZE_NARROW_FONT_24_XBM; + break; + case EB_FONT_30: + *size = EB_SIZE_NARROW_FONT_30_XBM; + break; + case EB_FONT_48: + *size = EB_SIZE_NARROW_FONT_48_XBM; + break; + default: + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + LOG(("out: eb_narrow_font_xbm_size(size=%ld) = %s", (long)*size, + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *size = 0; + LOG(("out: eb_narrow_font_xbm_size() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Return required buffer size for a narrow font character converted + * to XPM image format. + */ +EB_Error_Code +eb_narrow_font_xpm_size(EB_Font_Code height, size_t *size) +{ + EB_Error_Code error_code; + + LOG(("in: eb_narrow_font_xpm_size(height=%d)", (int)height)); + + switch (height) { + case EB_FONT_16: + *size = EB_SIZE_NARROW_FONT_16_XPM; + break; + case EB_FONT_24: + *size = EB_SIZE_NARROW_FONT_24_XPM; + break; + case EB_FONT_30: + *size = EB_SIZE_NARROW_FONT_30_XPM; + break; + case EB_FONT_48: + *size = EB_SIZE_NARROW_FONT_48_XPM; + break; + default: + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + LOG(("out: eb_narrow_font_xpm_size(size=%ld) = %s", (long)*size, + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *size = 0; + LOG(("out: eb_narrow_font_xpm_size() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Return required buffer size for a narrow font character converted + * to GIF image format. + */ +EB_Error_Code +eb_narrow_font_gif_size(EB_Font_Code height, size_t *size) +{ + EB_Error_Code error_code; + + LOG(("in: eb_narrow_font_gif_size(height=%d)", (int)height)); + + switch (height) { + case EB_FONT_16: + *size = EB_SIZE_NARROW_FONT_16_GIF; + break; + case EB_FONT_24: + *size = EB_SIZE_NARROW_FONT_24_GIF; + break; + case EB_FONT_30: + *size = EB_SIZE_NARROW_FONT_30_GIF; + break; + case EB_FONT_48: + *size = EB_SIZE_NARROW_FONT_48_GIF; + default: + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + LOG(("out: eb_narrow_font_gif_size(size=%ld) = %s", (long)*size, + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *size = 0; + LOG(("out: eb_narrow_font_gif_size() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Return required buffer size for a narrow font character converted + * to BMP image format. + */ +EB_Error_Code +eb_narrow_font_bmp_size(EB_Font_Code height, size_t *size) +{ + EB_Error_Code error_code; + + LOG(("in: eb_narrow_font_bmp_size(height=%d)", (int)height)); + + switch (height) { + case EB_FONT_16: + *size = EB_SIZE_NARROW_FONT_16_BMP; + break; + case EB_FONT_24: + *size = EB_SIZE_NARROW_FONT_24_BMP; + break; + case EB_FONT_30: + *size = EB_SIZE_NARROW_FONT_30_BMP; + break; + case EB_FONT_48: + *size = EB_SIZE_NARROW_FONT_48_BMP; + break; + default: + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + LOG(("out: eb_narrow_font_bmp_size(size=%ld) = %s", (long)*size, + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *size = 0; + LOG(("out: eb_narrow_font_bmp_size() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Return required buffer size for a narrow font character converted + * to PNG image format. + */ +EB_Error_Code +eb_narrow_font_png_size(EB_Font_Code height, size_t *size) +{ + EB_Error_Code error_code; + + LOG(("in: eb_narrow_font_png_size(height=%d)", (int)height)); + + switch (height) { + case EB_FONT_16: + *size = EB_SIZE_NARROW_FONT_16_PNG; + break; + case EB_FONT_24: + *size = EB_SIZE_NARROW_FONT_24_PNG; + break; + case EB_FONT_30: + *size = EB_SIZE_NARROW_FONT_30_PNG; + break; + case EB_FONT_48: + *size = EB_SIZE_NARROW_FONT_48_PNG; + default: + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + LOG(("out: eb_narrow_font_png_size(size=%ld) = %s", (long)*size, + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *size = 0; + LOG(("out: eb_narrow_font_png_size() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Return required buffer size for a wide font character converted + * to XBM image format. + */ +EB_Error_Code +eb_wide_font_xbm_size(EB_Font_Code height, size_t *size) +{ + EB_Error_Code error_code; + + LOG(("in: eb_wide_font_xbm_size(height=%d)", (int)height)); + + switch (height) { + case EB_FONT_16: + *size = EB_SIZE_WIDE_FONT_16_XBM; + break; + case EB_FONT_24: + *size = EB_SIZE_WIDE_FONT_24_XBM; + break; + case EB_FONT_30: + *size = EB_SIZE_WIDE_FONT_30_XBM; + break; + case EB_FONT_48: + *size = EB_SIZE_WIDE_FONT_48_XBM; + break; + default: + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + LOG(("out: eb_wide_font_xbm_size(size=%ld) = %s", (long)*size, + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *size = 0; + LOG(("out: eb_wide_font_xbm_size() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Return required buffer size for a wide font character converted + * to XPM image format. + */ +EB_Error_Code +eb_wide_font_xpm_size(EB_Font_Code height, size_t *size) +{ + EB_Error_Code error_code; + + LOG(("in: eb_wide_font_xpm_size(height=%d)", (int)height)); + + switch (height) { + case EB_FONT_16: + *size = EB_SIZE_WIDE_FONT_16_XPM; + break; + case EB_FONT_24: + *size = EB_SIZE_WIDE_FONT_24_XPM; + break; + case EB_FONT_30: + *size = EB_SIZE_WIDE_FONT_30_XPM; + break; + case EB_FONT_48: + *size = EB_SIZE_WIDE_FONT_48_XPM; + break; + default: + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + LOG(("out: eb_wide_font_xpm_size(size=%ld) = %s", (long)*size, + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *size = 0; + LOG(("out: eb_wide_font_xpm_size() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Return required buffer size for a wide font character converted + * to GIF image format. + */ +EB_Error_Code +eb_wide_font_gif_size(EB_Font_Code height, size_t *size) +{ + EB_Error_Code error_code; + + LOG(("in: eb_wide_font_gif_size(height=%d)", (int)height)); + + switch (height) { + case EB_FONT_16: + *size = EB_SIZE_WIDE_FONT_16_GIF; + break; + case EB_FONT_24: + *size = EB_SIZE_WIDE_FONT_24_GIF; + break; + case EB_FONT_30: + *size = EB_SIZE_WIDE_FONT_30_GIF; + break; + case EB_FONT_48: + *size = EB_SIZE_WIDE_FONT_48_GIF; + break; + default: + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + LOG(("out: eb_wide_font_gif_size(size=%ld) = %s", (long)*size, + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *size = 0; + LOG(("out: eb_wide_font_gif_size() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Return required buffer size for a wide font character converted + * to BMP image format. + */ +EB_Error_Code +eb_wide_font_bmp_size(EB_Font_Code height, size_t *size) +{ + EB_Error_Code error_code; + + LOG(("in: eb_wide_font_bmp_size(height=%d)", (int)height)); + + switch (height) { + case EB_FONT_16: + *size = EB_SIZE_WIDE_FONT_16_BMP; + break; + case EB_FONT_24: + *size = EB_SIZE_WIDE_FONT_24_BMP; + break; + case EB_FONT_30: + *size = EB_SIZE_WIDE_FONT_30_BMP; + break; + case EB_FONT_48: + *size = EB_SIZE_WIDE_FONT_48_BMP; + break; + default: + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + LOG(("out: eb_wide_font_bmp_size(size=%ld) = %s", (long)*size, + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *size = 0; + LOG(("out: eb_wide_font_bmp_size() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Return required buffer size for a wide font character converted + * to PNG image format. + */ +EB_Error_Code +eb_wide_font_png_size(EB_Font_Code height, size_t *size) +{ + EB_Error_Code error_code; + + LOG(("in: eb_wide_font_png_size(height=%d)", (int)height)); + + switch (height) { + case EB_FONT_16: + *size = EB_SIZE_WIDE_FONT_16_PNG; + break; + case EB_FONT_24: + *size = EB_SIZE_WIDE_FONT_24_PNG; + break; + case EB_FONT_30: + *size = EB_SIZE_WIDE_FONT_30_PNG; + break; + case EB_FONT_48: + *size = EB_SIZE_WIDE_FONT_48_PNG; + break; + default: + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + LOG(("out: eb_wide_font_png_size(size=%ld) = %s", (long)*size, + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *size = 0; + LOG(("out: eb_wide_font_png_size() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * The maximum number of octets in a line in a XBM file. + */ +#define XBM_MAX_OCTETS_A_LINE 12 + +/* + * The base name of a XBM file. + */ +#define XBM_BASE_NAME "default" + +/* + * Convert a bitmap image to XBM format. + * + * It requires four arguements. `xbm' is buffer to store the XBM + * image data. `bitmap', `width', and `height' are bitmap data, + * width, and height of the bitmap image. + */ +EB_Error_Code +eb_bitmap_to_xbm(const char *bitmap, int width, int height, char *xbm, + size_t *xbm_length) +{ + char *xbm_p = xbm; + const unsigned char *bitmap_p = (const unsigned char *)bitmap; + int bitmap_size = (width + 7) / 8 * height; + int hex; + int i; + + LOG(("in: eb_bitmap_to_xbm(width=%d, height=%d)", width, height)); + + /* + * Output a header. + */ + sprintf(xbm_p, "#define %s_width %4d\n", XBM_BASE_NAME, width); + xbm_p = strchr(xbm_p, '\n') + 1; + sprintf(xbm_p, "#define %s_height %4d\n", XBM_BASE_NAME, height); + xbm_p = strchr(xbm_p, '\n') + 1; + sprintf(xbm_p, "static unsigned char %s_bits[] = {\n", XBM_BASE_NAME); + xbm_p = strchr(xbm_p, '\n') + 1; + + /* + * Output image data. + */ + for (i = 0; i < bitmap_size; i++) { + hex = 0; + hex |= (*bitmap_p & 0x80) ? 0x01 : 0x00; + hex |= (*bitmap_p & 0x40) ? 0x02 : 0x00; + hex |= (*bitmap_p & 0x20) ? 0x04 : 0x00; + hex |= (*bitmap_p & 0x10) ? 0x08 : 0x00; + hex |= (*bitmap_p & 0x08) ? 0x10 : 0x00; + hex |= (*bitmap_p & 0x04) ? 0x20 : 0x00; + hex |= (*bitmap_p & 0x02) ? 0x40 : 0x00; + hex |= (*bitmap_p & 0x01) ? 0x80 : 0x00; + bitmap_p++; + + if (i % XBM_MAX_OCTETS_A_LINE != 0) { + sprintf(xbm_p, ", 0x%02x", hex); + xbm_p += 6; + } else if (i == 0) { + sprintf(xbm_p, " 0x%02x", hex); + xbm_p += 7; + } else { + sprintf(xbm_p, ",\n 0x%02x", hex); + xbm_p += 9; + } + } + + /* + * Output a footer. + */ + memcpy(xbm_p, "};\n", 3); + xbm_p += 3; + + *xbm_length = xbm_p - xbm; + + LOG(("out: eb_bitmap_to_xbm(xbm_length=%ld) = %s", + (long)(xbm_p - xbm), eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; +} + + +/* + * The base name of a XPM file. + */ +#define XPM_BASE_NAME "default" + +/* + * The foreground and background colors of XPM image. + */ +#define XPM_FOREGROUND_COLOR "Black" +#define XPM_BACKGROUND_COLOR "None" + +/* + * Convert a bitmap image to XPM format. + * + * It requires four arguements. `xpm' is buffer to store the XPM + * image data. `bitmap', `width', and `height' are bitmap data, + * width, and height of the bitmap image. + */ +EB_Error_Code +eb_bitmap_to_xpm(const char *bitmap, int width, int height, char *xpm, + size_t *xpm_length) +{ + char *xpm_p = xpm; + const unsigned char *bitmap_p = (const unsigned char *)bitmap; + int i, j; + + LOG(("in: eb_bitmap_to_xpm(width=%d, height=%d)", width, height)); + + /* + * Output a header. + */ + sprintf(xpm_p, "/* XPM */\n"); + xpm_p = strchr(xpm_p, '\n') + 1; + + sprintf(xpm_p, "static char * %s[] = {\n", XPM_BASE_NAME); + xpm_p = strchr(xpm_p, '\n') + 1; + + sprintf(xpm_p, "\"%d %d 2 1\",\n", width, height); + xpm_p = strchr(xpm_p, '\n') + 1; + + sprintf(xpm_p, "\" c %s\",\n", XPM_BACKGROUND_COLOR); + xpm_p = strchr(xpm_p, '\n') + 1; + + sprintf(xpm_p, "\". c %s\",\n", XPM_FOREGROUND_COLOR); + xpm_p = strchr(xpm_p, '\n') + 1; + + /* + * Output image data. + */ + for (i = 0; i < height; i++) { + if (0 < i) { + strcpy(xpm_p, "\",\n\""); + xpm_p += 4; + } else { + *xpm_p++ = '\"'; + } + + for (j = 0; j + 7 < width; j += 8, bitmap_p++) { + *xpm_p++ = (*bitmap_p & 0x80) ? '.' : ' '; + *xpm_p++ = (*bitmap_p & 0x40) ? '.' : ' '; + *xpm_p++ = (*bitmap_p & 0x20) ? '.' : ' '; + *xpm_p++ = (*bitmap_p & 0x10) ? '.' : ' '; + *xpm_p++ = (*bitmap_p & 0x08) ? '.' : ' '; + *xpm_p++ = (*bitmap_p & 0x04) ? '.' : ' '; + *xpm_p++ = (*bitmap_p & 0x02) ? '.' : ' '; + *xpm_p++ = (*bitmap_p & 0x01) ? '.' : ' '; + } + + if (j < width) { + if (j++ < width) + *xpm_p++ = (*bitmap_p & 0x80) ? '.' : ' '; + if (j++ < width) + *xpm_p++ = (*bitmap_p & 0x40) ? '.' : ' '; + if (j++ < width) + *xpm_p++ = (*bitmap_p & 0x20) ? '.' : ' '; + if (j++ < width) + *xpm_p++ = (*bitmap_p & 0x10) ? '.' : ' '; + if (j++ < width) + *xpm_p++ = (*bitmap_p & 0x08) ? '.' : ' '; + if (j++ < width) + *xpm_p++ = (*bitmap_p & 0x04) ? '.' : ' '; + if (j++ < width) + *xpm_p++ = (*bitmap_p & 0x02) ? '.' : ' '; + if (j++ < width) + *xpm_p++ = (*bitmap_p & 0x01) ? '.' : ' '; + bitmap_p++; + } + } + + /* + * Output a footer. + */ + memcpy(xpm_p, "\"};\n", 4); + xpm_p += 4; + + if (xpm_length != NULL) + *xpm_length = xpm_p - xpm; + + LOG(("out: eb_bitmap_to_xpm(xpm_length=%ld) = %s", + (long)(xpm_p - xpm), eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; +} + + +/* + * The Foreground and background colors of GIF image. + */ +#define GIF_FOREGROUND_COLOR 0x000000 +#define GIF_BACKGROUND_COLOR 0xffffff + +/* + * The preamble of GIF image. + */ +#define GIF_PREAMBLE_LENGTH 38 + +static const unsigned char gif_preamble[GIF_PREAMBLE_LENGTH] = { + /* + * Header. (6 bytes) + */ + 'G', 'I', 'F', '8', '9', 'a', + + /* + * Logical Screen Descriptor. (7 bytes) + * global color table flag = 1. + * color resolution = 1 - 1 = 0. + * sort flag = 0. + * size of global color table = 1 - 1 = 0. + * background color index = 0. + * the pixel aspect ratio = 0 (unused) + * Logical screen width and height are set at run time. + */ + 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + + /* + * Global Color Table. (6 bytes) + * These are set at run time. + */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + /* + * Graphic Control Extension. (8 bytes) + * disposal method = 0. + * user input flag = 0. + * transparency flag = 1. + * delay time = 0. + * transparent color index = 0. + */ + 0x21, 0xf9, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, + + /* + * Image Descriptor. (10 bytes) + * image left position = 0. + * image top position = 0. + * local color table flag = 0. + * interlace flag = 0. + * sort flag = 0. + * size of local color table = 0. + * Image width and height are set at run time. + */ + 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + /* + * Code size. (1byte) + */ + 0x03 +}; + + +/* + * Convert a bitmap image to GIF format. + * + * It requires four arguements. `gif' is buffer to store the GIF + * image data. `bitmap', `width', and `height' are bitmap data, + * width, and height of the bitmap image. + * + * Note: This GIF image doesn't use LZW because of patent. + */ +EB_Error_Code +eb_bitmap_to_gif(const char *bitmap, int width, int height, char *gif, + size_t *gif_length) +{ + unsigned char *gif_p = (unsigned char *)gif; + const unsigned char *bitmap_p = (const unsigned char *)bitmap; + int i, j; + + LOG(("in: eb_bitmap_to_gif(width=%d, height=%d)", width, height)); + + /* + * Copy the default preamble. + */ + memcpy(gif_p, gif_preamble, GIF_PREAMBLE_LENGTH); + + /* + * Set logical screen width and height. + */ + gif_p[6] = width & 0xff; + gif_p[7] = (width >> 8) & 0xff; + gif_p[8] = height & 0xff; + gif_p[9] = (height >> 8) & 0xff; + + /* + * Set global colors. + */ + gif_p[13] = (GIF_BACKGROUND_COLOR >> 16) & 0xff; + gif_p[14] = (GIF_BACKGROUND_COLOR >> 8) & 0xff; + gif_p[15] = GIF_BACKGROUND_COLOR & 0xff; + gif_p[16] = (GIF_FOREGROUND_COLOR >> 16) & 0xff; + gif_p[17] = (GIF_FOREGROUND_COLOR >> 8) & 0xff; + gif_p[18] = GIF_FOREGROUND_COLOR & 0xff; + + /* + * Set image width and height. + */ + gif_p[32] = width & 0xff; + gif_p[33] = (width >> 8) & 0xff; + gif_p[34] = height & 0xff; + gif_p[35] = (height >> 8) & 0xff; + + gif_p += GIF_PREAMBLE_LENGTH; + + /* + * Output image data. + */ + for (i = 0; i < height; i++) { + *gif_p++ = (unsigned char)width; + for (j = 0; j + 7 < width; j += 8, bitmap_p++) { + *gif_p++ = (*bitmap_p & 0x80) ? 0x81 : 0x80; + *gif_p++ = (*bitmap_p & 0x40) ? 0x81 : 0x80; + *gif_p++ = (*bitmap_p & 0x20) ? 0x81 : 0x80; + *gif_p++ = (*bitmap_p & 0x10) ? 0x81 : 0x80; + *gif_p++ = (*bitmap_p & 0x08) ? 0x81 : 0x80; + *gif_p++ = (*bitmap_p & 0x04) ? 0x81 : 0x80; + *gif_p++ = (*bitmap_p & 0x02) ? 0x81 : 0x80; + *gif_p++ = (*bitmap_p & 0x01) ? 0x81 : 0x80; + } + + if (j < width) { + if (j++ < width) + *gif_p++ = (*bitmap_p & 0x80) ? 0x81 : 0x80; + if (j++ < width) + *gif_p++ = (*bitmap_p & 0x40) ? 0x81 : 0x80; + if (j++ < width) + *gif_p++ = (*bitmap_p & 0x20) ? 0x81 : 0x80; + if (j++ < width) + *gif_p++ = (*bitmap_p & 0x10) ? 0x81 : 0x80; + if (j++ < width) + *gif_p++ = (*bitmap_p & 0x08) ? 0x81 : 0x80; + if (j++ < width) + *gif_p++ = (*bitmap_p & 0x04) ? 0x81 : 0x80; + if (j++ < width) + *gif_p++ = (*bitmap_p & 0x02) ? 0x81 : 0x80; + if (j++ < width) + *gif_p++ = (*bitmap_p & 0x01) ? 0x81 : 0x80; + bitmap_p++; + } + } + + /* + * Output a trailer. + */ + memcpy(gif_p, "\001\011\000\073", 4); + gif_p += 4; + + if (gif_length != NULL) + *gif_length = ((char *)gif_p - gif); + + LOG(("out: eb_bitmap_to_gif(gif_length=%ld) = %s", + (long)((char *)gif_p - gif), eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; +} + + +/* + * The preamble of BMP image. + */ +#define BMP_PREAMBLE_LENGTH 62 + +static const unsigned char bmp_preamble[] = { + /* Type. */ + 'B', 'M', + + /* File size. (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + + /* Reserved. */ + 0x00, 0x00, 0x00, 0x00, + + /* Offset of bitmap bits part. */ + 0x3e, 0x00, 0x00, 0x00, + + /* Size of bitmap info part. */ + 0x28, 0x00, 0x00, 0x00, + + /* Width. (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + + /* Height. (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + + /* Planes. */ + 0x01, 0x00, + + /* Bits per pixels. */ + 0x01, 0x00, + + /* Compression mode. */ + 0x00, 0x00, 0x00, 0x00, + + /* Size of bitmap bits part. (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + + /* X Pixels per meter. */ + 0x6d, 0x0b, 0x00, 0x00, + + /* Y Pixels per meter. */ + 0x6d, 0x0b, 0x00, 0x00, + + /* Colors */ + 0x02, 0x00, 0x00, 0x00, + + /* Important colors */ + 0x02, 0x00, 0x00, 0x00, + + /* RGB quad of color 0 RGB quad of color 1 */ + 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +/* + * Convert a bitmap image to BMP format. + * + * It requires four arguements. `bmp' is buffer to store the BMP + * image data. `bitmap', `width', and `height' are bitmap data, + * width, and height of the bitmap image. + */ +EB_Error_Code +eb_bitmap_to_bmp(const char *bitmap, int width, int height, char *bmp, + size_t *bmp_length) +{ + unsigned char *bmp_p = (unsigned char *)bmp; + size_t data_size; + size_t file_size; + size_t line_pad_length; + size_t bitmap_line_length; + int i, j; + + LOG(("in: eb_bitmap_to_bmp(width=%d, height=%d)", width, height)); + + if (width % 32 == 0) + line_pad_length = 0; + else if (width % 32 <= 8) + line_pad_length = 3; + else if (width % 32 <= 16) + line_pad_length = 2; + else if (width % 32 <= 24) + line_pad_length = 1; + else + line_pad_length = 0; + + data_size = (width / 2 + line_pad_length) * height; + file_size = data_size + BMP_PREAMBLE_LENGTH; + + /* + * Set BMP preamble. + */ + memcpy(bmp_p, bmp_preamble, BMP_PREAMBLE_LENGTH); + + bmp_p[2] = file_size & 0xff; + bmp_p[3] = (file_size >> 8) & 0xff; + bmp_p[4] = (file_size >> 16) & 0xff; + bmp_p[5] = (file_size >> 24) & 0xff; + + bmp_p[18] = width & 0xff; + bmp_p[19] = (width >> 8) & 0xff; + bmp_p[20] = (width >> 16) & 0xff; + bmp_p[21] = (width >> 24) & 0xff; + + bmp_p[22] = height & 0xff; + bmp_p[23] = (height >> 8) & 0xff; + bmp_p[24] = (height >> 16) & 0xff; + bmp_p[25] = (height >> 24) & 0xff; + + bmp_p[34] = data_size & 0xff; + bmp_p[35] = (data_size >> 8) & 0xff; + bmp_p[36] = (data_size >> 16) & 0xff; + bmp_p[37] = (data_size >> 24) & 0xff; + + bmp_p += BMP_PREAMBLE_LENGTH; + bitmap_line_length = (width + 7) / 8; + + for (i = height - 1; 0 <= i; i--) { + memcpy(bmp_p, bitmap + bitmap_line_length * i, bitmap_line_length); + bmp_p += bitmap_line_length; + for (j = 0; j < line_pad_length; j++, bmp_p++) + *bmp_p = 0x00; + } + + if (bmp_length != NULL) + *bmp_length = ((char *)bmp_p - bmp); + + LOG(("out: eb_bitmap_to_bmp(bmp_length=%ld) = %s", + (long)((char *)bmp_p - bmp), eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; +} + + +/* + * The Foreground and background colors of PNG image. + */ +#define PNG_FOREGROUND_COLOR 0x000000 +#define PNG_BACKGROUND_COLOR 0xffffff + +/* + * The preamble of PNG image. + */ +static const unsigned char png_preamble[] = { + /* + * PNG file signature (8 bytes) + */ + 0x89, 'P', 'N', 'G', '\r', '\n', 0x1a, '\n', + /* + * IHDR(Image Header) Chunk (25 bytes) + */ + /* Size of IHDR. */ + 0x00, 0x00, 0x00, 0x0d, + 'I', 'H', 'D', 'R', + /* Width. (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + /* Height. (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + /* misc. */ + 0x01, 0x03, 0x00, 0x00, 0x00, + /* CRC (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + + /* + * PLTE(Palette) Chunk (18 bytes) + */ + /* Size of PLTE */ + 0x00, 0x00, 0x00, 0x06, + 'P', 'L', 'T', 'E', + /* RGB for palette index 0 */ + 0xff, 0xff, 0xff, + /* RGB for palette index 1 */ + 0x00, 0x00, 0x00, + /* CRC (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + + /* + * tRNS(Transparency) Chunk (13 bytes) + */ + /* Size of tRNS */ + 0x00, 0x00, 0x00, 0x01, + 't', 'R', 'N', 'S', + /* Alpha for palette index 0 */ + 0x00, + /* CRC */ + 0x40, 0xe6, 0xd8, 0x66, + + /* + * IDAT(Image Data) Chunk (12+ bytes) + */ + /* Size of IDAT (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + 'I', 'D', 'A', 'T', +}; + +static const unsigned char png_trailer[] = { + /* CRC (set at run time) */ + 0x00, 0x00, 0x00, 0x00, + /* + * IEND(Image End) Chunk (12 bytes) + */ + /* Size of IEND */ + 0x00, 0x00, 0x00, 0x00, + 'I', 'E', 'N', 'D', + /* CRC */ + 0xae, 0x42, 0x60, 0x82, +}; + +/* + * Table of CRCs of all 8-bit messages. + */ +static const unsigned long png_crc_table[256] = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, /* 0x00 - 0x03 */ + 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, /* 0x04 - 0x07 */ + 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, /* 0x08 - 0x0b */ + 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, /* 0x0c - 0x0f */ + 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, /* 0x10 - 0x13 */ + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, /* 0x14 - 0x17 */ + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, /* 0x18 - 0x1b */ + 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, /* 0x1c - 0x1f */ + 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, /* 0x20 - 0x23 */ + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, /* 0x24 - 0x27 */ + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, /* 0x28 - 0x2b */ + 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, /* 0x2c - 0x2f */ + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, /* 0x30 - 0x33 */ + 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, /* 0x34 - 0x37 */ + 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, /* 0x38 - 0x3b */ + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, /* 0x3c - 0x3f */ + 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, /* 0x40 - 0x43 */ + 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, /* 0x44 - 0x47 */ + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, /* 0x48 - 0x4b */ + 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, /* 0x4c - 0x4f */ + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, /* 0x50 - 0x53 */ + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, /* 0x54 - 0x57 */ + 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, /* 0x58 - 0x5b */ + 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, /* 0x5c - 0x5f */ + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, /* 0x60 - 0x63 */ + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, /* 0x64 - 0x67 */ + 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, /* 0x68 - 0x6b */ + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, /* 0x6c - 0x6f */ + 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, /* 0x70 - 0x73 */ + 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, /* 0x74 - 0x77 */ + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, /* 0x78 - 0x7b */ + 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, /* 0x7c - 0x7f */ + 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, /* 0x80 - 0x83 */ + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, /* 0x84 - 0x87 */ + 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, /* 0x88 - 0x8b */ + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, /* 0x8c - 0x8f */ + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, /* 0x90 - 0x93 */ + 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, /* 0x94 - 0x97 */ + 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, /* 0x98 - 0x9b */ + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, /* 0x9c - 0x9f */ + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, /* 0xa0 - 0xa3 */ + 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, /* 0xa4 - 0xa7 */ + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, /* 0xa8 - 0xab */ + 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, /* 0xac - 0xaf */ + 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, /* 0xb0 - 0xb3 */ + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, /* 0xb4 - 0xb7 */ + 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, /* 0xb8 - 0xbb */ + 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, /* 0xbc - 0xbf */ + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, /* 0xc0 - 0xc3 */ + 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, /* 0xc4 - 0xc7 */ + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, /* 0xc8 - 0xcb */ + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, /* 0xcc - 0xcf */ + 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, /* 0xd0 - 0xd3 */ + 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, /* 0xd4 - 0xd7 */ + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, /* 0xd8 - 0xdb */ + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, /* 0xdc - 0xdf */ + 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, /* 0xe0 - 0xe3 */ + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, /* 0xe4 - 0xe7 */ + 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, /* 0xe8 - 0xeb */ + 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, /* 0xec - 0xef */ + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, /* 0xf0 - 0xf3 */ + 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, /* 0xf4 - 0xf7 */ + 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, /* 0xf8 - 0xfb */ + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d /* 0xfc - 0xff */ +}; + +static unsigned long +png_crc(const char *buf, size_t len) +{ + unsigned long c = 0xffffffffL; + int n; + + for (n = 0; n < len; n++) + c = png_crc_table[(c ^ *((unsigned char *)buf + n)) & 0xff] ^ (c >> 8); + return c ^ 0xffffffffL; +} + + +static int +png_compress(const char *src, int width, int height, char *dest, + size_t *dest_len) +{ + int line_size = (width + 7) / 8; + z_stream z; + int z_result; + unsigned char byte_zero = 0x00; + int i; + + z.zalloc = Z_NULL; + z.zfree = Z_NULL; + z.opaque = Z_NULL; + z_result = deflateInit(&z, Z_NO_COMPRESSION); + if (z_result != Z_OK) + return z_result; + + /* + * Exactly to say, `z.avail_out' must be: + * avail_out > (sizeof(src) + 12) * 1.001 + * but we use an approximation here. + */ + z.next_out = (unsigned char *)dest; + z.avail_out = (line_size + 1) * height + 12 + 256; + for (i = 0; i < height - 1; i++) { + z.next_in = &byte_zero; + z.avail_in = 1; + z_result = deflate(&z, Z_NO_FLUSH); + if (z_result != Z_OK || z.avail_in != 0) + goto failed; + + z.next_in = (unsigned char *)src + (line_size * i); + z.avail_in = line_size; + z_result = deflate(&z, Z_NO_FLUSH); + if (z_result != Z_OK || z.avail_in != 0) + goto failed; + } + + z.next_in = &byte_zero; + z.avail_in = 1; + z_result = deflate(&z, Z_NO_FLUSH); + if (z_result != Z_OK || z.avail_in != 0) + goto failed; + + z.next_in = (unsigned char *)src + (line_size * i); + z.avail_in = line_size; + if (deflate(&z, Z_FINISH) != Z_STREAM_END) + goto failed; + + z_result = deflateEnd(&z); + if (z_result != Z_OK) + return z_result; + + *dest_len = (z.next_out - (unsigned char *)dest); + return Z_STREAM_END; + + /* + * An error occurs... + */ + failed: + deflateEnd(&z); + return z_result; +} + + +#define INT2CHARS(p, i) do { \ + *(unsigned char *)(p) = ((i) >> 24) & 0xff; \ + *((unsigned char *)(p) + 1) = ((i) >> 16) & 0xff; \ + *((unsigned char *)(p) + 2) = ((i) >> 8) & 0xff; \ + *((unsigned char *)(p) + 3) = (i) & 0xff; \ +} while (0); + +#define RGB2CHARS(p, i) do { \ + *(unsigned char *)(p) = ((i) >> 16) & 0xff; \ + *((unsigned char *)(p) + 1) = ((i) >> 8) & 0xff; \ + *((unsigned char *)(p) + 2) = (i) & 0xff; \ +} while (0); + +/* + * Convert a bitmap image to PNG format. + * + * It requires four arguements. `png' is buffer to store the PNG + * image data. `bitmap', `width', and `height' are bitmap data, + * width, and height of the bitmap image. + */ +EB_Error_Code +eb_bitmap_to_png(const char *bitmap, int width, int height, char *png, + size_t *png_length) +{ + EB_Error_Code error_code; + char *png_p = png; + char *idat_start; + size_t idat_len; + unsigned long crc; + int z_result; + + LOG(("in: eb_bitmap_to_png(width=%d, height=%d)", width, height)); + + /* + * Copy the default preamble. + */ + memcpy(png_p, png_preamble, sizeof(png_preamble)); + + /* + * Set image width and height. + */ + INT2CHARS(png_p + 16, width); + INT2CHARS(png_p + 20, height); + + crc = png_crc(png_p + 12, 17); + INT2CHARS(png_p + 29, crc); + + /* + * Set global colors. + */ + RGB2CHARS(png_p + 41, PNG_BACKGROUND_COLOR); + RGB2CHARS(png_p + 44, PNG_FOREGROUND_COLOR); + crc = png_crc(png_p + 37, 10); + INT2CHARS(png_p + 47, crc); + + /* + * Output `bitmap'. + * We assume memory allocation error occurs if png_compress() doesn't + * return Z_STREAM_END. + */ + idat_start = png_p + sizeof(png_preamble); + z_result = png_compress(bitmap, width, height, idat_start, &idat_len); + if (z_result != Z_STREAM_END) { + error_code = EB_ERR_MEMORY_EXHAUSTED; + goto failed; + } + INT2CHARS(png_p + 64, idat_len); + crc = png_crc(idat_start - 4, idat_len + 4); + png_p = idat_start + idat_len; + + /* + * Output a trailer. + */ + memcpy(png_p, png_trailer, sizeof(png_trailer)); + INT2CHARS(png_p, crc); + png_p += sizeof(png_trailer); + if (png_length != NULL) + *png_length = ((char *)png_p - png); + + LOG(("out: eb_bitmap_to_png(png_length=%ld) = %s", + (long)((char *)png_p - png), eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_bitmap_to_png(png_length=%ld) = %s", + (long)((char *)png_p - png), eb_error_string(error_code))); + return error_code; +} + +#undef INT2CHARS +#undef RGB2CHARS + + +#ifdef TEST + +#include +#include +#include + +#define test_width 32 +#define test_height 16 +static unsigned char test_bitmap[] = { + 0xff, 0xff, 0xff, 0xff, 0x80, 0x81, 0x83, 0x01, 0x80, 0x81, 0x01, 0x01, + 0x80, 0x81, 0x01, 0x01, 0xe3, 0x8f, 0x11, 0xc7, 0xe3, 0x8f, 0x0f, 0xc7, + 0xe3, 0x81, 0x87, 0xc7, 0xe3, 0x81, 0xc3, 0xc7, 0xe3, 0x81, 0xe1, 0xc7, + 0xe3, 0x8f, 0x11, 0xc7, 0xe3, 0x8f, 0x11, 0xc7, 0xe3, 0x81, 0x01, 0xc7, + 0xe3, 0x81, 0x01, 0xc7, 0xe3, 0x81, 0x83, 0xc7, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff +}; + +int +main(int argc, char *argv[]) +{ + char image[EB_SIZE_FONT_IMAGE]; + size_t image_size; + int file; + + eb_bitmap_to_xbm(test_bitmap, test_width, test_height, image, &image_size); + file = creat("test.xbm", 0644); + if (file < 0) + exit(1); + if (write(file, image, image_size) != image_size) { + close(file); + exit(1); + } + + eb_bitmap_to_xpm(test_bitmap, test_width, test_height, image, &image_size); + file = creat("test.xpm", 0644); + if (file < 0) + exit(1); + if (write(file, image, image_size) != image_size) { + close(file); + exit(1); + } + + eb_bitmap_to_gif(test_bitmap, test_width, test_height, image, &image_size); + file = creat("test.gif", 0644); + if (file < 0) + exit(1); + if (write(file, image, image_size) != image_size) { + close(file); + exit(1); + } + + eb_bitmap_to_bmp(test_bitmap, test_width, test_height, image, &image_size); + file = creat("test.bmp", 0644); + if (file < 0) + exit(1); + if (write(file, image, image_size) != image_size) { + close(file); + exit(1); + } + + eb_bitmap_to_png(test_bitmap, test_width, test_height, image, &image_size); + file = creat("test.png", 0644); + if (file < 0) + exit(1); + if (write(file, image, image_size) != image_size) { + close(file); + exit(1); + } + + return 0; +} + +#endif /* TEST */ diff --git a/eb/book.c b/eb/book.c new file mode 100644 index 0000000..8dc8f7c --- /dev/null +++ b/eb/book.c @@ -0,0 +1,1003 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "font.h" +#ifdef ENABLE_EBNET +#include "ebnet.h" +#endif +#include "build-post.h" + +/* + * Book ID counter. + */ +static EB_Book_Code book_counter = 0; + +/* + * Mutex for `book_counter'. + */ +#ifdef ENABLE_PTHREAD +static pthread_mutex_t book_counter_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif + +/* + * Unexported functions. + */ +static void eb_fix_misleaded_book(EB_Book *book); +static EB_Error_Code eb_load_catalog(EB_Book *book); +static EB_Error_Code eb_load_catalog_eb(EB_Book *book, + const char *catalog_path); +static EB_Error_Code eb_load_catalog_epwing(EB_Book *book, + const char *catalog_path); +static Zio_Code eb_get_hint_zio_code(int catalog_hint_value); +static void eb_load_language(EB_Book *book); + + +/* + * Initialize `book'. + */ +void +eb_initialize_book(EB_Book *book) +{ + LOG(("in: eb_initialize_book()")); + + book->code = EB_BOOK_NONE; + book->disc_code = EB_DISC_INVALID; + book->character_code = EB_CHARCODE_INVALID; + book->path = NULL; + book->path_length = 0; + book->subbooks = NULL; + book->subbook_current = NULL; +#ifdef ENABLE_EBNET + book->ebnet_file = -1; +#endif + eb_initialize_text_context(book); + eb_initialize_binary_context(book); + eb_initialize_search_contexts(book); + eb_initialize_binary_context(book); + eb_initialize_lock(&book->lock); + + LOG(("out: eb_initialize_book()")); +} + + +/* + * Bind `book' to `path'. + */ +EB_Error_Code +eb_bind(EB_Book *book, const char *path) +{ + EB_Error_Code error_code; + char temporary_path[EB_MAX_PATH_LENGTH + 1]; + int is_ebnet; + + eb_lock(&book->lock); + LOG(("in: eb_bind(path=%s)", path)); + + /* + * Clear the book if the book has already been bound. + */ + if (book->path != NULL) { + eb_finalize_book(book); + eb_initialize_book(book); + } + + /* + * Assign a book code. + */ + pthread_mutex_lock(&book_counter_mutex); + book->code = book_counter++; + pthread_mutex_unlock(&book_counter_mutex); + + /* + * Check whether `path' is URL. + */ + is_ebnet = is_ebnet_url(path); +#ifndef ENABLE_EBNET + if (is_ebnet) { + error_code = EB_ERR_EBNET_UNSUPPORTED; + goto failed; + } +#endif + + /* + * Set the path of the book. + * The length of the file name "/subdir/subsubdir/file.ebz;1" must + * be EB_MAX_PATH_LENGTH maximum. + */ + if (EB_MAX_PATH_LENGTH < strlen(path)) { + error_code = EB_ERR_TOO_LONG_FILE_NAME; + goto failed; + } + strcpy(temporary_path, path); +#ifdef ENABLE_EBNET + if (is_ebnet) + error_code = ebnet_canonicalize_url(temporary_path); + else + error_code = eb_canonicalize_path_name(temporary_path); +#else + error_code = eb_canonicalize_path_name(temporary_path); +#endif + if (error_code != EB_SUCCESS) + goto failed; + + book->path_length = strlen(temporary_path); + if (EB_MAX_PATH_LENGTH + < book->path_length + 1 + EB_MAX_RELATIVE_PATH_LENGTH) { + error_code = EB_ERR_TOO_LONG_FILE_NAME; + goto failed; + } + + book->path = (char *)malloc(book->path_length + 1); + if (book->path == NULL) { + error_code = EB_ERR_MEMORY_EXHAUSTED; + goto failed; + } + strcpy(book->path, temporary_path); + + /* + * Establish a connection with a ebnet server. + */ +#ifdef ENABLE_EBNET + if (is_ebnet) { + error_code = ebnet_bind(book, book->path); + if (error_code != EB_SUCCESS) + goto failed; + } +#endif + + /* + * Read information from the `LANGUAGE' file. + * If failed to initialize, JIS X 0208 is assumed. + */ + eb_load_language(book); + + /* + * Read information from the `CATALOG(S)' file. + */ + error_code = eb_load_catalog(book); + if (error_code != EB_SUCCESS) + goto failed; + + LOG(("out: eb_bind(book=%d) = %s", (int)book->code, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_finalize_book(book); + LOG(("out: eb_bind() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Finish using `book'. + */ +void +eb_finalize_book(EB_Book *book) +{ + LOG(("in: eb_finalize_book(book=%d)", (int)book->code)); + + eb_unset_subbook(book); + + if (book->subbooks != NULL) { + eb_finalize_subbooks(book); + free(book->subbooks); + book->subbooks = NULL; + } + + book->subbook_current = NULL; + eb_finalize_text_context(book); + eb_finalize_binary_context(book); + eb_finalize_search_contexts(book); + eb_finalize_binary_context(book); + eb_finalize_lock(&book->lock); + +#ifdef ENABLE_EBNET + ebnet_finalize_book(book); +#endif + + if (book->path != NULL) + free(book->path); + + book->code = EB_BOOK_NONE; + book->disc_code = EB_DISC_INVALID; + book->character_code = EB_CHARCODE_INVALID; + book->path = NULL; + book->path_length = 0; + + LOG(("out: eb_finalize_book()")); +} + + +/* + * There are some books that EB Library sets wrong character code of + * the book. They are written in JIS X 0208, but the library sets + * ISO 8859-1. + * + * We fix the character of the books. The following table lists + * titles of the first subbook in those books. + */ +static const char * const misleaded_book_table[] = { + /* SONY DataDiskMan (DD-DR1) accessories. */ + "%;%s%A%e%j!\\%S%8%M%9!\\%/%i%&%s", + + /* Shin Eiwa Waei Chujiten (earliest edition) */ + "8&5fcode)); + + for (misleaded = misleaded_book_table; *misleaded != NULL; misleaded++) { + if (strcmp(book->subbooks[0].title, *misleaded) == 0) { + book->character_code = EB_CHARCODE_JISX0208; + for (i = 0, subbook = book->subbooks; i < book->subbook_count; + i++, subbook++) { + eb_jisx0208_to_euc(subbook->title, subbook->title); + } + break; + } + } + + LOG(("out: eb_fix_misleaded_book()")); +} + +/* + * Read information from the `CATALOG(S)' file in 'book'. + * Return EB_SUCCESS if it succeeds, error-code otherwise. + */ +static EB_Error_Code +eb_load_catalog(EB_Book *book) +{ + EB_Error_Code error_code; + char catalog_file_name[EB_MAX_FILE_NAME_LENGTH + 1]; + char catalog_path_name[EB_MAX_PATH_LENGTH + 1]; + + LOG(("in: eb_load_catalog(book=%d)", (int)book->code)); + + /* + * Find a catalog file. + */ + if (eb_find_file_name(book->path, "catalog", catalog_file_name) + == EB_SUCCESS) { + book->disc_code = EB_DISC_EB; + } else if (eb_find_file_name(book->path, "catalogs", catalog_file_name) + == EB_SUCCESS) { + book->disc_code = EB_DISC_EPWING; + } else { + error_code = EB_ERR_FAIL_OPEN_CAT; + goto failed; + } + + eb_compose_path_name(book->path, catalog_file_name, catalog_path_name); + + /* + * Load the catalog file. + */ + if (book->disc_code == EB_DISC_EB) + error_code = eb_load_catalog_eb(book, catalog_path_name); + else + error_code = eb_load_catalog_epwing(book, catalog_path_name); + if (error_code != EB_SUCCESS) + goto failed; + + /* + * Fix chachacter-code of the book. + */ + eb_fix_misleaded_book(book); + LOG(("out: eb_load_catalog() = %s", eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + if (book->subbooks != NULL) { + free(book->subbooks); + book->subbooks = NULL; + } + LOG(("out: eb_load_catalog() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Read information from the `CATALOG' file in 'book'. (EB) + */ +static EB_Error_Code +eb_load_catalog_eb(EB_Book *book, const char *catalog_path) +{ + EB_Error_Code error_code; + char buffer[EB_SIZE_PAGE]; + char *space; + EB_Subbook *subbook; + Zio zio; + Zio_Code zio_code; + int i; + + LOG(("in: eb_load_catalog_eb(book=%d, catalog=%s)", + (int)book->code, catalog_path)); + + zio_initialize(&zio); + + /* + * Open a catalog file. + */ + eb_path_name_zio_code(catalog_path, ZIO_PLAIN, &zio_code); + if (zio_open(&zio, catalog_path, zio_code) < 0) { + error_code = EB_ERR_FAIL_OPEN_CAT; + goto failed; + } + + /* + * Get the number of subbooks in this book. + */ + if (zio_read(&zio, buffer, 16) != 16) { + error_code = EB_ERR_FAIL_READ_CAT; + goto failed; + } + + book->subbook_count = eb_uint2(buffer); + LOG(("aux: eb_load_catalog_eb(): subbook_count=%d", + book->subbook_count)); + if (EB_MAX_SUBBOOKS < book->subbook_count) + book->subbook_count = EB_MAX_SUBBOOKS; + if (book->subbook_count == 0) { + error_code = EB_ERR_UNEXP_CAT; + goto failed; + } + + /* + * Allocate memories for subbook entries. + */ + book->subbooks = (EB_Subbook *) malloc(sizeof(EB_Subbook) + * book->subbook_count); + if (book->subbooks == NULL) { + error_code = EB_ERR_MEMORY_EXHAUSTED; + goto failed; + } + eb_initialize_subbooks(book); + + /* + * Read information about subbook. + */ + for (i = 0, subbook = book->subbooks; i < book->subbook_count; + i++, subbook++) { + /* + * Read data from the catalog file. + */ + if (zio_read(&zio, buffer, EB_SIZE_EB_CATALOG) + != EB_SIZE_EB_CATALOG) { + error_code = EB_ERR_FAIL_READ_CAT; + goto failed; + } + + /* + * Set a directory name. + */ + strncpy(subbook->directory_name, + buffer + 2 + EB_MAX_EB_TITLE_LENGTH, + EB_MAX_DIRECTORY_NAME_LENGTH); + subbook->directory_name[EB_MAX_DIRECTORY_NAME_LENGTH] = '\0'; + space = strchr(subbook->directory_name, ' '); + if (space != NULL) + *space = '\0'; + eb_fix_directory_name(book->path, subbook->directory_name); + + /* + * Set an index page. + */ + subbook->index_page = 1; + + /* + * Set a title. (Convert from JISX0208 to EUC JP) + */ + strncpy(subbook->title, buffer + 2, EB_MAX_EB_TITLE_LENGTH); + subbook->title[EB_MAX_EB_TITLE_LENGTH] = '\0'; + if (book->character_code != EB_CHARCODE_ISO8859_1) + eb_jisx0208_to_euc(subbook->title, subbook->title); + + subbook->initialized = 0; + subbook->code = i; + } + + /* + * Close the catalog file. + */ + zio_close(&zio); + zio_finalize(&zio); + + /* + * Fix chachacter-code of the book. + */ + eb_fix_misleaded_book(book); + LOG(("out: eb_load_catalog_eb() = %s", eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + zio_close(&zio); + zio_initialize(&zio); + LOG(("out: eb_load_catalog() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Read information from the `CATALOGS' file in 'book'. (EPWING) + */ +static EB_Error_Code +eb_load_catalog_epwing(EB_Book *book, const char *catalog_path) +{ + EB_Error_Code error_code; + char buffer[EB_SIZE_PAGE]; + char *buffer_p; + char *space; + EB_Subbook *subbook; + EB_Font *font; + Zio zio; + Zio_Code zio_code; + int epwing_version; + int data_types; + int i, j; + + LOG(("in: eb_load_catalog_epwing(book=%d, catalog=%s)", + (int)book->code, catalog_path)); + + zio_initialize(&zio); + + /* + * Open a catalog file. + */ + eb_path_name_zio_code(catalog_path, ZIO_PLAIN, &zio_code); + if (zio_open(&zio, catalog_path, zio_code) < 0) { + error_code = EB_ERR_FAIL_OPEN_CAT; + goto failed; + } + + /* + * Get the number of subbooks in this book. + */ + if (zio_read(&zio, buffer, 16) != 16) { + error_code = EB_ERR_FAIL_READ_CAT; + goto failed; + } + + book->subbook_count = eb_uint2(buffer); + LOG(("aux: eb_load_catalog_epwing(): subbook_count=%d", + book->subbook_count)); + if (EB_MAX_SUBBOOKS < book->subbook_count) + book->subbook_count = EB_MAX_SUBBOOKS; + if (book->subbook_count == 0) { + error_code = EB_ERR_UNEXP_CAT; + goto failed; + } + + epwing_version = eb_uint2(buffer + 2); + LOG(("aux: eb_load_catalog_epwing(): epwing_version=%d", epwing_version)); + + /* + * Allocate memories for subbook entries. + */ + book->subbooks = (EB_Subbook *) malloc(sizeof(EB_Subbook) + * book->subbook_count); + if (book->subbooks == NULL) { + error_code = EB_ERR_MEMORY_EXHAUSTED; + goto failed; + } + eb_initialize_subbooks(book); + + /* + * Read information about subbook. + */ + for (i = 0, subbook = book->subbooks; i < book->subbook_count; + i++, subbook++) { + /* + * Read data from the catalog file. + */ + if (zio_read(&zio, buffer, EB_SIZE_EPWING_CATALOG) + != EB_SIZE_EPWING_CATALOG) { + error_code = EB_ERR_FAIL_READ_CAT; + goto failed; + } + + /* + * Set a directory name. + */ + strncpy(subbook->directory_name, + buffer + 2 + EB_MAX_EPWING_TITLE_LENGTH, + EB_MAX_DIRECTORY_NAME_LENGTH); + subbook->directory_name[EB_MAX_DIRECTORY_NAME_LENGTH] = '\0'; + space = strchr(subbook->directory_name, ' '); + if (space != NULL) + *space = '\0'; + eb_fix_directory_name(book->path, subbook->directory_name); + + /* + * Set an index page. + */ + subbook->index_page = eb_uint2(buffer + 2 + EB_MAX_EPWING_TITLE_LENGTH + + EB_MAX_DIRECTORY_NAME_LENGTH + 4); + + /* + * Set a title. (Convert from JISX0208 to EUC JP) + */ + strncpy(subbook->title, buffer + 2, EB_MAX_EPWING_TITLE_LENGTH); + subbook->title[EB_MAX_EPWING_TITLE_LENGTH] = '\0'; + if (book->character_code != EB_CHARCODE_ISO8859_1) + eb_jisx0208_to_euc(subbook->title, subbook->title); + + /* + * Narrow font file names. + */ + buffer_p = buffer + 2 + EB_MAX_EPWING_TITLE_LENGTH + 50; + for (font = subbook->narrow_fonts, j = 0; j < EB_MAX_FONTS; + j++, font++) { + /* + * Skip this entry if the first character of the file name + * is not valid. + */ + if (*buffer_p == '\0' || 0x80 <= *((unsigned char *)buffer_p)) { + buffer_p += EB_MAX_DIRECTORY_NAME_LENGTH; + continue; + } + strncpy(font->file_name, buffer_p, EB_MAX_DIRECTORY_NAME_LENGTH); + font->file_name[EB_MAX_DIRECTORY_NAME_LENGTH] = '\0'; + font->font_code = j; + font->page = 1; + space = strchr(font->file_name, ' '); + if (space != NULL) + *space = '\0'; + buffer_p += EB_MAX_DIRECTORY_NAME_LENGTH; + } + + /* + * Wide font file names. + */ + buffer_p = buffer + 2 + EB_MAX_EPWING_TITLE_LENGTH + 18; + for (font = subbook->wide_fonts, j = 0; j < EB_MAX_FONTS; + j++, font++) { + /* + * Skip this entry if the first character of the file name + * is not valid. + */ + if (*buffer_p == '\0' || 0x80 <= *((unsigned char *)buffer_p)) { + buffer_p += EB_MAX_DIRECTORY_NAME_LENGTH; + continue; + } + strncpy(font->file_name, buffer_p, EB_MAX_DIRECTORY_NAME_LENGTH); + font->file_name[EB_MAX_DIRECTORY_NAME_LENGTH] = '\0'; + font->font_code = j; + font->page = 1; + space = strchr(font->file_name, ' '); + if (space != NULL) + *space = '\0'; + buffer_p += EB_MAX_DIRECTORY_NAME_LENGTH; + } + + subbook->initialized = 0; + subbook->code = i; + } + + /* + * Set default file names and compression types. + */ + for (i = 0, subbook = book->subbooks; i < book->subbook_count; + i++, subbook++) { + strcpy(subbook->text_file_name, EB_FILE_NAME_HONMON); + strcpy(subbook->graphic_file_name, EB_FILE_NAME_HONMON); + strcpy(subbook->sound_file_name, EB_FILE_NAME_HONMON); + subbook->text_hint_zio_code = ZIO_PLAIN; + subbook->graphic_hint_zio_code = ZIO_PLAIN; + subbook->sound_hint_zio_code = ZIO_PLAIN; + } + + if (epwing_version == 1) + goto succeeded; + + /* + * Read extra information about subbook. + */ + for (i = 0, subbook = book->subbooks; i < book->subbook_count; + i++, subbook++) { + /* + * Read data from the catalog file. + * + * We don't complain about unexpected EOF. In that case, we + * return EB_SUCCESS. + */ + ssize_t read_result = zio_read(&zio, buffer, EB_SIZE_EPWING_CATALOG); + if (read_result < 0) { + error_code = EB_ERR_FAIL_READ_CAT; + goto failed; + } else if (read_result != EB_SIZE_EPWING_CATALOG) { + break; + } + if (*(buffer + 4) == '\0') + continue; + + /* + * Set a text file name and its compression hint. + */ + *(subbook->text_file_name) = '\0'; + strncpy(subbook->text_file_name, + buffer + 4, EB_MAX_DIRECTORY_NAME_LENGTH); + subbook->text_file_name[EB_MAX_DIRECTORY_NAME_LENGTH] = '\0'; + space = strchr(subbook->text_file_name, ' '); + if (space != NULL) + *space = '\0'; + subbook->text_hint_zio_code + = eb_get_hint_zio_code(eb_uint1(buffer + 55)); + if (subbook->text_hint_zio_code == ZIO_INVALID) { + error_code = EB_ERR_UNEXP_CAT; + goto failed; + } + + data_types = eb_uint2(buffer + 41); + + /* + * Set a graphic file name and its compression hint. + */ + *(subbook->graphic_file_name) = '\0'; + if ((data_types & 0x03) == 0x02) { + strncpy(subbook->graphic_file_name, buffer + 44, + EB_MAX_DIRECTORY_NAME_LENGTH); + subbook->graphic_hint_zio_code + = eb_get_hint_zio_code(eb_uint1(buffer + 54)); + } else if (((data_types >> 8) & 0x03) == 0x02) { + strncpy(subbook->graphic_file_name, buffer + 56, + EB_MAX_DIRECTORY_NAME_LENGTH); + subbook->graphic_hint_zio_code + = eb_get_hint_zio_code(eb_uint1(buffer + 53)); + } + subbook->graphic_file_name[EB_MAX_DIRECTORY_NAME_LENGTH] = '\0'; + space = strchr(subbook->graphic_file_name, ' '); + if (space != NULL) + *space = '\0'; + if (*(subbook->graphic_file_name) == '\0') { + strcpy(subbook->graphic_file_name, subbook->text_file_name); + subbook->graphic_hint_zio_code = subbook->text_hint_zio_code; + } + + if (subbook->graphic_hint_zio_code == ZIO_INVALID) { + error_code = EB_ERR_UNEXP_CAT; + goto failed; + } + + /* + * Set a sound file name and its compression hint. + */ + *(subbook->sound_file_name) = '\0'; + if ((data_types & 0x03) == 0x01) { + strncpy(subbook->sound_file_name, buffer + 44, + EB_MAX_DIRECTORY_NAME_LENGTH); + subbook->sound_hint_zio_code + = eb_get_hint_zio_code(eb_uint1(buffer + 54)); + } else if (((data_types >> 8) & 0x03) == 0x01) { + strncpy(subbook->sound_file_name, buffer + 56, + EB_MAX_DIRECTORY_NAME_LENGTH); + subbook->sound_hint_zio_code + = eb_get_hint_zio_code(eb_uint1(buffer + 53)); + } + subbook->sound_file_name[EB_MAX_DIRECTORY_NAME_LENGTH] = '\0'; + space = strchr(subbook->sound_file_name, ' '); + if (space != NULL) + *space = '\0'; + if (*(subbook->sound_file_name) == '\0') { + strcpy(subbook->sound_file_name, subbook->text_file_name); + subbook->sound_hint_zio_code = subbook->text_hint_zio_code; + } + + if (subbook->sound_hint_zio_code == ZIO_INVALID) { + error_code = EB_ERR_UNEXP_CAT; + goto failed; + } + } + + /* + * Close the catalog file. + */ + succeeded: + zio_close(&zio); + zio_finalize(&zio); + + /* + * Fix chachacter-code of the book. + */ + eb_fix_misleaded_book(book); + LOG(("out: eb_load_catalog_epwing() = %s", eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + zio_close(&zio); + zio_initialize(&zio); + LOG(("out: eb_load_catalog_epwing() = %s", eb_error_string(error_code))); + return error_code; +} + + +static Zio_Code +eb_get_hint_zio_code(int catalog_hint_value) +{ + switch (catalog_hint_value) { + case 0x00: + return ZIO_PLAIN; + break; + case 0x11: + return ZIO_EPWING; + break; + case 0x12: + return ZIO_EPWING6; + break; + } + + return ZIO_INVALID; +} + + +/* + * Read information from the `LANGUAGE' file in `book'. + */ +static void +eb_load_language(EB_Book *book) +{ + Zio zio; + Zio_Code zio_code; + char language_path_name[EB_MAX_PATH_LENGTH + 1]; + char language_file_name[EB_MAX_FILE_NAME_LENGTH + 1]; + char buffer[16]; + + LOG(("in: eb_load_language(book=%d)", (int)book->code)); + + zio_initialize(&zio); + book->character_code = EB_CHARCODE_JISX0208; + + /* + * Open the language file. + */ + if (eb_find_file_name(book->path, "language", language_file_name) + != EB_SUCCESS) + goto failed; + + eb_compose_path_name(book->path, language_file_name, language_path_name); + eb_path_name_zio_code(language_path_name, ZIO_PLAIN, &zio_code); + + if (zio_open(&zio, language_path_name, zio_code) < 0) + goto failed; + + /* + * Get a character code of the book, and get the number of langueages + * in the file. + */ + if (zio_read(&zio, buffer, 16) != 16) + goto failed; + + book->character_code = eb_uint2(buffer); + if (book->character_code != EB_CHARCODE_ISO8859_1 + && book->character_code != EB_CHARCODE_JISX0208 + && book->character_code != EB_CHARCODE_JISX0208_GB2312) { + goto failed; + } + + zio_close(&zio); + LOG(("out: eb_load_language()")); + + return; + + /* + * An error occurs... + */ + failed: + zio_close(&zio); + LOG(("out: eb_load_language()")); +} + + +/* + * Test whether `book' is bound. + */ +int +eb_is_bound(EB_Book *book) +{ + int is_bound; + + eb_lock(&book->lock); + LOG(("in: eb_is_bound(book=%d)", (int)book->code)); + + /* + * Check for the current status. + */ + is_bound = (book->path != NULL); + + LOG(("out: eb_is_bound() = %d", is_bound)); + eb_unlock(&book->lock); + + return is_bound; +} + + +/* + * Return the bound path of `book'. + */ +EB_Error_Code +eb_path(EB_Book *book, char *path) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_path(book=%d)", (int)book->code)); + + /* + * Check for the current status. + */ + if (book->path == NULL) { + error_code = EB_ERR_UNBOUND_BOOK; + goto failed; + } + + /* + * Copy the path to `path'. + */ + strcpy(path, book->path); + + LOG(("out: eb_path(path=%s) = %s", path, eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *path = '\0'; + LOG(("out: eb_path() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Inspect a disc type. + */ +EB_Error_Code +eb_disc_type(EB_Book *book, EB_Disc_Code *disc_code) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_disc_type(book=%d)", (int)book->code)); + + /* + * Check for the current status. + */ + if (book->path == NULL) { + error_code = EB_ERR_UNBOUND_BOOK; + goto failed; + } + + /* + * Copy the disc code to `disc_code'. + */ + *disc_code = book->disc_code; + + LOG(("out: eb_disc_type(disc_code=%d) = %s", (int)*disc_code, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *disc_code = EB_DISC_INVALID; + LOG(("out: eb_disc_type() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Inspect a character code used in the book. + */ +EB_Error_Code +eb_character_code(EB_Book *book, EB_Character_Code *character_code) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_character_code(book=%d)", (int)book->code)); + + /* + * Check for the current status. + */ + if (book->path == NULL) { + error_code = EB_ERR_UNBOUND_BOOK; + goto failed; + } + + /* + * Copy the character code to `character_code'. + */ + *character_code = book->character_code; + + LOG(("out: eb_character_code(character_code=%d) = %s", + (int)*character_code, eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *character_code = EB_CHARCODE_INVALID; + LOG(("out: eb_character_code() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + diff --git a/eb/booklist.c b/eb/booklist.c new file mode 100644 index 0000000..9e8fac9 --- /dev/null +++ b/eb/booklist.c @@ -0,0 +1,326 @@ +/* + * Copyright (c) 2003-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#ifdef ENABLE_EBNET +#include "ebnet.h" +#endif +#include "build-post.h" + +/* + * Initial value of `max_entry_count' in `EB_BookList'. + */ +#define EB_INITIAL_BOOKLIST_MAX_ENTRY_COUNT 16 + +/* + * BookList ID counter. + */ +static EB_Book_Code booklist_counter = 0; + +/* + * Mutex for `booklist_counter'. + */ +#ifdef ENABLE_PTHREAD +static pthread_mutex_t booklist_counter_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif + + +/* + * Initialize a book list. + */ +void +eb_initialize_booklist(EB_BookList *booklist) +{ + LOG(("in: eb_initialize_booklist()")); + + booklist->entry_count = 0; + booklist->max_entry_count = 0; + booklist->entries = NULL; + eb_initialize_lock(&booklist->lock); + + LOG(("out: eb_initialize_booklist()")); +} + + +/* + * Finalize a book list. + */ +void +eb_finalize_booklist(EB_BookList *booklist) +{ + int i; + + LOG(("in: eb_finalize_booklist()")); + + if (booklist->entries != NULL) { + for (i = 0; i < booklist->entry_count; i++) { + free(booklist->entries[i].name); + free(booklist->entries[i].title); + } + free(booklist->entries); + booklist->entries = NULL; + } + booklist->entry_count = 0; + booklist->max_entry_count = 0; + + LOG(("out: eb_finalize_booklist()")); +} + + +/* + * Get a list of books from an EBNET server. + */ +EB_Error_Code +eb_bind_booklist(EB_BookList *booklist, const char *path) +{ + EB_Error_Code error_code; + int i; + + eb_lock(&booklist->lock); + LOG(("in: eb_bind_booklist(path=%s)", path)); + + pthread_mutex_lock(&booklist_counter_mutex); + booklist->code = booklist_counter++; + pthread_mutex_unlock(&booklist_counter_mutex); + +#ifndef ENABLE_EBNET + error_code = EB_ERR_EBNET_UNSUPPORTED; + goto failed; +#endif + if (!is_ebnet_url(path)) { + error_code = EB_ERR_BAD_FILE_NAME; + goto failed; + } + for (i = 0; i < booklist->entry_count; i++) { + free(booklist->entries[i].name); + free(booklist->entries[i].title); + } + + error_code = ebnet_bind_booklist(booklist, path); + if (error_code != EB_SUCCESS) + goto failed; + + LOG(("out: eb_bind_booklist(book=%d) = %s", (int)booklist->code, + eb_error_string(EB_SUCCESS))); + eb_unlock(&booklist->lock); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_finalize_booklist(booklist); + LOG(("out: eb_bind_booklist() = %s", eb_error_string(error_code))); + eb_unlock(&booklist->lock); + return error_code; +} + + +/* + * Add a book entry to `booklist'. + */ +EB_Error_Code +eb_booklist_add_book(EB_BookList *booklist, const char *name, + const char *title) +{ + int new_max_entry_count; + EB_BookList_Entry *new_entries; + char *new_name = NULL; + char *new_title = NULL; + EB_Error_Code error_code; + + LOG(("in: eb_booklist_add_book(name=%s, title=%s)", name, title)); + + if (booklist->entry_count == booklist->max_entry_count) { + if (booklist->max_entry_count == 0) { + new_max_entry_count = EB_INITIAL_BOOKLIST_MAX_ENTRY_COUNT; + new_entries = (EB_BookList_Entry *) + malloc(sizeof(EB_BookList_Entry) * new_max_entry_count); + } else { + new_max_entry_count = booklist->max_entry_count * 2; + new_entries = (EB_BookList_Entry *)realloc(booklist->entries, + sizeof(EB_BookList_Entry) * new_max_entry_count); + } + if (new_entries == NULL) { + error_code = EB_ERR_MEMORY_EXHAUSTED; + goto failed; + } + booklist->max_entry_count = new_max_entry_count; + booklist->entries = new_entries; + } + + new_name = (char *)malloc(strlen(name) + 1); + if (new_name == NULL) { + error_code = EB_ERR_MEMORY_EXHAUSTED; + goto failed; + } + strcpy(new_name, name); + + new_title = (char *)malloc(strlen(title) + 1); + if (new_title == NULL) { + error_code = EB_ERR_MEMORY_EXHAUSTED; + goto failed; + } + strcpy(new_title, title); + + booklist->entries[booklist->entry_count].name = new_name; + booklist->entries[booklist->entry_count].title = new_title; + booklist->entry_count++; + + LOG(("out: eb_booklist_add_book() = %s", eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + if (new_name != NULL) + free(new_name); + if (new_title != NULL) + free(new_title); + + LOG(("out: eb_booklist_book_add() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Return the number of books in `booklist'. + */ +EB_Error_Code +eb_booklist_book_count(EB_BookList *booklist, int *book_count) +{ + EB_Error_Code error_code; + + eb_lock(&booklist->lock); + LOG(("in: eb_booklist_book_count(booklist=%d)", (int)booklist->code)); + + if (booklist->entries == NULL) { + error_code = EB_ERR_UNBOUND_BOOKLIST; + goto failed; + } + *book_count = booklist->entry_count; + + LOG(("out: eb_booklist_book_count(count=%d) = %s", *book_count, + eb_error_string(EB_SUCCESS))); + eb_unlock(&booklist->lock); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_booklist_book_count() = %s", eb_error_string(error_code))); + eb_unlock(&booklist->lock); + return error_code; +} + + +/* + * Return title of a book entry in `booklist'. + */ +EB_Error_Code +eb_booklist_book_name(EB_BookList *booklist, int book_index, char **book_name) +{ + EB_Error_Code error_code; + + eb_lock(&booklist->lock); + LOG(("in: eb_booklist_book_name(booklist=%d,index=%d)", + (int)booklist->code, book_index)); + + if (booklist->entries == NULL) { + error_code = EB_ERR_UNBOUND_BOOKLIST; + goto failed; + } + if (book_index < 0 || booklist->entry_count <= book_index) { + error_code = EB_ERR_NO_SUCH_BOOK; + goto failed; + } + + *book_name = booklist->entries[book_index].name; + + LOG(("out: eb_booklist_book_name(*book_name=%s) = %s", + (*book_name == NULL) ? "NULL" : *book_name, + eb_error_string(EB_SUCCESS))); + + eb_unlock(&booklist->lock); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_booklist_book_name() = %s", eb_error_string(error_code))); + eb_unlock(&booklist->lock); + return error_code; +} + + +/* + * Return name of a book entry in `booklist'. + */ +EB_Error_Code +eb_booklist_book_title(EB_BookList *booklist, int book_index, + char **book_title) +{ + EB_Error_Code error_code; + + eb_lock(&booklist->lock); + LOG(("in: eb_booklist_book_title(booklist=%d,index=%d)", + (int)booklist->code, book_index)); + + if (booklist->entries == NULL) { + error_code = EB_ERR_UNBOUND_BOOKLIST; + goto failed; + } + if (book_index < 0 || booklist->entry_count <= book_index) { + error_code = EB_ERR_NO_SUCH_BOOK; + goto failed; + } + *book_title = booklist->entries[book_index].title; + + LOG(("out: eb_booklist_book_title(*book_title=%s) = %s", + (*book_title == NULL) ? "NULL" : *book_title, + eb_error_string(EB_SUCCESS))); + + eb_unlock(&booklist->lock); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_booklist_book_title() = %s", eb_error_string(error_code))); + eb_unlock(&booklist->lock); + return error_code; +} + + diff --git a/eb/booklist.h b/eb/booklist.h new file mode 100644 index 0000000..e239414 --- /dev/null +++ b/eb/booklist.h @@ -0,0 +1,60 @@ +/* -*- C -*- + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef EB_BOOKLIST_H +#define EB_BOOKLIST_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef EB_BUILD_LIBRARY +#include "eb.h" +#else +#include +#endif + +/* + * Function declarations. + */ +/* booklist.c */ +void eb_initialize_booklist(EB_BookList *booklist); +void eb_finalize_booklist(EB_BookList *booklist); +EB_Error_Code eb_bind_booklist(EB_BookList *booklist, const char *path); +EB_Error_Code eb_booklist_book_count(EB_BookList *booklist, int *book_count); +EB_Error_Code eb_booklist_book_name(EB_BookList *booklist, int book_index, + char **book_name); +EB_Error_Code eb_booklist_book_title(EB_BookList *booklist, int book_index, + char **book_title); + + +#ifdef __cplusplus +} +#endif + +#endif /* not EB_BOOKLIST_H */ diff --git a/eb/build-post.h.in b/eb/build-post.h.in new file mode 100644 index 0000000..408cd4e --- /dev/null +++ b/eb/build-post.h.in @@ -0,0 +1,366 @@ +/* -*- C -*- + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef EB_BUILD_POST_H +#define EB_BUILD_POST_H + +#include "defs.h" + +/* + * Text domain name. + */ +#define EB_TEXT_DOMAIN_NAME "eb" + +/* + * Locale directory. + */ +#ifndef WIN32 +#define EB_LOCALEDIR "@localedir@" +#else +#define EB_LOCALEDIR localedir() +#endif + +/* + * Data size of a book entry in a catalog file. + */ +#define EB_SIZE_EB_CATALOG 40 +#define EB_SIZE_EPWING_CATALOG 164 + +/* + * Maximum number of search titles. + */ +#define EB_MAX_SEARCH_TITLES 14 + +/* + * File names. + */ +#define EB_FILE_NAME_START "start" +#define EB_FILE_NAME_HONMON "honmon" +#define EB_FILE_NAME_FUROKU "furoku" +#define EB_FILE_NAME_APPENDIX "appendix" + +/* + * Directory names. + */ +#define EB_DIRECTORY_NAME_DATA "data" +#define EB_DIRECTORY_NAME_GAIJI "gaiji" +#define EB_DIRECTORY_NAME_STREAM "stream" +#define EB_DIRECTORY_NAME_MOVIE "movie" + +/* + * Search word types. + */ +#define EB_WORD_ALPHABET 0 +#define EB_WORD_KANA 1 +#define EB_WORD_OTHER 2 +#define EB_WORD_INVALID -1 + +/* + * Index Style flags. + */ +#define EB_INDEX_STYLE_CONVERT 0 +#define EB_INDEX_STYLE_ASIS 1 +#define EB_INDEX_STYLE_REVERSED_CONVERT 2 +#define EB_INDEX_STYLE_DELETE 2 + +/* + * Text content currently read. + */ +#define EB_TEXT_MAIN_TEXT 1 +#define EB_TEXT_HEADING 2 +#define EB_TEXT_RAWTEXT 3 +#define EB_TEXT_OPTIONAL_TEXT 4 +#define EB_TEXT_SEEKED 0 +#define EB_TEXT_INVALID -1 + +/* + * Search method currently processed. + */ +#define EB_SEARCH_EXACTWORD 0 +#define EB_SEARCH_WORD 1 +#define EB_SEARCH_ENDWORD 2 +#define EB_SEARCH_KEYWORD 3 +#define EB_SEARCH_MULTI 4 +#define EB_SEARCH_CROSS 5 +#define EB_SEARCH_NONE -1 + +/* + * Arrangement style of entries in a search index page. + */ +#define EB_ARRANGE_FIXED 0 +#define EB_ARRANGE_VARIABLE 1 +#define EB_ARRANGE_INVALID -1 + +/* + * Binary data types. + */ +#define EB_BINARY_MONO_GRAPHIC 0 +#define EB_BINARY_COLOR_GRAPHIC 1 +#define EB_BINARY_WAVE 2 +#define EB_BINARY_MPEG 3 +#define EB_BINARY_GRAY_GRAPHIC 4 +#define EB_BINARY_INVALID -1 + +/* + * Text-stop status. + */ +#define EB_TEXT_STATUS_CONTINUED 0 +#define EB_TEXT_STATUS_SOFT_STOP 1 +#define EB_TEXT_STATUS_HARD_STOP 2 + +/* + * The maximum index depth of search indexes. + */ +#define EB_MAX_INDEX_DEPTH 6 + +/* + * The maximum length of path name relative to top directory of a CD-ROM + * book. An example of the longest relative path is: + * + * "subdir01/subdir02/filename.ebz;1" + */ +#define EB_MAX_RELATIVE_PATH_LENGTH \ + (EB_MAX_DIRECTORY_NAME_LENGTH + 1 \ + + EB_MAX_DIRECTORY_NAME_LENGTH + 1 \ + + EB_MAX_FILE_NAME_LENGTH) + +/* + * The environment variable name to enable/disable debug messages. + */ +#define EB_DEBUG_ENVIRONMENT_VARIABLE "EB_DEBUG" + +/* + * Trace log macro. + */ +#define LOG(x) do {if (eb_log_flag) eb_log x;} while (0) + +/* + * Get an unsigned value from an octet stream buffer. + */ +#define eb_uint1(p) (*(const unsigned char *)(p)) + +#define eb_uint2(p) ((*(const unsigned char *)(p) << 8) \ + + (*(const unsigned char *)((p) + 1))) + +#define eb_uint3(p) ((*(const unsigned char *)(p) << 16) \ + + (*(const unsigned char *)((p) + 1) << 8) \ + + (*(const unsigned char *)((p) + 2))) + +#define eb_uint4(p) ((*(const unsigned char *)(p) << 24) \ + + (*(const unsigned char *)((p) + 1) << 16) \ + + (*(const unsigned char *)((p) + 2) << 8) \ + + (*(const unsigned char *)((p) + 3))) + +#define eb_uint4_le(p) ((*(const unsigned char *)(p)) \ + + (*(const unsigned char *)((p) + 1) << 8) \ + + (*(const unsigned char *)((p) + 2) << 16) \ + + (*(const unsigned char *)((p) + 3) << 24)) + +/* + * Test whether the path is URL with the `ebnet' scheme. + */ +#define is_ebnet_url(p) \ + ( ((p)[0] == 'E' || (p)[0] == 'e') \ + && ((p)[1] == 'B' || (p)[1] == 'b') \ + && ((p)[2] == 'N' || (p)[2] == 'n') \ + && ((p)[3] == 'E' || (p)[3] == 'e') \ + && ((p)[4] == 'T' || (p)[4] == 't') \ + && (p)[5] == ':' && (p)[6] == '/' && (p)[7] == '/') + +/* + * Test whether `off_t' represents a large integer. + */ +#define off_t_is_large \ + ((((off_t) 1 << 41) + ((off_t) 1 << 40) + 1) % 9999991 == 7852006) + +/* + * External variable declarations. + */ +/* log.c */ +extern int eb_log_flag; + +/* hook.c */ +extern EB_Hookset eb_default_hookset; + +/* + * Function declarations. + */ +/* appendix.c */ +void eb_initialize_alt_caches(EB_Appendix *appendix); +void eb_finalize_alt_caches(EB_Appendix *appendix); + +/* appsub.c */ +void eb_initialize_appendix_subbooks(EB_Appendix *appendix); +void eb_finalize_appendix_subbooks(EB_Appendix *appendix); + +/* bcd.c */ +unsigned eb_bcd2(const char *stream); +unsigned eb_bcd4(const char *stream); +unsigned eb_bcd6(const char *stream); + +/* binary.c */ +void eb_initialize_binary_context(EB_Book *book); +void eb_reset_binary_context(EB_Book *book); +void eb_finalize_binary_context(EB_Book *book); + +/* booklist.c */ +EB_Error_Code eb_booklist_add_book(EB_BookList *booklist, const char *name, + const char *title); + +/* filename.c */ +EB_Error_Code eb_canonicalize_path_name(char *path_name); +void eb_canonicalize_file_name(char *file_name); +EB_Error_Code eb_fix_directory_name(const char *path, char *directory_name); +EB_Error_Code eb_fix_directory_name2(const char *path, + const char *directory_name, char *sub_directory_name); +void eb_fix_path_name_suffix(char *path_name, const char *suffix); +EB_Error_Code eb_find_file_name(const char *path_name, + const char *target_file_name, char *found_file_name); +EB_Error_Code eb_find_file_name2(const char *path_name, + const char *sub_directory_name, const char *target_file_name, + char *found_file_name); +EB_Error_Code eb_find_file_name3(const char *path_name, + const char *sub_directory_name, const char *sub2_directory_name, + const char *target_file_name, char *found_file_name); +void eb_compose_path_name(const char *path_name, const char *file_name, + char *composed_path_name); +void eb_compose_path_name2(const char *path_name, + const char *sub_directory_name, const char *file_name, + char *composed_path_name); +void eb_compose_path_name3(const char *path_name, + const char *sub_directory_name, const char *sub2_directory_name, + const char *file_name, char *composed_path_name); +void eb_path_name_zio_code(const char *path_name, Zio_Code default_zio_code, + Zio_Code *zio_code); + +/* font.c */ +void eb_initialize_fonts(EB_Book *book); +void eb_load_font_headers(EB_Book *book); +void eb_finalize_fonts(EB_Book *book); + +/* hook.c */ +void eb_initialize_default_hookset(void); + +/* jacode.c */ +void eb_jisx0208_to_euc(char *out_string, const char *in_string); +void eb_sjis_to_euc(char *out_string, const char *in_string); + +/* lock.c */ +#ifdef ENABLE_PTHREAD +void eb_initialize_lock(EB_Lock *lock); +void eb_finalize_lock(EB_Lock *lock); +void eb_lock(EB_Lock *lock); +void eb_unlock(EB_Lock *lock); +#else /* not ENABLE_PTHREAD */ +#define eb_lock(x) +#define eb_unlock(x) +#define eb_initialize_lock(x) +#define eb_finalize_lock(x) +#endif /* not ENABLE_PTHREAD */ + +/* log.c */ +void eb_initialize_log(void); +const char *eb_quoted_stream(const char *stream, size_t stream_length); +const char *eb_quoted_string(const char *string); + +/* match.c */ +int eb_match_word(const char *word, const char *pattern, size_t length); +int eb_pre_match_word(const char *word, const char *pattern, size_t length); +int eb_exact_match_word_jis(const char *word, const char *pattern, + size_t length); +int eb_exact_pre_match_word_jis(const char *word, const char *pattern, + size_t length); +int eb_exact_match_word_latin(const char *word, const char *pattern, + size_t length); +int eb_exact_pre_match_word_latin(const char *word, const char *pattern, + size_t); +int eb_match_word_kana_single(const char *word, const char *pattern, + size_t length); +int eb_match_word_kana_group(const char *word, const char *pattern, + size_t length); +int eb_exact_match_word_kana_single(const char *word, const char *pattern, + size_t length); +int eb_exact_match_word_kana_group(const char *word, const char *pattern, + size_t length); + +/* message.c */ +EB_Error_Code eb_initialize_messages(EB_Book *book); + +/* multi.c */ +EB_Error_Code eb_load_multi_searches(EB_Book *book); +EB_Error_Code eb_load_multi_titles(EB_Book *book); + +/* narwfont.c */ +EB_Error_Code eb_open_narrow_font_file(EB_Book *book, EB_Font_Code font_code); +EB_Error_Code eb_load_narrow_font_header(EB_Book *book, + EB_Font_Code font_code); +EB_Error_Code eb_load_narrow_font_glyphs(EB_Book *book, + EB_Font_Code font_code); + +/* search.c */ +void eb_initialize_search_contexts(EB_Book *book); +void eb_finalize_search_contexts(EB_Book *book); +void eb_reset_search_contexts(EB_Book *book); +void eb_initialize_search(EB_Search *search); +void eb_finalize_search(EB_Search *search); +void eb_initialize_searches(EB_Book *book); +void eb_finalize_searches(EB_Book *book); +EB_Error_Code eb_presearch_word(EB_Book *book, EB_Search_Context *context); + +/* setword.c */ +EB_Error_Code eb_set_word(EB_Book *book, const char *input_word, char *word, + char *canonicalized_word, EB_Word_Code *word_code); +EB_Error_Code eb_set_endword(EB_Book *book, const char *input_word, char *word, + char *canonicalized_word, EB_Word_Code *word_code); +EB_Error_Code eb_set_keyword(EB_Book *book, const char *input_word, char *word, + char *canonicalized_word, EB_Word_Code *word_code); +EB_Error_Code eb_set_multiword(EB_Book *book, EB_Multi_Search_Code multi_id, + EB_Multi_Entry_Code entry_id, const char *input_word, char *word, + char *canonicalized_word, EB_Word_Code *word_code); + +/* subbook.c */ +void eb_initialize_subbooks(EB_Book *book); +void eb_finalize_subbooks(EB_Book *book); + +/* text.c */ +void eb_initialize_text_context(EB_Book *book); +void eb_finalize_text_context(EB_Book *book); +void eb_reset_text_context(EB_Book *book); +void eb_invalidate_text_context(EB_Book *book); +EB_Error_Code eb_forward_heading(EB_Book *book); + +/* widefont.c */ +EB_Error_Code eb_open_wide_font_file(EB_Book *book, EB_Font_Code font_code); +EB_Error_Code eb_load_wide_font_header(EB_Book *book, EB_Font_Code font_code); +EB_Error_Code eb_load_wide_font_glyphs(EB_Book *book, EB_Font_Code font_code); + +/* strcasecmp.c */ +int eb_strcasecmp(const char *string1, const char *string2); +int eb_strncasecmp(const char *string1, const char *string2, size_t n); + +#endif /* not EB_BUILD_POST_H */ diff --git a/eb/build-pre.h b/eb/build-pre.h new file mode 100644 index 0000000..0dd96bf --- /dev/null +++ b/eb/build-pre.h @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2000-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef EB_BUILD_PRE_H +#define EB_BUILD_PRE_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_DIRECT_H +#include +#endif + +#ifdef HAVE__GETDCWD +#define getcwd _getcwd +#define getdcwd _getdcwd +#endif + +#ifdef ENABLE_PTHREAD +#include +#endif + +#ifdef ENABLE_NLS +#include +#endif + +/* + * Mutual exclusion lock of Pthreads. + */ +#ifndef ENABLE_PTHREAD +#define pthread_mutex_lock(m) +#define pthread_mutex_unlock(m) +#endif + +/* + * stat() macros. + */ +#ifndef S_ISREG +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#endif +#ifndef S_ISDIR +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif + +/* + * Flags for open(). + */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + +/* + * Character type tests and conversions. + */ +#define ASCII_ISDIGIT(c) ('0' <= (c) && (c) <= '9') +#define ASCII_ISUPPER(c) ('A' <= (c) && (c) <= 'Z') +#define ASCII_ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define ASCII_ISALPHA(c) \ + (ASCII_ISUPPER(c) || ASCII_ISLOWER(c)) +#define ASCII_ISALNUM(c) \ + (ASCII_ISUPPER(c) || ASCII_ISLOWER(c) || ASCII_ISDIGIT(c)) +#define ASCII_ISXDIGIT(c) \ + (ASCII_ISDIGIT(c) || ('A' <= (c) && (c) <= 'F') || ('a' <= (c) && (c) <= 'f')) +#define ASCII_TOUPPER(c) (('a' <= (c) && (c) <= 'z') ? (c) - 0x20 : (c)) +#define ASCII_TOLOWER(c) (('A' <= (c) && (c) <= 'Z') ? (c) + 0x20 : (c)) + +/* + * Tricks for gettext. + */ +#ifdef ENABLE_NLS +#define _(string) gettext(string) +#ifdef gettext_noop +#define N_(string) gettext_noop(string) +#else +#define N_(string) (string) +#endif +#else +#define _(string) (string) +#define N_(string) (string) +#endif + +/* + * Fake missing function names. + */ +#ifndef HAVE_STRCASECMP +#define strcasecmp eb_strcasecmp +#define strncasecmp eb_strncasecmp +#endif + +#ifndef HAVE_GETADDRINFO +#define addrinfo ebnet_addrinfo +#define getaddrinfo ebnet_getaddrinfo +#define freeaddrinfo ebnet_freeaddrinfo +#endif + +#ifndef HAVE_GETNAMEINFO +#define getnameinfo ebnet_getnameinfo +#endif + +#ifndef HAVE_GAI_STRERROR +#define gai_strerror ebnet_gai_strerror +#endif + +#ifndef IN6ADDR_ANY_DECLARED +#define in6addr_any ebnet_in6addr_any +#endif + +#ifndef IN6ADDR_LOOPBACK_DECLARED +#define in6addr_loopback ebnet_in6addr_loopback +#endif + +#endif /* EB_BUILD_PRE_H */ diff --git a/eb/copyright.c b/eb/copyright.c new file mode 100644 index 0000000..d297382 --- /dev/null +++ b/eb/copyright.c @@ -0,0 +1,121 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "build-post.h" + +/* + * Examine whether the current subbook in `book' have a copyright + * notice or not. + */ +int +eb_have_copyright(EB_Book *book) +{ + eb_lock(&book->lock); + LOG(("in: eb_have_copyright(book=%d)", (int)book->code)); + + /* + * Check for the current status. + */ + if (book->subbook_current == NULL) + goto failed; + + /* + * Check for the index page of copyright notice. + */ + if (book->subbook_current->copyright.start_page == 0) + goto failed; + + LOG(("out: eb_have_copyright() = %d", 1)); + eb_unlock(&book->lock); + + return 1; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_have_copyright() = %d", 0)); + eb_unlock(&book->lock); + return 0; +} + + +/* + * Get a position of copyright notice. + */ +EB_Error_Code +eb_copyright(EB_Book *book, EB_Position *position) +{ + EB_Error_Code error_code; + int page; + + eb_lock(&book->lock); + LOG(("in: eb_copyright(book=%d)", (int)book->code)); + + /* + * Check for the current status. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Check for the page number of COPYRIGHT NOTICE. + */ + page = book->subbook_current->copyright.start_page; + if (page == 0) { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + + /* + * Copy the position to `position'. + */ + position->page = page; + position->offset = 0; + + LOG(("out: eb_copyright(position={%d,%d}) = %s", + position->page, position->offset, eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_copyright() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + diff --git a/eb/cross.c b/eb/cross.c new file mode 100644 index 0000000..2200965 --- /dev/null +++ b/eb/cross.c @@ -0,0 +1,190 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "build-post.h" + +/* + * Examine whether the current subbook in `book' supports `KEYWORD SEARCH' + * or not. + */ +int +eb_have_cross_search(EB_Book *book) +{ + eb_lock(&book->lock); + LOG(("in: eb_have_cross_search(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) + goto failed; + + if (book->subbook_current->cross.start_page == 0) + goto failed; + + LOG(("out: eb_have_cross_search() = %d", 1)); + eb_unlock(&book->lock); + + return 1; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_have_cross_search() = %d", 0)); + eb_unlock(&book->lock); + return 0; +} + + +/* + * Keyword search. + */ +EB_Error_Code +eb_search_cross(EB_Book *book, const char * const input_words[]) +{ + EB_Error_Code error_code; + EB_Search_Context *context; + EB_Word_Code word_code; + int word_count; + int i; + + /* + * Lock the book. + */ + eb_lock(&book->lock); + LOG(("in: eb_search_cross(book=%d, input_words=[below])", + (int)book->code)); + + if (eb_log_flag) { + for (i = 0; i < EB_MAX_KEYWORDS && input_words[i] != NULL; i++) { + LOG((" input_words[%d]=%s", i, + eb_quoted_string(input_words[i]))); + } + LOG((" input_words[%d]=NULL", i)); + } + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Check whether the current subbook has cross search. + */ + if (book->subbook_current->cross.start_page == 0) { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + + /* + * Attach a search context for each word, and pre-search the word. + */ + eb_reset_search_contexts(book); + word_count = 0; + + for (i = 0; i < EB_MAX_KEYWORDS; i++) { + if (input_words[i] == NULL) + break; + + /* + * Initialize search context. + */ + context = book->search_contexts + word_count; + context->code = EB_SEARCH_CROSS; + + /* + * Choose comparison functions. + */ + if (book->character_code == EB_CHARCODE_ISO8859_1) { + context->compare_pre = eb_pre_match_word; + context->compare_single = eb_match_word; + context->compare_group = eb_match_word; + } else { + context->compare_pre = eb_pre_match_word; + context->compare_single = eb_match_word; + context->compare_group = eb_match_word_kana_group; + } + context->page = book->subbook_current->cross.start_page; + + /* + * Make a fixed word and a canonicalized word to search from + * `input_words[i]'. + */ + error_code = eb_set_keyword(book, input_words[i], context->word, + context->canonicalized_word, &word_code); + if (error_code == EB_ERR_EMPTY_WORD) + continue; + else if (error_code != EB_SUCCESS) + goto failed; + + /* + * Pre-search. + */ + error_code = eb_presearch_word(book, context); + if (error_code != EB_SUCCESS) + goto failed; + + word_count++; + } + if (word_count == 0) { + error_code = EB_ERR_NO_WORD; + goto failed; + } else if (EB_MAX_KEYWORDS <= i && input_words[i] != NULL) { + error_code = EB_ERR_TOO_MANY_WORDS; + goto failed; + } + + /* + * Set `EB_SEARCH_NONE' to the rest unused search context. + */ + for (i = word_count; i < EB_MAX_KEYWORDS; i++) + (book->search_contexts + i)->code = EB_SEARCH_NONE; + + LOG(("out: eb_search_cross() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_reset_search_contexts(book); + LOG(("out: eb_search_cross() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + diff --git a/eb/defs.h b/eb/defs.h new file mode 100644 index 0000000..bd63cfe --- /dev/null +++ b/eb/defs.h @@ -0,0 +1,1040 @@ +/* -*- C -*- + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef EB_DEFS_H +#define EB_DEFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#ifdef EB_BUILD_LIBRARY +#include "sysdefs.h" +#include "zio.h" +#else +#include +#include +#endif + +#ifdef EB_ENABLE_PTHREAD +#include +#endif + +/* + * Disc code + */ +#define EB_DISC_EB 0 +#define EB_DISC_EPWING 1 +#define EB_DISC_INVALID -1 + +/* + * Character codes. + */ +#define EB_CHARCODE_ISO8859_1 1 +#define EB_CHARCODE_JISX0208 2 +#define EB_CHARCODE_JISX0208_GB2312 3 +#define EB_CHARCODE_INVALID -1 + +/* + * Special book ID for cache to represent "no cache data for any book". + */ +#define EB_BOOK_NONE -1 + +/* + * Special disc code, subbook code, multi search ID, and multi search + * entry ID, for representing error state. + */ +#define EB_SUBBOOK_INVALID -1 +#define EB_MULTI_INVALID -1 + +/* + * Size of a page (The term `page' means `block' in JIS X 4081). + */ +#define EB_SIZE_PAGE 2048 + +/* + * Maximum length of a word to be searched. + */ +#define EB_MAX_WORD_LENGTH 255 + +/* + * Maximum length of an EB* book title. + */ +#define EB_MAX_EB_TITLE_LENGTH 30 + +/* + * Maximum length of an EPWING book title. + */ +#define EB_MAX_EPWING_TITLE_LENGTH 80 + +/* + * Maximum length of a book title. + */ +#define EB_MAX_TITLE_LENGTH 80 + +/* + * Maximum length of a word to be searched. + */ +#if defined(PATH_MAX) +#define EB_MAX_PATH_LENGTH PATH_MAX +#elif defined(MAXPATHLEN) +#define EB_MAX_PATH_LENGTH MAXPATHLEN +#else +#define EB_MAX_PATH_LENGTH 1024 +#endif + +/* + * Maximum length of a directory name. + */ +#define EB_MAX_DIRECTORY_NAME_LENGTH 8 + +/* + * Maximum length of a file name under a certain directory. + * prefix(8 chars) + '.' + suffix(3 chars) + ';' + digit(1 char) + */ +#define EB_MAX_FILE_NAME_LENGTH 14 + +/* + * Maximum length of a label for multi-search entry. + */ +#define EB_MAX_MULTI_LABEL_LENGTH 30 + +/* + * Maximum length of alternation text string for a private character. + */ +#define EB_MAX_ALTERNATION_TEXT_LENGTH 31 + +/* + * Maximum length of title for multi search. + */ +#define EB_MAX_MULTI_TITLE_LENGTH 32 + +/* + * Maximum number of font heights in a subbok. + */ +#define EB_MAX_FONTS 4 + +/* + * Maximum number of subbooks in a book. + */ +#define EB_MAX_SUBBOOKS 50 + +/* + * Maximum number of multi-search types in a subbook. + */ +#define EB_MAX_MULTI_SEARCHES 10 + +/* + * Maximum number of entries in a multi-search. + */ +#define EB_MAX_MULTI_ENTRIES 5 + +/* + * Maximum number of entries in a keyword search. + */ +#define EB_MAX_KEYWORDS EB_MAX_MULTI_ENTRIES + +/* + * Maximum number of entries in a cross search. + */ +#define EB_MAX_CROSS_ENTRIES EB_MAX_MULTI_ENTRIES + +/* + * Maximum number of characters for alternation cache. + */ +#define EB_MAX_ALTERNATION_CACHE 16 + +/* + * The number of text hooks. + */ +#define EB_NUMBER_OF_HOOKS 54 + +/* + * The number of search contexts required by a book. + */ +#define EB_NUMBER_OF_SEARCH_CONTEXTS EB_MAX_MULTI_ENTRIES + +/* + * Types for various codes. + */ +typedef int EB_Error_Code; +typedef int EB_Book_Code; +typedef int EB_Disc_Code; +typedef int EB_Case_Code; +typedef int EB_Suffix_Code; +typedef int EB_Character_Code; +typedef int EB_Font_Code; +typedef int EB_Word_Code; +typedef int EB_Subbook_Code; +typedef int EB_Index_Style_Code; +typedef int EB_Search_Code; +typedef int EB_Text_Code; +typedef int EB_Text_Status_Code; +typedef int EB_Multi_Search_Code; +typedef int EB_Hook_Code; +typedef int EB_Binary_Code; + +/* + * Typedef for Structures. + */ +#ifdef EB_ENABLE_PTHREAD +typedef struct EB_Lock_Struct EB_Lock; +#endif +typedef struct EB_Position_Struct EB_Position; +typedef struct EB_Alternation_Cache_Struct EB_Alternation_Cache; +typedef struct EB_Appendix_Subbook_Struct EB_Appendix_Subbook; +typedef struct EB_Appendix_Struct EB_Appendix; +typedef struct EB_Font_Struct EB_Font; +typedef struct EB_Search_Struct EB_Search; +typedef struct EB_Multi_Search_Struct EB_Multi_Search; +typedef struct EB_Subbook_Struct EB_Subbook; +typedef struct EB_Text_Context_Struct EB_Text_Context; +typedef struct EB_Binary_Context_Struct EB_Binary_Context; +typedef struct EB_Search_Context_Struct EB_Search_Context; +typedef struct EB_Book_Struct EB_Book; +typedef struct EB_Hit_Struct EB_Hit; +typedef struct EB_Hook_Struct EB_Hook; +typedef struct EB_Hookset_Struct EB_Hookset; +typedef struct EB_BookList_Entry EB_BookList_Entry; +typedef struct EB_BookList EB_BookList; + +/* + * Pthreads lock. + */ +#ifdef EB_ENABLE_PTHREAD +struct EB_Lock_Struct { + /* + * Lock count. (For emulating recursive lock). + */ + int lock_count; + + /* + * Mutex for `lock_count'. + */ + pthread_mutex_t lock_count_mutex; + + /* + * Mutex for struct entity. + */ + pthread_mutex_t entity_mutex; +}; +#endif /* EB_ENABLE_PTHREAD */ + +/* + * A pair of page and offset. + */ +struct EB_Position_Struct { + /* + * Page. (1, 2, 3 ...) + */ + int page; + + /* + * Offset in `page'. (0 ... 2047) + */ + int offset; +}; + +/* + * Chace of aternation text. + */ +struct EB_Alternation_Cache_Struct { + /* + * Character number. + */ + int character_number; + + /* + * Alternation string for `char_no'. + */ + char text[EB_MAX_ALTERNATION_TEXT_LENGTH + 1]; +}; + +/* + * An appendix for a subbook. + */ +struct EB_Appendix_Subbook_Struct { + + /* + * Initialization flag. + */ + int initialized; + + /* + * Subbook ID. + */ + EB_Subbook_Code code; + + /* + * Directory name. + */ + char directory_name[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; + + /* + * Sub-directory name. (EPWING only) + */ + char data_directory_name[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; + + /* + * File name. + */ + char file_name[EB_MAX_FILE_NAME_LENGTH + 1]; + + /* + * Character code of the book. + */ + EB_Character_Code character_code; + + /* + * Start character number of the narrow/wide font. + */ + int narrow_start; + int wide_start; + + /* + * End character number of the narrow/wide font. + */ + int narrow_end; + int wide_end; + + /* + * Start page number of the narrow/wide font. + */ + int narrow_page; + int wide_page; + + /* + * Stop code (first and second characters). + */ + int stop_code0; + int stop_code1; + + /* + * Compression Information for appendix file. + */ + Zio zio; +}; + +/* + * Additional resources for a book. + */ +struct EB_Appendix_Struct { + /* + * Book ID. + */ + EB_Book_Code code; + + /* + * Path of the book. + */ + char *path; + + /* + * The length of the path. + */ + size_t path_length; + + /* + * Disc type. EB (EB/EBG/EBXA/EBXA-C/S-EBXA) or EPWING. + */ + EB_Disc_Code disc_code; + + /* + * The number of subbooks the book has. + */ + int subbook_count; + + /* + * Subbook list. + */ + EB_Appendix_Subbook *subbooks; + + /* + * Current subbook. + */ + EB_Appendix_Subbook *subbook_current; + + /* + * ebnet socket file. + */ +#ifdef EB_ENABLE_EBNET + int ebnet_file; +#endif + + /* + * Lock. + */ +#ifdef EB_ENABLE_PTHREAD + EB_Lock lock; +#endif + + /* + * Cache table for alternation text. + */ + EB_Alternation_Cache narrow_cache[EB_MAX_ALTERNATION_CACHE]; + EB_Alternation_Cache wide_cache[EB_MAX_ALTERNATION_CACHE]; +}; + +/* + * A font in a subbook. + */ +struct EB_Font_Struct { + /* + * Font Code. + * This font is not available, if the code is EB_FONT_INVALID. + */ + EB_Font_Code font_code; + + /* + * Whether the object has been initialized. + */ + int initialized; + + /* + * Character numbers of the start and end of the font. + */ + int start; + int end; + + /* + * Page number of the start page of the font data. + * Used in EB* only. (In EPWING, it is alyways 1). + */ + int page; + + /* + * File name of the font. (EPWING only) + */ + char file_name[EB_MAX_FILE_NAME_LENGTH + 1]; + + /* + * Font data cache. + */ + char *glyphs; + + /* + * Compression Information. + */ + Zio zio; +}; + +/* + * Search methods in a subbook. + */ +struct EB_Search_Struct { + /* + * Index ID. + */ + int index_id; + + /* + * Page number of the start page of an index. + * This search method is not available, if `start_page' is 0, + */ + int start_page; + int end_page; + + /* + * Page number of the start page of candidates. + * (for multi search entry) + */ + int candidates_page; + + /* + * Index style flags. + */ + EB_Index_Style_Code katakana; + EB_Index_Style_Code lower; + EB_Index_Style_Code mark; + EB_Index_Style_Code long_vowel; + EB_Index_Style_Code double_consonant; + EB_Index_Style_Code contracted_sound; + EB_Index_Style_Code voiced_consonant; + EB_Index_Style_Code small_vowel; + EB_Index_Style_Code p_sound; + EB_Index_Style_Code space; + + /* + * Label. (for an entry in multi search) + */ + char label[EB_MAX_MULTI_LABEL_LENGTH + 1]; +}; + +/* + * A multi-search entry in a subbook. + */ +struct EB_Multi_Search_Struct { + /* + * Search method information. + */ + EB_Search search; + + /* + * Search title. (EPWING only) + */ + char title[EB_MAX_MULTI_TITLE_LENGTH + 1]; + + /* + * The number of entries the multi search has. + */ + int entry_count; + + /* + * List of Word entry information. + */ + EB_Search entries[EB_MAX_MULTI_ENTRIES]; +}; + +/* + * A subbook in a book. + */ +struct EB_Subbook_Struct { + /* + * Whether the object has been initialized. + */ + int initialized; + + /* + * Index page. + */ + int index_page; + + /* + * Subbook ID. + * This subbook is not available, if the code is EB_SUBBOOK_INVALID. + */ + EB_Subbook_Code code; + + /* + * File descriptor and compression information for text file. + */ + Zio text_zio; + + /* + * File descriptor and compression information for graphic file. + */ + Zio graphic_zio; + + /* + * File descriptor and compression information for sound file. + */ + Zio sound_zio; + + /* + * File descriptor and compression information for movie file. + */ + Zio movie_zio; + + /* + * Title of the subbook. + */ + char title[EB_MAX_TITLE_LENGTH + 1]; + + /* + * Subbook directory name. + */ + char directory_name[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; + + /* + * Sub-directory names. (EPWING only) + */ + char data_directory_name[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; + char gaiji_directory_name[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; + char movie_directory_name[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; + + /* + * File names. + */ + char text_file_name[EB_MAX_FILE_NAME_LENGTH + 1]; + char graphic_file_name[EB_MAX_FILE_NAME_LENGTH + 1]; + char sound_file_name[EB_MAX_FILE_NAME_LENGTH + 1]; + + /* + * Compression hints of Text, graphic and sound files. + * (temporary need, EPWING only). + */ + Zio_Code text_hint_zio_code; + Zio_Code graphic_hint_zio_code; + Zio_Code sound_hint_zio_code; + + /* + * Page number where search method titles are stored. + * (temporary need, EPWING only). + */ + int search_title_page; + + /* + * The top page of search methods. + */ + EB_Search word_alphabet; + EB_Search word_asis; + EB_Search word_kana; + EB_Search endword_alphabet; + EB_Search endword_asis; + EB_Search endword_kana; + EB_Search keyword; + EB_Search menu; + EB_Search image_menu; + EB_Search cross; + EB_Search copyright; + EB_Search text; + EB_Search sound; + + /* + * The number of multi-search methods the subbook has. + */ + int multi_count; + + /* + * The top page of multi search methods. + */ + EB_Multi_Search multis[EB_MAX_MULTI_SEARCHES]; + + /* + * Font list. + */ + EB_Font narrow_fonts[EB_MAX_FONTS]; + EB_Font wide_fonts[EB_MAX_FONTS]; + + /* + * Current narrow and wide fonts. + */ + EB_Font *narrow_current; + EB_Font *wide_current; +}; + +/* + * Length of cache buffer in a binary context. + * It must be greater than 38, size of GIF preamble. + * It must be greater than 44, size of WAVE sound header. + * It must be greater than 118, size of BMP header + info + 16 rgbquads. + */ +#define EB_SIZE_BINARY_CACHE_BUFFER 128 + +/* + * Context parameters for binary data. + */ +struct EB_Binary_Context_Struct { + /* + * Binary type ID. + * The context is not active, if this code is EB_BINARY_INVALID. + */ + EB_Binary_Code code; + + /* + * Compress information. + */ + Zio *zio; + + /* + * Location of the the binary data, relative to the start of the file. + */ + off_t location; + + /* + * Data size. + * Size zero means that the binary has no size information. + */ + size_t size; + + /* + * The current offset of binary data. + */ + size_t offset; + + /* + * Cache buffer. + */ + char cache_buffer[EB_SIZE_BINARY_CACHE_BUFFER]; + + /* + * Length of cached data. + */ + size_t cache_length; + + /* + * Current offset of cached data. + */ + size_t cache_offset; + + /* + * Width of Image. (monochrome graphic only) + */ + int width; +}; + +/* + * Context parameters for text reading. + */ +struct EB_Text_Context_Struct { + /* + * Current text content type. + * The context is not active, if this code is EB_TEXT_INVALID. + */ + EB_Text_Code code; + + /* + * Current offset pointer of the START or HONMON file. + */ + off_t location; + + /* + * The current point of a buffer on which text is written. + */ + char *out; + + /* + * Length of `out'. + */ + size_t out_rest_length; + + /* + * Unprocessed string that a hook function writes on text. + */ + char *unprocessed; + + /* + * Size of `unprocessed'. + */ + size_t unprocessed_size; + + /* + * Length of the current output text phrase. + */ + size_t out_step; + + /* + * Narrow character region flag. + */ + int narrow_flag; + + /* + * Whether a printable character has been appeared in the current + * text content. + */ + int printable_count; + + /* + * EOF flag of the current subbook. + */ + int file_end_flag; + + /* + * Status of the current text processing. + */ + EB_Text_Status_Code text_status; + + /* + * Skip until `skipcode' appears. + */ + int skip_code; + + /* + * Stop-code automatically set by EB Library. + */ + int auto_stop_code; + + /* + * The current candidate word for multi search. + */ + char candidate[EB_MAX_WORD_LENGTH + 1]; + + /* + * Whether the current text point is in the candidate word or not. + */ + int is_candidate; + + /* + * Whether the current text point is in EBXA-C gaiji area. + */ + int ebxac_gaiji_flag; +}; + +/* + * Context parameters for word search. + */ +struct EB_Search_Context_Struct { + /* + * Current search method type. + * The context is not active, if this code is EB_SEARCH_NONE. + */ + EB_Search_Code code; + + /* + * Function which compares word to search and pattern in an index page. + */ + int (*compare_pre)(const char *word, const char *pattern, + size_t length); + int (*compare_single)(const char *word, const char *pattern, + size_t length); + int (*compare_group)(const char *word, const char *pattern, + size_t length); + + /* + * Result of comparison by `compare'. + */ + int comparison_result; + + /* + * Word to search. + */ + char word[EB_MAX_WORD_LENGTH + 1]; + + /* + * Canonicalized word to search. + */ + char canonicalized_word[EB_MAX_WORD_LENGTH + 1]; + + /* + * Page which is searched currently. + */ + int page; + + /* + * Offset which is searched currently in the page. + */ + int offset; + + /* + * Page ID of the current page. + */ + int page_id; + + /* + * How many entries in the current page. + */ + int entry_count; + + /* + * Entry index pointer. + */ + int entry_index; + + /* + * Length of the current entry. + */ + int entry_length; + + /* + * Arrangement style of entries in the current page (fixed or variable). + */ + int entry_arrangement; + + /* + * In a group entry or not. + */ + int in_group_entry; + + /* + * Current heading position (for keyword search). + */ + EB_Position keyword_heading; +}; + +/* + * A book. + */ +struct EB_Book_Struct { + /* + * Book ID. + */ + EB_Book_Code code; + + /* + * Disc type. EB* or EPWING. + */ + EB_Disc_Code disc_code; + + /* + * Character code of the book. + */ + EB_Character_Code character_code; + + /* + * Path of the book. + */ + char *path; + + /* + * The length of the path. + */ + size_t path_length; + + /* + * The number of subbooks the book has. + */ + int subbook_count; + + /* + * Subbook list. + */ + EB_Subbook *subbooks; + + /* + * Current subbook. + */ + EB_Subbook *subbook_current; + + /* + * Context parameters for text reading. + */ + EB_Text_Context text_context; + + /* + * Context parameters for binary reading. + */ + EB_Binary_Context binary_context; + + /* + * Context parameters for text reading. + */ + EB_Search_Context search_contexts[EB_NUMBER_OF_SEARCH_CONTEXTS]; + + /* + * ebnet socket file. + */ +#ifdef EB_ENABLE_EBNET + int ebnet_file; +#endif + + /* + * Lock. + */ +#ifdef EB_ENABLE_PTHREAD + EB_Lock lock; +#endif +}; + +/* + * In a word search, heading and text locations of a matched entry + * are stored. + */ +struct EB_Hit_Struct { + /* + * Heading position. + */ + EB_Position heading; + + /* + * Text position. + */ + EB_Position text; +}; + +/* + * A text hook. + */ +struct EB_Hook_Struct { + /* + * Hook code. + */ + EB_Hook_Code code; + + /* + * Hook function for the hook code `code'. + */ + EB_Error_Code (*function)(EB_Book *book, EB_Appendix *appendix, + void *container, EB_Hook_Code hook_code, int argc, + const unsigned int *argv); +}; + +/* + * A set of text hooks. + */ +struct EB_Hookset_Struct { + /* + * List of hooks. + */ + EB_Hook hooks[EB_NUMBER_OF_HOOKS]; + + /* + * Lock. + */ +#ifdef EB_ENABLE_PTHREAD + EB_Lock lock; +#endif +}; + +/* + * An entry of book list. + */ +struct EB_BookList_Entry { + /* + * name. + */ + char *name; + + /* + * Title. + */ + char *title; +}; + +/* + * Book list. + */ +struct EB_BookList { + /* + * Book List ID. + */ + EB_Book_Code code; + + /* + * The number of book entries this list has. + */ + int entry_count; + + /* + * The maximum number of book entries that `entries' can memory. + */ + int max_entry_count; + + /* + * Book entries. + */ + EB_BookList_Entry *entries; + + /* + * Lock. + */ +#ifdef EB_ENABLE_PTHREAD + EB_Lock lock; +#endif +}; + +/* for backward compatibility */ +#define EB_Multi_Entry_Code int + +#ifdef __cplusplus +} +#endif + +#endif /* not EB_DEFS_H */ diff --git a/eb/dummyin6.c b/eb/dummyin6.c new file mode 100644 index 0000000..e3ee2fa --- /dev/null +++ b/eb/dummyin6.c @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2001-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * This program provides macros, types and external variables related + * to basic IPv6 programming such as PF_INET6. This program is useful + * for application which supports both IPv6 and traditional IPv4 systems. + * + * To use this program, include the header file. + * + * #include "dummyin6.h" + * + * This program is intended to be used in combination with GNU Autoconf. + * (see below). + * + * Restriction: + * `struct sockaddr_storage' has no ss_ or __ss_ member (e.g. ss_family) + * since the structure is merely alias of `sturct sockaddr_in'. + */ + +/* + * This program requires the following Autoconf macros: + * AC_STRUCT_IN6_ADDR + * AC_STRUCT_SOCKADDR_IN6 + * AX_STRUCT_SOCKADDR_STORAGE + * AC_DECL_IN6ADDR_ANY + * AC_DECL_IN6ADDR_LOOPBACK + */ +#include "dummyin6.h" + +const struct in6_addr ebnet_in6addr_any = IN6ADDR_ANY_INIT; +const struct in6_addr ebnet_in6addr_loopback = IN6ADDR_LOOPBACK_INIT; + diff --git a/eb/dummyin6.h b/eb/dummyin6.h new file mode 100644 index 0000000..f4788bb --- /dev/null +++ b/eb/dummyin6.h @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2001-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef DUMMYIN6_H +#define DUMMYIN6_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#ifndef AF_INET6 +#define AF_INET6 (AF_INET + 1) +#endif + +#ifndef PF_INET6 +#define PF_INET6 (PF_INET + 1) +#endif + +#ifndef AF_UNSPEC +#define AF_UNSPEC AF_INET +#endif + +#ifndef PF_UNSPEC +#define PF_UNSPEC PF_INET +#endif + +#ifndef INET6_ADDRSTRLEN +#define INET6_ADDRSTRLEN 46 +#endif + +#ifndef INET_ADDRSTRLEN +#define INET_ADDRSTRLEN 16 +#endif + +#ifndef HAVE_STRUCT_IN6_ADDR +struct in6_addr { + unsigned char s6_addr[16]; +}; +#endif + +#ifndef HAVE_STRUCT_SOCKADDR_IN6 +struct sockaddr_in6 { + sa_family_t sin6_family; + in_port_t sin6_port; + unsigned long sin6_flowinfo; + struct in6_addr sin6_addr; + unsigned long sin6_scope_id; +}; +#endif + +#if !defined(HAVE_STRUCT_SOCKADDR_STORAGE) && !defined(sockaddr_storage) +#define sockaddr_storage sockaddr_in +#endif + +#ifndef IN6ADDR_ANY_DECLARED +extern const struct in6_addr in6addr_any; +#endif + +#ifndef IN6ADDR_LOOPBACK_DECLARED +extern const struct in6_addr in6addr_loopback; +#endif + +#ifndef IN6ADDR_ANY_INIT +#define IN6ADDR_ANY_INIT \ + {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}} +#endif + +#ifndef IN6ADDR_LOOPBACK_INIT +#define IN6ADDR_LOOPBACK_INIT \ + {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}} +#endif + +#ifndef IN6_IS_ADDR_UNSPECIFIED +#define IN6_IS_ADDR_UNSPECIFIED(a) \ + ( (a)->s6_addr[ 0] == 0 && (a)->s6_addr[ 1] == 0 \ + && (a)->s6_addr[ 2] == 0 && (a)->s6_addr[ 3] == 0 \ + && (a)->s6_addr[ 4] == 0 && (a)->s6_addr[ 5] == 0 \ + && (a)->s6_addr[ 6] == 0 && (a)->s6_addr[ 7] == 0 \ + && (a)->s6_addr[ 8] == 0 && (a)->s6_addr[ 9] == 0 \ + && (a)->s6_addr[10] == 0 && (a)->s6_addr[11] == 0 \ + && (a)->s6_addr[12] == 0 && (a)->s6_addr[13] == 0 \ + && (a)->s6_addr[14] == 0 && (a)->s6_addr[15] == 0) +#endif + +#ifndef IN6_IS_ADDR_LOOPBACK +#define IN6_IS_ADDR_LOOPBACK(a) \ + ( (a)->s6_addr[ 0] == 0 && (a)->s6_addr[ 1] == 0 \ + && (a)->s6_addr[ 2] == 0 && (a)->s6_addr[ 3] == 0 \ + && (a)->s6_addr[ 4] == 0 && (a)->s6_addr[ 5] == 0 \ + && (a)->s6_addr[ 6] == 0 && (a)->s6_addr[ 7] == 0 \ + && (a)->s6_addr[ 8] == 0 && (a)->s6_addr[ 9] == 0 \ + && (a)->s6_addr[10] == 0 && (a)->s6_addr[11] == 0 \ + && (a)->s6_addr[12] == 0 && (a)->s6_addr[13] == 0 \ + && (a)->s6_addr[14] == 0 && (a)->s6_addr[15] == 1) +#endif + +#ifndef IN6_IS_ADDR_MULTICAST +#define IN6_IS_ADDR_MULTICAST(a) \ + ((a)->s6_addr[0] == 0xff) +#endif + +#ifndef IN6_IS_ADDR_LINKLOCAL +#define IN6_IS_ADDR_LINKLOCAL(a) \ + (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80)) +#endif + +#ifndef IN6_IS_ADDR_SITELOCAL +#define IN6_IS_ADDR_SITELOCAL(a) \ + (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0)) +#endif + +#ifndef IN6_IS_ADDR_V4MAPPED +#define IN6_IS_ADDR_V4MAPPED(a) \ + ( (a)->s6_addr[ 0] == 0 && (a)->s6_addr[ 1] == 0 \ + && (a)->s6_addr[ 2] == 0 && (a)->s6_addr[ 3] == 0 \ + && (a)->s6_addr[ 4] == 0 && (a)->s6_addr[ 5] == 0 \ + && (a)->s6_addr[ 6] == 0 && (a)->s6_addr[ 7] == 0 \ + && (a)->s6_addr[ 8] == 0 && (a)->s6_addr[ 9] == 0 \ + && (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff) +#endif + +#ifndef IN6_IS_ADDR_V4COMPAT +#define IN6_IS_ADDR_V4COMPAT(a) \ + ( (a)->s6_addr[ 0] == 0 && (a)->s6_addr[ 1] == 0 \ + && (a)->s6_addr[ 2] == 0 && (a)->s6_addr[ 3] == 0 \ + && (a)->s6_addr[ 4] == 0 && (a)->s6_addr[ 5] == 0 \ + && (a)->s6_addr[ 6] == 0 && (a)->s6_addr[ 7] == 0 \ + && (a)->s6_addr[ 8] == 0 && (a)->s6_addr[ 9] == 0 \ + && (a)->s6_addr[10] == 0 && (a)->s6_addr[11] == 0 \ + && ((a)->s6_addr[12] != 0 || (a)->s6_addr[13] != 0 \ + || (a)->s6_addr[14] != 0 \ + || ((a)->s6_addr[15] != 0 && (a)->s6_addr[15] != 1))) +#endif + +#endif /* not DUMMYIN6_H */ diff --git a/eb/eb.c b/eb/eb.c new file mode 100644 index 0000000..bf6375e --- /dev/null +++ b/eb/eb.c @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2000-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#ifdef ENABLE_EBNET +#include "ebnet.h" +#endif +#include "build-post.h" + +/* + * Initialize the library. + */ +EB_Error_Code +eb_initialize_library(void) +{ + EB_Error_Code error_code; + + eb_initialize_log(); + + LOG(("in: eb_initialize_library()")); + LOG(("aux: EB Library version %s", EB_VERSION_STRING)); + + eb_initialize_default_hookset(); +#ifdef ENABLE_NLS + bindtextdomain(EB_TEXT_DOMAIN_NAME, EB_LOCALEDIR); +#endif +#ifdef ENABLE_EBNET + ebnet_initialize(); +#endif + if (zio_initialize_library() < 0) { + error_code = EB_ERR_MEMORY_EXHAUSTED; + goto failed; + } + + LOG(("out: eb_initialize_library() = %s", eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_initialize_library() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Finalize the library. + */ +void +eb_finalize_library(void) +{ + LOG(("in: eb_finalize_library()")); + + zio_finalize_library(); +#ifdef ENABLE_EBNET + ebnet_finalize(); +#endif + + LOG(("out: eb_finalize_library()")); +} diff --git a/eb/eb.h b/eb/eb.h new file mode 100644 index 0000000..9adf57a --- /dev/null +++ b/eb/eb.h @@ -0,0 +1,155 @@ +/* -*- C -*- + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef EB_EB_H +#define EB_EB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef EB_BUILD_LIBRARY +#include "defs.h" +#else +#include +#endif + +#include + +/* + * Function declarations. + */ +/* book.c */ +void eb_initialize_book(EB_Book *book); +EB_Error_Code eb_bind(EB_Book *book, const char *path); +void eb_finalize_book(EB_Book *book); +int eb_is_bound(EB_Book *book); +EB_Error_Code eb_path(EB_Book *book, char *path); +EB_Error_Code eb_disc_type(EB_Book *book, EB_Disc_Code *disc_code); +EB_Error_Code eb_character_code(EB_Book *book, + EB_Character_Code *character_code); + +/* copyright.h */ +int eb_have_copyright(EB_Book *book); +EB_Error_Code eb_copyright(EB_Book *book, EB_Position *position); +EB_Error_Code eb_search_cross(EB_Book *book, + const char * const input_words[]); + +/* cross.c */ +int eb_have_cross_search(EB_Book *book); + +/* eb.c */ +EB_Error_Code eb_initialize_library(void); +void eb_finalize_library(void); + +/* endword.c */ +int eb_have_endword_search(EB_Book *book); +EB_Error_Code eb_search_endword(EB_Book *book, const char *input_word); + +/* exactword.c */ +int eb_have_exactword_search(EB_Book *book); +EB_Error_Code eb_search_exactword(EB_Book *book, const char *input_word); + +/* graphic.c */ +int eb_have_graphic_search(EB_Book *book); + +/* keyword.c */ +int eb_have_keyword_search(EB_Book *book); +EB_Error_Code eb_search_keyword(EB_Book *book, + const char * const input_words[]); + +/* lock.c */ +int eb_pthread_enabled(void); + +/* log.c */ +void eb_set_log_function(void (*function)(const char *message, va_list ap)); +void eb_enable_log(void); +void eb_disable_log(void); +void eb_log(const char *message, ...); +void eb_log_stderr(const char *message, va_list ap); + +/* menu.c */ +int eb_have_menu(EB_Book *book); +EB_Error_Code eb_menu(EB_Book *book, EB_Position *position); +int eb_have_image_menu(EB_Book *book); +EB_Error_Code eb_image_menu(EB_Book *book, EB_Position *position); + +/* multi.c */ +int eb_have_multi_search(EB_Book *book); +EB_Error_Code eb_multi_title(EB_Book *book, EB_Multi_Search_Code multi_id, + char *title); +EB_Error_Code eb_multi_search_list(EB_Book *book, + EB_Multi_Search_Code *search_list, int *search_count); +EB_Error_Code eb_multi_entry_count(EB_Book *book, + EB_Multi_Search_Code multi_id, int *entry_count); +EB_Error_Code eb_multi_entry_list(EB_Book *book, + EB_Multi_Search_Code multi_id, int *entry_list, int *entry_count); +EB_Error_Code eb_multi_entry_label(EB_Book *book, + EB_Multi_Search_Code multi_id, int entry_index, char *label); +int eb_multi_entry_have_candidates(EB_Book *book, + EB_Multi_Search_Code multi_id, int entry_index); +EB_Error_Code eb_multi_entry_candidates(EB_Book *book, + EB_Multi_Search_Code multi_id, int entry_index, EB_Position *position); +EB_Error_Code eb_search_multi(EB_Book *book, EB_Multi_Search_Code multi_id, + const char * const input_words[]); + +/* text.c */ +int eb_have_text(EB_Book *book); +EB_Error_Code eb_text(EB_Book *book, EB_Position *position); + +/* search.c */ +EB_Error_Code eb_hit_list(EB_Book *book, int max_hit_count, EB_Hit *hit_list, + int *hit_count); + +/* subbook.c */ +EB_Error_Code eb_load_all_subbooks(EB_Book *book); +EB_Error_Code eb_subbook_list(EB_Book *book, EB_Subbook_Code *subbook_list, + int *subbook_count); +EB_Error_Code eb_subbook(EB_Book *book, EB_Subbook_Code *subbook_code); +EB_Error_Code eb_subbook_title(EB_Book *book, char *title); +EB_Error_Code eb_subbook_title2(EB_Book *book, EB_Subbook_Code subbook_code, + char *title); +EB_Error_Code eb_subbook_directory(EB_Book *book, char *directory); +EB_Error_Code eb_subbook_directory2(EB_Book *book, + EB_Subbook_Code subbook_code, char *directory); +EB_Error_Code eb_set_subbook(EB_Book *book, EB_Subbook_Code subbook_code); +void eb_unset_subbook(EB_Book *book); + +/* word.c */ +int eb_have_word_search(EB_Book *book); +EB_Error_Code eb_search_word(EB_Book *book, const char *input_word); + +/* for backward compatibility */ +#define eb_suspend eb_unset_subbook +#define eb_initialize_all_subbooks eb_load_all_subbooks + +#ifdef __cplusplus +} +#endif + +#endif /* not EB_EB_H */ diff --git a/eb/ebnet.c b/eb/ebnet.c new file mode 100644 index 0000000..e01beeb --- /dev/null +++ b/eb/ebnet.c @@ -0,0 +1,1166 @@ +/* + * Copyright (c) 2003-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "build-pre.h" + +#include +#include + +#include "eb.h" +#include "error.h" +#include "build-post.h" +#include "dummyin6.h" + +#if !defined(HAVE_GETADDRINFO) || !defined(HAVE_GETNAMEINFO) +#include "getaddrinfo.h" +#endif + +#include "ebnet.h" +#include "linebuf.h" +#include "urlparts.h" + +#ifndef IF_NAMESIZE +#ifdef IFNAMSIZ +#define IF_NAMESIZE IFNAMSIZ +#else +#define IF_NAMESIZE 16 +#endif +#endif + +#ifndef NI_MAXHOST +#define NI_MAXHOST 1025 +#endif + +#ifndef SHUT_RD +#define SHUT_RD 0 +#endif +#ifndef SHUT_WR +#define SHUT_WR 1 +#endif +#ifndef SHUT_RDWR +#define SHUT_RDWR 2 +#endif + +/* + * Max retry count for establishing a new connection with the server. + */ +#define EBNET_MAX_RETRY_COUNT 1 + +/* + * Unexported functions. + */ +static int ebnet_parse_booklist_entry(const char *line, char *book_name, + char *book_title); +static int ebnet_send_quit(int file); +static int ebnet_parse_url(const char *url, char *host, in_port_t *port, + char *book_name, char *file_path); +static int is_integer(const char *string); +static int write_string_all(int file, int timeout, const char *string); + + +/* + * Initialize ebnet. + */ +void +ebnet_initialize(void) +{ +#ifdef WINSOCK + WSADATA wsa_data; + + WSAStartup(MAKEWORD(2, 2), &wsa_data); +#endif + ebnet_initialize_multiplex(); + ebnet_set_bye_hook(ebnet_send_quit); +} + + +/* + * Get a book list from a server. + */ +EB_Error_Code +ebnet_bind_booklist(EB_BookList *booklist, const char *url) +{ + EB_Error_Code error_code; + char host[NI_MAXHOST]; + in_port_t port; + char book_name[EBNET_MAX_BOOK_NAME_LENGTH + 1]; + char book_title[EBNET_MAX_BOOK_TITLE_LENGTH + 1]; + char url_path[EB_MAX_RELATIVE_PATH_LENGTH + 1]; + Line_Buffer line_buffer; + char line[EBNET_MAX_LINE_LENGTH + 1]; + int ebnet_file = -1; + ssize_t read_result; + int lost_sync; + int retry_count = 0; + + LOG(("in: ebnet_bind_booklist(url=%s)", url)); + + retry: + lost_sync = 0; + initialize_line_buffer(&line_buffer); + set_line_buffer_timeout(&line_buffer, EBNET_TIMEOUT_SECONDS); + + /* + * Parse URL. + */ + if (ebnet_parse_url(url, host, &port, book_name, url_path) < 0 + || *book_name != '\0') { + error_code = EB_ERR_BAD_FILE_NAME; + goto failed; + } + + /* + * Establish a connection. + */ + ebnet_file = ebnet_connect_socket(host, port, PF_UNSPEC); + if (ebnet_file < 0) { + error_code = EB_ERR_EBNET_FAIL_CONNECT; + goto failed; + } + + /* + * Request BOOKLIST. + */ + bind_file_to_line_buffer(&line_buffer, ebnet_file); + sprintf(line, "BOOKLIST %s\r\n", book_name); + if (write_string_all(ebnet_file, EBNET_TIMEOUT_SECONDS, line) <= 0) { + error_code = EB_ERR_EBNET_FAIL_CONNECT; + lost_sync = 1; + goto failed; + } + read_result = read_line_buffer(&line_buffer, line, sizeof(line)); + if (read_result < 0 || read_result == sizeof(line) || *line != '!') { + lost_sync = 1; + error_code = EB_ERR_EBNET_FAIL_CONNECT; + goto failed; + } + if (strncasecmp(line, "!OK;", 4) != 0) { + error_code = EB_ERR_EBNET_FAIL_CONNECT; + goto failed; + } + + /* + * Get a list. + */ + for (;;) { + read_result = read_line_buffer(&line_buffer, line, sizeof(line)); + if (read_result < 0 || read_result == sizeof(line)) { + lost_sync = 1; + error_code = EB_ERR_EBNET_FAIL_CONNECT; + goto failed; + } + if (*line == '\0') + break; + if (ebnet_parse_booklist_entry(line, book_name, book_title) < 0) { + lost_sync = 1; + error_code = EB_ERR_EBNET_FAIL_CONNECT; + goto failed; + } + error_code = eb_booklist_add_book(booklist, book_name, book_title); + if (error_code != EB_SUCCESS) + goto failed; + } + + ebnet_disconnect_socket(ebnet_file); + finalize_line_buffer(&line_buffer); + LOG(("out: ebnet_bind_booklist() = %s", eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + finalize_line_buffer(&line_buffer); + if (0 <= ebnet_file) { + if (lost_sync) { + shutdown(ebnet_file, SHUT_RDWR); + ebnet_set_lost_sync(ebnet_file); + } + ebnet_disconnect_socket(ebnet_file); + ebnet_file = -1; + if (lost_sync && retry_count < EBNET_MAX_RETRY_COUNT) { + retry_count++; + goto retry; + } + } + LOG(("out: ebnet_bind_booklist() = %s", eb_error_string(error_code))); + return error_code; +} + + +static int +ebnet_parse_booklist_entry(const char *line, char *book_name, char *book_title) +{ + const char *space; + size_t book_name_length; + size_t book_title_length; + char *p; + + space = strchr(line, ' '); + if (space == NULL) + return -1; + book_name_length = space - line; + book_title_length = strlen(space + 1); + + if (book_name_length == 0 + || EBNET_MAX_BOOK_NAME_LENGTH < book_name_length) + return -1; + if (book_title_length == 0 + || EBNET_MAX_BOOK_TITLE_LENGTH < book_title_length) + return -1; + + memcpy(book_name, line, book_name_length); + *(book_name + book_name_length) = '\0'; + memcpy(book_title, space + 1, book_title_length); + *(book_title + book_title_length) = '\0'; + + for (p = book_name; *p != '\0'; p++) { + if (!ASCII_ISLOWER(*p) && !ASCII_ISDIGIT(*p) + && *p != '_' && *p != '-' && *p != '.') + return -1; + } + + return 0; +} + + +/* + * Extension code for eb_bind() to support ebnet. + */ +EB_Error_Code +ebnet_bind(EB_Book *book, const char *url) +{ + EB_Error_Code error_code; + char host[NI_MAXHOST]; + in_port_t port; + char book_name[EBNET_MAX_BOOK_NAME_LENGTH + 1]; + char url_path[EB_MAX_RELATIVE_PATH_LENGTH + 1]; + Line_Buffer line_buffer; + char line[EBNET_MAX_LINE_LENGTH + 1]; + ssize_t read_result; + int lost_sync; + int retry_count = 0; + + LOG(("in: ebnet_bind(url=%s)", url)); + + retry: + lost_sync = 0; + initialize_line_buffer(&line_buffer); + set_line_buffer_timeout(&line_buffer, EBNET_TIMEOUT_SECONDS); + + /* + * Parse URL. + */ + if (ebnet_parse_url(url, host, &port, book_name, url_path) < 0 + || *book_name == '\0') { + error_code = EB_ERR_BAD_FILE_NAME; + goto failed; + } + + /* + * Establish a connection. + */ + book->ebnet_file = ebnet_connect_socket(host, port, PF_UNSPEC); + if (book->ebnet_file < 0) { + error_code = EB_ERR_EBNET_FAIL_CONNECT; + goto failed; + } + + ebnet_set_book_name(book->ebnet_file, book_name); + + /* + * Request BOOK. + */ + bind_file_to_line_buffer(&line_buffer, book->ebnet_file); + sprintf(line, "BOOK %s\r\n", book_name); + if (write_string_all(book->ebnet_file, EBNET_TIMEOUT_SECONDS, line) <= 0) { + error_code = EB_ERR_FAIL_OPEN_CAT; + lost_sync = 1; + goto failed; + } + read_result = read_line_buffer(&line_buffer, line, sizeof(line)); + if (read_result < 0 || read_result == sizeof(line) || *line != '!') { + lost_sync = 1; + error_code = EB_ERR_EBNET_FAIL_CONNECT; + goto failed; + } + if (strncasecmp(line, "!OK;", 4) != 0) { + if (strncasecmp(line, "!BUSY;", 6) == 0) + error_code = EB_ERR_EBNET_SERVER_BUSY; + else if (strncasecmp(line, "!PERM;", 6) == 0) + error_code = EB_ERR_EBNET_NO_PERMISSION; + else + error_code = EB_ERR_FAIL_OPEN_CAT; + goto failed; + } + + finalize_line_buffer(&line_buffer); + LOG(("out: ebnet_bind() = %s", eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + finalize_line_buffer(&line_buffer); + if (0 <= book->ebnet_file) { + if (lost_sync) { + shutdown(book->ebnet_file, SHUT_RDWR); + ebnet_set_lost_sync(book->ebnet_file); + } + ebnet_disconnect_socket(book->ebnet_file); + book->ebnet_file = -1; + if (lost_sync && retry_count < EBNET_MAX_RETRY_COUNT) { + retry_count++; + goto retry; + } + } + LOG(("out: ebnet_bind() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Extension code for eb_bind_appendix() to support ebnet. + */ +EB_Error_Code +ebnet_bind_appendix(EB_Appendix *appendix, const char *url) +{ + EB_Error_Code error_code; + char host[NI_MAXHOST]; + in_port_t port; + char appendix_name[EBNET_MAX_BOOK_NAME_LENGTH + 1]; + char url_path[EB_MAX_RELATIVE_PATH_LENGTH + 1]; + Line_Buffer line_buffer; + char line[EBNET_MAX_LINE_LENGTH + 1]; + ssize_t read_result; + int lost_sync; + int retry_count = 0; + + LOG(("in: ebnet_bind(url=%s)", url)); + + retry: + lost_sync = 0; + initialize_line_buffer(&line_buffer); + set_line_buffer_timeout(&line_buffer, EBNET_TIMEOUT_SECONDS); + + /* + * Parse URL. + */ + if (ebnet_parse_url(url, host, &port, appendix_name, url_path) < 0 + || *appendix_name == '\0') { + error_code = EB_ERR_BAD_FILE_NAME; + goto failed; + } + + /* + * Establish a connection. + */ + appendix->ebnet_file = ebnet_connect_socket(host, port, PF_UNSPEC); + if (appendix->ebnet_file < 0) { + error_code = EB_ERR_EBNET_FAIL_CONNECT; + goto failed; + } + + ebnet_set_book_name(appendix->ebnet_file, appendix_name); + + /* + * Request BOOK. + */ + bind_file_to_line_buffer(&line_buffer, appendix->ebnet_file); + sprintf(line, "BOOK %s\r\n", appendix_name); + if (write_string_all(appendix->ebnet_file, EBNET_TIMEOUT_SECONDS, line) + <= 0) { + error_code = EB_ERR_FAIL_OPEN_CAT; + lost_sync = 1; + goto failed; + } + read_result = read_line_buffer(&line_buffer, line, sizeof(line)); + if (read_result < 0 || read_result == sizeof(line) || *line != '!') { + lost_sync = 1; + error_code = EB_ERR_EBNET_FAIL_CONNECT; + goto failed; + } + if (strncasecmp(line, "!OK;", 4) != 0) { + if (strncasecmp(line, "!BUSY;", 6) == 0) + error_code = EB_ERR_EBNET_SERVER_BUSY; + else if (strncasecmp(line, "!PERM;", 6) == 0) + error_code = EB_ERR_EBNET_NO_PERMISSION; + else + error_code = EB_ERR_FAIL_OPEN_CAT; + goto failed; + } + + finalize_line_buffer(&line_buffer); + LOG(("out: ebnet_bind() = %s", eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + finalize_line_buffer(&line_buffer); + if (0 <= appendix->ebnet_file) { + if (lost_sync) { + shutdown(appendix->ebnet_file, SHUT_RDWR); + ebnet_set_lost_sync(appendix->ebnet_file); + } + ebnet_disconnect_socket(appendix->ebnet_file); + appendix->ebnet_file = -1; + if (lost_sync && retry_count < EBNET_MAX_RETRY_COUNT) { + retry_count++; + goto retry; + } + } + LOG(("out: ebnet_bind() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Extension code for eb_finalize_book() to support ebnet. + */ +void +ebnet_finalize_book(EB_Book *book) +{ + LOG(("in+out: ebnet_finalize_book(book=%d)", (int)book->code)); + + if (0 <= book->ebnet_file) { + ebnet_disconnect_socket(book->ebnet_file); + book->ebnet_file = -1; + } +} + + +/* + * Extension code for eb_finalize_appendix() to support ebnet. + */ +void +ebnet_finalize_appendix(EB_Appendix *appendix) +{ + LOG(("in+out: ebnet_finalize_appendix(appendix=%d)", (int)appendix->code)); + + if (0 <= appendix->ebnet_file) { + ebnet_disconnect_socket(appendix->ebnet_file); + appendix->ebnet_file = -1; + } +} + + +/* + * Extension code for zio_open_raw() to support ebnet. + */ +int +ebnet_open(const char *url) +{ + char host[NI_MAXHOST]; + in_port_t port; + char book_name[EBNET_MAX_BOOK_NAME_LENGTH + 1]; + char url_path[EB_MAX_RELATIVE_PATH_LENGTH + 1]; + Line_Buffer line_buffer; + char line[EBNET_MAX_LINE_LENGTH + 1]; + ssize_t read_result; + off_t file_size; + int new_file; + int lost_sync; + int retry_count = 0; + + LOG(("in: ebnet_open(url=%s)", url)); + + retry: + new_file = -1; + lost_sync = 0; + initialize_line_buffer(&line_buffer); + set_line_buffer_timeout(&line_buffer, EBNET_TIMEOUT_SECONDS); + + /* + * Parse URL. + */ + if (ebnet_parse_url(url, host, &port, book_name, url_path) < 0 + || *book_name == '\0') { + goto failed; + } + + /* + * Connect with a server. + */ + new_file = ebnet_connect_socket(host, port, PF_UNSPEC); + if (new_file < 0) + goto failed; + + ebnet_set_book_name(new_file, book_name); + ebnet_set_file_path(new_file, url_path); + + /* + * Request FILESIZE. + */ + bind_file_to_line_buffer(&line_buffer, new_file); + sprintf(line, "FILESIZE %s /%s\r\n", book_name, url_path); + if (write_string_all(new_file, EBNET_TIMEOUT_SECONDS, line) <= 0) { + lost_sync = 1; + goto failed; + } + read_result = read_line_buffer(&line_buffer, line, sizeof(line)); + if (read_result < 0 || read_result == sizeof(line) || *line != '!') { + lost_sync = 1; + goto failed; + } + if (strncasecmp(line, "!OK;", 4) != 0) + goto failed; + + read_result = read_line_buffer(&line_buffer, line, sizeof(line)); + if (read_result < 0 || read_result == sizeof(line) || !is_integer(line)) { + lost_sync = 1; + goto failed; + } + +#if defined(HAVE_ATOLL) + file_size = atoll(line); +#elif defined(HAVE__ATOI64) + file_size = _atoi64(line); +#else + file_size = atol(line); +#endif + + if (file_size < 0) + goto failed; + ebnet_set_file_size(new_file, file_size); + + finalize_line_buffer(&line_buffer); + LOG(("out: ebnet_open() = %d", new_file)); + return new_file; + + /* + * An error occurs... + */ + failed: + finalize_line_buffer(&line_buffer); + if (0 <= new_file) { + if (lost_sync) { + shutdown(new_file, SHUT_RDWR); + ebnet_set_lost_sync(new_file); + } + ebnet_disconnect_socket(new_file); + if (lost_sync && retry_count < EBNET_MAX_RETRY_COUNT) { + retry_count++; + goto retry; + } + } + LOG(("out: ebnet_open() = %d", -1)); + return -1; +} + + +/* + * Extension code for zio_close_raw() to support ebnet. + */ +int +ebnet_close(int file) +{ + LOG(("in+out: ebnet_close(file=%d)", file)); + ebnet_disconnect_socket(file); + return 0; +} + + +/* + * Extension code for zio_lseek_raw() to support ebnet. + */ +off_t +ebnet_lseek(int file, off_t offset, int whence) +{ + off_t file_size; + off_t new_offset = 0; + + LOG(("in: ebnet_lseek(file=%d, location=%ld, whence=%d)", file, + (long)offset, whence)); + + file_size = ebnet_get_file_size(file); + if (file_size < 0) + goto failed; + + switch (whence) { + case SEEK_SET: + new_offset = offset; + break; + case SEEK_CUR: + new_offset = new_offset + offset; + break; + case SEEK_END: + if (offset <= file_size) + new_offset = file_size - offset; + else + new_offset = 0; + break; + default: + goto failed; + } + + ebnet_set_offset(file, new_offset); + LOG(("out: ebnet_lseek() = %ld", (long)new_offset)); + return new_offset; + + /* + * An error occurs... + */ + failed: + LOG(("out: ebnet_lseek() = %ld", (long)-1)); + return -1; +} + + +/* + * Extension code for zio_read_raw() to support ebnet. + */ +ssize_t +ebnet_read(int *file, char *buffer, size_t length) +{ + Line_Buffer line_buffer; + char line[EBNET_MAX_LINE_LENGTH + 1]; + const char *book_name; + const char *url_path; + off_t offset; + size_t received_length; + ssize_t read_result; + ssize_t chunk_length; + int lost_sync; + int retry_count = 0; + + LOG(("in: ebnet_read(*file=%d, length=%ld)", *file, (long)length)); + + if (length == 0) { + LOG(("out: ebnet_read() = %ld", (long)0)); + return 0; + } + + retry: + lost_sync = 0; + initialize_line_buffer(&line_buffer); + + /* + * Request READ. + */ + book_name = ebnet_get_book_name(*file); + url_path = ebnet_get_file_path(*file); + offset = ebnet_get_offset(*file); + if (book_name == NULL || url_path == NULL || offset < 0) + goto failed; + + bind_file_to_line_buffer(&line_buffer, *file); +#if defined(PRINTF_LL_MODIFIER) + sprintf(line, "READ %s /%s %llu %ld\r\n", book_name, url_path, + (unsigned long long) offset, (long) length); +#elif defined(PRINTF_I64_MODIFIER) + sprintf(line, "READ %s /%s %I64u %ld\r\n", book_name, url_path, + (unsigned __int64) offset, (long) length); +#else + sprintf(line, "READ %s /%s %lu %ld\r\n", book_name, url_path, + (unsigned long) offset, (long) length); +#endif + if (write_string_all(*file, EBNET_TIMEOUT_SECONDS, line) <= 0) { + lost_sync = 1; + goto failed; + } + read_result = read_line_buffer(&line_buffer, line, sizeof(line)); + if (read_result < 0 || read_result == sizeof(line) || *line != '!') { + lost_sync = 1; + goto failed; + } + if (strncasecmp(line, "!OK;", 4) != 0) + goto failed; + + received_length = 0; + while (received_length < length) { + read_result = read_line_buffer(&line_buffer, line, sizeof(line)); + if (read_result < 0 || read_result == sizeof(line) || *line != '*') { + lost_sync = 1; + goto failed; + } + + if (!is_integer(line + 1)) { + lost_sync = 1; + goto failed; + } else if (strcmp(line + 1, "-1") == 0) { + ebnet_set_offset(*file, (off_t) offset + received_length); + goto failed; + } else if (strcmp(line + 1, "0") == 0) { + break; + } + chunk_length = atoi(line + 1); + if (chunk_length <= 0 || length < received_length + chunk_length) { + lost_sync = 1; + goto failed; + } + + read_result = binary_read_line_buffer(&line_buffer, + buffer + received_length, chunk_length); + if (read_result != chunk_length) { + lost_sync = 1; + goto failed; + } + received_length += chunk_length; + } + + ebnet_set_offset(*file, (off_t) offset + received_length); + finalize_line_buffer(&line_buffer); + LOG(("out: ebnet_read(*file=%d) = %ld", *file, (long)received_length)); + return received_length; + + /* + * An error occurs... + */ + failed: + finalize_line_buffer(&line_buffer); + if (lost_sync) { + shutdown(*file, SHUT_RDWR); + ebnet_set_lost_sync(*file); + if (retry_count < EBNET_MAX_RETRY_COUNT) { + int new_file = ebnet_reconnect_socket(*file); + if (0 <= new_file) { + *file = new_file; + retry_count++; + goto retry; + } + } + } + LOG(("out: ebnet_read(*file=%d) = %ld", *file, (long)-1)); + return -1; +} + + +/* + * Extension code for eb_fix_directory_name() to support ebnet. + */ +EB_Error_Code +ebnet_fix_directory_name(const char *url, char *directory_name) +{ + char host[NI_MAXHOST]; + in_port_t port; + char book_name[EBNET_MAX_BOOK_NAME_LENGTH + 1]; + char url_path[EB_MAX_RELATIVE_PATH_LENGTH + 1]; + Line_Buffer line_buffer; + char line[EBNET_MAX_LINE_LENGTH + 1]; + ssize_t read_result; + int new_file; + int lost_sync; + int retry_count = 0; + + retry: + new_file = -1; + lost_sync = 0; + initialize_line_buffer(&line_buffer); + set_line_buffer_timeout(&line_buffer, EBNET_TIMEOUT_SECONDS); + + /* + * Parse URL. + */ + if (ebnet_parse_url(url, host, &port, book_name, url_path) < 0 + || *book_name == '\0') { + goto failed; + } + + /* + * Connect with a server. + */ + new_file = ebnet_connect_socket(host, port, PF_UNSPEC); + if (new_file < 0) + goto failed; + + /* + * Request DIR. + */ + bind_file_to_line_buffer(&line_buffer, new_file); + sprintf(line, "DIR %s /%s %s\r\n", book_name, url_path, directory_name); + if (write_string_all(new_file, EBNET_TIMEOUT_SECONDS, line) <= 0) { + lost_sync = 1; + goto failed; + } + read_result = read_line_buffer(&line_buffer, line, sizeof(line)); + if (read_result < 0 || read_result == sizeof(line) || *line != '!') { + lost_sync = 1; + goto failed; + } + if (strncasecmp(line, "!OK;", 4) != 0) + goto failed; + + read_result = read_line_buffer(&line_buffer, line, sizeof(line)); + if (read_result < 0 || read_result == sizeof(line)) { + lost_sync = 1; + goto failed; + } + + if (*line == '\0' || EB_MAX_DIRECTORY_NAME_LENGTH < strlen(line)) + goto failed; + strcpy(directory_name, line); + + finalize_line_buffer(&line_buffer); + ebnet_disconnect_socket(new_file); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + finalize_line_buffer(&line_buffer); + if (0 <= new_file) { + if (lost_sync) { + shutdown(new_file, SHUT_RDWR); + ebnet_set_lost_sync(new_file); + } + ebnet_disconnect_socket(new_file); + if (lost_sync && retry_count < EBNET_MAX_RETRY_COUNT) { + retry_count++; + goto retry; + } + } + return EB_ERR_BAD_DIR_NAME; +} + + +/* + * Extension code for eb_find_file_name() to support ebnet. + */ +EB_Error_Code +ebnet_find_file_name(const char *url, const char *target_file_name, + char *found_file_name) +{ + char host[NI_MAXHOST]; + in_port_t port; + char book_name[EBNET_MAX_BOOK_NAME_LENGTH + 1]; + char url_path[EB_MAX_RELATIVE_PATH_LENGTH + 1]; + Line_Buffer line_buffer; + char line[EBNET_MAX_LINE_LENGTH + 1]; + ssize_t read_result; + int new_file; + int lost_sync; + int retry_count = 0; + + retry: + new_file = -1; + lost_sync = 0; + initialize_line_buffer(&line_buffer); + set_line_buffer_timeout(&line_buffer, EBNET_TIMEOUT_SECONDS); + + /* + * Parse URL. + */ + if (ebnet_parse_url(url, host, &port, book_name, url_path) < 0 + || *book_name == '\0') { + goto failed; + } + + /* + * Connect with a server. + */ + new_file = ebnet_connect_socket(host, port, PF_UNSPEC); + if (new_file < 0) + goto failed; + + /* + * Request FILE. + */ + bind_file_to_line_buffer(&line_buffer, new_file); + sprintf(line, "FILE %s /%s %s\r\n", book_name, url_path, target_file_name); + if (write_string_all(new_file, EBNET_TIMEOUT_SECONDS, line) <= 0) { + lost_sync = 1; + goto failed; + } + read_result = read_line_buffer(&line_buffer, line, sizeof(line)); + if (read_result < 0 || read_result == sizeof(line) || *line != '!') { + lost_sync = 1; + goto failed; + } + if (strncasecmp(line, "!OK;", 4) != 0) + goto failed; + + read_result = read_line_buffer(&line_buffer, line, sizeof(line)); + if (read_result < 0 || read_result == sizeof(line)) { + lost_sync = 1; + goto failed; + } + + if (*line == '\0' || EB_MAX_FILE_NAME_LENGTH < strlen(line)) + goto failed; + strcpy(found_file_name, line); + + finalize_line_buffer(&line_buffer); + ebnet_disconnect_socket(new_file); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + finalize_line_buffer(&line_buffer); + if (0 <= new_file) { + if (lost_sync) { + shutdown(new_file, SHUT_RDWR); + ebnet_set_lost_sync(new_file); + } + ebnet_disconnect_socket(new_file); + if (lost_sync && retry_count < EBNET_MAX_RETRY_COUNT) { + retry_count++; + goto retry; + } + } + return EB_ERR_BAD_FILE_NAME; +} + + +/* + * Bye hook. + * We must send `QUIT' command before close a connection. + */ +static int +ebnet_send_quit(int file) +{ + if (write_string_all(file, EBNET_TIMEOUT_SECONDS, "QUIT\r\n") <= 0) + return -1; + return 0; +} + + +/* + * URL version of eb_canonicalize_path_name(). + */ +EB_Error_Code +ebnet_canonicalize_url(char *url) +{ + char host[NI_MAXHOST]; + in_port_t port; + char book_name[EBNET_MAX_BOOK_NAME_LENGTH + 1]; + char url_path[EB_MAX_RELATIVE_PATH_LENGTH + 1]; + + if (ebnet_parse_url(url, host, &port, book_name, url_path) < 0 + || *book_name == '\0') { + return EB_ERR_BAD_FILE_NAME; + } + + /* + * "ebnet://[]:/" must not exceed + * EB_MAX_PATH_LENGTH. + * + * Note: + * "ebnet://[" + "]:" + "/" = 12 characters. + * is 5 characters maximum. + */ + if (EB_MAX_PATH_LENGTH + < strlen(host) + strlen(book_name) + strlen(url_path) + 17) + return EB_ERR_TOO_LONG_FILE_NAME; + + if (strchr(host, ':') != NULL) + sprintf(url, "ebnet://[%s]:%d/%s", host, (int)port, book_name); + else + sprintf(url, "ebnet://%s:%d/%s", host, (int)port, book_name); + + return EB_SUCCESS; +} + + +/* + * Parse URL. + * + * As the result, host, port, book_name and file-path are put into + * the corresponding arguments. + */ +static int +ebnet_parse_url(const char *url, char *host, in_port_t *port, + char *book_name, char *file_path) +{ + URL_Parts parts; + const char *scheme_part; + const char *host_part; + const char *port_part; + const char *port_part_p; + const char *path_part; + const char *slash; + size_t book_name_length; + + *host = '\0'; + *port = 0; + *book_name = '\0'; + *file_path = '\0'; + + url_parts_initialize(&parts); + if (url_parts_parse(&parts, url) < 0) + goto failed; + + /* + * Check scheme. + */ + scheme_part = url_parts_scheme(&parts); + if (scheme_part == NULL || strcmp(scheme_part, EBNET_SERVICE_NAME) != 0) + goto failed; + + /* + * Check host. + */ + host_part = url_parts_host(&parts); + if (host_part == NULL || *host_part == '\0' + || NI_MAXHOST < strlen(host_part) + 1) + goto failed; + strcpy(host, host_part); + + /* + * Check port. + */ + port_part = url_parts_port(&parts); + if (port_part == NULL || *port_part == '\0') + port_part = EBNET_DEFAULT_PORT; + + for (port_part_p = port_part; *port_part_p != '\0'; port_part_p++) { + if (!ASCII_ISDIGIT(*port_part_p)) + goto failed; + } + *port = atoi(port_part); + + /* + * Check path. + */ + path_part = url_parts_path(&parts); + if (path_part == NULL || *path_part == '\0') { + *book_name = '\0'; + *file_path = '\0'; + } else { + slash = strchr(path_part + 1, '/'); + if (slash == NULL) { + book_name_length = strlen(path_part + 1); + if (EBNET_MAX_BOOK_NAME_LENGTH < book_name_length) + goto failed; + strcpy(book_name, path_part + 1); + *file_path = '\0'; + } else { + book_name_length = slash - (path_part + 1); + if (book_name_length == 0 + || EBNET_MAX_BOOK_NAME_LENGTH < book_name_length) + goto failed; + memcpy(book_name, path_part + 1, book_name_length); + *(book_name + book_name_length) = '\0'; + + if (EB_MAX_RELATIVE_PATH_LENGTH < strlen(slash + 1)) + goto failed; + strcpy(file_path, slash + 1); + } + } + + url_parts_finalize(&parts); + return 0; + + /* + * An error occurs... + */ + failed: + *host = '\0'; + *port = 0; + *book_name = '\0'; + *file_path = '\0'; + url_parts_finalize(&parts); + return -1; +} + + +/* + * Check whether `string' is integer or not. + * Return 1 if it is, 0 otherwise. + */ +static int +is_integer(const char *string) +{ + const char *s = string; + + if (*s == '-') + s++; + if (!ASCII_ISDIGIT(*s)) + return 0; + s++; + + while (*s != '\0') { + if (!ASCII_ISDIGIT(*s)) + return 0; + s++; + } + + return 1; +} + + +/* + * Write data to a file. + * It repeats to call write() until all data will have written. + * The function returns 1 upon success, 0 upon timeout, -1 upon error. + */ +static int +write_string_all(int file, int timeout, const char *string) +{ + const char *string_p = string; + ssize_t rest_length = strlen(string); + fd_set fdset; + struct timeval timeval; + int select_result; + ssize_t write_result; + + while (0 < rest_length) { + errno = 0; + FD_ZERO(&fdset); + FD_SET(file, &fdset); + + if (timeout == 0) + select_result = select(file + 1, NULL, &fdset, NULL, NULL); + else { + timeval.tv_sec = timeout; + timeval.tv_usec = 0; + select_result = select(file + 1, NULL, &fdset, NULL, &timeval); + } + if (select_result < 0) { + if (errno == EINTR) + continue; + return -1; + } else if (select_result == 0) { + return 0; + } + + errno = 0; + write_result = send(file, string_p, rest_length, 0); + if (write_result < 0) { + if (errno == EINTR) + continue; + return -1; + } else { + rest_length -= write_result; + string_p += write_result; + } + } + + return 1; +} + + diff --git a/eb/ebnet.h b/eb/ebnet.h new file mode 100644 index 0000000..1ab8eb7 --- /dev/null +++ b/eb/ebnet.h @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2003-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef EBNET_H +#define EBNET_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "eb.h" + +/* + * Service name. + */ +#define EBNET_SERVICE_NAME "ebnet" + +/* + * Default port number. + */ +#define EBNET_DEFAULT_PORT "22010" + +/* + * Maximum length of book name. + * EBNETD defins 14, but we add +4 for the ".app" suffix here. + */ +#define EBNET_MAX_BOOK_NAME_LENGTH 18 + +/* + * Maximum length of book title. + * EBNETD defins 80, and EB Library uses the same value. + */ +#define EBNET_MAX_BOOK_TITLE_LENGTH 80 + +/* + * Maximum length of an EBNET request or response line. + */ +#define EBNET_MAX_LINE_LENGTH 511 + +/* + * Timeout period in seconds. + */ +#define EBNET_TIMEOUT_SECONDS 30 + +/* + * Function declarations. + */ +/* multiplex.c */ +void ebnet_initialize_multiplex(void); +void ebnet_finalize(void); +void ebnet_set_hello_hook(int (*hook)(int file)); +void ebnet_set_bye_hook(int (*hook)(int file)); +int ebnet_connect_socket(const char *host, int port, int family); +void ebnet_disconnect_socket(int file); +int ebnet_reconnect_socket(int file); +int ebnet_set_lost_sync(int file); +int ebnet_set_book_name(int file, const char *book_name); +const char *ebnet_get_book_name(int file); +int ebnet_set_file_path(int file, const char *file_path); +const char *ebnet_get_file_path(int file); +int ebnet_set_offset(int file, off_t offset); +off_t ebnet_get_offset(int file); +int ebnet_set_file_size(int file, off_t file_size); +off_t ebnet_get_file_size(int file); + +/* ebnet.c */ +void ebnet_initialize(void); +EB_Error_Code ebnet_bind_booklist(EB_BookList *booklist, const char *url); +EB_Error_Code ebnet_bind(EB_Book *book, const char *url); +EB_Error_Code ebnet_bind_appendix(EB_Appendix *appendix, const char *url); +void ebnet_finalize_book(EB_Book *book); +void ebnet_finalize_appendix(EB_Appendix *appendix); +int ebnet_open(const char *url); +int ebnet_close(int file); +off_t ebnet_lseek(int file, off_t offset, int whence); +ssize_t ebnet_read(int *file, char *buffer, size_t length); +EB_Error_Code ebnet_fix_directory_name(const char *url, char *directory_name); +EB_Error_Code ebnet_find_file_name(const char *url, + const char *target_file_name, char *found_file_name); +EB_Error_Code ebnet_canonicalize_url(char *url); + +#endif /* EBNET_H */ diff --git a/eb/endword.c b/eb/endword.c new file mode 100644 index 0000000..4170e47 --- /dev/null +++ b/eb/endword.c @@ -0,0 +1,191 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "build-post.h" + +/* + * Examine whether the current subbook in `book' supports `ENDWORD SEARCH' + * or not. + */ +int +eb_have_endword_search(EB_Book *book) +{ + eb_lock(&book->lock); + LOG(("in: eb_have_endword_search(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) + goto failed; + + /* + * Check for the index page of endword search. + */ + if (book->subbook_current->endword_alphabet.start_page == 0 + && book->subbook_current->endword_asis.start_page == 0 + && book->subbook_current->endword_kana.start_page == 0) + goto failed; + + LOG(("out: eb_have_endword_search() = %d", 1)); + eb_unlock(&book->lock); + + return 1; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_have_endword_search() = %d", 0)); + eb_unlock(&book->lock); + return 0; +} + + +/* + * Endword search. + */ +EB_Error_Code +eb_search_endword(EB_Book *book, const char *input_word) +{ + EB_Error_Code error_code; + EB_Word_Code word_code; + EB_Search_Context *context; + + eb_lock(&book->lock); + LOG(("in: eb_search_endword(book=%d, input_word=%s)", (int)book->code, + eb_quoted_string(input_word))); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Initialize search context. + */ + eb_reset_search_contexts(book); + context = book->search_contexts; + context->code = EB_SEARCH_ENDWORD; + + /* + * Make a fixed word and a canonicalized word to search from + * `input_word'. + */ + error_code = eb_set_endword(book, input_word, context->word, + context->canonicalized_word, &word_code); + if (error_code != EB_SUCCESS) + goto failed; + + /* + * Get a page number. + */ + switch (word_code) { + case EB_WORD_ALPHABET: + if (book->subbook_current->endword_alphabet.start_page != 0) + context->page = book->subbook_current->endword_alphabet.start_page; + else if (book->subbook_current->endword_asis.start_page != 0) + context->page = book->subbook_current->endword_asis.start_page; + else { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + break; + + case EB_WORD_KANA: + if (book->subbook_current->endword_kana.start_page != 0) + context->page = book->subbook_current->endword_kana.start_page; + else if (book->subbook_current->endword_asis.start_page != 0) + context->page = book->subbook_current->endword_asis.start_page; + else { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + break; + + case EB_WORD_OTHER: + if (book->subbook_current->endword_asis.start_page != 0) + context->page = book->subbook_current->endword_asis.start_page; + else { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + break; + + default: + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + + /* + * Choose comparison functions. + */ + + if (book->character_code == EB_CHARCODE_ISO8859_1) { + context->compare_pre = eb_pre_match_word; + context->compare_single = eb_match_word; + context->compare_group = eb_match_word; + } else if (context->page == book->subbook_current->word_kana.start_page) { + context->compare_pre = eb_pre_match_word; + context->compare_single = eb_match_word_kana_single; + context->compare_group = eb_match_word_kana_group; + } else { + context->compare_pre = eb_pre_match_word; + context->compare_single = eb_match_word; + context->compare_group = eb_match_word_kana_group; + } + + /* + * Pre-search. + */ + error_code = eb_presearch_word(book, context); + if (error_code != EB_SUCCESS) + goto failed; + + LOG(("out: eb_search_endword() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_reset_search_contexts(book); + LOG(("out: eb_search_endword() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + diff --git a/eb/error.c b/eb/error.c new file mode 100644 index 0000000..c26e390 --- /dev/null +++ b/eb/error.c @@ -0,0 +1,284 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "build-post.h" + +/* + * Mutex for gettext function call. + */ +#if defined(ENABLE_NLS) && defined(ENABLE_PTHREAD) +pthread_mutex_t gettext_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif + +/* + * Error code strings. + */ +static const char * const error_strings[] = { + /* 0 -- 4 */ + "EB_SUCCESS", + "EB_ERR_MEMORY_EXHAUSTED", + "EB_ERR_EMPTY_FILE_NAME", + "EB_ERR_TOO_LONG_FILE_NAME", + "EB_ERR_BAD_FILE_NAME", + + /* 5 -- 9 */ + "EB_ERR_BAD_DIR_NAME", + "EB_ERR_TOO_LONG_WORD", + "EB_ERR_BAD_WORD", + "EB_ERR_EMPTY_WORD", + "EB_ERR_FAIL_GETCWD", + + /* 10 -- 14 */ + "EB_ERR_FAIL_OPEN_CAT", + "EB_ERR_FAIL_OPEN_CATAPP", + "EB_ERR_FAIL_OPEN_TEXT", + "EB_ERR_FAIL_OPEN_FONT", + "EB_ERR_FAIL_OPEN_APP", + + /* 15 -- 19 */ + "EB_ERR_FAIL_OPEN_BINARY", + "EB_ERR_FAIL_READ_CAT", + "EB_ERR_FAIL_READ_CATAPP", + "EB_ERR_FAIL_READ_TEXT", + "EB_ERR_FAIL_READ_FONT", + + /* 20 -- 24 */ + "EB_ERR_FAIL_READ_APP", + "EB_ERR_FAIL_READ_BINARY", + "EB_ERR_FAIL_SEEK_CAT", + "EB_ERR_FAIL_SEEK_CATAPP", + "EB_ERR_FAIL_SEEK_TEXT", + + /* 25 -- 29 */ + "EB_ERR_FAIL_SEEK_FONT", + "EB_ERR_FAIL_SEEK_APP", + "EB_ERR_FAIL_SEEK_BINARY", + "EB_ERR_UNEXP_CAT", + "EB_ERR_UNEXP_CATAPP", + + /* 30 -- 34 */ + "EB_ERR_UNEXP_TEXT", + "EB_ERR_UNEXP_FONT", + "EB_ERR_UNEXP_APP", + "EB_ERR_UNEXP_BINARY", + "EB_ERR_UNBOUND_BOOK", + + /* 35 -- 39 */ + "EB_ERR_UNBOUND_APP", + "EB_ERR_NO_SUB", + "EB_ERR_NO_APPSUB", + "EB_ERR_NO_FONT", + "EB_ERR_NO_TEXT", + + /* 40 -- 44 */ + "EB_ERR_NO_STOPCODE", + "EB_ERR_NO_ALT", + "EB_ERR_NO_CUR_SUB", + "EB_ERR_NO_CUR_APPSUB", + "EB_ERR_NO_CUR_FONT", + + /* 45 -- 49 */ + "EB_ERR_NO_CUR_BINARY", + "EB_ERR_NO_SUCH_SUB", + "EB_ERR_NO_SUCH_APPSUB", + "EB_ERR_NO_SUCH_FONT", + "EB_ERR_NO_SUCH_CHAR_BMP", + + /* 50 -- 54 */ + "EB_ERR_NO_SUCH_CHAR_TEXT", + "EB_ERR_NO_SUCH_SEARCH", + "EB_ERR_NO_SUCH_HOOK", + "EB_ERR_NO_SUCH_BINARY", + "EB_ERR_DIFF_CONTENT", + + /* 55 -- 59 */ + "EB_ERR_NO_PREV_SEARCH", + "EB_ERR_NO_SUCH_MULTI_ID", + "EB_ERR_NO_SUCH_ENTRY_ID", + "EB_ERR_TOO_MANY_WORDS", + "EB_ERR_NO_WORD", + + /* 60 -- 64 */ + "EB_ERR_NO_CANDIDATES", + "EB_ERR_END_OF_CONTENT", + "EB_ERR_NO_PREV_SEEK", + "EB_ERR_EBNET_UNSUPPORTED", + "EB_ERR_EBNET_FAIL_CONNECT", + + /* 65 -- 69 */ + "EB_ERR_EBNET_SERVER_BUSY", + "EB_ERR_EBNET_NO_PERMISSION", + "EB_ERR_UNBOUND_BOOKLIST", + "EB_ERR_NO_SUCH_BOOK", + + NULL +}; + +/* + * Look up the error message corresponding to the error code `error_code'. + */ +const char * +eb_error_string(EB_Error_Code error_code) +{ + const char *string; + + if (0 <= error_code && error_code < EB_NUMBER_OF_ERRORS) + string = error_strings[error_code]; + else + string = "EB_ERR_UNKNOWN"; + + return string; +} + + +/* + * Error messages. + */ +static const char * const error_messages[] = { + /* 0 -- 4 */ + N_("no error"), + N_("memory exhausted"), + N_("an empty file name"), + N_("too long file name"), + N_("bad file name"), + + /* 5 -- 9 */ + N_("bad directory name"), + N_("too long word"), + N_("a word contains bad character"), + N_("an empty word"), + N_("failed to get the current working directory"), + + /* 10 -- 14 */ + N_("failed to open a catalog file"), + N_("failed to open an appendix catalog file"), + N_("failed to open a text file"), + N_("failed to open a font file"), + N_("failed to open an appendix file"), + + /* 15 -- 19 */ + N_("failed to open a binary file"), + N_("failed to read a catalog file"), + N_("failed to read an appendix catalog file"), + N_("failed to read a text file"), + N_("failed to read a font file"), + + /* 20 -- 24 */ + N_("failed to read an appendix file"), + N_("failed to read a binary file"), + N_("failed to seek a catalog file"), + N_("failed to seek an appendix catalog file"), + N_("failed to seek a text file"), + + /* 25 -- 29 */ + N_("failed to seek a font file"), + N_("failed to seek an appendix file"), + N_("failed to seek a binary file"), + N_("unexpected format in a catalog file"), + N_("unexpected format in an appendix catalog file"), + + /* 30 -- 34 */ + N_("unexpected format in a text file"), + N_("unexpected format in a font file"), + N_("unexpected format in an appendix file"), + N_("unexpected format in a binary file"), + N_("book not bound"), + + /* 35 -- 39 */ + N_("appendix not bound"), + N_("no subbook"), + N_("no subbook in the appendix"), + N_("no font"), + N_("no text file"), + + /* 40 -- 44 */ + N_("no stop-code"), + N_("no alternation string"), + N_("no current subbook"), + N_("no current appendix subbook"), + N_("no current font"), + + /* 45 -- 49 */ + N_("no current binary"), + N_("no such subbook"), + N_("no such appendix subbook"), + N_("no such font"), + N_("no such character bitmap"), + + /* 50 -- 54 */ + N_("no such character text"), + N_("no such search method"), + N_("no such hook"), + N_("no such binary"), + N_("different content type"), + + /* 55 -- 59 */ + N_("no previous search"), + N_("no such multi search"), + N_("no such multi search entry"), + N_("too many words specified"), + N_("no word specified"), + + /* 60 -- 64 */ + N_("no candidates"), + N_("end of content"), + N_("no previous seek"), + N_("ebnet is not supported"), + N_("failed to connect to an ebnet server"), + + /* 65 -- 69 */ + N_("ebnet server is busy"), + N_("no access permission"), + N_("booklist not bound"), + N_("no such book"), + + NULL +}; + +/* + * Look up the error message corresponding to the error code `error_code'. + */ +const char * +eb_error_message(EB_Error_Code error_code) +{ + const char *message; + + if (0 <= error_code && error_code < EB_NUMBER_OF_ERRORS) + message = error_messages[error_code]; + else + message = N_("unknown error"); + +#ifdef ENABLE_NLS + message = dgettext(EB_TEXT_DOMAIN_NAME, message); +#endif /* ENABLE_NLS */ + + return message; +} diff --git a/eb/error.h b/eb/error.h new file mode 100644 index 0000000..b2f2b39 --- /dev/null +++ b/eb/error.h @@ -0,0 +1,150 @@ +/* -*- C -*- + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef EB_ERROR_H +#define EB_ERROR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef EB_BUILD_LIBRARY +#include "defs.h" +#else +#include +#endif + +/* + * Error codes. + */ +#define EB_SUCCESS 0 +#define EB_ERR_MEMORY_EXHAUSTED 1 +#define EB_ERR_EMPTY_FILE_NAME 2 +#define EB_ERR_TOO_LONG_FILE_NAME 3 +#define EB_ERR_BAD_FILE_NAME 4 + +#define EB_ERR_BAD_DIR_NAME 5 +#define EB_ERR_TOO_LONG_WORD 6 +#define EB_ERR_BAD_WORD 7 +#define EB_ERR_EMPTY_WORD 8 +#define EB_ERR_FAIL_GETCWD 9 + +#define EB_ERR_FAIL_OPEN_CAT 10 +#define EB_ERR_FAIL_OPEN_CATAPP 11 +#define EB_ERR_FAIL_OPEN_TEXT 12 +#define EB_ERR_FAIL_OPEN_FONT 13 +#define EB_ERR_FAIL_OPEN_APP 14 + +#define EB_ERR_FAIL_OPEN_BINARY 15 +#define EB_ERR_FAIL_READ_CAT 16 +#define EB_ERR_FAIL_READ_CATAPP 17 +#define EB_ERR_FAIL_READ_TEXT 18 +#define EB_ERR_FAIL_READ_FONT 19 + +#define EB_ERR_FAIL_READ_APP 20 +#define EB_ERR_FAIL_READ_BINARY 21 +#define EB_ERR_FAIL_SEEK_CAT 22 +#define EB_ERR_FAIL_SEEK_CATAPP 23 +#define EB_ERR_FAIL_SEEK_TEXT 24 + +#define EB_ERR_FAIL_SEEK_FONT 25 +#define EB_ERR_FAIL_SEEK_APP 26 +#define EB_ERR_FAIL_SEEK_BINARY 27 +#define EB_ERR_UNEXP_CAT 28 +#define EB_ERR_UNEXP_CATAPP 29 + +#define EB_ERR_UNEXP_TEXT 30 +#define EB_ERR_UNEXP_FONT 31 +#define EB_ERR_UNEXP_APP 32 +#define EB_ERR_UNEXP_BINARY 33 +#define EB_ERR_UNBOUND_BOOK 34 + +#define EB_ERR_UNBOUND_APP 35 +#define EB_ERR_NO_SUB 36 +#define EB_ERR_NO_APPSUB 37 +#define EB_ERR_NO_FONT 38 +#define EB_ERR_NO_TEXT 39 + +#define EB_ERR_NO_STOPCODE 40 +#define EB_ERR_NO_ALT 41 +#define EB_ERR_NO_CUR_SUB 42 +#define EB_ERR_NO_CUR_APPSUB 43 +#define EB_ERR_NO_CUR_FONT 44 + +#define EB_ERR_NO_CUR_BINARY 45 +#define EB_ERR_NO_SUCH_SUB 46 +#define EB_ERR_NO_SUCH_APPSUB 47 +#define EB_ERR_NO_SUCH_FONT 48 +#define EB_ERR_NO_SUCH_CHAR_BMP 49 + +#define EB_ERR_NO_SUCH_CHAR_TEXT 50 +#define EB_ERR_NO_SUCH_SEARCH 51 +#define EB_ERR_NO_SUCH_HOOK 52 +#define EB_ERR_NO_SUCH_BINARY 53 +#define EB_ERR_DIFF_CONTENT 54 + +#define EB_ERR_NO_PREV_SEARCH 55 +#define EB_ERR_NO_SUCH_MULTI_ID 56 +#define EB_ERR_NO_SUCH_ENTRY_ID 57 +#define EB_ERR_TOO_MANY_WORDS 58 +#define EB_ERR_NO_WORD 59 + +#define EB_ERR_NO_CANDIDATES 60 +#define EB_ERR_END_OF_CONTENT 61 +#define EB_ERR_NO_PREV_SEEK 62 +#define EB_ERR_EBNET_UNSUPPORTED 63 +#define EB_ERR_EBNET_FAIL_CONNECT 64 + +#define EB_ERR_EBNET_SERVER_BUSY 65 +#define EB_ERR_EBNET_NO_PERMISSION 66 +#define EB_ERR_UNBOUND_BOOKLIST 67 +#define EB_ERR_NO_SUCH_BOOK 68 + + +/* + * The number of error codes. + */ +#define EB_NUMBER_OF_ERRORS 69 + +/* + * The maximum length of an error message. + */ +#define EB_MAX_ERROR_MESSAGE_LENGTH 127 + +/* + * Function declarations. + */ +/* error.c */ +const char *eb_error_string(EB_Error_Code error_code); +const char *eb_error_message(EB_Error_Code error_code); + +#ifdef __cplusplus +} +#endif + +#endif /* not EB_ERROR_H */ diff --git a/eb/exactword.c b/eb/exactword.c new file mode 100644 index 0000000..fe37798 --- /dev/null +++ b/eb/exactword.c @@ -0,0 +1,188 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "build-post.h" + +/* + * Examine whether the current subbook in `book' supports `EXACTWORD SEARCH' + * or not. + */ +int +eb_have_exactword_search(EB_Book *book) +{ + eb_lock(&book->lock); + LOG(("in: eb_have_exactword_search(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) + goto failed; + + /* + * Check for the index page of word search. + */ + if (book->subbook_current->word_alphabet.start_page == 0 + && book->subbook_current->word_asis.start_page == 0 + && book->subbook_current->word_kana.start_page == 0) + goto failed; + + LOG(("out: eb_have_exactword_search() = %d", 1)); + eb_unlock(&book->lock); + + return 1; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_have_exactword_search() = %d", 0)); + eb_unlock(&book->lock); + return 0; +} + + +/* + * Exactword search. + */ +EB_Error_Code +eb_search_exactword(EB_Book *book, const char *input_word) +{ + EB_Error_Code error_code; + EB_Word_Code word_code; + EB_Search_Context *context; + + eb_lock(&book->lock); + LOG(("in: eb_search_exactword(book=%d, input_word=%s)", (int)book->code, + eb_quoted_string(input_word))); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Initialize search context. + */ + eb_reset_search_contexts(book); + context = book->search_contexts; + context->code = EB_SEARCH_EXACTWORD; + + /* + * Make a fixed word and a canonicalized word to search from + * `input_word'. + */ + error_code = eb_set_word(book, input_word, context->word, + context->canonicalized_word, &word_code); + if (error_code != EB_SUCCESS) + goto failed; + + /* + * Get a page number. + */ + switch (word_code) { + case EB_WORD_ALPHABET: + if (book->subbook_current->word_alphabet.start_page != 0) + context->page = book->subbook_current->word_alphabet.start_page; + else if (book->subbook_current->word_asis.start_page != 0) + context->page = book->subbook_current->word_asis.start_page; + else { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + break; + + case EB_WORD_KANA: + if (book->subbook_current->word_kana.start_page != 0) + context->page = book->subbook_current->word_kana.start_page; + else if (book->subbook_current->word_asis.start_page != 0) + context->page = book->subbook_current->word_asis.start_page; + else { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + break; + + case EB_WORD_OTHER: + if (book->subbook_current->word_asis.start_page != 0) + context->page = book->subbook_current->word_asis.start_page; + else { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + break; + + default: + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + + /* + * Choose comparison functions. + */ + if (book->character_code == EB_CHARCODE_ISO8859_1) { + context->compare_pre = eb_exact_pre_match_word_latin; + context->compare_single = eb_exact_match_word_latin; + context->compare_group = eb_exact_match_word_latin; + } else if (context->page == book->subbook_current->word_kana.start_page) { + context->compare_pre = eb_exact_pre_match_word_jis; + context->compare_single = eb_exact_match_word_kana_single; + context->compare_group = eb_exact_match_word_kana_group; + } else { + context->compare_pre = eb_exact_pre_match_word_jis; + context->compare_single = eb_exact_match_word_jis; + context->compare_group = eb_exact_match_word_kana_group; + } + + /* + * Pre-search. + */ + error_code = eb_presearch_word(book, context); + if (error_code != EB_SUCCESS) + goto failed; + + LOG(("out: eb_search_exactword() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_reset_search_contexts(book); + LOG(("out: eb_search_exactword() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} diff --git a/eb/filename.c b/eb/filename.c new file mode 100644 index 0000000..ee87969 --- /dev/null +++ b/eb/filename.c @@ -0,0 +1,783 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#ifdef ENABLE_EBNET +#include "ebnet.h" +#endif +#include "build-post.h" + +#if defined(DOS_FILE_PATH) && defined(HAVE_MBSTRING_H) +/* a path may contain double-byte chars in SJIS. */ +#include +#define strchr _mbschr +#define strrchr _mbsrchr +#endif + + +#ifndef DOS_FILE_PATH + +/* + * Canonicalize `path_name' (UNIX version). + * Convert a path name to an absolute path. + */ +EB_Error_Code +eb_canonicalize_path_name(char *path_name) +{ + char cwd[EB_MAX_PATH_LENGTH + 1]; + char temporary_path_name[EB_MAX_PATH_LENGTH + 1]; + char *last_slash; + + if (*path_name != '/') { + /* + * `path_name' is an relative path. Convert to an absolute + * path. + */ + if (getcwd(cwd, EB_MAX_PATH_LENGTH + 1) == NULL) + return EB_ERR_FAIL_GETCWD; + if (EB_MAX_PATH_LENGTH < strlen(cwd) + 1 + strlen(path_name)) + return EB_ERR_TOO_LONG_FILE_NAME; + + if (strcmp(path_name, ".") == 0) { + strcpy(path_name, cwd); + } else if (strncmp(path_name, "./", 2) == 0) { + sprintf(temporary_path_name, "%s/%s", cwd, path_name + 2); + strcpy(path_name, temporary_path_name); + } else { + sprintf(temporary_path_name, "%s/%s", cwd, path_name); + strcpy(path_name, temporary_path_name); + } + } + + /* + * Unless `path_name' is "/", eliminate `/' in the tail of the + * path name. + */ + last_slash = strrchr(path_name, '/'); + if (last_slash != path_name && *(last_slash + 1) == '\0') + *last_slash = '\0'; + + return EB_SUCCESS; +} + +#else /* DOS_FILE_PATH */ + +/* + * Canonicalize `path_name' (DOS version). + * Convert a path name to an absolute path with drive letter unless + * that is an UNC path. + * + * Original version by KSK Jan/30/1998. + * Current version by Motoyuki Kasahara. + */ +EB_Error_Code +eb_canonicalize_path_name(char *path_name) +{ + char cwd[EB_MAX_PATH_LENGTH + 1]; + char temporary_path_name[EB_MAX_PATH_LENGTH + 1]; + char *slash; + char *last_backslash; + + /* + * Replace `/' with `\\'. + */ + slash = path_name; + for (;;) { + slash = strchr(slash, '/'); + if (slash == NULL) + break; + *slash++ = '\\'; + } + + if (*path_name == '\\' && *(path_name + 1) == '\\') { + /* + * `path_name' is UNC path. Nothing to be done. + */ + } else if (ASCII_ISALPHA(*path_name) && *(path_name + 1) == ':') { + /* + * `path_name' has a drive letter. + * Nothing to be done if it is an absolute path. + */ + if (*(path_name + 2) != '\\') { + /* + * `path_name' is a relative path. + * Covert the path name to an absolute path. + */ + if (getdcwd(ASCII_TOUPPER(*path_name) - 'A' + 1, cwd, + EB_MAX_PATH_LENGTH + 1) == NULL) { + return EB_ERR_FAIL_GETCWD; + } + if (EB_MAX_PATH_LENGTH < strlen(cwd) + 1 + strlen(path_name + 2)) + return EB_ERR_TOO_LONG_FILE_NAME; + sprintf(temporary_path_name, "%s\\%s", cwd, path_name + 2); + strcpy(path_name, temporary_path_name); + } + } else if (*path_name == '\\') { + /* + * `path_name' has no drive letter and is an absolute path. + * Add a drive letter to the path name. + */ + if (getcwd(cwd, EB_MAX_PATH_LENGTH + 1) == NULL) + return EB_ERR_FAIL_GETCWD; + cwd[1] = '\0'; + if (EB_MAX_PATH_LENGTH < strlen(cwd) + 1 + strlen(path_name)) + return EB_ERR_TOO_LONG_FILE_NAME; + sprintf(temporary_path_name, "%s:%s", cwd, path_name); + strcpy(path_name, temporary_path_name); + + } else { + /* + * `path_name' has no drive letter and is a relative path. + * Add a drive letter and convert it to an absolute path. + */ + if (getcwd(cwd, EB_MAX_PATH_LENGTH + 1) == NULL) + return EB_ERR_FAIL_GETCWD; + + if (EB_MAX_PATH_LENGTH < strlen(cwd) + 1 + strlen(path_name)) + return EB_ERR_TOO_LONG_FILE_NAME; + sprintf(temporary_path_name, "%s\\%s", cwd, path_name); + strcpy(path_name, temporary_path_name); + } + + + /* + * Now `path_name' is `X:\...' or `\\...'. + * Unless it is "X:\", eliminate `\' in the tail of the path name. + */ + last_backslash = strrchr(path_name, '\\'); + if (ASCII_ISALPHA(*path_name)) { + if (last_backslash != path_name + 2 && *(last_backslash + 1) == '\0') + *last_backslash = '\0'; + } else { + if (last_backslash != path_name + 1 && *(last_backslash + 1) == '\0') + *last_backslash = '\0'; + } + + return EB_SUCCESS; +} + +#endif /* DOS_FILE_PATH */ + + +/* + * Canonicalize file name. + * - Suffix including dot is removed + * - Version including semicolon is removed. + * - Letters are converted to upper case. + * + * We minght fail to load a file after we fix the file name. + * If loading the file is tried again, we need the original file name, + * not fixed file name. Therefore, we get orignal file name from fixed + * file name using this function. + */ +void +eb_canonicalize_file_name(char *file_name) +{ + char *p; + + for (p = file_name; *p != '\0' && *p != '.' && *p != ';'; p++) + *p = ASCII_TOUPPER(*p); + *p = '\0'; +} + + +/* + * Rewrite `directory_name' to a real directory name in the `path' directory. + * + * If a directory matched to `directory_name' exists, then EB_SUCCESS is + * returned, and `directory_name' is rewritten to that name. Otherwise + * EB_ERR_BAD_DIR_NAME is returned. + */ +EB_Error_Code +eb_fix_directory_name(const char *path, char *directory_name) +{ + struct dirent *entry; + DIR *dir; + +#ifdef ENABLE_EBNET + if (is_ebnet_url(path)) + return ebnet_fix_directory_name(path, directory_name); +#endif + + /* + * Open the directory `path'. + */ + dir = opendir(path); + if (dir == NULL) + goto failed; + + for (;;) { + /* + * Read the directory entry. + */ + entry = readdir(dir); + if (entry == NULL) + goto failed; + + if (strcasecmp(entry->d_name, directory_name) == 0) + break; + } + + strcpy(directory_name, entry->d_name); + closedir(dir); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + if (dir != NULL) + closedir(dir); + return EB_ERR_BAD_DIR_NAME; +} + + +/* + * Rewrite `sub_directory_name' to a real sub directory name in the + * `path/directory_name' directory. + * + * If a directory matched to `sub_directory_name' exists, then EB_SUCCESS + * is returned, and `directory_name' is rewritten to that name. Otherwise + * EB_ERR_BAD_FILE_NAME is returned. + */ +EB_Error_Code +eb_fix_directory_name2(const char *path, const char *directory_name, + char *sub_directory_name) +{ + char sub_path_name[EB_MAX_PATH_LENGTH + 1]; + + eb_compose_path_name(path, directory_name, sub_path_name); + return eb_fix_directory_name(sub_path_name, sub_directory_name); +} + + +/* + * Fix suffix of `path_name'. + * + * If `suffix' is an empty string, delete suffix from `path_name'. + * Otherwise, add `suffix' to `path_name'. + */ +void +eb_fix_path_name_suffix(char *path_name, const char *suffix) +{ + char *base_name; + char *dot; + char *semicolon; + +#ifndef DOS_FILE_PATH + base_name = strrchr(path_name, '/'); +#else + if (is_ebnet_url(path_name)) + base_name = strrchr(path_name, '/'); + else + base_name = strrchr(path_name, '\\'); +#endif + if (base_name == NULL) + base_name = path_name; + else + base_name++; + + dot = strchr(base_name, '.'); + semicolon = strchr(base_name, ';'); + + if (*suffix == '\0') { + /* + * Remove `.xxx' from `fixed_file_name': + * foo.xxx --> foo + * foo.xxx;1 --> foo;1 + * foo. --> foo. (unchanged) + * foo.;1 --> foo.;1 (unchanged) + */ + if (dot != NULL && *(dot + 1) != '\0' && *(dot + 1) != ';') { + if (semicolon != NULL) + sprintf(dot, ";%c", *(semicolon + 1)); + else + *dot = '\0'; + } + } else { + /* + * Add `.xxx' to `fixed_file_name': + * foo --> foo.xxx + * foo. --> foo.xxx + * foo;1 --> foo.xxx;1 + * foo.;1 --> foo.xxx;1 + * foo.xxx --> foo.xxx (unchanged) + */ + if (dot != NULL) { + if (semicolon != NULL) + sprintf(dot, "%s;%c", suffix, *(semicolon + 1)); + else + strcpy(dot, suffix); + } else { + if (semicolon != NULL) + sprintf(semicolon, "%s;%c", suffix, *(semicolon + 1)); + else + strcat(base_name, suffix); + } + } +} + + +#define FOUND_NONE 0 +#define FOUND_EBZ 1 +#define FOUND_BASENAME 2 +#define FOUND_ORG 3 + +/* + * Rewrite `found_file_name' to a real file name in the `path_name' + * directory. + * + * If a file matched to `target_file_name' exists, then EB_SUCCESS + * is returned, and `found_file_name' is rewritten to that name. + * Otherwise EB_ERR_BAD_FILE_NAME is returned. + * + * Note that `target_file_name' must not contain `.' or excceed + * EB_MAX_DIRECTORY_NAME_LENGTH characters. + */ +EB_Error_Code +eb_find_file_name(const char *path_name, const char *target_file_name, + char *found_file_name) +{ + char ebz_target_file_name[EB_MAX_FILE_NAME_LENGTH + 1]; + char org_target_file_name[EB_MAX_FILE_NAME_LENGTH + 1]; + char candidate_file_name[EB_MAX_FILE_NAME_LENGTH + 1]; + DIR *dir; + struct dirent *entry; + size_t d_namlen; + int found = FOUND_NONE; + +#ifdef ENABLE_EBNET + if (is_ebnet_url(path_name)) { + return ebnet_find_file_name(path_name, target_file_name, + found_file_name); + } +#endif + + strcpy(ebz_target_file_name, target_file_name); + strcat(ebz_target_file_name, ".ebz"); + strcpy(org_target_file_name, target_file_name); + strcat(org_target_file_name, ".org"); + candidate_file_name[0] = '\0'; + + /* + * Open the directory `path_name'. + */ + dir = opendir(path_name); + if (dir == NULL) + goto failed; + + for (;;) { + /* + * Read the directory entry. + */ + entry = readdir(dir); + if (entry == NULL) + break; + + /* + * Compare the given file names and the current entry name. + * We consider they are matched when one of the followings + * is true: + * + * == + * +";1' == + * +"." == + * +".;1" == + * +".ebz" == + * +".ebz;1" == + * +".org" == + * +".org;1" == + * + * All the comparisons are done without case sensitivity. + * We support version number ";1" only. + */ + d_namlen = strlen(entry->d_name); + if (2 < d_namlen + && *(entry->d_name + d_namlen - 2) == ';' + && ASCII_ISDIGIT(*(entry->d_name + d_namlen - 1))) { + d_namlen -= 2; + } + if (1 < d_namlen && *(entry->d_name + d_namlen - 1) == '.') + d_namlen--; + + if (strcasecmp(entry->d_name, ebz_target_file_name) == 0 + && *(ebz_target_file_name + d_namlen) == '\0' + && found < FOUND_EBZ) { + strcpy(candidate_file_name, entry->d_name); + found = FOUND_EBZ; + } + if (strncasecmp(entry->d_name, target_file_name, d_namlen) == 0 + && *(target_file_name + d_namlen) == '\0' + && found < FOUND_BASENAME) { + strcpy(candidate_file_name, entry->d_name); + found = FOUND_BASENAME; + } + if (strcasecmp(entry->d_name, org_target_file_name) == 0 + && *(org_target_file_name + d_namlen) == '\0' + && found < FOUND_ORG) { + strcpy(candidate_file_name, entry->d_name); + found = FOUND_ORG; + break; + } + } + + if (found == FOUND_NONE) + goto failed; + + closedir(dir); + strcpy(found_file_name, candidate_file_name); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + if (dir != NULL) + closedir(dir); + return EB_ERR_BAD_FILE_NAME; +} + + +/* + * Rewrite `file_name' to a real file name in the directory + * `path_name/sub_directory_name'. + * + * If a file matched to `file_name' exists, then EB_SUCCESS is returned, + * and `file_name' is rewritten to that name. Otherwise EB_ERR_BAD_FILE_NAME + * is returned. + */ +EB_Error_Code +eb_find_file_name2(const char *path_name, const char *sub_directory_name, + const char *target_file_name, char *found_file_name) +{ + char sub_path_name[EB_MAX_PATH_LENGTH + 1]; + + eb_compose_path_name(path_name, sub_directory_name, sub_path_name); + return eb_find_file_name(sub_path_name, target_file_name, found_file_name); +} + + +EB_Error_Code +eb_find_file_name3(const char *path_name, const char *sub_directory_name, + const char *sub2_directory_name, const char *target_file_name, + char *found_file_name) +{ + char sub2_path_name[EB_MAX_PATH_LENGTH + 1]; + + eb_compose_path_name2(path_name, sub_directory_name, sub2_directory_name, + sub2_path_name); + return eb_find_file_name(sub2_path_name, target_file_name, + found_file_name); +} + + +/* + * Compose a file name + * `path_name/file_name' + * and copy it into `composed_path_name'. + */ +void +eb_compose_path_name(const char *path_name, const char *file_name, + char *composed_path_name) +{ +#ifndef DOS_FILE_PATH + if (strcmp(path_name, "/") == 0) + sprintf(composed_path_name, "%s%s", path_name, file_name); + else + sprintf(composed_path_name, "%s/%s", path_name, file_name); +#else + if (is_ebnet_url(path_name)) + sprintf(composed_path_name, "%s/%s", path_name, file_name); + else if (ASCII_ISALPHA(*path_name) && strcmp(path_name + 1, ":\\") == 0) + sprintf(composed_path_name, "%s%s", path_name, file_name); + else + sprintf(composed_path_name, "%s\\%s", path_name, file_name); +#endif +} + + +/* + * Compose a file name + * `path_name/sub_directory/file_name' + * and copy it into `composed_path_name'. + */ +void +eb_compose_path_name2(const char *path_name, const char *sub_directory_name, + const char *file_name, char *composed_path_name) +{ +#ifndef DOS_FILE_PATH + if (strcmp(path_name, "/") == 0) { + sprintf(composed_path_name, "%s%s/%s", + path_name, sub_directory_name, file_name); + } else { + sprintf(composed_path_name, "%s/%s/%s", + path_name, sub_directory_name, file_name); + } +#else + if (is_ebnet_url(path_name)) { + sprintf(composed_path_name, "%s/%s/%s", + path_name, sub_directory_name, file_name); + } else if (ASCII_ISALPHA(*path_name) + && strcmp(path_name + 1, ":\\") == 0) { + sprintf(composed_path_name, "%s%s\\%s", + path_name, sub_directory_name, file_name); + } else { + sprintf(composed_path_name, "%s\\%s\\%s", + path_name, sub_directory_name, file_name); + } +#endif +} + + +/* + * Compose a file name + * `path_name/sub_directory/sub2_directory/file_name' + * and copy it into `composed_path_name'. + */ +void +eb_compose_path_name3(const char *path_name, const char *sub_directory_name, + const char *sub2_directory_name, const char *file_name, + char *composed_path_name) +{ +#ifndef DOS_FILE_PATH + if (strcmp(path_name, "/") == 0) { + sprintf(composed_path_name, "%s%s/%s/%s", + path_name, sub_directory_name, sub2_directory_name, file_name); + } else { + sprintf(composed_path_name, "%s/%s/%s/%s", + path_name, sub_directory_name, sub2_directory_name, file_name); + } +#else + if (is_ebnet_url(path_name)) { + sprintf(composed_path_name, "%s/%s/%s/%s", + path_name, sub_directory_name, sub2_directory_name, file_name); + } else if (ASCII_ISALPHA(*path_name) + && strcmp(path_name + 1, ":\\") == 0) { + sprintf(composed_path_name, "%s%s\\%s\\%s", + path_name, sub_directory_name, sub2_directory_name, file_name); + } else { + sprintf(composed_path_name, "%s\\%s\\%s\\%s", + path_name, sub_directory_name, sub2_directory_name, file_name); + } +#endif +} + + +/* + * Compose movie file name from argv[], and copy the result to + * `composed_file_name'. Note that upper letters are converted to lower + * letters. + * + * If a file `composed_path_name' exists, then EB_SUCCESS is returned. + * Otherwise EB_ERR_BAD_FILE_NAME is returned. + */ +EB_Error_Code +eb_compose_movie_file_name(const unsigned int *argv, char *composed_file_name) +{ + unsigned short jis_characters[EB_MAX_DIRECTORY_NAME_LENGTH]; + const unsigned int *arg_p; + char *composed_p; + unsigned short c; + int i; + + /* + * Initialize `jis_characters[]'. + */ + for (i = 0, arg_p = argv; + i + 1 < EB_MAX_DIRECTORY_NAME_LENGTH; i += 2, arg_p++) { + jis_characters[i] = (*arg_p >> 16) & 0xffff; + jis_characters[i + 1] = (*arg_p) & 0xffff; + } + if (i < EB_MAX_DIRECTORY_NAME_LENGTH) + jis_characters[i] = (*arg_p >> 16) & 0xffff; + + /* + * Compose file name. + */ + for (i = 0, composed_p = composed_file_name; + i < EB_MAX_DIRECTORY_NAME_LENGTH; i++, composed_p++) { + c = jis_characters[i]; + if (c == 0x2121 || c == 0x0000) + break; + if ((0x2330 <= c && c <= 0x2339) || (0x2361 <= c && c <= 0x237a)) + *composed_p = c & 0xff; + else if (0x2341 <= c && c <= 0x235a) + *composed_p = (c | 0x20) & 0xff; + else + return EB_ERR_BAD_FILE_NAME; + } + + *composed_p = '\0'; + + return EB_SUCCESS; +} + + +/* + * This function is similar to eb_compose_movie_file_name(), but it + * returns full path of the movie file name. + */ +EB_Error_Code +eb_compose_movie_path_name(EB_Book *book, const unsigned int *argv, + char *composed_path_name) +{ + EB_Subbook *subbook; + EB_Error_Code error_code; + char composed_file_name[EB_MAX_FILE_NAME_LENGTH + 1]; + + /* + * Lock the book. + */ + eb_lock(&book->lock); + LOG(("in: eb_compose_movie_path_name(book=%d, argv=%x)", + (int)book->code, argv)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + subbook = book->subbook_current; + + error_code = eb_compose_movie_file_name(argv, composed_file_name); + if (error_code != EB_SUCCESS) + goto failed; + + error_code = eb_find_file_name3(book->path, subbook->directory_name, + subbook->movie_directory_name, composed_file_name, composed_file_name); + if (error_code != EB_SUCCESS) + goto failed; + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->movie_directory_name, composed_file_name, composed_path_name); + + LOG(("out: eb_compse_movie_path_name() = %s", + eb_error_string(EB_SUCCESS))); + + eb_unlock(&book->lock); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_compse_movie_path_name() = %s", + eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Decompose movie file name into argv[]. This is the reverse of + * eb_compose_movie_file_name(). Note that lower letters are converted + * to upper letters. + * + * EB_SUCCESS is returned upon success, EB_ERR_BAD_FILE_NAME otherwise. + */ +EB_Error_Code +eb_decompose_movie_file_name(unsigned int *argv, + const char *composed_file_name) +{ + unsigned short jis_characters[EB_MAX_DIRECTORY_NAME_LENGTH]; + unsigned int *arg_p; + const char *composed_p; + int i; + + /* + * Initialize `jis_characters[]'. + */ + for (i = 0; i < EB_MAX_DIRECTORY_NAME_LENGTH; i++) + jis_characters[i] = 0x0000; + + /* + * Set jis_characters[]. + */ + for (i = 0, composed_p = composed_file_name; + i < EB_MAX_DIRECTORY_NAME_LENGTH && *composed_p != '\0'; + i++, composed_p++) { + if ('0' <= *composed_p && *composed_p <= '9') + jis_characters[i] = 0x2330 + (*composed_p - '0'); + else if ('A' <= *composed_p && *composed_p <= 'Z') + jis_characters[i] = 0x2341 + (*composed_p - 'A'); + else if ('a' <= *composed_p && *composed_p <= 'z') + jis_characters[i] = 0x2341 + (*composed_p - 'a'); + else + return EB_ERR_BAD_FILE_NAME; + } + if (*composed_p != '\0') + return EB_ERR_BAD_FILE_NAME; + + /* + * Decompose file name. + */ + for (i = 0, arg_p = argv; + i + 1 < EB_MAX_DIRECTORY_NAME_LENGTH; i += 2, arg_p++) { + *arg_p = (jis_characters[i] << 16) | jis_characters[i + 1]; + } + if (i < EB_MAX_DIRECTORY_NAME_LENGTH) { + *arg_p++ = jis_characters[i] << 16; + } + *arg_p = '\0'; + + return EB_SUCCESS; +} + + +void +eb_path_name_zio_code(const char *path_name, Zio_Code default_zio_code, + Zio_Code *zio_code) +{ + const char *base_name; + const char *dot; + +#ifndef DOS_FILE_PATH + base_name = strrchr(path_name, '/'); +#else + if (is_ebnet_url(path_name)) + base_name = strrchr(path_name, '/'); + else + base_name = strrchr(path_name, '\\'); +#endif + if (base_name != NULL) + base_name++; + else + base_name = path_name; + + dot = strchr(base_name, '.'); + if (dot != NULL && strncasecmp(dot, ".ebz", 4) == 0) + *zio_code = ZIO_EBZIP1; + else if (dot != NULL && strncasecmp(dot, ".org", 4) == 0) + *zio_code = ZIO_PLAIN; + else + *zio_code = default_zio_code; +} diff --git a/eb/font.c b/eb/font.c new file mode 100644 index 0000000..6d28ca1 --- /dev/null +++ b/eb/font.c @@ -0,0 +1,551 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "font.h" +#include "build-post.h" + +/* + * Initialize all fonts in the current subbook. + */ +void +eb_initialize_fonts(EB_Book *book) +{ + EB_Subbook *subbook; + EB_Font *font; + int i; + + LOG(("in: eb_initialize_fonts(book=%d)", (int)book->code)); + + subbook = book->subbook_current; + + for (i = 0, font = subbook->narrow_fonts; i < EB_MAX_FONTS; i++, font++) { + font->font_code = EB_FONT_INVALID; + font->initialized = 0; + font->start = -1; + font->end = -1; + font->page = 0; + font->glyphs = NULL; + zio_initialize(&font->zio); + } + + for (i = 0, font = subbook->wide_fonts; i < EB_MAX_FONTS; i++, font++) { + font->font_code = EB_FONT_INVALID; + font->initialized = 0; + font->start = -1; + font->end = -1; + font->page = 0; + font->glyphs = NULL; + zio_initialize(&font->zio); + } + + LOG(("out: eb_initialize_fonts()")); +} + + +/* + * Load font files. + */ +void +eb_load_font_headers(EB_Book *book) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + EB_Font_Code i; + + LOG(("in: eb_load_fonts(book=%d)", (int)book->code)); + + subbook = book->subbook_current; + + /* + * Load narrow font headers. + */ + for (i = 0; i < EB_MAX_FONTS; i++) { + if (subbook->narrow_fonts[i].font_code == EB_FONT_INVALID + || subbook->narrow_fonts[i].initialized) + continue; + + error_code = eb_open_narrow_font_file(book, i); + if (error_code == EB_SUCCESS) + error_code = eb_load_narrow_font_header(book, i); + if (error_code != EB_SUCCESS) + subbook->narrow_fonts[i].font_code = EB_FONT_INVALID; + subbook->narrow_fonts[i].initialized = 1; + zio_close(&subbook->narrow_fonts[i].zio); + } + + /* + * Load wide font header. + */ + for (i = 0; i < EB_MAX_FONTS; i++) { + if (subbook->wide_fonts[i].font_code == EB_FONT_INVALID + || subbook->wide_fonts[i].initialized) + continue; + + error_code = eb_open_wide_font_file(book, i); + if (error_code == EB_SUCCESS) + error_code = eb_load_wide_font_header(book, i); + if (error_code != EB_SUCCESS) + subbook->wide_fonts[i].font_code = EB_FONT_INVALID; + subbook->wide_fonts[i].initialized = 1; + zio_close(&subbook->wide_fonts[i].zio); + } + + LOG(("out: eb_load_font_headers()")); +} + + +/* + * Finalize all fonts in the current subbook. + */ +void +eb_finalize_fonts(EB_Book *book) +{ + EB_Subbook *subbook; + EB_Font *font; + int i; + + LOG(("in: eb_finalize_fonts(book=%d)", (int)book->code)); + + subbook = book->subbook_current; + + for (i = 0, font = subbook->narrow_fonts; i < EB_MAX_FONTS; i++, font++) { + zio_finalize(&font->zio); + if (font->glyphs != NULL) { + free(font->glyphs); + font->glyphs = NULL; + } + } + + for (i = 0, font = subbook->wide_fonts; i < EB_MAX_FONTS; i++, font++) { + zio_finalize(&font->zio); + if (font->glyphs != NULL) { + free(font->glyphs); + font->glyphs = NULL; + } + } + + LOG(("out: eb_finalize_fonts()")); +} + + +/* + * Look up the height of the current font of the current subbook in + * `book'. + */ +EB_Error_Code +eb_font(EB_Book *book, EB_Font_Code *font_code) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_font(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Look up the height of the current font. + */ + if (book->subbook_current->narrow_current != NULL) + *font_code = book->subbook_current->narrow_current->font_code; + else if (book->subbook_current->wide_current != NULL) + *font_code = book->subbook_current->wide_current->font_code; + else { + error_code = EB_ERR_NO_CUR_FONT; + goto failed; + } + + LOG(("out: eb_font(font_code=%d) = %s", (int)*font_code, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *font_code = EB_FONT_INVALID; + LOG(("out: eb_font() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Set the font with `font_code' as the current font of the current + * subbook in `book'. + */ +EB_Error_Code +eb_set_font(EB_Book *book, EB_Font_Code font_code) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + + eb_lock(&book->lock); + LOG(("in: eb_set_font(book=%d, font_code=%d)", (int)book->code, + (int)font_code)); + + /* + * Check `font_code'. + */ + if (font_code < 0 || EB_MAX_FONTS <= font_code) { + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + /* + * Current subbook must have been set. + */ + subbook = book->subbook_current; + if (subbook == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * If the current font is the font with `font_code', return immediately. + * Otherwise close the current font and continue. + */ + if (subbook->narrow_current != NULL) { + if (subbook->narrow_current->font_code == font_code) + goto succeeded; + if (book->disc_code == EB_DISC_EPWING) + zio_close(&subbook->narrow_current->zio); + subbook->narrow_current = NULL; + } + if (subbook->wide_current != NULL) { + if (subbook->wide_current->font_code == font_code) + goto succeeded; + if (book->disc_code == EB_DISC_EPWING) + zio_close(&subbook->wide_current->zio); + subbook->wide_current = NULL; + } + + /* + * Set the current font. + */ + if (subbook->narrow_fonts[font_code].font_code != EB_FONT_INVALID) + subbook->narrow_current = subbook->narrow_fonts + font_code; + if (subbook->wide_fonts[font_code].font_code != EB_FONT_INVALID) + subbook->wide_current = subbook->wide_fonts + font_code; + + if (subbook->narrow_current == NULL && subbook->wide_current == NULL) { + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + /* + * Initialize current font informtaion. + */ + if (subbook->narrow_current != NULL) { + error_code = eb_open_narrow_font_file(book, font_code); + if (error_code != EB_SUCCESS) + goto failed; + if (is_ebnet_url(book->path)) { + error_code = eb_load_narrow_font_glyphs(book, font_code); + if (error_code != EB_SUCCESS) + goto failed; + } + } + if (subbook->wide_current != NULL) { + error_code = eb_open_wide_font_file(book, font_code); + if (error_code != EB_SUCCESS) + goto failed; + if (is_ebnet_url(book->path)) { + error_code = eb_load_wide_font_glyphs(book, font_code); + if (error_code != EB_SUCCESS) + goto failed; + } + } + + + succeeded: + LOG(("out: eb_set_font() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_unset_font(book); + LOG(("out: eb_set_font() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Unset the font in the current subbook in `book'. + */ +void +eb_unset_font(EB_Book *book) +{ + EB_Subbook *subbook; + + eb_lock(&book->lock); + LOG(("in: eb_unset_font(book=%d)", (int)book->code)); + + subbook = book->subbook_current; + + if (subbook == NULL) + goto succeeded; + + /* + * Close font files. + */ + if (subbook->narrow_current != NULL) { + zio_close(&subbook->narrow_current->zio); + if (subbook->narrow_current->glyphs != NULL) { + free(subbook->narrow_current->glyphs); + subbook->narrow_current->glyphs = NULL; + } + } + if (subbook->wide_current != NULL) { + zio_close(&subbook->wide_current->zio); + if (subbook->wide_current->glyphs != NULL) { + free(subbook->wide_current->glyphs); + subbook->wide_current->glyphs = NULL; + } + } + + book->subbook_current->narrow_current = NULL; + book->subbook_current->wide_current = NULL; + + succeeded: + LOG(("out: eb_unset_font()")); + eb_unlock(&book->lock); +} + + +/* + * Make a list of fonts in the current subbook in `book'. + */ +EB_Error_Code +eb_font_list(EB_Book *book, EB_Font_Code *font_list, int *font_count) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + EB_Font_Code *list_p; + int i; + + eb_lock(&book->lock); + LOG(("in: eb_font_list(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + subbook = book->subbook_current; + if (subbook == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Scan the font table in the book. + */ + subbook = book->subbook_current; + list_p = font_list; + *font_count = 0; + for (i = 0; i < EB_MAX_FONTS; i++) { + if (subbook->narrow_fonts[i].font_code != EB_FONT_INVALID + || subbook->wide_fonts[i].font_code != EB_FONT_INVALID) { + *list_p++ = i; + *font_count += 1; + } + } + + LOG(("out: eb_font(font_count=%d) = %s", *font_count, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_font_list() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Test whether the current subbook in `book' has a font with + * `font_code' or not. + */ +int +eb_have_font(EB_Book *book, EB_Font_Code font_code) +{ + EB_Subbook *subbook; + + eb_lock(&book->lock); + LOG(("in: eb_have_font(book=%d, font_code=%d)", (int)book->code, + (int)font_code)); + + /* + * Check `font_code'. + */ + if (font_code < 0 || EB_MAX_FONTS <= font_code) + goto failed; + + /* + * Current subbook must have been set. + */ + subbook = book->subbook_current; + if (subbook == NULL) + goto failed; + + if (subbook->narrow_fonts[font_code].font_code == EB_FONT_INVALID + && subbook->wide_fonts[font_code].font_code == EB_FONT_INVALID) + goto failed; + + LOG(("out: eb_have_font() = %d", 1)); + eb_unlock(&book->lock); + + return 1; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_have_font() = %d", 0)); + eb_unlock(&book->lock); + return 0; +} + + +/* + * Get height of the font `font_code' in the current subbook of `book'. + */ +EB_Error_Code +eb_font_height(EB_Book *book, int *height) +{ + EB_Error_Code error_code; + EB_Font_Code font_code; + + eb_lock(&book->lock); + LOG(("in: eb_font_height(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * The narrow font must exist in the current subbook. + */ + if (book->subbook_current->narrow_current != NULL) + font_code = book->subbook_current->narrow_current->font_code; + else if (book->subbook_current->wide_current != NULL) + font_code = book->subbook_current->wide_current->font_code; + else { + error_code = EB_ERR_NO_CUR_FONT; + goto failed; + } + + /* + * Calculate height. + */ + error_code = eb_font_height2(font_code, height); + if (error_code != EB_SUCCESS) + goto failed; + + LOG(("out: eb_font_heigt(height=%d) = %s", *height, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *height = 0; + LOG(("out: eb_font_height() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Get height of the font `font_code'. + */ +EB_Error_Code +eb_font_height2(EB_Font_Code font_code, int *height) +{ + EB_Error_Code error_code; + + LOG(("in: eb_font_height2(font_code=%d)", (int)font_code)); + + switch (font_code) { + case EB_FONT_16: + *height = EB_HEIGHT_FONT_16; + break; + case EB_FONT_24: + *height = EB_HEIGHT_FONT_24; + break; + case EB_FONT_30: + *height = EB_HEIGHT_FONT_30; + break; + case EB_FONT_48: + *height = EB_HEIGHT_FONT_48; + break; + default: + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + LOG(("out: eb_font_heigt2(height=%d) = %s", *height, + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *height = 0; + LOG(("out: eb_font_height2() = %s", eb_error_string(error_code))); + return error_code; +} + + diff --git a/eb/font.h b/eb/font.h new file mode 100644 index 0000000..bd4d675 --- /dev/null +++ b/eb/font.h @@ -0,0 +1,200 @@ +/* -*- C -*- + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef EB_FONT_H +#define EB_FONT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef EB_BUILD_LIBRARY +#include "defs.h" +#else +#include +#endif + +/* + * Font types. + */ +#define EB_FONT_16 0 +#define EB_FONT_24 1 +#define EB_FONT_30 2 +#define EB_FONT_48 3 +#define EB_FONT_INVALID -1 + +/* + * Font sizes. + */ +#define EB_SIZE_NARROW_FONT_16 16 +#define EB_SIZE_WIDE_FONT_16 32 +#define EB_SIZE_NARROW_FONT_24 48 +#define EB_SIZE_WIDE_FONT_24 72 +#define EB_SIZE_NARROW_FONT_30 60 +#define EB_SIZE_WIDE_FONT_30 120 +#define EB_SIZE_NARROW_FONT_48 144 +#define EB_SIZE_WIDE_FONT_48 288 + +/* + * Font width. + */ +#define EB_WIDTH_NARROW_FONT_16 8 +#define EB_WIDTH_WIDE_FONT_16 16 +#define EB_WIDTH_NARROW_FONT_24 16 +#define EB_WIDTH_WIDE_FONT_24 24 +#define EB_WIDTH_NARROW_FONT_30 16 +#define EB_WIDTH_WIDE_FONT_30 32 +#define EB_WIDTH_NARROW_FONT_48 24 +#define EB_WIDTH_WIDE_FONT_48 48 + +/* + * Font height. + */ +#define EB_HEIGHT_FONT_16 16 +#define EB_HEIGHT_FONT_24 24 +#define EB_HEIGHT_FONT_30 30 +#define EB_HEIGHT_FONT_48 48 + +/* + * Bitmap image sizes. + */ +#define EB_SIZE_NARROW_FONT_16_XBM 184 +#define EB_SIZE_WIDE_FONT_16_XBM 284 +#define EB_SIZE_NARROW_FONT_16_XPM 266 +#define EB_SIZE_WIDE_FONT_16_XPM 395 +#define EB_SIZE_NARROW_FONT_16_GIF 186 +#define EB_SIZE_WIDE_FONT_16_GIF 314 +#define EB_SIZE_NARROW_FONT_16_BMP 126 +#define EB_SIZE_WIDE_FONT_16_BMP 126 +#define EB_SIZE_NARROW_FONT_16_PNG 131 +#define EB_SIZE_WIDE_FONT_16_PNG 147 + +#define EB_SIZE_NARROW_FONT_24_XBM 383 +#define EB_SIZE_WIDE_FONT_24_XBM 533 +#define EB_SIZE_NARROW_FONT_24_XPM 555 +#define EB_SIZE_WIDE_FONT_24_XPM 747 +#define EB_SIZE_NARROW_FONT_24_GIF 450 +#define EB_SIZE_WIDE_FONT_24_GIF 642 +#define EB_SIZE_NARROW_FONT_24_BMP 158 +#define EB_SIZE_WIDE_FONT_24_BMP 158 +#define EB_SIZE_NARROW_FONT_24_PNG 171 +#define EB_SIZE_WIDE_FONT_24_PNG 195 + +#define EB_SIZE_NARROW_FONT_30_XBM 458 +#define EB_SIZE_WIDE_FONT_30_XBM 833 +#define EB_SIZE_NARROW_FONT_30_XPM 675 +#define EB_SIZE_WIDE_FONT_30_XPM 1155 +#define EB_SIZE_NARROW_FONT_30_GIF 552 +#define EB_SIZE_WIDE_FONT_30_GIF 1032 +#define EB_SIZE_NARROW_FONT_30_BMP 182 +#define EB_SIZE_WIDE_FONT_30_BMP 182 +#define EB_SIZE_NARROW_FONT_30_PNG 189 +#define EB_SIZE_WIDE_FONT_30_PNG 249 + +#define EB_SIZE_NARROW_FONT_48_XBM 983 +#define EB_SIZE_WIDE_FONT_48_XBM 1883 +#define EB_SIZE_NARROW_FONT_48_XPM 1419 +#define EB_SIZE_WIDE_FONT_48_XPM 2571 +#define EB_SIZE_NARROW_FONT_48_GIF 1242 +#define EB_SIZE_WIDE_FONT_48_GIF 2394 +#define EB_SIZE_NARROW_FONT_48_BMP 254 +#define EB_SIZE_WIDE_FONT_48_BMP 446 +#define EB_SIZE_NARROW_FONT_48_PNG 291 +#define EB_SIZE_WIDE_FONT_48_PNG 435 + +#define EB_SIZE_FONT_IMAGE EB_SIZE_WIDE_FONT_48_XPM + +/* + * Function declarations. + */ +/* bitmap.c */ +EB_Error_Code eb_narrow_font_xbm_size(EB_Font_Code font_code, size_t *size); +EB_Error_Code eb_narrow_font_xpm_size(EB_Font_Code font_code, size_t *size); +EB_Error_Code eb_narrow_font_gif_size(EB_Font_Code font_code, size_t *size); +EB_Error_Code eb_narrow_font_bmp_size(EB_Font_Code font_code, size_t *size); +EB_Error_Code eb_narrow_font_png_size(EB_Font_Code font_code, size_t *size); +EB_Error_Code eb_wide_font_xbm_size(EB_Font_Code font_code, size_t *size); +EB_Error_Code eb_wide_font_xpm_size(EB_Font_Code font_code, size_t *size); +EB_Error_Code eb_wide_font_gif_size(EB_Font_Code font_code, size_t *size); +EB_Error_Code eb_wide_font_bmp_size(EB_Font_Code font_code, size_t *size); +EB_Error_Code eb_wide_font_png_size(EB_Font_Code font_code, size_t *size); +EB_Error_Code eb_bitmap_to_xbm(const char *bitmap, int width, int height, + char *xbm, size_t *xbm_length); +EB_Error_Code eb_bitmap_to_xpm(const char *bitmap, int width, int height, + char *xpm, size_t *xpm_length); +EB_Error_Code eb_bitmap_to_gif(const char *bitmap, int width, int height, + char *gif, size_t *gif_length); +EB_Error_Code eb_bitmap_to_bmp(const char *bitmap, int width, int height, + char *bmp, size_t *bmp_length); +EB_Error_Code eb_bitmap_to_png(const char *bitmap, int width, int height, + char *png, size_t *png_length); + +/* font.c */ +EB_Error_Code eb_font(EB_Book *book, EB_Font_Code *font_code); +EB_Error_Code eb_set_font(EB_Book *book, EB_Font_Code font_code); +void eb_unset_font(EB_Book *book); +EB_Error_Code eb_font_list(EB_Book *book, EB_Font_Code *font_list, + int *font_count); +int eb_have_font(EB_Book *book, EB_Font_Code font_code); +EB_Error_Code eb_font_height(EB_Book *book, int *height); +EB_Error_Code eb_font_height2(EB_Font_Code font_code, int *height); + +/* narwfont.c */ +int eb_have_narrow_font(EB_Book *book); +EB_Error_Code eb_narrow_font_width(EB_Book *book, int *width); +EB_Error_Code eb_narrow_font_width2(EB_Font_Code font_code, int *width); +EB_Error_Code eb_narrow_font_size(EB_Book *book, size_t *size); +EB_Error_Code eb_narrow_font_size2(EB_Font_Code font_code, size_t *size); +EB_Error_Code eb_narrow_font_start(EB_Book *book, int *start); +EB_Error_Code eb_narrow_font_end(EB_Book *book, int *end); +EB_Error_Code eb_narrow_font_character_bitmap(EB_Book *book, int, char *); +EB_Error_Code eb_forward_narrow_font_character(EB_Book *book, int, int *); +EB_Error_Code eb_backward_narrow_font_character(EB_Book *book, int, int *); + +/* widefont.c */ +int eb_have_wide_font(EB_Book *book); +EB_Error_Code eb_wide_font_width(EB_Book *book, int *width); +EB_Error_Code eb_wide_font_width2(EB_Font_Code font_code, int *width); +EB_Error_Code eb_wide_font_size(EB_Book *book, size_t *size); +EB_Error_Code eb_wide_font_size2(EB_Font_Code font_code, size_t *size); +EB_Error_Code eb_wide_font_start(EB_Book *book, int *start); +EB_Error_Code eb_wide_font_end(EB_Book *book, int *end); +EB_Error_Code eb_wide_font_character_bitmap(EB_Book *book, + int character_number, char *bitmap); +EB_Error_Code eb_forward_wide_font_character(EB_Book *book, int n, + int *character_number); +EB_Error_Code eb_backward_wide_font_character(EB_Book *book, int n, + int *character_number); + +#ifdef __cplusplus +} +#endif + +#endif /* not EB_FONT_H */ diff --git a/eb/getaddrinfo.c b/eb/getaddrinfo.c new file mode 100644 index 0000000..04f07ab --- /dev/null +++ b/eb/getaddrinfo.c @@ -0,0 +1,551 @@ +/* + * Copyright (c) 2001-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * This program provides getaddrinfo() and getnameinfo() described in + * RFC2133, 2553 and 3493. These functions are mainly used for IPv6 + * application to resolve hostname or address. + * + * This program is designed to be working on traditional IPv4 systems + * which don't have those functions. Therefore, this implementation + * supports IPv4 only. + * + * This program is useful for application which should support both IPv6 + * and traditional IPv4 systems. Use genuine getaddrinfo() and getnameinfo() + * provided by system if the system supports IPv6. Otherwise, use this + * implementation. + * + * This program is intended to be used in combination with GNU Autoconf. + * + * This program also provides freeaddrinfo() and gai_strerror(). + * + * To use this program in your application, insert the following lines to + * C source files after including `sys/types.h', `sys/socket.h' and + * `netdb.h'. `getaddrinfo.h' defines `struct addrinfo' and AI_, NI_, + * EAI_ macros. + * + * #ifndef HAVE_GETADDRINFO + * #include "getaddrinfo.h" + * #endif + * + * Restriction: + * getaddrinfo() and getnameinfo() of this program are NOT thread + * safe, unless the cpp macro ENABLE_PTHREAD is defined. + */ + +/* + * Add the following code to your configure.ac (or configure.in). + * AC_TYPE_SOCKLEN_T + * AC_TYPE_IN_PORT_T + * AC_DECL_H_ERRNO + * + * AC_CHECK_FUNCS(getaddrinfo getnameinfo) + * if test "$ac_cv_func_getaddrinfo$ac_cv_func_getnameinfo" != yesyes ; then + * LIBOBJS="$LIBOBJS getaddrinfo.$ac_objext" + * fi + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef ENABLE_PTHREAD +#include +#endif + +#ifdef ENABLE_NLS +#include +#endif + +#if !defined(H_ERRNO_DECLARED) && !defined(WINSOCK) +extern int h_errno; +#endif + +#include "getaddrinfo.h" + +#ifdef ENABLE_NLS +#define _(string) gettext(string) +#ifdef gettext_noop +#define N_(string) gettext_noop(string) +#else +#define N_(string) (string) +#endif +#else +#define gettext(string) (string) +#define _(string) (string) +#define N_(string) (string) +#endif + +/* + * Error messages for gai_strerror(). + */ +static char *eai_errlist[] = { + N_("Success"), + + /* EAI_ADDRFAMILY */ + N_("Address family for hostname not supported"), + + /* EAI_AGAIN */ + N_("Temporary failure in name resolution"), + + /* EAI_BADFLAGS */ + N_("Invalid value for ai_flags"), + + /* EAI_FAIL */ + N_("Non-recoverable failure in name resolution"), + + /* EAI_FAMILY */ + N_("ai_family not supported"), + + /* EAI_MEMORY */ + N_("Memory allocation failure"), + + /* EAI_NONAME */ + N_("hostname nor servname provided, or not known"), + + /* EAI_OVERFLOW */ + N_("An argument buffer overflowed"), + + /* EAI_SERVICE */ + N_("servname not supported for ai_socktype"), + + /* EAI_SOCKTYPE */ + N_("ai_socktype not supported"), + + /* EAI_SYSTEM */ + N_("System error returned in errno") +}; + +/* + * Default hints for getaddrinfo(). + */ +static struct addrinfo default_hints = { + 0, PF_UNSPEC, 0, 0, 0, NULL, NULL, NULL +}; + +/* + * Mutex. + */ +#ifdef ENABLE_PTHREAD +static pthread_mutex_t gai_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif + +/* + * Declaration of static functions. + */ +static int is_integer(const char *s); +static int is_address(const char *s); +static int itoa_length(int n); + + +/* + * gai_strerror(). + */ +const char * +gai_strerror(int ecode) +{ + if (ecode < 0 || ecode > EAI_SYSTEM) + return _("Unknown error"); + + return gettext(eai_errlist[ecode]); +} + +/* + * freeaddrinfo(). + */ +void +freeaddrinfo(struct addrinfo *ai) +{ + struct addrinfo *next_ai; + + while (ai != NULL) { + if (ai->ai_canonname != NULL) + free(ai->ai_canonname); + if (ai->ai_addr != NULL) + free(ai->ai_addr); + next_ai = ai->ai_next; + free(ai); + ai = next_ai; + } +} + +/* + * Return 1 if the string `s' represents an integer. + */ +static int +is_integer(const char *s) +{ + if (*s == '-' || *s == '+') + s++; + if (*s < '0' || '9' < *s) + return 0; + + s++; + while ('0' <= *s && *s <= '9') + s++; + + return (*s == '\0'); +} + +/* + * Return 1 if the string `s' represents an IPv4 address. + * Unlike inet_addr(), it doesn't permit malformed nortation such + * as "192.168". + */ +static int +is_address(const char *s) +{ + const static char delimiters[] = {'.', '.', '.', '\0'}; + int i, j; + int octet; + + for (i = 0; i < 4; i++) { + if (*s == '0' && *(s + 1) != delimiters[i]) + return 0; + for (j = 0, octet = 0; '0' <= *s && *s <= '9' && j < 3; s++, j++) + octet = octet * 10 + (*s - '0'); + if (j == 0 || octet > 255 || *s != delimiters[i]) + return 0; + s++; + } + + return 1; +} + +/* + * Calcurate length of the string `s', where `s' is set by + * sprintf(s, "%d", n). + */ +static int +itoa_length(int n) +{ + int result = 1; + + if (n < 0) { + n = -n; + result++; + } + + while (n >= 10) { + result++; + n /= 10; + } + + return result; +} + +/* + * getaddrinfo(). + */ +int +getaddrinfo(const char *nodename, const char *servname, + const struct addrinfo *hints, struct addrinfo **res) +{ + struct addrinfo *head_res = NULL; + struct addrinfo *tail_res = NULL; + struct addrinfo *new_res; + struct sockaddr_in *sa_in; + struct in_addr **addr_list; + struct in_addr *addr_list_buf[2]; + struct in_addr addr_buf; + struct in_addr **ap; + struct servent *servent; + struct hostent *hostent; + const char *canonname = NULL; + in_port_t port; + int saved_h_errno; + int result = 0; + +#ifdef ENABLE_PTHREAD + pthread_mutex_lock(&gai_mutex); +#endif + + saved_h_errno = h_errno; + + if (nodename == NULL && servname == NULL) { + result = EAI_NONAME; + goto end; + } + + if (hints != NULL) { + if (hints->ai_family != PF_INET && hints->ai_family != PF_UNSPEC) { + result = EAI_FAMILY; + goto end; + } + if (hints->ai_socktype != SOCK_DGRAM + && hints->ai_socktype != SOCK_STREAM + && hints->ai_socktype != 0) { + result = EAI_SOCKTYPE; + goto end; + } + } else { + hints = &default_hints; + } + + if (servname != NULL) { + if (is_integer(servname)) + port = htons(atoi(servname)); + else { + if (hints->ai_flags & AI_NUMERICSERV) { + result = EAI_NONAME; + goto end; + } + + if (hints->ai_socktype == SOCK_DGRAM) + servent = getservbyname(servname, "udp"); + else if (hints->ai_socktype == SOCK_STREAM) + servent = getservbyname(servname, "tcp"); + else if (hints->ai_socktype == 0) + servent = getservbyname(servname, "tcp"); + else { + result = EAI_SOCKTYPE; + goto end; + } + + if (servent == NULL) { + result = EAI_SERVICE; + goto end; + } + port = servent->s_port; + } + } else { + port = htons(0); + } + + if (nodename != NULL) { + if (is_address(nodename)) { + addr_buf.s_addr = inet_addr(nodename); + addr_list_buf[0] = &addr_buf; + addr_list_buf[1] = NULL; + addr_list = addr_list_buf; + + if (hints->ai_flags & AI_CANONNAME + && !(hints->ai_flags & AI_NUMERICHOST)) { + hostent = gethostbyaddr((char *)&addr_buf, + sizeof(struct in_addr), AF_INET); + if (hostent != NULL) + canonname = hostent->h_name; + else + canonname = nodename; + } + } else { + if (hints->ai_flags & AI_NUMERICHOST) { + result = EAI_NONAME; + goto end; + } + + hostent = gethostbyname(nodename); + if (hostent == NULL) { + switch (h_errno) { + case HOST_NOT_FOUND: + case NO_DATA: + result = EAI_NONAME; + goto end; + case TRY_AGAIN: + result = EAI_AGAIN; + goto end; + default: + result = EAI_FAIL; + goto end; + } + } + addr_list = (struct in_addr **)hostent->h_addr_list; + + if (hints->ai_flags & AI_CANONNAME) + canonname = hostent->h_name; + } + } else { + if (hints->ai_flags & AI_PASSIVE) + addr_buf.s_addr = htonl(INADDR_ANY); + else + addr_buf.s_addr = htonl(0x7F000001); + addr_list_buf[0] = &addr_buf; + addr_list_buf[1] = NULL; + addr_list = addr_list_buf; + } + + for (ap = addr_list; *ap != NULL; ap++) { + new_res = (struct addrinfo *)malloc(sizeof(struct addrinfo)); + if (new_res == NULL) { + if (head_res != NULL) + freeaddrinfo(head_res); + result = EAI_MEMORY; + goto end; + } + + new_res->ai_family = PF_INET; + new_res->ai_socktype = hints->ai_socktype; + new_res->ai_protocol = hints->ai_protocol; + new_res->ai_addr = NULL; + new_res->ai_addrlen = sizeof(struct sockaddr_in); + new_res->ai_canonname = NULL; + new_res->ai_next = NULL; + + new_res->ai_addr = (struct sockaddr *) + malloc(sizeof(struct sockaddr_in)); + if (new_res->ai_addr == NULL) { + free(new_res); + if (head_res != NULL) + freeaddrinfo(head_res); + result = EAI_MEMORY; + goto end; + } + + sa_in = (struct sockaddr_in *)new_res->ai_addr; + memset(sa_in, 0, sizeof(struct sockaddr_in)); + sa_in->sin_family = PF_INET; + sa_in->sin_port = port; + memcpy(&sa_in->sin_addr, *ap, sizeof(struct in_addr)); + + if (head_res == NULL) + head_res = new_res; + else + tail_res->ai_next = new_res; + tail_res = new_res; + } + + if (canonname != NULL && head_res != NULL) { + head_res->ai_canonname = (char *)malloc(strlen(canonname) + 1); + if (head_res->ai_canonname != NULL) + strcpy(head_res->ai_canonname, canonname); + } + + *res = head_res; + + end: +#ifndef WINSOCK + h_errno = saved_h_errno; +#else + WSASetLastError(saved_h_errno); +#endif +#ifdef ENABLE_PTHREAD + pthread_mutex_unlock(&gai_mutex); +#endif + return result; +} + +/* + * getnameinfo(). + */ +int +getnameinfo(const struct sockaddr *sa, socklen_t salen, char *node, + socklen_t nodelen, char *serv, socklen_t servlen, int flags) +{ + const struct sockaddr_in *sa_in = (const struct sockaddr_in *)sa; + struct hostent *hostent; + struct servent *servent; + char *ntoa_address; + int saved_h_errno; + int result = 0; + +#ifdef ENABLE_PTHREAD + pthread_mutex_lock(&gai_mutex); +#endif + + saved_h_errno = h_errno; + + if (sa_in->sin_family != PF_INET) { + result = EAI_FAMILY; + goto end; + } else if (node == NULL && serv == NULL) { + result = EAI_NONAME; + goto end; + } + + if (serv != NULL && servlen > 0) { + if (flags & NI_NUMERICSERV) + servent = NULL; + else if (flags & NI_DGRAM) + servent = getservbyport(sa_in->sin_port, "udp"); + else + servent = getservbyport(sa_in->sin_port, "tcp"); + + if (servent != NULL) { + if (servlen <= strlen(servent->s_name)) { + result = EAI_OVERFLOW; + goto end; + } + strcpy(serv, servent->s_name); + } else { + if (servlen <= itoa_length(ntohs(sa_in->sin_port))) { + result = EAI_OVERFLOW; + goto end; + } + sprintf(serv, "%d", ntohs(sa_in->sin_port)); + } + } + + if (node != NULL && nodelen > 0) { + if (flags & NI_NUMERICHOST) + hostent = NULL; + else { + hostent = gethostbyaddr((char *)&sa_in->sin_addr, + sizeof(struct in_addr), AF_INET); + } + if (hostent != NULL) { + if (nodelen <= strlen(hostent->h_name)) { + result = EAI_OVERFLOW; + goto end; + } + strcpy(node, hostent->h_name); + } else { + if (flags & NI_NAMEREQD) { + result = EAI_NONAME; + goto end; + } + ntoa_address = inet_ntoa(sa_in->sin_addr); + if (nodelen <= strlen(ntoa_address)) { + result = EAI_OVERFLOW; + goto end; + } + strcpy(node, ntoa_address); + } + + } + + end: +#ifndef WINSOCK + h_errno = saved_h_errno; +#else + WSASetLastError(saved_h_errno); +#endif +#ifdef ENABLE_PTHREAD + pthread_mutex_unlock(&gai_mutex); +#endif + return result; +} + diff --git a/eb/getaddrinfo.h b/eb/getaddrinfo.h new file mode 100644 index 0000000..ba9f9e7 --- /dev/null +++ b/eb/getaddrinfo.h @@ -0,0 +1,222 @@ +/* + * Copyright (c) 2001-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef GETADDRINFO_H +#define GETADDRINFO_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include "build-pre.h" + +/********************************************************************/ +/* + * Undefine all the macros. + * might defines some of them. + */ +#ifdef EAI_ADDRFAMILY +#undef EAI_ADDRFAMILY +#endif +#ifdef EAI_AGAIN +#undef EAI_AGAIN +#endif +#ifdef EAI_BADFLAGS +#undef EAI_BADFLAGS +#endif +#ifdef EAI_FAIL +#undef EAI_FAIL +#endif +#ifdef EAI_FAMILY +#undef EAI_FAMILY +#endif +#ifdef EAI_MEMORY +#undef EAI_MEMORY +#endif +#ifdef EAI_NONAME +#undef EAI_NONAME +#endif +#ifdef EAI_OVERFLOW +#undef EAI_OVERFLOW +#endif +#ifdef EAI_SERVICE +#undef EAI_SERVICE +#endif +#ifdef EAI_SOCKTYPE +#undef EAI_SOCKTYPE +#endif +#ifdef EAI_SYSTEM +#undef EAI_SYSTEM +#endif + +#ifdef AI_PASSIVE +#undef AI_PASSIVE +#endif +#ifdef AI_CANONNAME +#undef AI_CANONNAME +#endif +#ifdef AI_NUMERICHOST +#undef AI_NUMERICHOST +#endif +#ifdef AI_NUMERICSERV +#undef AI_NUMERICSERV +#endif +#ifdef AI_V4MAPPED +#undef AI_V4MAPPED +#endif +#ifdef AI_ALL +#undef AI_ALL +#endif +#ifdef AI_ADDRCONFIG +#undef AI_ADDRCONFIG +#endif +#ifdef AI_DEFAULT +#undef AI_DEFAULT +#endif + +#ifdef NI_NOFQDN +#undef NI_NOFQDN +#endif +#ifdef NI_NUMERICHOST +#undef NI_NUMERICHOST +#endif +#ifdef NI_NAMEREQD +#undef NI_NAMEREQD +#endif +#ifdef NI_NUMERICSERV +#undef NI_NUMERICSERV +#endif +#ifdef NI_NUMERICSCOPE +#undef NI_NUMERICSCOPE +#endif + +#ifdef NI_DGRAM +#undef NI_DGRAM +#endif +#ifdef NI_MAXHOST +#undef NI_MAXHOST +#endif +#ifdef NI_MAXSERV +#undef NI_MAXSERV +#endif + +/* + * Fake struct and function names. + * might declares all or some of them. + */ +#if defined(HAVE_GETADDRINFO) || defined(HAVE_GETNAMEINFO) +#define addrinfo ebnet_addrinfo +#define gai_strerror ebnet_gai_strerror +#define freeaddrinfo ebnet_freeaddrinfo +#define getaddrinfo ebnet_getaddrinfo +#define getnameinfo ebnet_getnameinfo +#endif + +/********************************************************************/ +/* + * Error codes. + */ +#define EAI_ADDRFAMILY 1 +#define EAI_AGAIN 2 +#define EAI_BADFLAGS 3 +#define EAI_FAIL 4 +#define EAI_FAMILY 5 +#define EAI_MEMORY 6 +#define EAI_NONAME 7 +#define EAI_OVERFLOW 8 +#define EAI_SERVICE 9 +#define EAI_SOCKTYPE 10 +#define EAI_SYSTEM 11 + +/* + * Flags for getaddrinfo(). + */ +#define AI_ADDRCONFIG 0x0001 +#define AI_ALL 0x0002 +#define AI_CANONNAME 0x0004 +#define AI_NUMERICHOST 0x0008 +#define AI_NUMERICSERV 0x0010 +#define AI_PASSIVE 0x0020 +#define AI_V4MAPPED 0x0040 +#define AI_DEFAULT (AI_V4MAPPED | AI_ADDRCONFIG) + +/* + * Flags for getnameinfo(). + */ +#define NI_DGRAM 0x0001 +#define NI_NAMEREQD 0x0002 +#define NI_NOFQDN 0x0004 +#define NI_NUMERICHOST 0x0008 +#define NI_NUMERICSCOPE 0x0010 +#define NI_NUMERICSERV 0x0020 + +/* + * Maximum length of FQDN and servie name for getnameinfo(). + */ +#define NI_MAXHOST 1025 +#define NI_MAXSERV 32 + +/* + * Address families and Protocol families. + */ +#ifndef AF_UNSPEC +#define AF_UNSPEC AF_INET +#endif +#ifndef PF_UNSPEC +#define PF_UNSPEC PF_INET +#endif + +/* + * struct addrinfo. + */ +struct addrinfo { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + socklen_t ai_addrlen; + char *ai_canonname; + struct sockaddr *ai_addr; + struct addrinfo *ai_next; +}; + +/* + * Functions. + */ +const char *gai_strerror(int ecode); +void freeaddrinfo(struct addrinfo *ai); +int getaddrinfo(const char *nodename, const char *servname, + const struct addrinfo *hints, struct addrinfo **res); +int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *node, + socklen_t nodelen, char *serv, socklen_t servlen, int flags); + +#endif /* not GETADDRINFO_H */ diff --git a/eb/hook.c b/eb/hook.c new file mode 100644 index 0000000..9590e51 --- /dev/null +++ b/eb/hook.c @@ -0,0 +1,321 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "appendix.h" +#include "text.h" +#include "build-post.h" + +/* + * Default hookset. + */ +EB_Hookset eb_default_hookset; + + +/* + * Initialize default hookset. + */ +void +eb_initialize_default_hookset(void) +{ + LOG(("in: eb_initialize_default_hookset()")); + + eb_initialize_hookset(&eb_default_hookset); + + LOG(("out: eb_initialize_default_hookset()")); +} + + +/* + * Initialize a hookset. + */ +void +eb_initialize_hookset(EB_Hookset *hookset) +{ + int i; + + LOG(("in: eb_initialize_hookset()")); + + eb_initialize_lock(&hookset->lock); + + for (i = 0; i < EB_NUMBER_OF_HOOKS; i++) { + hookset->hooks[i].code = i; + hookset->hooks[i].function = NULL; + } + hookset->hooks[EB_HOOK_NARROW_JISX0208].function + = eb_hook_euc_to_ascii; + hookset->hooks[EB_HOOK_NARROW_FONT].function + = eb_hook_narrow_character_text; + hookset->hooks[EB_HOOK_WIDE_FONT].function + = eb_hook_wide_character_text; + hookset->hooks[EB_HOOK_NEWLINE].function + = eb_hook_newline; + + LOG(("out: eb_initialize_hookset()")); +} + + +/* + * Finalize a hookset. + */ +void +eb_finalize_hookset(EB_Hookset *hookset) +{ + int i; + + LOG(("in: eb_finalize_hookset()")); + + for (i = 0; i < EB_NUMBER_OF_HOOKS; i++) { + hookset->hooks[i].code = i; + hookset->hooks[i].function = NULL; + } + eb_finalize_lock(&hookset->lock); + + LOG(("out: eb_finalize_hookset()")); +} + + +/* + * Set a hook. + */ +EB_Error_Code +eb_set_hook(EB_Hookset *hookset, const EB_Hook *hook) +{ + EB_Error_Code error_code; + + eb_lock(&hookset->lock); + LOG(("in: eb_set_hook(hook=%d)", (int)hook->code)); + + /* + * Set a hook. + */ + if (hook->code < 0 || EB_NUMBER_OF_HOOKS <= hook->code) { + error_code = EB_ERR_NO_SUCH_HOOK; + goto failed; + } + hookset->hooks[hook->code].function = hook->function; + + LOG(("out: eb_set_hook() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&hookset->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_set_hook() = %s", eb_error_string(error_code))); + eb_unlock(&hookset->lock); + return error_code; +} + + +/* + * Set a list of hooks. + */ +EB_Error_Code +eb_set_hooks(EB_Hookset *hookset, const EB_Hook *hook) +{ + EB_Error_Code error_code; + const EB_Hook *h; + + eb_lock(&hookset->lock); + LOG(("in: eb_set_hooks(hooks=[below])")); + + if (eb_log_flag) { + for (h = hook; h->code != EB_HOOK_NULL; h++) + LOG((" hook=%d", h->code)); + } + + /* + * Set hooks. + */ + for (h = hook; h->code != EB_HOOK_NULL; h++) { + if (h->code < 0 || EB_NUMBER_OF_HOOKS <= h->code) { + error_code = EB_ERR_NO_SUCH_HOOK; + goto failed; + } + hookset->hooks[h->code].function = h->function; + } + + /* + * Unlock the hookset. + */ + LOG(("out: eb_set_hooks() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&hookset->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_set_hooks() = %s", eb_error_string(error_code))); + eb_unlock(&hookset->lock); + return error_code; +} + + +/* + * EUC JP to ASCII conversion table. + */ +#define EUC_TO_ASCII_TABLE_START 0xa0 +#define EUC_TO_ASCII_TABLE_END 0xff + +static const unsigned char euc_a1_to_ascii_table[] = { + 0x00, 0x20, 0x00, 0x00, 0x2c, 0x2e, 0x00, 0x3a, /* 0xa0 */ + 0x3b, 0x3f, 0x21, 0x00, 0x00, 0x00, 0x60, 0x00, /* 0xa8 */ + 0x5e, 0x7e, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x2f, /* 0xb8 */ + 0x5c, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x27, /* 0xc0 */ + 0x00, 0x22, 0x28, 0x29, 0x00, 0x00, 0x5b, 0x5d, /* 0xc8 */ + 0x7b, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0 */ + 0x00, 0x00, 0x00, 0x00, 0x2b, 0x2d, 0x00, 0x00, /* 0xd8 */ + 0x00, 0x3d, 0x00, 0x3c, 0x3e, 0x00, 0x00, 0x00, /* 0xe0 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, /* 0xe8 */ + 0x24, 0x00, 0x00, 0x25, 0x23, 0x26, 0x2a, 0x40, /* 0xf0 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8 */ +}; + +static const unsigned char euc_a3_to_ascii_table[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8 */ + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0xb0 */ + 0x38, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8 */ + 0x00, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0xc0 */ + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* 0xc8 */ + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 0xd0 */ + 0x58, 0x59, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8 */ + 0x00, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0xe0 */ + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* 0xe8 */ + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0xf0 */ + 0x78, 0x79, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8 */ +}; + + +/* + * Hook which converts a character from EUC-JP to ASCII. + */ +EB_Error_Code +eb_hook_euc_to_ascii(EB_Book *book, EB_Appendix *appendix, void *container, + EB_Hook_Code hook_code, int argc, const unsigned int *argv) +{ + int in_code1, in_code2; + int out_code = 0; + + in_code1 = argv[0] >> 8; + in_code2 = argv[0] & 0xff; + + if (in_code2 < EUC_TO_ASCII_TABLE_START + || EUC_TO_ASCII_TABLE_END < in_code2) { + out_code = 0; + } else if (in_code1 == 0xa1) { + out_code = euc_a1_to_ascii_table[in_code2 - EUC_TO_ASCII_TABLE_START]; + } else if (in_code1 == 0xa3) { + out_code = euc_a3_to_ascii_table[in_code2 - EUC_TO_ASCII_TABLE_START]; + } + + if (out_code == 0) + eb_write_text_byte2(book, in_code1, in_code2); + else + eb_write_text_byte1(book, out_code); + + return EB_SUCCESS; +} + + +/* + * Hook for narrow local character. + */ +EB_Error_Code +eb_hook_narrow_character_text(EB_Book *book, EB_Appendix *appendix, + void *container, EB_Hook_Code hook_code, int argc, + const unsigned int *argv) +{ + char alt_text[EB_MAX_ALTERNATION_TEXT_LENGTH + 1]; + + if (appendix == NULL + || eb_narrow_alt_character_text(appendix, (int)argv[0], alt_text) + != EB_SUCCESS) { + eb_write_text_string(book, ""); + } else { + eb_write_text_string(book, alt_text); + } + + return EB_SUCCESS; +} + + +/* + * Hook for wide local character. + */ +EB_Error_Code +eb_hook_wide_character_text(EB_Book *book, EB_Appendix *appendix, + void *container, EB_Hook_Code hook_code, int argc, + const unsigned int *argv) +{ + char alt_text[EB_MAX_ALTERNATION_TEXT_LENGTH + 1]; + + if (appendix == NULL + || eb_wide_alt_character_text(appendix, (int)argv[0], alt_text) + != EB_SUCCESS) { + eb_write_text_string(book, ""); + } else { + eb_write_text_string(book, alt_text); + } + + return EB_SUCCESS; +} + + +/* + * Hook for a newline character. + */ +EB_Error_Code +eb_hook_newline(EB_Book *book, EB_Appendix *appendix, void *container, + EB_Hook_Code code, int argc, const unsigned int *argv) +{ + eb_write_text_byte1(book, '\n'); + + return EB_SUCCESS; +} + + +/* + * Hook which does nothing. + */ +EB_Error_Code +eb_hook_empty(EB_Book *book, EB_Appendix *appendix, void *container, + EB_Hook_Code hook_code, int argc, const unsigned int *argv) +{ + return EB_SUCCESS; +} + + diff --git a/eb/jacode.c b/eb/jacode.c new file mode 100644 index 0000000..059ef63 --- /dev/null +++ b/eb/jacode.c @@ -0,0 +1,110 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" + +/* + * Convert a string from JIS X 0208 to EUC JP. + */ +void +eb_jisx0208_to_euc(char *out_string, const char *in_string) +{ + unsigned char *out_p = (unsigned char *)out_string; + const unsigned char *in_p = (unsigned char *)in_string; + + while (*in_p != '\0') + *out_p++ = ((*in_p++) | 0x80); + + *out_p = '\0'; +} + + +/* + * Convert a string from shift-JIS to EUC JP. + * (Shift-JIS is used only in the `LANGUAGE' file.) + */ +void +eb_sjis_to_euc(char *out_string, const char *in_string) +{ + unsigned char *out_p = (unsigned char *)out_string; + const unsigned char *in_p = (unsigned char *)in_string; + unsigned char c1, c2; + + for (;;) { + /* + * Break at '\0'. + */ + c1 = *in_p++; + if (c1 == '\0') + break; + + if (c1 <= 0x7f) { + /* + * JIS X 0201 Roman character. + */ + *out_p++ = c1; + } else if (0xa1 <= c1 && c1 <= 0xdf) { + /* + * JIS X 0201 Kana. + */ + *out_p++ = ' '; + } else { + /* + * JIS X 0208 character. + */ + c2 = *in_p++; + if (c2 == 0x00) + break; + + if (c2 < 0x9f) { + if (c1 < 0xdf) + c1 = ((c1 - 0x30) << 1) - 1; + else + c1 = ((c1 - 0x70) << 1) - 1; + + if (c2 < 0x7f) + c2 += 0x61; + else + c2 += 0x60; + } else { + if (c1 < 0xdf) + c1 = (c1 - 0x30) << 1; + else + c1 = (c1 - 0x70) << 1; + c2 += 0x02; + } + + *out_p++ = c1; + *out_p++ = c2; + } + } + + *out_p = '\0'; +} + + diff --git a/eb/keyword.c b/eb/keyword.c new file mode 100644 index 0000000..dabc7a4 --- /dev/null +++ b/eb/keyword.c @@ -0,0 +1,191 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "build-post.h" + +/* + * Examine whether the current subbook in `book' supports `KEYWORD SEARCH' + * or not. + */ +int +eb_have_keyword_search(EB_Book *book) +{ + eb_lock(&book->lock); + LOG(("in: eb_have_keyword_search(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) + goto failed; + + if (book->subbook_current->keyword.start_page == 0) + goto failed; + + LOG(("out: eb_have_keyword_search() = %d", 1)); + eb_unlock(&book->lock); + + return 1; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_have_keyword_search() = %d", 0)); + eb_unlock(&book->lock); + return 0; +} + + +/* + * Keyword search. + */ +EB_Error_Code +eb_search_keyword(EB_Book *book, const char * const input_words[]) +{ + EB_Error_Code error_code; + EB_Search_Context *context; + EB_Word_Code word_code; + int word_count; + int i; + + /* + * Lock the book. + */ + eb_lock(&book->lock); + LOG(("in: eb_search_keyword(book=%d, input_words=[below])", + (int)book->code)); + + if (eb_log_flag) { + for (i = 0; i < EB_MAX_KEYWORDS && input_words[i] != NULL; i++) { + LOG((" input_words[%d]=%s", i, + eb_quoted_string(input_words[i]))); + } + LOG((" input_words[%d]=NULL", i)); + } + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Check whether the current subbook has keyword search. + */ + if (book->subbook_current->keyword.start_page == 0) { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + + /* + * Attach a search context for each keyword, and pre-search the + * keywords. + */ + eb_reset_search_contexts(book); + word_count = 0; + + for (i = 0; i < EB_MAX_KEYWORDS; i++) { + if (input_words[i] == NULL) + break; + + /* + * Initialize search context. + */ + context = book->search_contexts + word_count; + context->code = EB_SEARCH_KEYWORD; + + /* + * Choose comparison functions. + */ + if (book->character_code == EB_CHARCODE_ISO8859_1) { + context->compare_pre = eb_pre_match_word; + context->compare_single = eb_match_word; + context->compare_group = eb_match_word; + } else { + context->compare_pre = eb_pre_match_word; + context->compare_single = eb_match_word; + context->compare_group = eb_match_word_kana_group; + } + context->page = book->subbook_current->keyword.start_page; + + /* + * Make a fixed word and a canonicalized word to search from + * `input_words[i]'. + */ + error_code = eb_set_keyword(book, input_words[i], context->word, + context->canonicalized_word, &word_code); + if (error_code == EB_ERR_EMPTY_WORD) + continue; + else if (error_code != EB_SUCCESS) + goto failed; + + /* + * Pre-search. + */ + error_code = eb_presearch_word(book, context); + if (error_code != EB_SUCCESS) + goto failed; + + word_count++; + } + if (word_count == 0) { + error_code = EB_ERR_NO_WORD; + goto failed; + } else if (EB_MAX_KEYWORDS <= i && input_words[i] != NULL) { + error_code = EB_ERR_TOO_MANY_WORDS; + goto failed; + } + + /* + * Set `EB_SEARCH_NONE' to the rest unused search context. + */ + for (i = word_count; i < EB_MAX_KEYWORDS; i++) + (book->search_contexts + i)->code = EB_SEARCH_NONE; + + LOG(("out: eb_search_keyword() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_reset_search_contexts(book); + LOG(("out: eb_search_keyword() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + diff --git a/eb/linebuf.c b/eb/linebuf.c new file mode 100644 index 0000000..6aab186 --- /dev/null +++ b/eb/linebuf.c @@ -0,0 +1,417 @@ +/* + * copyright (c) 1997-2005 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "linebuf.h" + +#ifdef USE_FAKELOG +#include "fakelog.h" +#endif + + +/* + * Initialize `linebuffer'. + */ +void +initialize_line_buffer(Line_Buffer *line_buffer) +{ + line_buffer->buffer[0] = '\0'; + line_buffer->file = -1; + line_buffer->cache_length = 0; + line_buffer->timeout = 0; +} + + +/* + * Finalize `line_buffer'. + */ +void +finalize_line_buffer(Line_Buffer *line_buffer) +{ + line_buffer->buffer[0] = '\0'; + line_buffer->file = -1; + line_buffer->cache_length = 0; + line_buffer->timeout = 0; +} + + +/* + * Set timeout seconds. + */ +void +set_line_buffer_timeout(Line_Buffer *line_buffer, int timeout) +{ + line_buffer->timeout = timeout; +} + + +/* + * Bind `file' to `line_buffer'. + */ +void +bind_file_to_line_buffer(Line_Buffer *line_buffer, int file) +{ + if (line_buffer->file < 0) + initialize_line_buffer(line_buffer); + line_buffer->file = file; +} + + +/* + * Return file descriptor bound to `line_buffer'. + * Return -1 when no file is bound. + */ +int +file_bound_to_line_buffer(Line_Buffer *line_buffer) +{ + return line_buffer->file; +} + + +/* + * Discard cache data in `line_buffer'. + */ +void +discard_cache_in_line_buffer(Line_Buffer *line_buffer) +{ + line_buffer->cache_length = 0; +} + + +/* + * Get the length of cache data in `line_buffer'. + */ +size_t +cache_length_in_line_buffer(Line_Buffer *line_buffer) +{ + return line_buffer->cache_length; +} + + +/* + * Read a line from the file bound to `line_buffer', and copy the read + * line to `line'. It reads at most `max_line_length' bytes. + * + * The function recognizes both "\n" and "\r\n" as end of line. + * "\n" or "\r\n" is not copied to `buffer', but "\0" is added, instead. + * + * The function returns the number of characters in the line, upon + * successful. It doesn't count "\n" or "\r\n" in the tail of the line, + * so that 0 is returned for an empty line, and the line length doesn't + * exceed one less than `max_line_length'. + * + * If EOF is received or an error occurs, -1 is returned. If the + * line is too long, `max_line_length' is returned. + */ +ssize_t +read_line_buffer(Line_Buffer *line_buffer, char *line, size_t max_line_length) +{ + char *line_p; + char *newline; + size_t search_length; + size_t additional_length; + size_t line_length; + fd_set fdset; + struct timeval timeval; + int select_result; + ssize_t read_result; + + /* + * Return -1 if no file is bound, or if `max_line_length' is 0. + */ + if (line_buffer->file < 0) + return -1; + if (max_line_length == 0) + return -1; + + /* + * Read a file until newline is appeared. + */ + line_length = 0; + line_p = line; + + for (;;) { + if (0 < line_buffer->cache_length) { + /* + * Find a newline in the cache data. + */ + if (max_line_length - line_length < line_buffer->cache_length) + search_length = max_line_length - line_length; + else + search_length = line_buffer->cache_length; + + newline = (char *)memchr(line_buffer->buffer, '\n', search_length); + + /* + * Append cache data in front of the newline to `line'. + */ + if (newline != NULL) + additional_length = newline - line_buffer->buffer + 1; + else + additional_length = search_length; + memcpy(line_p, line_buffer->buffer, additional_length); + line_p += additional_length; + line_length += additional_length; + line_buffer->cache_length -= additional_length; + + /* + * If cache data not copied to `line' are remained in the + * buffer, we move them to the beginning of the buffer. + */ + memmove(line_buffer->buffer, + line_buffer->buffer + additional_length, + line_buffer->cache_length); + + if (newline != NULL) + break; + } + + /* + * Check for the length of the current line. Return if the + * line is too long. + * + * Note that the following conditional expression can be + * substituted to (line_buffer->cache_length != 0), because + * remained cache data mean that the line is too long. + */ + if (max_line_length <= line_length) + return line_length; + + /* + * Call select(). + */ + errno = 0; + FD_ZERO(&fdset); + FD_SET(line_buffer->file, &fdset); + + if (line_buffer->timeout == 0) { + select_result = select(line_buffer->file + 1, &fdset, NULL, NULL, + NULL); + } else { + timeval.tv_sec = line_buffer->timeout; + timeval.tv_usec = 0; + select_result = select(line_buffer->file + 1, &fdset, NULL, NULL, + &timeval); + } + if (select_result < 0) { + if (errno == EINTR) + continue; + return -1; + } else if (select_result == 0) { + return -1; + } + + /* + * Read from a file. (No cache data are remaind.) + */ + errno = 0; + read_result = recv(line_buffer->file, line_buffer->buffer, + LINEBUF_BUFFER_SIZE, 0); + if (read_result < 0) { + if (errno == EINTR) + continue; + return -1; + } else if (read_result == 0) { + if (line_length == 0) { + return -1; + } + return line_length; + } + line_buffer->cache_length += read_result; + } + + /* + * Overwrite `\n' with `\0'. + */ + line_p--; + *line_p = '\0'; + line_length--; + + /* + * If the line is end with `\r\n', remove not only `\n' but `\r'. + */ + if (0 < line_length && *(line_p - 1) == '\r') { + line_p--; + *line_p = '\0'; + line_length--; + } + + return line_length; +} + + +/* + * Read just `stream_length' bytes from the file bound to `line_buffer', + * and copy the read bytes to `stream'. + * + * Unlike read_line_buffer(), it doesn't append `\0' to the read data, + * nor remove newline character in the read data. + * + * If it succeeds, the number of bytes actually read is returned. + * If EOF is received or an error occurs, -1 is returned. + */ +ssize_t +binary_read_line_buffer(Line_Buffer *line_buffer, char *stream, + size_t stream_length) +{ + char *stream_p; + size_t done_length; + fd_set fdset; + struct timeval timeval; + int select_result; + ssize_t read_result; + + /* + * Return -1 if no file is bound. + */ + if (line_buffer->file < 0) + return -1; + + /* + * Return 0 if `stream_length' is 0. + */ + if (stream_length == 0) + return 0; + + /* + * Test whether cache data are left in `line_buffer->buffer'. + * If they are, copy them to `stream'. + */ + stream_p = stream; + done_length = 0; + + if (0 < line_buffer->cache_length) { + if (stream_length <= line_buffer->cache_length) + done_length = stream_length; + else + done_length = line_buffer->cache_length; + + memcpy(stream_p, line_buffer->buffer, done_length); + stream_p += done_length; + line_buffer->cache_length -= done_length; + memmove(line_buffer->buffer, + line_buffer->buffer + done_length, + line_buffer->cache_length); + } + + /* + * Read the file until the number of read bytes (`done_length') is + * reached to `stream_length'. + */ + while (done_length < stream_length) { + /* + * Call select(). + */ + errno = 0; + FD_ZERO(&fdset); + FD_SET(line_buffer->file, &fdset); + + if (line_buffer->timeout == 0) { + select_result = select(line_buffer->file + 1, NULL, &fdset, NULL, + NULL); + } else { + timeval.tv_sec = line_buffer->timeout; + timeval.tv_usec = 0; + select_result = select(line_buffer->file + 1, NULL, &fdset, NULL, + &timeval); + } + if (select_result < 0) { + if (errno == EINTR) + continue; + return -1; + } else if (select_result == 0) { + return -1; + } + + /* + * Read from a file. + */ + errno = 0; + read_result = recv(line_buffer->file, stream_p, + stream_length - done_length, 0); + if (read_result < 0) { + if (errno == EINTR) + continue; + return read_result; + } else if (read_result == 0) { + if (done_length == 0) { + return -1; + } + return done_length; + } + stream_p += read_result; + done_length += read_result; + } + + return stream_length; +} + + +/* + * Skip too long line read by read_line_buffer(). + * + * If a line read by read_line_buffer() doesn't contain a newline + * character, the line is too long. This function reads and discards + * the rest of the line. + * + * If EOF is received or an error occurs, -1 is returned. + * Otherwise, 0 is returned. + */ +int +skip_line_buffer(Line_Buffer *line_buffer) +{ + ssize_t line_length; + + /* + * Read data until the end of the line is found. + */ + for (;;) { + line_length = read_line_buffer(line_buffer, line_buffer->buffer, + LINEBUF_BUFFER_SIZE); + if (line_length < 0) + return -1; + if (line_length < LINEBUF_BUFFER_SIZE) + break; + } + + return 0; +} + + diff --git a/eb/linebuf.h b/eb/linebuf.h new file mode 100644 index 0000000..82fdd4c --- /dev/null +++ b/eb/linebuf.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef LINEBUF_H +#define LINEBUF_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +/* + * Buffer size of `Line_Buffer' struct. + */ +#define LINEBUF_BUFFER_SIZE 256 + +/* + * Line buffer manager. + */ +typedef struct { + int file; /* file descriptor */ + int timeout; /* idle timeout interval */ + size_t cache_length; /* length of cache data */ + char buffer[LINEBUF_BUFFER_SIZE]; /* buffer */ +} Line_Buffer; + + +/* + * Function declarations. + */ +void initialize_line_buffer(Line_Buffer *line_buffer); +void finalize_line_buffer(Line_Buffer *line_buffer); +void set_line_buffer_timeout(Line_Buffer *line_buffer, int timeout); +void bind_file_to_line_buffer(Line_Buffer *line_buffer, int file); +int file_bound_to_line_buffer(Line_Buffer *line_buffer); +void discard_cache_in_line_buffer(Line_Buffer *line_buffer); +size_t cache_length_in_line_buffer(Line_Buffer *line_buffer); +ssize_t read_line_buffer(Line_Buffer *line_buffer, char *line, + size_t max_line_length); +ssize_t binary_read_line_buffer(Line_Buffer *line_buffer, char *stream, + size_t stream_length); +int skip_line_buffer(Line_Buffer *line_buffer); + +#endif /* not LINEBUF_H */ diff --git a/eb/lock.c b/eb/lock.c new file mode 100644 index 0000000..faded3e --- /dev/null +++ b/eb/lock.c @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2000-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "defs.h" +#include "build-post.h" + +/* + * Examine whether built library supports Pthread. + */ +int +eb_pthread_enabled(void) +{ +#ifdef ENABLE_PTHREAD + return 1; +#else + return 0; +#endif +} + + +/* + * These functions are compiled only when ENABLE_PTHREAD is defined. + */ +#ifdef ENABLE_PTHREAD + +/* + * Ininialize a lock manager. + */ +void +eb_initialize_lock(EB_Lock *lock) +{ + pthread_mutex_init(&lock->lock_count_mutex, NULL); + pthread_mutex_init(&lock->entity_mutex, NULL); + lock->lock_count = 0; +} + + +/* + * Finalize a lock manager. + */ +void +eb_finalize_lock(EB_Lock *lock) +{ + /* Nothing to be done. */ +} + + +/* + * Lock an entity. + */ +void +eb_lock(EB_Lock *lock) +{ + pthread_mutex_lock(&lock->lock_count_mutex); + if (lock->lock_count == 0) + pthread_mutex_lock(&lock->entity_mutex); + lock->lock_count++; + pthread_mutex_unlock(&lock->lock_count_mutex); +} + + +/* + * Unlock an entity. + */ +void +eb_unlock(EB_Lock *lock) +{ + pthread_mutex_lock(&lock->lock_count_mutex); + if (0 < lock->lock_count) { + lock->lock_count--; + if (lock->lock_count == 0) + pthread_mutex_unlock(&lock->entity_mutex); + } + pthread_mutex_unlock(&lock->lock_count_mutex); +} + +#endif /* ENABLE_PTHREAD */ diff --git a/eb/log.c b/eb/log.c new file mode 100644 index 0000000..6c0d3ed --- /dev/null +++ b/eb/log.c @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2001-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "build-post.h" + +#include + + +/* + * Mutex. + */ +#ifdef ENABLE_PTHREAD +static pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif + +/* + * Initialization flag. + */ +int eb_log_initialized = 0; + +/* + * Debug log flag. + */ +int eb_log_flag = 0; + +/* + * Pointer to log function. + */ +static void (*eb_log_function)(const char *message, va_list) = eb_log_stderr; + + +/* + * Initialize logging sub-system. + */ +void +eb_initialize_log(void) +{ + if (eb_log_initialized) + return; + + eb_log_flag = (getenv(EB_DEBUG_ENVIRONMENT_VARIABLE) != NULL); + eb_log_function = eb_log_stderr; + eb_log_initialized = 1; +} + +/* + * Set log function. + */ +void +eb_set_log_function(void (*function)(const char *message, va_list ap)) +{ + if (!eb_log_initialized) + eb_initialize_log(); + eb_log_function = function; +} + +/* + * Enable logging. + */ +void +eb_enable_log(void) +{ + if (!eb_log_initialized) + eb_initialize_log(); + eb_log_flag = 1; +} + +/* + * Disable logging. + */ +void +eb_disable_log(void) +{ + if (!eb_log_initialized) + eb_initialize_log(); + eb_log_flag = 0; +} + +/* + * Log a message. + */ +void +eb_log(const char *message, ...) +{ + va_list ap; + + va_start(ap, message); + + if (eb_log_flag && eb_log_function != NULL) + eb_log_function(message, ap); + + va_end(ap); +} + +/* + * Output a log message to standard error. + * This is the default log handler. + * + * Currently, this function doesn't work if the system lacks vprintf() + * and dopront(). + */ +void +eb_log_stderr(const char *message, va_list ap) +{ + pthread_mutex_lock(&log_mutex); + + fputs("[EB] ", stderr); + + vfprintf(stderr, message, ap); + fputc('\n', stderr); + fflush(stderr); + + pthread_mutex_unlock(&log_mutex); +} + +#define MAX_QUOTED_STREAM_LENGTH 100 + +/* + * Return Quoted printable string of `stream'. + */ +const char * +eb_quoted_stream(const char *stream, size_t stream_length) +{ + static char quoted_streams[EB_MAX_KEYWORDS][MAX_QUOTED_STREAM_LENGTH + 3]; + static int current_index = 0; + unsigned char *quoted_p; + const unsigned char *stream_p; + size_t quoted_length = 0; + int i; + + current_index = (current_index + 1) % EB_MAX_KEYWORDS; + quoted_p = (unsigned char *)quoted_streams[current_index]; + stream_p = (const unsigned char *)stream; + + if (stream == NULL) + return ""; + + for (i = 0; i < stream_length && *stream_p != '\0'; i++) { + if (0x20 <= *stream_p && *stream_p <= 0x7f && *stream_p != '=') { + if (MAX_QUOTED_STREAM_LENGTH < quoted_length + 1) { + *quoted_p++ = '.'; + *quoted_p++ = '.'; + break; + } + *quoted_p++ = *stream_p; + quoted_length++; + } else { + if (MAX_QUOTED_STREAM_LENGTH < quoted_length + 3) { + *quoted_p++ = '.'; + *quoted_p++ = '.'; + break; + } + *quoted_p++ = '='; + *quoted_p++ = "0123456789ABCDEF" [*stream_p / 0x10]; + *quoted_p++ = "0123456789ABCDEF" [*stream_p % 0x10]; + quoted_length += 3; + } + stream_p++; + } + + *quoted_p = '\0'; + return quoted_streams[current_index]; +} + + +/* + * Return Quoted printable string. + */ +const char * +eb_quoted_string(const char *string) +{ + return eb_quoted_stream(string, strlen(string)); +} diff --git a/eb/match.c b/eb/match.c new file mode 100644 index 0000000..c619083 --- /dev/null +++ b/eb/match.c @@ -0,0 +1,585 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "build-post.h" + +/* + * Compare `word' and `pattern'. + * `word' must be terminated by `\0' and `pattern' is assumed to be + * `length' characters long. + * + * When `word' is equal to `pattern', or equal to the beginning of + * `pattern', 0 is returned. A positive or negateive integer is + * returned according as `pattern' is greater or less than `word'. + */ +int +eb_match_word(const char *word, const char *pattern, size_t length) +{ + int i = 0; + unsigned char *word_p = (unsigned char *)word; + unsigned char *pattern_p = (unsigned char *)pattern; + int result; + + LOG(("in: eb_match_word(word=%s, pattern=%s)", + eb_quoted_stream(word, EB_MAX_WORD_LENGTH), + eb_quoted_stream(pattern, length))); + + for (;;) { + if (length <= i) { + result = *word_p; + break; + } + if (*word_p == '\0') { + result = 0; + break; + } + + if (*word_p != *pattern_p) { + result = *word_p - *pattern_p; + break; + } + + word_p++; + pattern_p++; + i++; + } + + LOG(("out: eb_match_word() = %d", result)); + return result; +} + + +/* + * Compare `word' and `pattern' for pre-search. + * `word' must be terminated by `\0' and `pattern' is assumed to be + * `length' characters long. + * + * When `word' is equal to `pattern', or equal to the beginning of + * `pattern', 0 is returned. A positive or negateive integer is + * returned according as `pattern' is greater or less than `word'. + */ +int +eb_pre_match_word(const char *word, const char *pattern, size_t length) +{ + int i = 0; + unsigned char *word_p = (unsigned char *)word; + unsigned char *pattern_p = (unsigned char *)pattern; + int result; + + LOG(("in: eb_pre_match_word(word=%s, pattern=%s)", + eb_quoted_stream(word, EB_MAX_WORD_LENGTH), + eb_quoted_stream(pattern, length))); + + for (;;) { + if (length <= i) { + result = 0; + break; + } + if (*word_p == '\0') { + result = 0; + break; + } + + if (*word_p != *pattern_p) { + result = *word_p - *pattern_p; + break; + } + + word_p++; + pattern_p++; + i++; + } + + LOG(("out: eb_pre_match_word() = %d", result)); + return result; +} + + +/* + * Compare `word' and `pattern' in JIS X 0208. + * `word' must be terminated by `\0' and `pattern' is assumed to be + * `length' characters long. + * + * When the word is equal to the pattern, 0 is returned. A positive or + * negateive integer is returned according as `pattern' is greater or + * less than `word'. + */ +int +eb_exact_match_word_jis(const char *word, const char *pattern, size_t length) +{ + int i = 0; + unsigned char *word_p = (unsigned char *)word; + unsigned char *pattern_p = (unsigned char *)pattern; + int result; + + LOG(("in: eb_exact_match_word_jis(word=%s, pattern=%s)", + eb_quoted_stream(word, EB_MAX_WORD_LENGTH), + eb_quoted_stream(pattern, length))); + + for (;;) { + if (length <= i) { + result = *word_p; + break; + } + if (*word_p == '\0') { + /* ignore spaces in the tail of the pattern */ + while (i < length && *pattern_p == '\0') { + pattern_p++; + i++; + } + result = (i - length); + break; + } + if (*word_p != *pattern_p) { + result = *word_p - *pattern_p; + break; + } + + word_p++; + pattern_p++; + i++; + } + + LOG(("out: eb_exact_match_word_jis() = %d", result)); + return result; +} + + +/* + * Compare `word' and `pattern' in JIS X 0208 for pre-search. + * `word' must be terminated by `\0' and `pattern' is assumed to be + * `length' characters long. + * + * When the word is equal to the pattern, 0 is returned. A positive or + * negateive integer is returned according as `pattern' is greater or + * less than `word'. + */ +int +eb_exact_pre_match_word_jis(const char *word, const char *pattern, + size_t length) +{ + int i = 0; + unsigned char *word_p = (unsigned char *)word; + unsigned char *pattern_p = (unsigned char *)pattern; + int result; + + LOG(("in: eb_exact_pre_match_word_jis(word=%s, pattern=%s)", + eb_quoted_stream(word, EB_MAX_WORD_LENGTH), + eb_quoted_stream(pattern, length))); + + for (;;) { + if (length <= i) { + result = 0; + break; + } + if (*word_p == '\0') { + /* ignore spaces in the tail of the pattern */ + while (i < length && *pattern_p == '\0') { + pattern_p++; + i++; + } + result = (i - length); + break; + } + if (*word_p != *pattern_p) { + result = *word_p - *pattern_p; + break; + } + + word_p++; + pattern_p++; + i++; + } + + LOG(("out: eb_exact_pre_match_word_jis() = %d", result)); + return result; +} + + +/* + * Compare `word' and `pattern' in Latin1. + * `word' must be terminated by `\0' and `pattern' is assumed to be + * `length' characters long. + * + * When the word is equal to the pattern, 0 is returned. A positive or + * negateive integer is returned according as `pattern' is greater or + * less than `word'. + */ +int +eb_exact_match_word_latin(const char *word, const char *pattern, size_t length) +{ + int i = 0; + unsigned char *word_p = (unsigned char *)word; + unsigned char *pattern_p = (unsigned char *)pattern; + int result; + + LOG(("in: eb_exact_match_word_latin(word=%s, pattern=%s)", + eb_quoted_stream(word, EB_MAX_WORD_LENGTH), + eb_quoted_stream(pattern, length))); + + for (;;) { + if (length <= i) { + result = *word_p; + break; + } + if (*word_p == '\0') { + /* ignore spaces in the tail of the pattern */ + while (i < length && (*pattern_p == ' ' || *pattern_p == '\0')) { + pattern_p++; + i++; + } + result = (i - length); + break; + } + if (*word_p != *pattern_p) { + result = *word_p - *pattern_p; + break; + } + + word_p++; + pattern_p++; + i++; + } + + LOG(("out: eb_exact_match_word_latin() = %d", result)); + return result; +} + + +/* + * Compare `word' and `pattern' in Latin1 for pre-search. + * `word' must be terminated by `\0' and `pattern' is assumed to be + * `length' characters long. + * + * When the word is equal to the pattern, 0 is returned. A positive or + * negateive integer is returned according as `pattern' is greater or + * less than `word'. + */ +int +eb_exact_pre_match_word_latin(const char *word, const char *pattern, + size_t length) +{ + int i = 0; + unsigned char *word_p = (unsigned char *)word; + unsigned char *pattern_p = (unsigned char *)pattern; + int result; + + LOG(("in: eb_exact_pre_match_word_latin(word=%s, pattern=%s)", + eb_quoted_stream(word, EB_MAX_WORD_LENGTH), + eb_quoted_stream(pattern, length))); + + for (;;) { + if (length <= i) { + result = 0; + break; + } + if (*word_p == '\0') { + /* ignore spaces in the tail of the pattern */ + while (i < length && (*pattern_p == ' ' || *pattern_p == '\0')) { + pattern_p++; + i++; + } + result = (i - length); + break; + } + if (*word_p != *pattern_p) { + result = *word_p - *pattern_p; + break; + } + + word_p++; + pattern_p++; + i++; + } + + LOG(("out: eb_exact_pre_match_word_latin() = %d", result)); + return result; +} + + +/* + * Compare `word' and `pattern' in JIS X 0208. + * + * This function is equivalent to eb_match_word() except that this function + * ignores differences of kana (katakana and hiragana). The order of + * hiragana and katakana characters is: + * + * If `word' and `pattern' differ, the function compares their characters + * with the following rule: + * + * HIRAGANA `KA' < HIRAGANA `GA' < KATAKANA `KA' < KATAKANA `GA' + */ +int +eb_match_word_kana_group(const char *word, const char *pattern, size_t length) +{ + int i = 0; + unsigned char *word_p = (unsigned char *)word; + unsigned char *pattern_p = (unsigned char *)pattern; + unsigned char wc0, wc1, pc0, pc1; + int result; + + LOG(("in: eb_match_word_kana_group(word=%s, pattern=%s)", + eb_quoted_stream(word, EB_MAX_WORD_LENGTH), + eb_quoted_stream(pattern, length))); + + for (;;) { + if (length <= i) { + result = *word_p; + break; + } + if (*word_p == '\0') { + result = 0; + break; + } + if (length <= i + 1 || *(word_p + 1) == '\0') { + result = *word_p - *pattern_p; + break; + } + + wc0 = *word_p; + wc1 = *(word_p + 1); + pc0 = *pattern_p; + pc1 = *(pattern_p + 1); + + if ((wc0 == 0x24 || wc0 == 0x25) && (pc0 == 0x24 || pc0 == 0x25)) { + if (wc1 != pc1) { + result = ((wc0 << 8) + wc1) - ((pc0 << 8) + pc1); + break; + } + } else { + if (wc0 != pc0 || wc1 != pc1) { + result = ((wc0 << 8) + wc1) - ((pc0 << 8) + pc1); + break; + } + } + word_p += 2; + pattern_p += 2; + i += 2; + } + + LOG(("out: eb_match_word_kana_group() = %d", result)); + return result; +} + + +/* + * Compare `word' and `pattern' in JIS X 0208. + * + * This function is equivalent to eb_match_word() except that this function + * ignores differences of kana (katakana and hiragana). The order of + * hiragana and katakana characters is: + * + * If `word' and `pattern' differ, the function compares their characters + * with the following rule: + * + * HIRAGANA `KA' == KATAKANA `KA' < HIRAGANA `GA' == KATAKANA `GA'. + */ +int +eb_match_word_kana_single(const char *word, const char *pattern, size_t length) +{ + int i = 0; + unsigned char *word_p = (unsigned char *)word; + unsigned char *pattern_p = (unsigned char *)pattern; + unsigned char wc0, wc1, pc0, pc1; + int result; + + LOG(("in: eb_match_word_kana_single(word=%s, pattern=%s)", + eb_quoted_stream(word, EB_MAX_WORD_LENGTH), + eb_quoted_stream(pattern, length))); + + for (;;) { + if (length <= i) { + result = *word_p; + break; + } + if (*word_p == '\0') { + result = 0; + break; + } + if (length <= i + 1 || *(word_p + 1) == '\0') { + result = *word_p - *pattern_p; + break; + } + + wc0 = *word_p; + wc1 = *(word_p + 1); + pc0 = *pattern_p; + pc1 = *(pattern_p + 1); + + if ((wc0 == 0x24 || wc0 == 0x25) && (pc0 == 0x24 || pc0 == 0x25)) { + if (wc1 != pc1) { + result = wc1 - pc1; + break; + } + } else { + if (wc0 != pc0 || wc1 != pc1) { + result = ((wc0 << 8) + wc1) - ((pc0 << 8) + pc1); + break; + } + } + word_p += 2; + pattern_p += 2; + i += 2; + } + + LOG(("out: eb_match_word_kana_single() = %d", result)); + return result; +} + + +/* + * Compare `word' and `pattern' in JIS X 0208. + * + * This function is equivalent to eb_exact_match_word_jis() except that + * this function ignores differences of kana (katakana and hiragana). + * + * If `word' and `pattern' differ, the function compares their characters + * with the following rule: + * + * HIRAGANA `KA' < HIRAGANA `GA' < KATAKANA `KA' < KATAKANA `GA' + */ +int +eb_exact_match_word_kana_group(const char *word, const char *pattern, + size_t length) +{ + int i = 0; + unsigned char *word_p = (unsigned char *)word; + unsigned char *pattern_p = (unsigned char *)pattern; + unsigned char wc0, wc1, pc0, pc1; + int result; + + LOG(("in: eb_exact_match_word_kana_group(word=%s, pattern=%s)", + eb_quoted_stream(word, EB_MAX_WORD_LENGTH), + eb_quoted_stream(pattern, length))); + + for (;;) { + if (length <= i) { + result = *word_p; + break; + } + if (*word_p == '\0') { + result = - *pattern_p; + break; + } + if (length <= i + 1 || *(word_p + 1) == '\0') { + result = *word_p - *pattern_p; + break; + } + wc0 = *word_p; + wc1 = *(word_p + 1); + pc0 = *pattern_p; + pc1 = *(pattern_p + 1); + + if ((wc0 == 0x24 || wc0 == 0x25) && (pc0 == 0x24 || pc0 == 0x25)) { + if (wc1 != pc1) { + result = ((wc0 << 8) + wc1) - ((pc0 << 8) + pc1); + break; + } + } else { + if (wc0 != pc0 || wc1 != pc1) { + result = ((wc0 << 8) + wc1) - ((pc0 << 8) + pc1); + break; + } + } + word_p += 2; + pattern_p += 2; + i += 2; + } + + LOG(("out: eb_exact_match_word_kana_group() = %d", result)); + return result; +} + + +/* + * Compare `word' and `pattern' in JIS X 0208. + * + * This function is equivalent to eb_exact_match_word_jis() except that + * this function ignores differences of kana (katakana and hiragana). + * The order of hiragana and katakana characters is: + * + * If `word' and `pattern' differ, the function compares their characters + * with the following rule: + * + * HIRAGANA `KA' == KATAKANA `KA' < HIRAGANA `GA' == KATAKANA `GA'. + */ +int +eb_exact_match_word_kana_single(const char *word, const char *pattern, + size_t length) +{ + int i = 0; + unsigned char *word_p = (unsigned char *)word; + unsigned char *pattern_p = (unsigned char *)pattern; + unsigned char wc0, wc1, pc0, pc1; + int result; + + LOG(("in: eb_exact_match_word_kana_single(word=%s, pattern=%s)", + eb_quoted_stream(word, EB_MAX_WORD_LENGTH), + eb_quoted_stream(pattern, length))); + + for (;;) { + if (length <= i) { + result = *word_p; + break; + } + if (*word_p == '\0') { + result = - *pattern_p; + break; + } + if (length <= i + 1 || *(word_p + 1) == '\0') { + result = *word_p - *pattern_p; + break; + } + wc0 = *word_p; + wc1 = *(word_p + 1); + pc0 = *pattern_p; + pc1 = *(pattern_p + 1); + + if ((wc0 == 0x24 || wc0 == 0x25) && (pc0 == 0x24 || pc0 == 0x25)) { + if (wc1 != pc1) { + result = wc1 - pc1; + break; + } + } else { + if (wc0 != pc0 || wc1 != pc1) { + result = ((wc0 << 8) + wc1) - ((pc0 << 8) + pc1); + break; + } + } + word_p += 2; + pattern_p += 2; + i += 2; + } + + LOG(("out: eb_exact_match_word_kana_single() = %d", result)); + return result; +} + + diff --git a/eb/menu.c b/eb/menu.c new file mode 100644 index 0000000..298be55 --- /dev/null +++ b/eb/menu.c @@ -0,0 +1,206 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "build-post.h" + +/* + * Examine whether the current subbook in `book' supports `MENU SEARCH' + * or not. + */ +int +eb_have_menu(EB_Book *book) +{ + eb_lock(&book->lock); + LOG(("in: eb_have_menu(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) + goto failed; + + /* + * Check for the index page of menu search. + */ + if (book->subbook_current->menu.start_page == 0) + goto failed; + + LOG(("out: eb_have_menu() = %d", 1)); + eb_unlock(&book->lock); + + return 1; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_have_menu() = %d", 0)); + eb_unlock(&book->lock); + return 0; +} + + +/* + * Menu. + */ +EB_Error_Code +eb_menu(EB_Book *book, EB_Position *position) +{ + EB_Error_Code error_code; + int page; + + eb_lock(&book->lock); + LOG(("in: eb_menu(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Check for the page number of menu search. + */ + page = book->subbook_current->menu.start_page; + if (page == 0) { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + + /* + * Copy the position to `position'. + */ + position->page = page; + position->offset = 0; + + LOG(("out: eb_menu(position={%d,%d}) = %s", + position->page, position->offset, eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_menu() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + +/* + * Examine whether the current subbook in `book' supports `GRAPHIC MENU SEARCH' + * or not. + */ +int +eb_have_image_menu(EB_Book *book) +{ + eb_lock(&book->lock); + LOG(("in: eb_have_image_menu(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) + goto failed; + + /* + * Check for the index page of graphic menu search. + */ + if (book->subbook_current->image_menu.start_page == 0) + goto failed; + + LOG(("out: eb_have_image_menu() = %d", 1)); + eb_unlock(&book->lock); + + return 1; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_have_image_menu() = %d", 0)); + eb_unlock(&book->lock); + return 0; +} + + +/* + * Graphic Menu. + */ +EB_Error_Code +eb_image_menu(EB_Book *book, EB_Position *position) +{ + EB_Error_Code error_code; + int page; + + eb_lock(&book->lock); + LOG(("in: eb_image_menu(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Check for the page number of graphic menu search. + */ + page = book->subbook_current->image_menu.start_page; + if (page == 0) { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + + /* + * Copy the position to `position'. + */ + position->page = page; + position->offset = 0; + + LOG(("out: eb_image_menu(position={%d,%d}) = %s", + position->page, position->offset, eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_image_menu() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} diff --git a/eb/multi.c b/eb/multi.c new file mode 100644 index 0000000..f818cd9 --- /dev/null +++ b/eb/multi.c @@ -0,0 +1,841 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "build-post.h" + +/* + * Get information about the current subbook. + */ +EB_Error_Code +eb_load_multi_searches(EB_Book *book) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + EB_Multi_Search *multi; + EB_Search *entry; + char buffer[EB_SIZE_PAGE]; + char *buffer_p; + int index_count; + int index_id; + int i, j, k; + + LOG(("in: eb_load_multi_searches(book=%d)", book->code)); + + subbook = book->subbook_current; + + for (i = 0, multi = subbook->multis; i < subbook->multi_count; + i++, multi++) { + /* + * Read the index table page of the multi search. + */ + if (zio_lseek(&subbook->text_zio, + ((off_t) multi->search.start_page - 1) * EB_SIZE_PAGE, SEEK_SET) + < 0) { + error_code = EB_ERR_FAIL_SEEK_TEXT; + goto failed; + } + if (zio_read(&subbook->text_zio, buffer, EB_SIZE_PAGE) + != EB_SIZE_PAGE) { + error_code = EB_ERR_FAIL_READ_TEXT; + goto failed; + } + + /* + * Get the number of entries in this multi search. + */ + multi->entry_count = eb_uint2(buffer); + if (EB_MAX_MULTI_SEARCHES <= multi->entry_count) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + buffer_p = buffer + 16; + for (j = 0, entry = multi->entries; + j < multi->entry_count; j++, entry++) { + /* + * Get the number of indexes in this entry, and title + * of this entry. + */ + index_count = eb_uint1(buffer_p); + strncpy(entry->label, buffer_p + 2, EB_MAX_MULTI_LABEL_LENGTH); + entry->label[EB_MAX_MULTI_LABEL_LENGTH] = '\0'; + eb_jisx0208_to_euc(entry->label, entry->label); + buffer_p += EB_MAX_MULTI_LABEL_LENGTH + 2; + + /* + * Initialize index page information of the entry. + */ + for (k = 0; k < index_count; k++) { + /* + * Get the index page information of the entry. + */ + index_id = eb_uint1(buffer_p); + switch (index_id) { + case 0x71: + case 0x91: + case 0xa1: + if (entry->start_page != 0 && entry->index_id != 0x71) + break; + entry->start_page = eb_uint4(buffer_p + 2); + entry->end_page = entry->start_page + + eb_uint4(buffer_p + 6) - 1; + entry->index_id = index_id; + entry->katakana = EB_INDEX_STYLE_ASIS; + entry->lower = EB_INDEX_STYLE_CONVERT; + entry->mark = EB_INDEX_STYLE_ASIS; + entry->long_vowel = EB_INDEX_STYLE_ASIS; + entry->double_consonant = EB_INDEX_STYLE_ASIS; + entry->contracted_sound = EB_INDEX_STYLE_ASIS; + entry->voiced_consonant = EB_INDEX_STYLE_ASIS; + entry->small_vowel = EB_INDEX_STYLE_ASIS; + entry->p_sound = EB_INDEX_STYLE_ASIS; + entry->space = EB_INDEX_STYLE_ASIS; + break; + case 0x01: + entry->candidates_page = eb_uint4(buffer_p + 2); + break; + } + buffer_p += 16; + } + } + } + + LOG(("out: eb_load_multi_searches() = %s", eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_load_multi_searches() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Default multi search titles (written in JIS X 0208). + */ +static const char *default_multi_titles_jisx0208[] = { + "J#9g8!:w#1", /* Multi search 1. */ + "J#9g8!:w#2", /* Multi search 2. */ + "J#9g8!:w#3", /* Multi search 3. */ + "J#9g8!:w#4", /* Multi search 4. */ + "J#9g8!:w#5", /* Multi search 5. */ + "J#9g8!:w#6", /* Multi search 6. */ + "J#9g8!:w#7", /* Multi search 7. */ + "J#9g8!:w#8", /* Multi search 8. */ + "J#9g8!:w#9", /* Multi search 9. */ + "J#9g8!:w#1#0", /* Multi search 10. */ +}; + +/* + * Default multi search titles (written in ASCII, subset of ISO 8859-1). + */ +static const char *default_multi_titles_latin[] = { + "Multi search 1", + "Multi search 2", + "Multi search 3", + "Multi search 4", + "Multi search 5", + "Multi search 6", + "Multi search 7", + "Multi search 8", + "Multi search 9", + "Multi search 10", +}; + +/* + * Load multi search titles. + */ +EB_Error_Code +eb_load_multi_titles(EB_Book *book) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + char buffer[EB_SIZE_PAGE]; + int title_count; + char *title; + size_t offset; + int i; + + LOG(("in: eb_load_multi_searches(book=%d)", book->code)); + + subbook = book->subbook_current; + + /* + * Set default titles. + */ + if (book->character_code == EB_CHARCODE_ISO8859_1) { + for (i = 0; i < subbook->multi_count; i++) { + title = subbook->multis[i].title; + strcpy(title, default_multi_titles_latin[i]); + } + } else { + for (i = 0; i < subbook->multi_count; i++) { + title = subbook->multis[i].title; + strcpy(title, default_multi_titles_jisx0208[i]); + eb_jisx0208_to_euc(title, title); + } + } + + if (book->disc_code != EB_DISC_EPWING || subbook->search_title_page == 0) + goto succeeded; + + /* + * Read the page of the multi search. + */ + if (zio_lseek(&subbook->text_zio, + ((off_t) subbook->search_title_page - 1) * EB_SIZE_PAGE, SEEK_SET) + < 0) { + error_code = EB_ERR_FAIL_SEEK_TEXT; + goto failed; + } + if (zio_read(&subbook->text_zio, buffer, EB_SIZE_PAGE) != EB_SIZE_PAGE) { + error_code = EB_ERR_FAIL_READ_TEXT; + goto failed; + } + + title_count = eb_uint2(buffer); + if (EB_MAX_SEARCH_TITLES < title_count) + title_count = EB_MAX_SEARCH_TITLES; + + /* + * We need titles for multi searches only. + * titles[ 0]: title for word and endword searches. + * titles[ 1]: title for keyword search. + * titles[ 2]: common title for all multi searches. + * (we don't need this) + * titles[ 3]: title for multi search 1. + * : + * titles[12]: title for multi search 10. + * titles[13]: title for menu search. + * + * The offset of titles[3] is: + * the number of entries(2bytes) + * + reserved 1 (68bytes) + * + title for word and endword searches (70bytes) + * + title for keyword search (70bytes) + * + common title for all multi searches (70bytes) + * + reserved 2 (70bytes) + * = 2 + 68 + 70 + 70 + 70 + 70 = 350 + */ + for (i = 4, offset = 350; i < EB_MAX_SEARCH_TITLES; i++, offset += 70) { + if (subbook->multi_count <= i - 4) + break; + if (eb_uint2(buffer + offset) != 0x02) + continue; + + /* + * Each titles[] consists of + * parameter (2bytes) + * short title (16bytes) + * long title (32bytes) + * We get long title rather than short one. + */ + title = subbook->multis[i - 4].title; + strncpy(title, buffer + offset + 2 + 16, EB_MAX_MULTI_TITLE_LENGTH); + title[EB_MAX_MULTI_TITLE_LENGTH] = '\0'; + eb_jisx0208_to_euc(title, title); + } + +succeeded: + LOG(("out: eb_load_multi_titles() = %s", eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_load_multi_titles() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Examine whether the current subbook in `book' supports `MULTI SEARCH' + * or not. + */ +int +eb_have_multi_search(EB_Book *book) +{ + eb_lock(&book->lock); + LOG(("in: eb_have_multi_search(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) + goto failed; + + if (book->subbook_current->multi_count == 0) + goto failed; + + LOG(("out: eb_have_multi_search() = %d", 1)); + eb_unlock(&book->lock); + + return 1; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_have_multi_search() = %d", 0)); + eb_unlock(&book->lock); + return 0; +} + + +/* + * Return a title of the multi search `multi_id'. + */ +EB_Error_Code +eb_multi_title(EB_Book *book, EB_Multi_Search_Code multi_id, char *title) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + + eb_lock(&book->lock); + LOG(("in: eb_multi_title(book=%d, multi_id=%d)", + (int)book->code, (int)multi_id)); + + /* + * The book must have been bound. + */ + if (book->path == NULL) { + error_code = EB_ERR_UNBOUND_BOOK; + goto failed; + } + + /* + * Current subbook must have been set. + */ + subbook = book->subbook_current; + if (subbook == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * `multi_id' must be a valid code. + */ + if (multi_id < 0 || subbook->multi_count <= multi_id) { + error_code = EB_ERR_NO_SUCH_MULTI_ID; + goto failed; + } + + strcpy(title, subbook->multis[multi_id].title); + + LOG(("out: eb_multi_title(title=%s) = %s", title, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *title = '\0'; + LOG(("out: eb_multi_title() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Return a list of multi search ids in `book'. + */ +EB_Error_Code +eb_multi_search_list(EB_Book *book, EB_Multi_Search_Code *search_list, + int *search_count) +{ + EB_Error_Code error_code; + EB_Subbook_Code *list_p; + int i; + + eb_lock(&book->lock); + LOG(("in: eb_multi_search_list(book=%d)", (int)book->code)); + + /* + * The book must have been bound. + */ + if (book->path == NULL) { + error_code = EB_ERR_UNBOUND_BOOK; + goto failed; + } + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + *search_count = book->subbook_current->multi_count; + for (i = 0, list_p = search_list; i < *search_count; i++, list_p++) + *list_p = i; + + LOG(("out: eb_multi_search_list(search_count=%d) = %s", *search_count, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *search_count = 0; + LOG(("out: eb_multi_search_list() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Return the number of entries that the multi search `multi_id' in `book'. + */ +EB_Error_Code +eb_multi_entry_count(EB_Book *book, EB_Multi_Search_Code multi_id, + int *entry_count) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_multi_entry_count(book=%d, multi_id=%d)", (int)book->code, + (int)multi_id)); + + /* + * The book must have been bound. + */ + if (book->path == NULL) { + error_code = EB_ERR_UNBOUND_BOOK; + goto failed; + } + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * `multi_id' must be a valid code. + */ + if (multi_id < 0 || book->subbook_current->multi_count <= multi_id) { + error_code = EB_ERR_NO_SUCH_MULTI_ID; + goto failed; + } + + *entry_count = book->subbook_current->multis[multi_id].entry_count; + + LOG(("out: eb_multi_entry_count(entry_count=%d) = %s", (int)*entry_count, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *entry_count = 0; + LOG(("out: eb_multi_entry_count() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Return a list of entries that the multi search `multi_id' in `book' has. + * (Legacy function) + */ +EB_Error_Code +eb_multi_entry_list(EB_Book *book, EB_Multi_Search_Code multi_id, + int *entry_list, int *entry_count) +{ + EB_Error_Code error_code; + EB_Subbook_Code *list_p; + int i; + + error_code = eb_multi_entry_count(book, multi_id, entry_count); + if (error_code != EB_SUCCESS) + return error_code; + + for (i = 0, list_p = entry_list; i < *entry_count; i++, list_p++) + *list_p = i; + + return EB_SUCCESS; +} + + +/* + * Return a lable of the entry `entry_index' in the multi search `multi_id'. + */ +EB_Error_Code +eb_multi_entry_label(EB_Book *book, EB_Multi_Search_Code multi_id, + int entry_index, char *label) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + + eb_lock(&book->lock); + LOG(("in: eb_multi_entry_label(book=%d, multi_id=%d, entry_index=%d)", + (int)book->code, (int)multi_id, entry_index)); + + /* + * The book must have been bound. + */ + if (book->path == NULL) { + error_code = EB_ERR_UNBOUND_BOOK; + goto failed; + } + + /* + * Current subbook must have been set. + */ + subbook = book->subbook_current; + if (subbook == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * `multi_id' must be a valid code. + */ + if (multi_id < 0 || subbook->multi_count <= multi_id) { + error_code = EB_ERR_NO_SUCH_MULTI_ID; + goto failed; + } + + /* + * `entry_index' must be a valid code. + */ + if (entry_index < 0 + || subbook->multis[multi_id].entry_count <= entry_index) { + error_code = EB_ERR_NO_SUCH_ENTRY_ID; + goto failed; + } + + strcpy(label, subbook->multis[multi_id].entries[entry_index].label); + + LOG(("out: eb_multi_entry_label(label=%s) = %s", label, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *label = '\0'; + LOG(("out: eb_multi_entry_label() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Whether the entry `entry_index' in the multi search `multi_id' has + * candidates or not. + */ +int +eb_multi_entry_have_candidates(EB_Book *book, EB_Multi_Search_Code multi_id, + int entry_index) +{ + EB_Multi_Search *multi; + + eb_lock(&book->lock); + LOG(("in: eb_multi_entry_have_candidates(book=%d, multi_id=%d, \ +entry_index=%d)", + (int)book->code, (int)multi_id, entry_index)); + + /* + * The book must have been bound. + */ + if (book->path == NULL) + goto failed; + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) + goto failed; + + /* + * `multi_id' must be a valid code. + */ + if (multi_id < 0 || book->subbook_current->multi_count <= multi_id) + goto failed; + + /* + * `entry_index' must be a valid code. + */ + multi = book->subbook_current->multis + multi_id; + if (entry_index < 0 || multi->entry_count <= entry_index) + goto failed; + + if (multi->entries[entry_index].candidates_page == 0) + goto failed; + + LOG(("out: eb_multi_entry_have_candidates() = %d", 1)); + eb_unlock(&book->lock); + + return 1; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_multi_entry_have_candidates() = %d", 0)); + eb_unlock(&book->lock); + return 0; +} + + +/* + * Return a position of candidates for the entry `entry_index' in the multi + * search `multi_id'. + */ +EB_Error_Code +eb_multi_entry_candidates(EB_Book *book, EB_Multi_Search_Code multi_id, + int entry_index, EB_Position *position) +{ + EB_Error_Code error_code; + EB_Multi_Search *multi; + + eb_lock(&book->lock); + LOG(("in: eb_multi_entry_candidates(book=%d, multi_id=%d, entry_index=%d)", + (int)book->code, (int)multi_id, entry_index)); + + /* + * The book must have been bound. + */ + if (book->path == NULL) { + error_code = EB_ERR_UNBOUND_BOOK; + goto failed; + } + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * `multi_id' must be a valid code. + */ + if (multi_id < 0 || book->subbook_current->multi_count <= multi_id) { + error_code = EB_ERR_NO_SUCH_MULTI_ID; + goto failed; + } + + /* + * `entry_index' must be a valid code. + */ + multi = book->subbook_current->multis + multi_id; + if (entry_index < 0 || multi->entry_count <= entry_index) { + error_code = EB_ERR_NO_SUCH_ENTRY_ID; + goto failed; + } + + if (multi->entries[entry_index].candidates_page == 0) { + error_code = EB_ERR_NO_CANDIDATES; + goto failed; + } + + position->page = multi->entries[entry_index].candidates_page; + position->offset = 0; + + LOG(("out: eb_multi_entry_candidates(position={%d,%d}) = %s", + position->page, position->offset, eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_multi_entry_candidates() = %s", + eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Multi search. + */ +EB_Error_Code +eb_search_multi(EB_Book *book, EB_Multi_Search_Code multi_id, + const char * const input_words[]) +{ + EB_Error_Code error_code; + EB_Search_Context *context; + EB_Search *entry; + EB_Word_Code word_code; + int word_count; + int i; + + eb_lock(&book->lock); + LOG(("in: eb_search_multi(book=%d, multi_id=%d, input_words=[below])", + (int)book->code, (int)multi_id)); + + if (eb_log_flag) { + for (i = 0; i < EB_MAX_KEYWORDS && input_words[i] != NULL; i++) { + LOG((" input_words[%d]=%s", i, + eb_quoted_string(input_words[i]))); + } + LOG((" input_words[%d]=NULL", i)); + } + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Check whether the current subbook has keyword search. + */ + if (multi_id < 0 || book->subbook_current->multi_count <= multi_id) { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + + /* + * Attach a search context for each keyword, and pre-search the + * keywords. + */ + eb_reset_search_contexts(book); + word_count = 0; + + for (i = 0, entry = book->subbook_current->multis[multi_id].entries; + i < book->subbook_current->multis[multi_id].entry_count; + i++, entry++) { + + if (input_words[i] == NULL) + break; + + /* + * Initialize search context. + */ + context = book->search_contexts + word_count; + context->code = EB_SEARCH_MULTI; + + /* + * Choose comparison functions. + */ + if (entry->candidates_page == 0) { + if (book->character_code == EB_CHARCODE_ISO8859_1) { + context->compare_pre = eb_pre_match_word; + context->compare_single = eb_match_word; + context->compare_group = eb_match_word; + } else { + context->compare_pre = eb_pre_match_word; + context->compare_single = eb_match_word; + context->compare_group = eb_match_word_kana_group; + } + } else { + if (book->character_code == EB_CHARCODE_ISO8859_1) { + context->compare_pre = eb_exact_pre_match_word_latin; + context->compare_single = eb_exact_match_word_latin; + context->compare_group = eb_exact_match_word_latin; + } else { + context->compare_pre = eb_exact_pre_match_word_jis; + context->compare_single = eb_exact_match_word_jis; + context->compare_group = eb_exact_match_word_kana_group; + } + } + context->page = entry->start_page; + if (context->page == 0) + continue; + + /* + * Make a fixed word and a canonicalized word to search from + * `input_words[i]'. + */ + error_code = eb_set_multiword(book, multi_id, i, input_words[i], + context->word, context->canonicalized_word, &word_code); + if (error_code == EB_ERR_EMPTY_WORD) + continue; + else if (error_code != EB_SUCCESS) + goto failed; + + /* + * Pre-search. + */ + error_code = eb_presearch_word(book, context); + if (error_code != EB_SUCCESS) + goto failed; + + word_count++; + } + if (word_count == 0) { + error_code = EB_ERR_NO_WORD; + goto failed; + } else if (book->subbook_current->multis[multi_id].entry_count <= i + && input_words[i] != NULL) { + error_code = EB_ERR_TOO_MANY_WORDS; + goto failed; + } + + /* + * Set `EB_SEARCH_NONE' to the rest unused search context. + */ + for (i = word_count; i < EB_MAX_KEYWORDS; i++) + (book->search_contexts + i)->code = EB_SEARCH_NONE; + + LOG(("out: eb_search_multi() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_reset_search_contexts(book); + LOG(("out: eb_search_multi() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + diff --git a/eb/multiplex.c b/eb/multiplex.c new file mode 100644 index 0000000..5c703cd --- /dev/null +++ b/eb/multiplex.c @@ -0,0 +1,966 @@ +/* + * Copyright (c) 2003-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include + +#ifdef HAVE_NET_IF_H +#include +#endif + +#include "build-pre.h" +#include "eb.h" +#include "build-post.h" +#include "dummyin6.h" + +#if !defined(HAVE_GETADDRINFO) || !defined(HAVE_GETNAMEINFO) +#include "getaddrinfo.h" +#endif + +#include "ebnet.h" + +#ifndef IF_NAMESIZE +#ifdef IFNAMSIZ +#define IF_NAMESIZE IFNAMSIZ +#else +#define IF_NAMESIZE 16 +#endif +#endif + +#ifndef AI_NUMERICHOST +#define AI_NUMERICHOST 0 +#endif +#ifndef NI_WITHSCOPEID +#define NI_WITHSCOPEID 0 +#endif + +#ifdef WINSOCK +#define close closesocket +#endif + +/* + * Maximum length (including NUL) of a TCP/UDP port number string. + */ +#define IN_PORTSTRLEN 6 + +/* + * Socket entry pool. + */ +typedef struct EBNet_Socket_Entry_Struct EBNet_Socket_Entry; +struct EBNet_Socket_Entry_Struct { + /* IPv6 or IPv4 Address of peer */ + char address[INET6_ADDRSTRLEN + IF_NAMESIZE]; + + /* destination port */ + in_port_t port; + + /* socket file */ + int file; + + /* reference count of the entry */ + int reference_count; + + /* object ID of the entry */ + int reference_id; + + /* lost synchronization flag */ + int lost_sync; + + /* next and previous entries. */ + EBNet_Socket_Entry *next; + EBNet_Socket_Entry *back; + + /* book name */ + char book_name[EBNET_MAX_BOOK_NAME_LENGTH + 1]; + + /* file path */ + char file_path[EB_MAX_RELATIVE_PATH_LENGTH + 1]; + + /* current file pointer */ + off_t offset; + + /* file size */ + off_t file_size; +}; + +static EBNet_Socket_Entry *ebnet_socket_entries; +static EBNet_Socket_Entry *ebnet_socket_entry_cache; + +/* + * Host name information cache. + */ +typedef struct { + /* hostname or IP address */ + char *host; + + /* IPv6 address of `host' */ + char ipv6_address[INET6_ADDRSTRLEN + IF_NAMESIZE]; + + /* IPv4 address of `host' */ + char ipv4_address[INET_ADDRSTRLEN]; +} EBNet_Host_Info; + +static EBNet_Host_Info ebnet_host_info_cache; + + +/* + * Hello and Bye hooks. + * + * The multiplex module invokes the hello hook each time it establish + * a new connection with a server, and invokes the bye hook each time + * it closes a last socket connected with a server. + */ +static int (*hello_hook)(int file); +static int (*bye_hook)(int file); + +/* + * Unexported functions. + */ +static void ebnet_get_addresses(const char *host, char *ipv6_address, + char *ipv4_address); +static EBNet_Socket_Entry *ebnet_find_multiplex_entry(const char *ipv6_address, + const char *ipv4_address, int port, int family); +static int ebnet_create_new_connection(const char *address, int port); +static void ebnet_add_socket_entry(EBNet_Socket_Entry *new_entry); +static void ebnet_delete_socket_entry(EBNet_Socket_Entry *target_entry); +static EBNet_Socket_Entry *ebnet_find_socket_entry(int file); + + +/* + * Initialize the multiplex module. + */ +void +ebnet_initialize_multiplex(void) +{ + ebnet_socket_entries = NULL; + ebnet_socket_entry_cache = NULL; + + ebnet_host_info_cache.host = NULL; + ebnet_host_info_cache.ipv6_address[0] = '\0'; + ebnet_host_info_cache.ipv4_address[0] = '\0'; + + hello_hook = NULL; + bye_hook = NULL; +} + + +/* + * Finalize the multiplex module. + */ +void +ebnet_finalize(void) +{ + while (ebnet_socket_entries != NULL) { + close(ebnet_socket_entries->file); + ebnet_delete_socket_entry(ebnet_socket_entries); + } + + ebnet_socket_entries = NULL; + ebnet_socket_entry_cache = NULL; + + if (ebnet_host_info_cache.host != NULL) + free(ebnet_host_info_cache.host); +} + + +/* + * Set hello hook. + */ +void +ebnet_set_hello_hook(int (*hook)(int file)) +{ + hello_hook = hook; +} + + +/* + * Set bye hook. + */ +void +ebnet_set_bye_hook(int (*hook)(int file)) +{ + bye_hook = hook; +} + + +/* + * Create a socket connected with a server. + * + * `host' is a host name or an IP address of the server. `port' is + * destination port number of the TCP connection. `family' is protocol + * family: PF_INET, PF_INET6 or PF_UNSPEC. + * + * Upon success, file descriptor of the socket is returned. + * Otherwise -1 is returned. + * + * If there has been a socket entry in `ebnet_socket_entries' which is + * connected with the server, this function simply duplicates the socket. + */ +int +ebnet_connect_socket(const char *host, int port, int family) +{ + char ipv6_address[INET6_ADDRSTRLEN + IF_NAMESIZE]; + char ipv4_address[INET_ADDRSTRLEN]; + EBNet_Socket_Entry *multiplex_entry = NULL; + EBNet_Socket_Entry *new_entry = NULL; + int new_file = -1; + + /* + * Get IP addresses of `host'. + */ + *ipv6_address = '\0'; + *ipv4_address = '\0'; + ebnet_get_addresses(host, ipv6_address, ipv4_address); + + switch (family) { + case PF_UNSPEC: + if (*ipv6_address == '\0' && *ipv4_address == '\0') + goto failed; + break; + + case PF_INET6: + if (*ipv6_address == '\0') + goto failed; + break; + + case PF_INET: + if (*ipv4_address == '\0') + goto failed; + break; + } + + /* + * Search `ebnet_socket_entries' for a connection entry with + * the server. + */ + multiplex_entry = ebnet_find_multiplex_entry(ipv6_address, ipv4_address, + port, family); + + /* + * Create a socket entry. + */ + new_entry = (EBNet_Socket_Entry *)malloc(sizeof(EBNet_Socket_Entry)); + if (new_entry == NULL) + goto failed; + + new_entry->address[0] = '\0'; + new_entry->port = port; + new_entry->file = -1; + new_entry->reference_count = 1; + new_entry->reference_id = -1; + new_entry->lost_sync = 0; + new_entry->next = NULL; + new_entry->back = NULL; + new_entry->book_name[0] = '\0'; + new_entry->file_path[0] = '\0'; + new_entry->offset = 0; + new_entry->file_size = 0; + + if (multiplex_entry != NULL) { + /* + * There is an IPv6 or IPv4 socket with the server. + * Duplicate the socket entry. + */ +#ifndef WINSOCK + new_file = dup(multiplex_entry->file); +#else /* WINSOCK */ + { + WSAPROTOCOL_INFO info; + + if (WSADuplicateSocket(multiplex_entry->file, + GetCurrentProcessId(), &info) != 0) + goto failed; + new_file = WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, + FROM_PROTOCOL_INFO, &info, 0, 0); + } +#endif /* WINSOCK */ + if (new_file < 0) + goto failed; + + strcpy(new_entry->address, multiplex_entry->address); + new_entry->file = new_file; + new_entry->reference_count = multiplex_entry->reference_count; + new_entry->reference_id = multiplex_entry->reference_id; + + } else { + /* + * There is no socket connected with the server. + * Establish a connection with the server. + */ + do { + if ((family == PF_INET6 || family == PF_UNSPEC) + && *ipv6_address != '\0') { + new_file = ebnet_create_new_connection(ipv6_address, port); + if (0 <= new_file) { + strcpy(new_entry->address, ipv6_address); + new_entry->file = new_file; + new_entry->reference_id = new_file; + break; + } + } + if ((family == PF_INET || family == PF_UNSPEC) + && *ipv4_address != '\0') { + new_file = ebnet_create_new_connection(ipv4_address, port); + if (0 <= new_file) { + strcpy(new_entry->address, ipv4_address); + new_entry->file = new_file; + new_entry->reference_id = new_file; + break; + } + } + goto failed; + + } while (0); + + } + + /* + * Add the entry to `ebnet_socket_entries'. + */ + ebnet_add_socket_entry(new_entry); + + /* + * Say hello. + */ + if (multiplex_entry == NULL && hello_hook != NULL) { + if (hello_hook(new_file) < 0) + goto failed; + } + + return new_file; + + /* + * An error occurs... + */ + failed: + if (new_entry != NULL) { + if (ebnet_find_socket_entry(new_file) != NULL) + ebnet_delete_socket_entry(new_entry); + else + free(new_entry); + } + if (new_file >= 0) + close(new_file); + return -1; +} + + +/* + * Get IPv6 and IPv4 addresses of `host'. + * + * `host' may be either an host name or an IP address. + * If `host' has an IPv6 address, the address is written on `ipv6_address'. + * Otherwise an empty string is written. + * If `host' has an IPv4 address, the address is written on `ipv4_address'. + * Otherwise an empty string is written. + */ +static void +ebnet_get_addresses(const char *host, char *ipv6_address, char *ipv4_address) +{ + struct addrinfo hints; + struct addrinfo *info_list = NULL; + struct addrinfo *info; + char dummy_service[IN_PORTSTRLEN]; + int gai_error; + + *ipv6_address = '\0'; + *ipv4_address = '\0'; + + /* + * Look up `ebnet_host_info_cache'. + */ + if (ebnet_host_info_cache.host != NULL + && strcmp(ebnet_host_info_cache.host, host) == 0) { + strcpy(ipv6_address, ebnet_host_info_cache.ipv6_address); + strcpy(ipv4_address, ebnet_host_info_cache.ipv4_address); + return; + } + + /* + * Get IP addresses using getaddrinfo(). + */ + hints.ai_flags = 0; + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = 0; + hints.ai_addrlen = 0; + hints.ai_canonname = NULL; + hints.ai_addr = NULL; + hints.ai_next = NULL; + + gai_error = getaddrinfo(host, EBNET_DEFAULT_PORT, &hints, &info_list); + if (gai_error != 0) + return; + + for (info = info_list; info != NULL; info = info->ai_next) { + if (info->ai_family != PF_INET6) + continue; + gai_error = getnameinfo(info->ai_addr, info->ai_addrlen, + ipv6_address, INET6_ADDRSTRLEN + IF_NAMESIZE, + dummy_service, sizeof(dummy_service), + NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID); +#if NI_WITHSCOPEID != 0 + if (gai_error != 0) { + gai_error = getnameinfo(info->ai_addr, info->ai_addrlen, + ipv6_address, INET6_ADDRSTRLEN + IF_NAMESIZE, + dummy_service, sizeof(dummy_service), + NI_NUMERICHOST | NI_NUMERICSERV); + } +#endif + if (gai_error == 0) + break; + *ipv6_address = '\0'; + } + + for (info = info_list; info != NULL; info = info->ai_next) { + if (info->ai_family != PF_INET) + continue; + gai_error = getnameinfo(info->ai_addr, info->ai_addrlen, + ipv4_address, INET_ADDRSTRLEN, + dummy_service, sizeof(dummy_service), + NI_NUMERICHOST | NI_NUMERICSERV); + if (gai_error == 0) + break; + *ipv4_address = '\0'; + } + + freeaddrinfo(info_list); + + /* + * Update `ebnet_host_info_cache'. + */ + if (ebnet_host_info_cache.host != NULL) { + free(ebnet_host_info_cache.host); + ebnet_host_info_cache.host = NULL; + } + ebnet_host_info_cache.host = malloc(strlen(host) + 1); + if (ebnet_host_info_cache.host != NULL) { + strcpy(ebnet_host_info_cache.host, host); + strcpy(ebnet_host_info_cache.ipv6_address, ipv6_address); + strcpy(ebnet_host_info_cache.ipv4_address, ipv4_address); + } + + return; +} + + +/* + * Find `ebnet_socket_entries' for a socket entry which matches with + * port, family and either `ipv6_address' or `ipv4_address'. + * + * If found, the function returns the entry. Otherwise it returns NULL. + */ +static EBNet_Socket_Entry * +ebnet_find_multiplex_entry(const char *ipv6_address, const char *ipv4_address, + int port, int family) +{ + EBNet_Socket_Entry *entry; + + /* + * Inspect `ebnet_socket_entry_cache'. + */ + if (ebnet_socket_entry_cache != NULL + && (family == PF_INET6 || family == PF_UNSPEC) + && strcasecmp(ebnet_socket_entry_cache->address, ipv6_address) == 0 + && ebnet_socket_entry_cache->port == port + && !ebnet_socket_entry_cache->lost_sync) { + return ebnet_socket_entry_cache; + } + if (ebnet_socket_entry_cache != NULL + && (family == PF_INET || family == PF_UNSPEC) + && strcasecmp(ebnet_socket_entry_cache->address, ipv4_address) == 0 + && ebnet_socket_entry_cache->port == port + && !ebnet_socket_entry_cache->lost_sync) { + return ebnet_socket_entry_cache; + } + + /* + * Then inspect entires in `ebnet_socket_entries'. + */ + for (entry = ebnet_socket_entries; entry != NULL; entry = entry->next) { + if ((family == PF_INET6 || family == PF_UNSPEC) + && strcasecmp(entry->address, ipv6_address) == 0 + && entry->port == port + && !entry->lost_sync) { + ebnet_socket_entry_cache = entry; + return entry; + } + if ((family == PF_INET || family == PF_UNSPEC) + && strcasecmp(entry->address, ipv4_address) == 0 + && entry->port == port + && !entry->lost_sync) { + ebnet_socket_entry_cache = entry; + return entry; + } + } + + return NULL; +} + + +/* + * Establish a TCP connection with an EBNET server. + * + * `host' is a host name or an IP address of the server. `port' is + * destination port number of the TCP connection. + * + * Upon success, file descriptor of the socket is returned. + * Otherwise -1 is returned. + */ +static int +ebnet_create_new_connection(const char *address, int port) +{ + struct addrinfo hints; + struct addrinfo *info_list = NULL; + int new_file = -1; + int gai_error; + char port_string[IN_PORTSTRLEN]; +#ifdef O_NONBLOCK + int file_flags; +#endif + + if (port < 0 || 65535 < port) + goto failed; + sprintf(port_string, "%d", port); + + hints.ai_flags = AI_NUMERICHOST; + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = 0; + hints.ai_addrlen = 0; + hints.ai_canonname = NULL; + hints.ai_addr = NULL; + hints.ai_next = NULL; + + gai_error = getaddrinfo(address, port_string, &hints, &info_list); + if (gai_error != 0) + goto failed; + + new_file = socket(info_list->ai_addr->sa_family, SOCK_STREAM, 0); + if (new_file < 0) + goto failed; + if (connect(new_file, info_list->ai_addr, info_list->ai_addrlen) < 0) + goto failed; + +#ifdef O_NONBLOCK + file_flags = fcntl(new_file, F_GETFL, 0); + if (file_flags >= 0) + fcntl(new_file, F_SETFL, file_flags | O_NONBLOCK); +#endif + + freeaddrinfo(info_list); + + return new_file; + + /* + * An error occurs... + */ + failed: + if (info_list != NULL) + freeaddrinfo(info_list); + if (new_file >= 0) + close(new_file); + return -1; +} + + +/* + * Add `new_entry' to `ebnet_socket_entries'. + */ +static void +ebnet_add_socket_entry(EBNet_Socket_Entry *new_entry) +{ + EBNet_Socket_Entry *entry; + int reference_count; + + /* + * Increment reference counts. + */ + reference_count = 1; + for (entry = ebnet_socket_entries; entry != NULL; entry = entry->next) { + if (entry->reference_id == new_entry->reference_id) { + entry->reference_count++; + reference_count = entry->reference_count; + } + } + + new_entry->reference_count = reference_count; + + /* + * Add `new_entry' to `ebnet_socket_entries'. + */ + if (ebnet_socket_entries != NULL) + ebnet_socket_entries->back = new_entry; + new_entry->back = NULL; + new_entry->next = ebnet_socket_entries; + ebnet_socket_entries = new_entry; + + ebnet_socket_entry_cache = new_entry; +} + + +/* + * Delete `target_entry' from `ebnet_socket_entries'. + */ +static void +ebnet_delete_socket_entry(EBNet_Socket_Entry *target_entry) +{ + EBNet_Socket_Entry *entry; + int new_reference_id; + + if (ebnet_socket_entry_cache == target_entry) + ebnet_socket_entry_cache = NULL; + + /* + * Delete `target_entry' from `ebnet_socket_entries'. + */ + if (target_entry->next != NULL) + target_entry->next->back = target_entry->back; + if (target_entry->back != NULL) + target_entry->back->next = target_entry->next; + if (target_entry == ebnet_socket_entries) + ebnet_socket_entries = ebnet_socket_entries->next; + + /* + * Decrement reference counts and update reference ID. + */ + entry = ebnet_socket_entries; + while (entry != NULL) { + if (entry->reference_id == target_entry->reference_id) { + new_reference_id = entry->file; + break; + } + entry = entry->next; + } + while (entry != NULL) { + if (entry->reference_id == target_entry->reference_id) { + entry->reference_id = new_reference_id; + entry->reference_count--; + } + entry = entry->next; + } + + /* + * Dispose `target_entry'. + */ + free(target_entry); +} + + +/* + * Disconnect with a server. + */ +void +ebnet_disconnect_socket(int file) +{ + EBNet_Socket_Entry *entry; + + /* + * Search `ebnet_socket_entries' for a connection entry with `file'. + */ + entry = ebnet_find_socket_entry(file); + if (entry == NULL) + return; + + /* + * Say good bye and close the connection. + */ + if (entry->reference_count == 1 && !entry->lost_sync && bye_hook != NULL) + bye_hook(entry->file); + + close(entry->file); + ebnet_delete_socket_entry(entry); +} + + +/* + * Reconnect `file'. + * It returns `file' upon success, -1 otherwise. + */ +int +ebnet_reconnect_socket(int file) +{ + EBNet_Socket_Entry *old_entry; + EBNet_Socket_Entry *new_entry = NULL; + int new_file; + + /* + * Search `ebnet_socket_entries' for a connection entry with `file'. + */ + old_entry = ebnet_find_socket_entry(file); + if (old_entry == NULL) + goto failed; + + /* + * Say good bye. + */ + if (old_entry->reference_count == 1 && !old_entry->lost_sync + && bye_hook != NULL) + bye_hook(old_entry->file); + + /* + * Establish a new connection with the server. + */ + ebnet_set_lost_sync(file); + new_file = ebnet_connect_socket(old_entry->address, old_entry->port, + PF_UNSPEC); + if (new_file < 0) + goto failed; + + new_entry = ebnet_find_socket_entry(new_file); + if (new_entry == NULL) + goto failed; + + /* + * Replace `old_entry' by `new_entry'. + */ + strcpy(new_entry->book_name, old_entry->book_name); + strcpy(new_entry->file_path, old_entry->file_path); + new_entry->offset = old_entry->offset; + new_entry->file_size = old_entry->file_size; + + ebnet_delete_socket_entry(old_entry); + +#ifndef WINSOCK + if (dup2(new_entry->file, file) < 0) + goto failed; + close(new_entry->file); + + if (new_entry->reference_id == new_entry->file) + new_entry->reference_id = file; + new_entry->file = file; +#else + close(file); +#endif + + return new_entry->file; + + /* + * An error occurs... + */ + failed: + if (new_entry != NULL && new_entry->file != file) + ebnet_disconnect_socket(new_entry->file); + return -1; +} + + +/* + * Mark files as lost-synchronization. + * + * Socket entries in `ebnet_socket_entries' which has the same reference + * ID as `file' are marked as lost-synchronization. + * The function doesn't close the files, but ebnet_connect_socket() + * doesn't duplicate lost-synchronized files. + */ +int +ebnet_set_lost_sync(int file) +{ + EBNet_Socket_Entry *entry; + int reference_id; + + entry = ebnet_find_socket_entry(file); + if (entry == NULL) + return -1; + reference_id = entry->reference_id; + + for (entry = ebnet_socket_entries; entry != NULL; entry = entry->next) { + if (entry->reference_id == reference_id) + entry->lost_sync = 1; + } + + return 0; +} + + +/* + * Search `ebnet_socket_entries' for a connection entry with `file'. + */ +static EBNet_Socket_Entry * +ebnet_find_socket_entry(int file) +{ + EBNet_Socket_Entry *entry; + + if (ebnet_socket_entry_cache != NULL + && ebnet_socket_entry_cache->file == file) + return ebnet_socket_entry_cache; + + for (entry = ebnet_socket_entries; entry != NULL; entry = entry->next) { + if (entry->file == file) { + ebnet_socket_entry_cache = entry; + return entry; + } + } + + return NULL; +} + + +/* + * Set book name associated with `file'. + */ +int +ebnet_set_book_name(int file, const char *book_name) +{ + EBNet_Socket_Entry *entry; + + entry = ebnet_find_socket_entry(file); + if (entry == NULL) + return -1; + + strncpy(entry->book_name, book_name, EBNET_MAX_BOOK_NAME_LENGTH + 1); + *(entry->book_name + EBNET_MAX_BOOK_NAME_LENGTH) = '\0'; + + return 0; +} + + +/* + * Get book name associated with `file'. + */ +const char * +ebnet_get_book_name(int file) +{ + EBNet_Socket_Entry *entry; + + entry = ebnet_find_socket_entry(file); + if (entry == NULL) + return NULL; + + return entry->book_name; +} + + +/* + * Set book name associated with `file'. + */ +int +ebnet_set_file_path(int file, const char *file_path) +{ + EBNet_Socket_Entry *entry; + + entry = ebnet_find_socket_entry(file); + if (entry == NULL) + return -1; + + strncpy(entry->file_path, file_path, EB_MAX_RELATIVE_PATH_LENGTH + 1); + *(entry->file_path + EB_MAX_RELATIVE_PATH_LENGTH + 1) = '\0'; + + return 0; +} + + +/* + * Get file path associated with `file'. + */ +const char * +ebnet_get_file_path(int file) +{ + EBNet_Socket_Entry *entry; + + entry = ebnet_find_socket_entry(file); + if (entry == NULL) + return NULL; + + return entry->file_path; +} + + +/* + * Set file offset. + */ +int +ebnet_set_offset(int file, off_t offset) +{ + EBNet_Socket_Entry *entry; + + entry = ebnet_find_socket_entry(file); + if (entry == NULL) + return -1; + + entry->offset = offset; + return 0; +} + + +/* + * Get file offset. + */ +off_t +ebnet_get_offset(int file) +{ + EBNet_Socket_Entry *entry; + + entry = ebnet_find_socket_entry(file); + if (entry == NULL) + return -1; + + return entry->offset; +} + + +/* + * Set file size. + */ +int +ebnet_set_file_size(int file, off_t file_size) +{ + EBNet_Socket_Entry *entry; + + entry = ebnet_find_socket_entry(file); + if (entry == NULL) + return -1; + + entry->file_size = file_size; + return 0; +} + + +/* + * Get file size. + */ +off_t +ebnet_get_file_size(int file) +{ + EBNet_Socket_Entry *entry; + + entry = ebnet_find_socket_entry(file); + if (entry == NULL) + return -1; + + return entry->file_size; +} + + diff --git a/eb/narwalt.c b/eb/narwalt.c new file mode 100644 index 0000000..eb07991 --- /dev/null +++ b/eb/narwalt.c @@ -0,0 +1,628 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "appendix.h" +#include "build-post.h" + +/* + * Unexported functions. + */ +static EB_Error_Code eb_narrow_character_text_jis(EB_Appendix *appendix, + int character_number, char *text); +static EB_Error_Code eb_narrow_character_text_latin(EB_Appendix *appendix, + int character_number, char *text); + +/* + * Hash macro for cache data. + */ +#define EB_HASH_ALT_CACHE(c) ((c) & 0x0f) + + +/* + * Examine whether the current subbook in `book' has a narrow font + * alternation or not. + */ +int +eb_have_narrow_alt(EB_Appendix *appendix) +{ + eb_lock(&appendix->lock); + LOG(("in: eb_have_narrow_alt(appendix=%d)", (int)appendix->code)); + + /* + * Current subbook must have been set. + */ + if (appendix->subbook_current == NULL) + goto failed; + + if (appendix->subbook_current->narrow_page == 0) + goto failed; + + LOG(("out: eb_have_narrow_alt() = %d", 1)); + eb_unlock(&appendix->lock); + + return 1; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_have_narrow_alt() = %d", 0)); + eb_unlock(&appendix->lock); + return 0; +} + + +/* + * Look up the character number of the start of the narrow font alternation + * of the current subbook in `book'. + */ +EB_Error_Code +eb_narrow_alt_start(EB_Appendix *appendix, int *start) +{ + EB_Error_Code error_code; + + eb_lock(&appendix->lock); + LOG(("in: eb_narrow_alt_start(appendix=%d)", (int)appendix->code)); + + /* + * Current subbook must have been set. + */ + if (appendix->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_APPSUB; + goto failed; + } + + if (appendix->subbook_current->narrow_page == 0) { + error_code = EB_ERR_NO_ALT; + goto failed; + } + + *start = appendix->subbook_current->narrow_start; + + LOG(("out: eb_narrow_alt_start(start=%d) = %s", *start, + eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *start = -1; + LOG(("out: eb_narrow_alt_start() = %s", eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + +/* + * Return the character number of the end of the narrow font alternation + * of the current subbook in `book'. + */ +EB_Error_Code +eb_narrow_alt_end(EB_Appendix *appendix, int *end) +{ + EB_Error_Code error_code; + + eb_lock(&appendix->lock); + LOG(("in: eb_narrow_alt_end(appendix=%d)", (int)appendix->code)); + + /* + * Current subbook must have been set. + */ + if (appendix->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_APPSUB; + goto failed; + } + + if (appendix->subbook_current->narrow_page == 0) { + error_code = EB_ERR_NO_ALT; + goto failed; + } + + *end = appendix->subbook_current->narrow_end; + + LOG(("out: eb_narrow_alt_end(end=%d) = %s", *end, + eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *end = -1; + LOG(("out: eb_narrow_alt_end() = %s", eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + +/* + * Get the alternation text of the character number `character_number'. + */ +EB_Error_Code +eb_narrow_alt_character_text(EB_Appendix *appendix, int character_number, + char *text) +{ + EB_Error_Code error_code; + + eb_lock(&appendix->lock); + LOG(("in: eb_narrow_alt_character_text(appendix=%d, character_number=%d)", + (int)appendix->code, character_number)); + + /* + * Current subbook must have been set. + */ + if (appendix->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_APPSUB; + goto failed; + } + + /* + * The narrow font must exist in the current subbook. + */ + if (appendix->subbook_current->narrow_page == 0) { + error_code = EB_ERR_NO_ALT; + goto failed; + } + + if (appendix->subbook_current->character_code == EB_CHARCODE_ISO8859_1) { + error_code = eb_narrow_character_text_latin(appendix, + character_number, text); + } else { + error_code = eb_narrow_character_text_jis(appendix, character_number, + text); + } + if (error_code != EB_SUCCESS) + goto failed; + + LOG(("out: eb_narrow_alt_character_text(text=%s) = %s", + eb_quoted_string(text), eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *text = '\0'; + LOG(("out: eb_narrow_alt_character_text() = %s", + eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + +/* + * Get the alternation text of the character number `character_number'. + */ +static EB_Error_Code +eb_narrow_character_text_jis(EB_Appendix *appendix, int character_number, + char *text) +{ + EB_Error_Code error_code; + int start; + int end; + off_t location; + EB_Alternation_Cache *cachep; + + LOG(("in: eb_narrow_alt_character_text_jis(appendix=%d, \ +character_number=%d)", + (int)appendix->code, character_number)); + + start = appendix->subbook_current->narrow_start; + end = appendix->subbook_current->narrow_end; + + /* + * Check for `character_number'. Is it in a font? + * This test works correctly even when the font doesn't exist in + * the current subbook because `start' and `end' have set to -1 + * in the case. + */ + if (character_number < start + || end < character_number + || (character_number & 0xff) < 0x21 + || 0x7e < (character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + + /* + * Calculate the location of alternation data. + */ + location + = (appendix->subbook_current->narrow_page - 1) * EB_SIZE_PAGE + + (((character_number >> 8) - (start >> 8)) * 0x5e + + (character_number & 0xff) - (start & 0xff)) + * (EB_MAX_ALTERNATION_TEXT_LENGTH + 1); + + /* + * Check for the cache data. + */ + cachep = appendix->narrow_cache + EB_HASH_ALT_CACHE(character_number); + if (cachep->character_number == character_number) { + memcpy(text, cachep->text, EB_MAX_ALTERNATION_TEXT_LENGTH + 1); + goto succeeded; + } + + /* + * Read the alternation data. + */ + if (zio_lseek(&appendix->subbook_current->zio, location, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_APP; + goto failed; + } + cachep->character_number = -1; + if (zio_read(&appendix->subbook_current->zio, cachep->text, + EB_MAX_ALTERNATION_TEXT_LENGTH + 1) + != EB_MAX_ALTERNATION_TEXT_LENGTH + 1) { + error_code = EB_ERR_FAIL_READ_APP; + goto failed; + } + + /* + * Update cache data. + */ + memcpy(text, cachep->text, EB_MAX_ALTERNATION_TEXT_LENGTH + 1); + cachep->text[EB_MAX_ALTERNATION_TEXT_LENGTH] = '\0'; + cachep->character_number = character_number; + + succeeded: + LOG(("out: eb_narrow_alt_character_text_jis(text=%s) = %s", + eb_quoted_string(text), eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *text = '\0'; + LOG(("out: eb_narrow_alt_character_text_jis() = %s", + eb_error_string(error_code))); + return error_code; +} + + +/* + * Get the alternation text of the character number `character_number'. + */ +static EB_Error_Code +eb_narrow_character_text_latin(EB_Appendix *appendix, int character_number, + char *text) +{ + EB_Error_Code error_code; + int start; + int end; + off_t location; + EB_Alternation_Cache *cache_p; + + LOG(("in: eb_narrow_alt_character_text_latin(appendix=%d, \ +character_number=%d)", + (int)appendix->code, character_number)); + + start = appendix->subbook_current->narrow_start; + end = appendix->subbook_current->narrow_end; + + /* + * Check for `character_number'. Is it in a font? + * This test works correctly even when the font doesn't exist in + * the current subbook because `start' and `end' have set to -1 + * in the case. + */ + if (character_number < start + || end < character_number + || (character_number & 0xff) < 0x01 + || 0xfe < (character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + + /* + * Calculate the location of alternation data. + */ + location + = (appendix->subbook_current->narrow_page - 1) * EB_SIZE_PAGE + + (((character_number >> 8) - (start >> 8)) * 0xfe + + (character_number & 0xff) - (start & 0xff)) + * (EB_MAX_ALTERNATION_TEXT_LENGTH + 1); + + /* + * Check for the cache data. + */ + cache_p = appendix->narrow_cache + EB_HASH_ALT_CACHE(character_number); + if (cache_p->character_number == character_number) { + memcpy(text, cache_p->text, EB_MAX_ALTERNATION_TEXT_LENGTH + 1); + goto succeeded; + } + + /* + * Read the alternation data. + */ + if (zio_lseek(&appendix->subbook_current->zio, location, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_APP; + goto failed; + } + cache_p->character_number = -1; + if (zio_read(&appendix->subbook_current->zio, cache_p->text, + EB_MAX_ALTERNATION_TEXT_LENGTH + 1) + != EB_MAX_ALTERNATION_TEXT_LENGTH + 1) { + error_code = EB_ERR_FAIL_READ_APP; + goto failed; + } + + /* + * Update cache data. + */ + memcpy(text, cache_p->text, EB_MAX_ALTERNATION_TEXT_LENGTH + 1); + cache_p->text[EB_MAX_ALTERNATION_TEXT_LENGTH] = '\0'; + cache_p->character_number = character_number; + + succeeded: + LOG(("out: eb_narrow_alt_character_text_latin(text=%s) = %s", + eb_quoted_string(text), eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *text = '\0'; + LOG(("out: eb_narrow_alt_character_text_latin() = %s", + eb_error_string(error_code))); + return error_code; +} + + +/* + * Return next `n'th character number from `*character_number'. + */ +EB_Error_Code +eb_forward_narrow_alt_character(EB_Appendix *appendix, int n, + int *character_number) +{ + EB_Error_Code error_code; + int start; + int end; + int i; + + if (n < 0) { + return eb_backward_narrow_alt_character(appendix, -n, + character_number); + } + + eb_lock(&appendix->lock); + LOG(("in: eb_forward_narrow_alt_character(appendix=%d, n=%d, \ +character_number=%d)", + (int)appendix->code, n, *character_number)); + + /* + * Current subbook must have been set. + */ + if (appendix->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_APPSUB; + goto failed; + } + + /* + * The narrow font must exist in the current subbook. + */ + if (appendix->subbook_current->narrow_page == 0) { + error_code = EB_ERR_NO_ALT; + goto failed; + } + + start = appendix->subbook_current->narrow_start; + end = appendix->subbook_current->narrow_end; + + if (appendix->subbook_current->character_code == EB_CHARCODE_ISO8859_1) { + /* + * Check for `*character_number'. (ISO 8859 1) + */ + if (*character_number < start + || end < *character_number + || (*character_number & 0xff) < 0x01 + || 0xfe < (*character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + + /* + * Get character number. (ISO 8859 1) + */ + for (i = 0; i < n; i++) { + if (0xfe <= (*character_number & 0xff)) + *character_number += 3; + else + *character_number += 1; + if (end < *character_number) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + } + } else { + /* + * Check for `*character_number'. (JIS X 0208) + */ + if (*character_number < start + || end < *character_number + || (*character_number & 0xff) < 0x21 + || 0x7e < (*character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + + /* + * Get character number. (JIS X 0208) + */ + for (i = 0; i < n; i++) { + if (0x7e <= (*character_number & 0xff)) + *character_number += 0xa3; + else + *character_number += 1; + if (end < *character_number) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + } + } + + LOG(("out: eb_forkward_narrow_alt_character(character_number=%d) = %s", + *character_number, eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *character_number = -1; + LOG(("out: eb_forward_narrow_alt_character() = %s", + eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + +/* + * Return previous `n'th character number from `*character_number'. + */ +EB_Error_Code +eb_backward_narrow_alt_character(EB_Appendix *appendix, int n, + int *character_number) +{ + EB_Error_Code error_code; + int start; + int end; + int i; + + if (n < 0) { + return eb_forward_narrow_alt_character(appendix, -n, character_number); + } + + eb_lock(&appendix->lock); + LOG(("in: eb_backward_narrow_alt_character(appendix=%d, n=%d, \ +character_number=%d)", + (int)appendix->code, n, *character_number)); + + /* + * Current subbook must have been set. + */ + if (appendix->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_APPSUB; + goto failed; + } + + /* + * The narrow font must exist in the current subbook. + */ + if (appendix->subbook_current->narrow_page == 0) { + error_code = EB_ERR_NO_ALT; + goto failed; + } + + start = appendix->subbook_current->narrow_start; + end = appendix->subbook_current->narrow_end; + + if (appendix->subbook_current->character_code == EB_CHARCODE_ISO8859_1) { + /* + * Check for `*character_number'. (ISO 8859 1) + */ + if (*character_number < start + || end < *character_number + || (*character_number & 0xff) < 0x01 + || 0xfe < (*character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + + /* + * Get character number. (ISO 8859 1) + */ + for (i = 0; i < n; i++) { + if ((*character_number & 0xff) <= 0x01) + *character_number -= 3; + else + *character_number -= 1; + if (*character_number < start) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + } + } else { + /* + * Check for `*character_number'. (JIS X 0208) + */ + if (*character_number < start + || end < *character_number + || (*character_number & 0xff) < 0x21 + || 0x7e < (*character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + + /* + * Get character number. (JIS X 0208) + */ + for (i = 0; i < n; i++) { + if ((*character_number & 0xff) <= 0x21) + *character_number -= 0xa3; + else + *character_number -= 1; + if (*character_number < start) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + } + } + + LOG(("out: eb_backward_narrow_alt_character(character_number=%d) = %s", + *character_number, eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *character_number = -1; + LOG(("out: eb_backward_narrow_alt_character() = %s", + eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + diff --git a/eb/narwfont.c b/eb/narwfont.c new file mode 100644 index 0000000..245a751 --- /dev/null +++ b/eb/narwfont.c @@ -0,0 +1,1099 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "font.h" +#include "build-post.h" + +/* + * Unexported functions. + */ +static EB_Error_Code eb_narrow_character_bitmap_jis(EB_Book *book, + int character_number, char *bitmap); +static EB_Error_Code eb_narrow_character_bitmap_latin(EB_Book *book, + int character_number, char *bitmap); + + +/* + * Open a font file. + */ +EB_Error_Code +eb_open_narrow_font_file(EB_Book *book, EB_Font_Code font_code) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + EB_Font *narrow_font; + char font_path_name[EB_MAX_PATH_LENGTH + 1]; + Zio_Code zio_code; + + LOG(("in: eb_open_narrow_font(book=%d, font_code=%d)", + (int)book->code, (int)font_code)); + + subbook = book->subbook_current; + narrow_font = subbook->narrow_fonts + font_code; + + if (narrow_font->font_code == EB_FONT_INVALID) { + error_code = EB_ERR_FAIL_OPEN_FONT; + goto failed; + } + if (0 <= zio_file(&narrow_font->zio)) + goto succeeded; + + /* + * If the book is EBWING, open the narrow font file. + * (In EB books, font data are stored in the `START' file.) + */ + zio_code = ZIO_INVALID; + + if (book->disc_code == EB_DISC_EB) { + if (narrow_font->initialized) { + if (zio_mode(&narrow_font->zio) != ZIO_INVALID) + zio_code = ZIO_REOPEN; + } else { + zio_code = zio_mode(&subbook->text_zio); + } + eb_compose_path_name2(book->path, subbook->directory_name, + subbook->text_file_name, font_path_name); + + } else { + if (narrow_font->initialized) { + if (zio_mode(&narrow_font->zio) != ZIO_INVALID) + zio_code = ZIO_REOPEN; + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->gaiji_directory_name, narrow_font->file_name, + font_path_name); + } else { + eb_canonicalize_file_name(narrow_font->file_name); + if (eb_find_file_name3(book->path, subbook->directory_name, + subbook->gaiji_directory_name, narrow_font->file_name, + narrow_font->file_name) != EB_SUCCESS) { + error_code = EB_ERR_FAIL_OPEN_FONT; + goto failed; + } + + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->gaiji_directory_name, narrow_font->file_name, + font_path_name); + eb_path_name_zio_code(font_path_name, ZIO_PLAIN, &zio_code); + } + } + + if (zio_code != ZIO_INVALID + && zio_open(&narrow_font->zio, font_path_name, zio_code) < 0) { + error_code = EB_ERR_FAIL_OPEN_FONT; + goto failed; + } + + succeeded: + LOG(("out: eb_open_narrow_font_file(file=%d) = %s", + zio_file(&narrow_font->zio), eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_open_narrow_font_file() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Read font header. + */ +EB_Error_Code +eb_load_narrow_font_header(EB_Book *book, EB_Font_Code font_code) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + EB_Font *narrow_font; + char buffer[16]; + int character_count; + Zio *zio; + + LOG(("in: eb_load_narrow_font_header(book=%d, font_code=%d)", + (int)book->code, (int)font_code)); + + subbook = book->subbook_current; + narrow_font = subbook->narrow_fonts + font_code; + zio = &narrow_font->zio; + + if (narrow_font->initialized) + goto succeeded; + + /* + * Read information from the text file. + */ + if (zio_lseek(zio, ((off_t) narrow_font->page - 1) * EB_SIZE_PAGE, + SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_FONT; + goto failed; + } + if (zio_read(zio, buffer, 16) != 16) { + error_code = EB_ERR_FAIL_READ_FONT; + goto failed; + } + + /* + * If the number of characters (`character_count') is 0, the font + * is unavailable. We return EB_ERR_NO_SUCH_FONT. + */ + character_count = eb_uint2(buffer + 12); + if (character_count == 0) { + zio_close(zio); + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + /* + * Set the information. + */ + narrow_font->start = eb_uint2(buffer + 10); + if (book->character_code == EB_CHARCODE_ISO8859_1) { + narrow_font->end = narrow_font->start + + ((character_count / 0xfe) << 8) + (character_count % 0xfe) - 1; + if (0xfe < (narrow_font->end & 0xff)) + narrow_font->end += 3; + } else { + narrow_font->end = narrow_font->start + + ((character_count / 0x5e) << 8) + (character_count % 0x5e) - 1; + if (0x7e < (narrow_font->end & 0xff)) + narrow_font->end += 0xa3; + } + + if (book->character_code == EB_CHARCODE_ISO8859_1) { + if ((narrow_font->start & 0xff) < 0x01 + || 0xfe < (narrow_font->start & 0xff) + || narrow_font->start < 0x0001 + || 0x1efe < narrow_font->end) { + error_code = EB_ERR_UNEXP_FONT; + goto failed; + } + } else { + if ((narrow_font->start & 0xff) < 0x21 + || 0x7e < (narrow_font->start & 0xff) + || narrow_font->start < 0xa121 + || 0xfe7e < narrow_font->end) { + error_code = EB_ERR_UNEXP_FONT; + goto failed; + } + } + + succeeded: + LOG(("out: eb_load_narrow_font_header()", eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_load_narrow_font_header()", eb_error_string(error_code))); + return error_code; +} + + +/* + * Read font glyph data. + */ +EB_Error_Code +eb_load_narrow_font_glyphs(EB_Book *book, EB_Font_Code font_code) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + EB_Font *narrow_font; + int character_count; + size_t glyph_size; + size_t total_glyph_size; + Zio *zio; + + LOG(("in: eb_load_narrow_font_glyphs(book=%d, font_code=%d)", + (int)book->code, (int)font_code)); + + subbook = book->subbook_current; + narrow_font = subbook->narrow_fonts + font_code; + zio = &narrow_font->zio; + + if (narrow_font->glyphs != NULL) + goto succeeded; + + /* + * Calculate size of glyph data (`total_glyph_size'). + * + * Set the number of local defined characters to `character_count'. + * Set the number of character glpyhs in a page to `page_glyph_count'. + * Set size of glyph data to `total_glyph_size'. + */ + if (book->character_code == EB_CHARCODE_ISO8859_1) { + character_count + = ((narrow_font->end >> 8) - (narrow_font->start >> 8)) * 0xfe + + ((narrow_font->end & 0xff) - (narrow_font->start & 0xff)) + 1; + } else { + character_count + = ((narrow_font->end >> 8) - (narrow_font->start >> 8)) * 0x5e + + ((narrow_font->end & 0xff) - (narrow_font->start & 0xff)) + 1; + } + + eb_narrow_font_size2(font_code, &glyph_size); + total_glyph_size + = (character_count / (1024 / glyph_size)) * 1024 + + (character_count % (1024 / glyph_size)) * glyph_size; + + /* + * Allocate memory for glyph data. + */ + narrow_font->glyphs = (char *) malloc(total_glyph_size); + if (narrow_font->glyphs == NULL) { + error_code = EB_ERR_MEMORY_EXHAUSTED; + goto failed; + } + + /* + * Read glyphs. + */ + if (zio_lseek(zio, (off_t) narrow_font->page * EB_SIZE_PAGE, SEEK_SET) + < 0) { + error_code = EB_ERR_FAIL_SEEK_FONT; + goto failed; + } + if (zio_read(zio, narrow_font->glyphs, total_glyph_size) + != total_glyph_size) { + error_code = EB_ERR_FAIL_READ_FONT; + goto failed; + } + + succeeded: + LOG(("out: eb_load_narrow_font_glyphs()", eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_load_narrow_font_glyphs()", eb_error_string(error_code))); + if (narrow_font->glyphs != NULL) { + free(narrow_font->glyphs); + narrow_font->glyphs = NULL; + } + return error_code; +} + + +/* + * Examine whether the current subbook in `book' has a narrow font. + */ +int +eb_have_narrow_font(EB_Book *book) +{ + int i; + + eb_lock(&book->lock); + LOG(("in: eb_have_narrow_font(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) + goto failed; + + /* + * If the narrow font has already set, the subbook has narrow fonts. + */ + if (book->subbook_current->narrow_current != NULL) + goto succeeded; + + /* + * Scan the font table. + */ + for (i = 0; i < EB_MAX_FONTS; i++) { + if (book->subbook_current->narrow_fonts[i].font_code + != EB_FONT_INVALID) + break; + } + + if (EB_MAX_FONTS <= i) + goto failed; + + succeeded: + LOG(("out: eb_have_narrow_font() = %d", 1)); + eb_unlock(&book->lock); + return 1; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_have_narrow_font() = %d", 0)); + eb_unlock(&book->lock); + return 0; +} + + +/* + * Get width of the font `font_code' in the current subbook of `book'. + */ +EB_Error_Code +eb_narrow_font_width(EB_Book *book, int *width) +{ + EB_Error_Code error_code; + EB_Font_Code font_code; + + eb_lock(&book->lock); + LOG(("in: eb_narrow_font_width(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * The narrow font must exist in the current subbook. + */ + if (book->subbook_current->narrow_current == NULL) { + error_code = EB_ERR_NO_CUR_FONT; + goto failed; + } + + /* + * Calculate width. + */ + font_code = book->subbook_current->narrow_current->font_code; + error_code = eb_narrow_font_width2(font_code, width); + if (error_code != EB_SUCCESS) + goto failed; + + LOG(("out: eb_narrow_font_width(width=%d) = %s", (int)*width, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *width = 0; + LOG(("out: eb_narrow_font_width() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Get width of the font `font_code'. + */ +EB_Error_Code +eb_narrow_font_width2(EB_Font_Code font_code, int *width) +{ + EB_Error_Code error_code; + + LOG(("in: eb_narrow_font_width2(font_code=%d)", (int)font_code)); + + switch (font_code) { + case EB_FONT_16: + *width = EB_WIDTH_NARROW_FONT_16; + break; + case EB_FONT_24: + *width = EB_WIDTH_NARROW_FONT_24; + break; + case EB_FONT_30: + *width = EB_WIDTH_NARROW_FONT_30; + break; + case EB_FONT_48: + *width = EB_WIDTH_NARROW_FONT_48; + break; + default: + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + LOG(("out: eb_narrow_font_width2(width=%d) = %s", *width, + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *width = 0; + LOG(("out: eb_narrow_font_width2() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Get the bitmap size of the font `font_code' in the current subbook + * of `book'. + */ +EB_Error_Code +eb_narrow_font_size(EB_Book *book, size_t *size) +{ + EB_Error_Code error_code; + EB_Font_Code font_code; + int width; + int height; + + eb_lock(&book->lock); + LOG(("in: eb_narrow_font_size(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * The narrow font must exist in the current subbook. + */ + if (book->subbook_current->narrow_current == NULL) { + error_code = EB_ERR_NO_CUR_FONT; + goto failed; + } + + /* + * Calculate size. + */ + font_code = book->subbook_current->narrow_current->font_code; + error_code = eb_narrow_font_width2(font_code, &width); + if (error_code != EB_SUCCESS) + goto failed; + error_code = eb_font_height2(font_code, &height); + if (error_code != EB_SUCCESS) + goto failed; + *size = (width / 8) * height; + + LOG(("out: eb_narrow_font_size(size=%ld) = %s", (long)*size, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *size = 0; + LOG(("out: eb_narrow_font_size() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Get the bitmap size of a character in `font_code' of the current + * subbook. + */ +EB_Error_Code +eb_narrow_font_size2(EB_Font_Code font_code, size_t *size) +{ + EB_Error_Code error_code; + + LOG(("in: eb_narrow_font_size2(font_code=%d)", (int)font_code)); + + switch (font_code) { + case EB_FONT_16: + *size = EB_SIZE_NARROW_FONT_16; + break; + case EB_FONT_24: + *size = EB_SIZE_NARROW_FONT_24; + break; + case EB_FONT_30: + *size = EB_SIZE_NARROW_FONT_30; + break; + case EB_FONT_48: + *size = EB_SIZE_NARROW_FONT_48; + break; + default: + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + LOG(("out: eb_narrow_font_size2(size=%ld) = %s", (long)*size, + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *size = 0; + LOG(("out: eb_narrow_font_size2() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Get the character number of the start of the narrow font of the current + * subbook in `book'. + */ +EB_Error_Code +eb_narrow_font_start(EB_Book *book, int *start) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_narrow_font_start(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * The narrow font must exist in the current subbook. + */ + if (book->subbook_current->narrow_current == NULL) { + error_code = EB_ERR_NO_CUR_FONT; + goto failed; + } + + *start = book->subbook_current->narrow_current->start; + + LOG(("out: eb_narrow_font_start(start=%d) = %s", *start, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_narrow_font_start() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Get the character number of the end of the narrow font of the current + * subbook in `book'. + */ +EB_Error_Code +eb_narrow_font_end(EB_Book *book, int *end) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_narrow_font_end(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * The narrow font must exist in the current subbook. + */ + if (book->subbook_current->narrow_current == NULL) { + error_code = EB_ERR_NO_CUR_FONT; + goto failed; + } + + *end = book->subbook_current->narrow_current->end; + + LOG(("out: eb_narrow_font_end(end=%d) = %s", *end, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_narrow_font_end() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Get bitmap data of the character with character number `character_number' + * in the current narrow font of the current subbook in `book'. + */ +EB_Error_Code +eb_narrow_font_character_bitmap(EB_Book *book, int character_number, + char *bitmap) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_narrow_font_character_bitmap(book=%d, character_number=%d)", + (int)book->code, character_number)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * The narrow font must exist in the current subbook. + */ + if (book->subbook_current->narrow_current == NULL) { + error_code = EB_ERR_NO_CUR_FONT; + goto failed; + } + + if (book->character_code == EB_CHARCODE_ISO8859_1) { + error_code = eb_narrow_character_bitmap_latin(book, character_number, + bitmap); + } else { + error_code = eb_narrow_character_bitmap_jis(book, character_number, + bitmap); + } + if (error_code != EB_SUCCESS) + goto failed; + + LOG(("out: eb_narrow_font_character_bitmap() = %s", + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *bitmap = '\0'; + LOG(("out: eb_narrow_font_character_bitmap() = %s", + eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Get bitmap data of the character with character number `character_number' + * in the current narrow font of the current subbook in `book'. + */ +static EB_Error_Code +eb_narrow_character_bitmap_jis(EB_Book *book, int character_number, + char *bitmap) +{ + EB_Error_Code error_code; + EB_Font *narrow_current; + int start; + int end; + int character_index; + off_t offset; + size_t size; + Zio *zio; + + LOG(("in: eb_narrow_font_character_bitmap_jis(book=%d, \ +character_number=%d)", + (int)book->code, character_number)); + + start = book->subbook_current->narrow_current->start; + end = book->subbook_current->narrow_current->end; + narrow_current = book->subbook_current->narrow_current; + + /* + * Check for `character_number'. Is it in a range of bitmaps? + * This test works correctly even when the font doesn't exist in + * the current subbook because `start' and `end' have set to -1 + * in the case. + */ + if (character_number < start + || end < character_number + || (character_number & 0xff) < 0x21 + || 0x7e < (character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + + /* + * Calculate the size and the location of bitmap data. + */ + error_code = eb_narrow_font_size(book, &size); + if (error_code != EB_SUCCESS) + goto failed; + + character_index = ((character_number >> 8) - (start >> 8)) * 0x5e + + ((character_number & 0xff) - (start & 0xff)); + offset + = (character_index / (1024 / size)) * 1024 + + (character_index % (1024 / size)) * size; + + /* + * Read bitmap data. + */ + if (narrow_current->glyphs == NULL) { + zio = &narrow_current->zio; + + if (zio_lseek(zio, + (off_t) narrow_current->page * EB_SIZE_PAGE + offset, + SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_FONT; + goto failed; + } + if (zio_read(zio, bitmap, size) != size) { + error_code = EB_ERR_FAIL_READ_FONT; + goto failed; + } + } else { + memcpy(bitmap, narrow_current->glyphs + offset, size); + } + + LOG(("out: eb_narrow_font_character_bitmap_jis() = %s", + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *bitmap = '\0'; + LOG(("out: eb_narrow_font_character_bitmap_jis() = %s", + eb_error_string(error_code))); + return error_code; +} + + +/* + * Get bitmap data of the character with character number `character_number' + * in the current narrow font of the current subbook in `book'. + */ +static EB_Error_Code +eb_narrow_character_bitmap_latin(EB_Book *book, int character_number, + char *bitmap) +{ + EB_Error_Code error_code; + EB_Font *narrow_current; + int start; + int end; + int character_index; + off_t offset; + size_t size; + Zio *zio; + + LOG(("in: eb_narrow_font_character_bitmap_latin(book=%d, \ +character_number=%d)", + (int)book->code, character_number)); + + start = book->subbook_current->narrow_current->start; + end = book->subbook_current->narrow_current->end; + narrow_current = book->subbook_current->narrow_current; + + /* + * Check for `ch'. Is it in a range of bitmaps? + * This test works correctly even when the font doesn't exist in + * the current subbook because `start' and `end' have set to -1 + * in the case. + */ + if (character_number < start + || end < character_number + || (character_number & 0xff) < 0x01 + || 0xfe < (character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + + /* + * Calculate the size and the location of bitmap data. + */ + error_code = eb_narrow_font_size(book, &size); + if (error_code != EB_SUCCESS) + goto failed; + + character_index = ((character_number >> 8) - (start >> 8)) * 0xfe + + ((character_number & 0xff) - (start & 0xff)); + offset + = (character_index / (1024 / size)) * 1024 + + (character_index % (1024 / size)) * size; + + /* + * Read bitmap data. + */ + if (narrow_current->glyphs == NULL) { + zio = &narrow_current->zio; + + if (zio_lseek(zio, + (off_t) narrow_current->page * EB_SIZE_PAGE + offset, + SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_FONT; + goto failed; + } + if (zio_read(zio, bitmap, size) != size) { + error_code = EB_ERR_FAIL_READ_FONT; + goto failed; + } + } else { + memcpy(bitmap, narrow_current->glyphs + offset, size); + } + + LOG(("out: eb_narrow_font_character_bitmap_latin() = %s", + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *bitmap = '\0'; + LOG(("out: eb_narrow_font_character_bitmap_latin() = %s", + eb_error_string(error_code))); + return error_code; +} + + +/* + * Return next `n'th character number from `character_number'. + */ +EB_Error_Code +eb_forward_narrow_font_character(EB_Book *book, int n, int *character_number) +{ + EB_Error_Code error_code; + int start; + int end; + int i; + + if (n < 0) + return eb_backward_narrow_font_character(book, -n, character_number); + + eb_lock(&book->lock); + LOG(("in: eb_forward_narrow_font_character(book=%d, n=%d, \ +character_number=%d)", + (int)book->code, n, *character_number)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * The narrow font must exist in the current subbook. + */ + if (book->subbook_current->narrow_current == NULL) { + error_code = EB_ERR_NO_CUR_FONT; + goto failed; + } + + start = book->subbook_current->narrow_current->start; + end = book->subbook_current->narrow_current->end; + + if (book->character_code == EB_CHARCODE_ISO8859_1) { + /* + * Check for `*character_number'. (ISO 8859 1) + */ + if (*character_number < start + || end < *character_number + || (*character_number & 0xff) < 0x01 + || 0xfe < (*character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + + /* + * Get character number. (ISO 8859 1) + */ + for (i = 0; i < n; i++) { + if (0xfe <= (*character_number & 0xff)) + *character_number += 3; + else + *character_number += 1; + if (end < *character_number) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + } + } else { + /* + * Check for `*character_number'. (JIS X 0208) + */ + if (*character_number < start + || end < *character_number + || (*character_number & 0xff) < 0x21 + || 0x7e < (*character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + + /* + * Get character number. (JIS X 0208) + */ + for (i = 0; i < n; i++) { + if (0x7e <= (*character_number & 0xff)) + *character_number += 0xa3; + else + *character_number += 1; + if (end < *character_number) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + } + } + + LOG(("out: eb_forward_narrow_font_character(character_number=%d) = %s", + *character_number, eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *character_number = -1; + LOG(("out: eb_forward_narrow_font_character() = %s", + eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Return previous `n'th character number from `*character_number'. + */ +EB_Error_Code +eb_backward_narrow_font_character(EB_Book *book, int n, int *character_number) +{ + EB_Error_Code error_code; + int start; + int end; + int i; + + if (n < 0) + return eb_forward_narrow_font_character(book, -n, character_number); + + eb_lock(&book->lock); + LOG(("in: eb_backward_narrow_font_character(book=%d, n=%d, \ +character_number=%d)", + (int)book->code, n, *character_number)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * The narrow font must exist in the current subbook. + */ + if (book->subbook_current->narrow_current == NULL) { + error_code = EB_ERR_NO_CUR_FONT; + goto failed; + } + + start = book->subbook_current->narrow_current->start; + end = book->subbook_current->narrow_current->end; + + if (book->character_code == EB_CHARCODE_ISO8859_1) { + /* + * Check for `*character_number'. (ISO 8859 1) + */ + if (*character_number < start + || end < *character_number + || (*character_number & 0xff) < 0x01 + || 0xfe < (*character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + + /* + * Get character number. (ISO 8859 1) + */ + for (i = 0; i < n; i++) { + if ((*character_number & 0xff) <= 0x01) + *character_number -= 3; + else + *character_number -= 1; + if (*character_number < start) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + } + } else { + /* + * Check for `*character_number'. (JIS X 0208) + */ + if (*character_number < start + || end < *character_number + || (*character_number & 0xff) < 0x21 + || 0x7e < (*character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + + /* + * Get character number. (JIS X 0208) + */ + for (i = 0; i < n; i++) { + if ((*character_number & 0xff) <= 0x21) + *character_number -= 0xa3; + else + *character_number -= 1; + if (*character_number < start) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + } + } + + LOG(("out: eb_backward_narrow_font_character(character_number=%d) = %s", + *character_number, eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *character_number = -1; + LOG(("out: eb_backward_narrow_font_character() = %s", + eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + diff --git a/eb/readtext.c b/eb/readtext.c new file mode 100644 index 0000000..6e3c218 --- /dev/null +++ b/eb/readtext.c @@ -0,0 +1,2148 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "text.h" +#include "build-post.h" + +/* + * The maximum number of arguments for an escape sequence. + */ +#define EB_MAX_ARGV 7 + +/* + * Read next when the length of cached data is shorter than this value. + */ +#define SIZE_FEW_REST 48 + +/* + * Special skip-code that represents `no skip-code is set'. + */ +#define SKIP_CODE_NONE -1 + +/* + * Cache data buffer. + */ +static char cache_buffer[EB_SIZE_PAGE]; + +/* + * Book code of which `cache_buffer' records data. + */ +static EB_Book_Code cache_book_code = EB_BOOK_NONE; + +/* + * Location of cache data loaded in `cache_buffer'. + */ +static off_t cache_location; + +/* + * Length of cache data loaded in `cache_buffer'. + */ +static size_t cache_length; + +/* + * Null hook. + */ +static const EB_Hook null_hook = {EB_HOOK_NULL, NULL}; + +/* + * Mutex for cache variables. + */ +#ifdef ENABLE_PTHREAD +static pthread_mutex_t cache_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif + +/* + * Unexported functions. + */ +static EB_Error_Code eb_read_text_internal(EB_Book *book, + EB_Appendix *appendix, EB_Hookset *hookset, void *container, + size_t text_max_length, char *text, ssize_t *text_length, + int forward_only); +static int eb_is_stop_code(EB_Book *book, EB_Appendix *appendix, + unsigned int code0, unsigned int code1); + + +/* + * Initialize text context of `book'. + */ +void +eb_initialize_text_context(EB_Book *book) +{ + LOG(("in: eb_initialize_text_context(book=%d)", (int)book->code)); + + book->text_context.code = EB_TEXT_INVALID; + book->text_context.location = -1; + book->text_context.out = NULL; + book->text_context.out_rest_length = 0; + book->text_context.unprocessed = NULL; + book->text_context.unprocessed_size = 0; + book->text_context.out_step = 0; + book->text_context.narrow_flag = 0; + book->text_context.printable_count = 0; + book->text_context.file_end_flag = 0; + book->text_context.text_status = EB_TEXT_STATUS_CONTINUED; + book->text_context.skip_code = SKIP_CODE_NONE; + book->text_context.auto_stop_code = -1; + book->text_context.candidate[0] = '\0'; + book->text_context.is_candidate = 0; + book->text_context.ebxac_gaiji_flag = 0; + + LOG(("out: eb_initialize_text_context()")); +} + + +/* + * Finalize text context of `book'. + */ +void +eb_finalize_text_context(EB_Book *book) +{ + LOG(("in: eb_finalize_text_context(book=%d)", (int)book->code)); + + if (book->text_context.unprocessed != NULL) + free(book->text_context.unprocessed); + + LOG(("out: eb_finalize_text_context()")); +} + + +/* + * Reset text context of `book'. + * Note that `contexxt_code' and `context_location' are unchanged. + */ +void +eb_reset_text_context(EB_Book *book) +{ + LOG(("in: eb_reset_text_context(book=%d)", (int)book->code)); + + eb_finalize_text_context(book); + + book->text_context.out = NULL; + book->text_context.out_rest_length = 0; + book->text_context.unprocessed = NULL; + book->text_context.unprocessed_size = 0; + book->text_context.out_step = 0; + book->text_context.narrow_flag = 0; + book->text_context.printable_count = 0; + book->text_context.file_end_flag = 0; + book->text_context.text_status = EB_TEXT_STATUS_CONTINUED; + book->text_context.skip_code = SKIP_CODE_NONE; + book->text_context.auto_stop_code = -1; + book->text_context.candidate[0] = '\0'; + book->text_context.is_candidate = 0; + book->text_context.ebxac_gaiji_flag = 0; + + LOG(("out: eb_reset_text_context()")); +} + + +/* + * Invalidate text context of `book'. + */ +void +eb_invalidate_text_context(EB_Book *book) +{ + LOG(("in: eb_invalidate_text_context(book=%d)", (int)book->code)); + + eb_finalize_text_context(book); + eb_initialize_text_context(book); + book->text_context.code = EB_TEXT_INVALID; + + LOG(("out: eb_invalidate_text_context()")); +} + + +/* + * Reposition the offset of the subbook file. + */ +EB_Error_Code +eb_seek_text(EB_Book *book, const EB_Position *position) +{ + EB_Error_Code error_code; + + pthread_mutex_lock(&cache_mutex); + eb_lock(&book->lock); + LOG(("in: eb_seek_text(book=%d, position={%d,%d})", (int)book->code, + position->page, position->offset)); + + /* + * Current subbook must have been set and START file must exist. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + if (zio_file(&book->subbook_current->text_zio) < 0) { + error_code = EB_ERR_NO_TEXT; + goto failed; + } + + if (position->page <= 0 || position->offset < 0) { + error_code = EB_ERR_FAIL_SEEK_TEXT; + goto failed; + } + + /* + * Set text-context variables. + */ + eb_reset_text_context(book); + book->text_context.code = EB_TEXT_SEEKED; + book->text_context.location = ((off_t) position->page - 1) * EB_SIZE_PAGE + + position->offset; + + /* + * Unlock cache data and the book. + */ + LOG(("out: eb_seek_text() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + pthread_mutex_unlock(&cache_mutex); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_invalidate_text_context(book); + LOG(("out: eb_seek_text() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + pthread_mutex_unlock(&cache_mutex); + return error_code; +} + + +/* + * Get the current text position of the subbook file. + */ +EB_Error_Code +eb_tell_text(EB_Book *book, EB_Position *position) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_tell_text(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set and START file must exist. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + if (zio_file(&book->subbook_current->text_zio) < 0) { + error_code = EB_ERR_NO_TEXT; + goto failed; + } + + position->page = book->text_context.location / EB_SIZE_PAGE + 1; + position->offset = book->text_context.location % EB_SIZE_PAGE; + + LOG(("out: eb_seek_text(position={%d,%d}) = %s", + position->page, position->offset, eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_invalidate_text_context(book); + LOG(("out: eb_seek_text() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Get text in the current subbook in `book'. + */ +EB_Error_Code +eb_read_text(EB_Book *book, EB_Appendix *appendix, EB_Hookset *hookset, + void *container, size_t text_max_length, char *text, ssize_t *text_length) +{ + EB_Error_Code error_code; + const EB_Hook *hook; + EB_Position position; + + eb_lock(&book->lock); + if (appendix != NULL) + eb_lock(&appendix->lock); + if (hookset != NULL) + eb_lock(&hookset->lock); + LOG(("in: eb_read_text(book=%d, appendix=%d, text_max_length=%ld)", + (int)book->code, (appendix != NULL) ? (int)appendix->code : 0, + (long)text_max_length)); + + /* + * Current subbook must have been set and START file must exist. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + if (zio_file(&book->subbook_current->text_zio) < 0) { + error_code = EB_ERR_NO_TEXT; + goto failed; + } + + /* + * Use `eb_default_hookset' when `hookset' is `NULL'. + */ + if (hookset == NULL) + hookset = &eb_default_hookset; + + /* + * Set text mode to `text'. + */ + if (book->text_context.code == EB_TEXT_INVALID) { + error_code = EB_ERR_NO_PREV_SEEK; + goto failed; + } else if (book->text_context.code == EB_TEXT_SEEKED) { + eb_tell_text(book, &position); + eb_reset_text_context(book); + + if (book->subbook_current->menu.start_page <= position.page + && position.page <= book->subbook_current->menu.end_page) + book->text_context.code = EB_TEXT_OPTIONAL_TEXT; + else if (book->subbook_current->image_menu.start_page <= position.page + && position.page <= book->subbook_current->image_menu.end_page) + book->text_context.code = EB_TEXT_OPTIONAL_TEXT; + else if (book->subbook_current->copyright.start_page <= position.page + && position.page <= book->subbook_current->copyright.end_page) + book->text_context.code = EB_TEXT_OPTIONAL_TEXT; + else + book->text_context.code = EB_TEXT_MAIN_TEXT; + + hook = hookset->hooks + EB_HOOK_INITIALIZE; + if (hook->function != NULL) { + error_code = hook->function(book, appendix, container, + EB_HOOK_INITIALIZE, 0, NULL); + if (error_code != EB_SUCCESS) + goto failed; + } + } else if (book->text_context.code != EB_TEXT_MAIN_TEXT + && book->text_context.code != EB_TEXT_OPTIONAL_TEXT) { + error_code = EB_ERR_DIFF_CONTENT; + goto failed; + } + + error_code = eb_read_text_internal(book, appendix, hookset, container, + text_max_length, text, text_length, 0); + if (error_code != EB_SUCCESS) + goto failed; + + LOG(("out: eb_read_text(text_length=%ld) = %s", (long)*text_length, + eb_error_string(EB_SUCCESS))); + if (hookset != &eb_default_hookset) + eb_unlock(&hookset->lock); + if (appendix != NULL) + eb_unlock(&appendix->lock); + eb_unlock(&book->lock); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_invalidate_text_context(book); + LOG(("out: eb_read_text() = %s", eb_error_string(error_code))); + if (hookset != &eb_default_hookset) + eb_unlock(&hookset->lock); + if (appendix != NULL) + eb_unlock(&appendix->lock); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Get text in the current subbook in `book'. + */ +EB_Error_Code +eb_read_heading(EB_Book *book, EB_Appendix *appendix, EB_Hookset *hookset, + void *container, size_t text_max_length, char *text, ssize_t *text_length) +{ + EB_Error_Code error_code; + const EB_Hook *hook; + + eb_lock(&book->lock); + if (appendix != NULL) + eb_lock(&appendix->lock); + if (hookset != NULL) + eb_lock(&hookset->lock); + LOG(("in: eb_read_heading(book=%d, appendix=%d, text_max_length=%ld)", + (int)book->code, (appendix != NULL) ? (int)appendix->code : 0, + (long)text_max_length)); + + /* + * Current subbook must have been set and START file must exist. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + if (zio_file(&book->subbook_current->text_zio) < 0) { + error_code = EB_ERR_NO_TEXT; + goto failed; + } + + /* + * Use `eb_default_hookset' when `hookset' is `NULL'. + */ + if (hookset == NULL) + hookset = &eb_default_hookset; + + /* + * Set text mode to `heading'. + */ + if (book->text_context.code == EB_TEXT_INVALID) { + error_code = EB_ERR_NO_PREV_SEEK; + goto failed; + } else if (book->text_context.code == EB_TEXT_SEEKED) { + eb_reset_text_context(book); + book->text_context.code = EB_TEXT_HEADING; + + hook = hookset->hooks + EB_HOOK_INITIALIZE; + if (hook->function != NULL) { + error_code = hook->function(book, appendix, container, + EB_HOOK_INITIALIZE, 0, NULL); + if (error_code != EB_SUCCESS) + goto failed; + } + } else if (book->text_context.code != EB_TEXT_HEADING) { + error_code = EB_ERR_DIFF_CONTENT; + goto failed; + } + + error_code = eb_read_text_internal(book, appendix, hookset, container, + text_max_length, text, text_length, 0); + if (error_code != EB_SUCCESS) + goto failed; + + LOG(("out: eb_read_heading(text_length=%ld) = %s", (long)*text_length, + eb_error_string(EB_SUCCESS))); + if (hookset != &eb_default_hookset) + eb_unlock(&hookset->lock); + if (appendix != NULL) + eb_unlock(&appendix->lock); + eb_unlock(&book->lock); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_invalidate_text_context(book); + LOG(("out: eb_read_heading() = %s", eb_error_string(error_code))); + if (hookset != &eb_default_hookset) + eb_unlock(&hookset->lock); + if (appendix != NULL) + eb_unlock(&appendix->lock); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Read data from the subbook file directly. + */ +EB_Error_Code +eb_read_rawtext(EB_Book *book, size_t text_max_length, char *text, + ssize_t *text_length) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_read_rawtext(book=%d, text_max_length=%ld)", + (int)book->code, (long)text_max_length)); + + /* + * Current subbook must have been set and START file must exist. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + if (zio_file(&book->subbook_current->text_zio) < 0) { + error_code = EB_ERR_NO_TEXT; + goto failed; + } + + /* + * Set text mode to `rawtext'. + */ + if (book->text_context.code == EB_TEXT_INVALID) { + error_code = EB_ERR_NO_PREV_SEEK; + goto failed; + } else if (book->text_context.code == EB_TEXT_SEEKED) { + eb_reset_text_context(book); + book->text_context.code = EB_TEXT_RAWTEXT; + } else if (book->text_context.code != EB_TEXT_RAWTEXT) { + error_code = EB_ERR_DIFF_CONTENT; + goto failed; + } + + /* + * Seek START file and read data. + */ + if (zio_lseek(&book->subbook_current->text_zio, + book->text_context.location, SEEK_SET) == -1) { + error_code = EB_ERR_FAIL_SEEK_TEXT; + goto failed; + } + *text_length = zio_read(&book->subbook_current->text_zio, text, + text_max_length); + book->text_context.location += *text_length; + if (*text_length < 0) { + error_code = EB_ERR_FAIL_READ_TEXT; + goto failed; + } + + LOG(("out: eb_read_rawtext(text_length=%ld) = %s", (long)*text_length, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *text_length = -1; + eb_invalidate_text_context(book); + LOG(("out: eb_read_rawtext() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Get text or heading. + */ +static EB_Error_Code +eb_read_text_internal(EB_Book *book, EB_Appendix *appendix, + EB_Hookset *hookset, void *container, size_t text_max_length, char *text, + ssize_t *text_length, int forward_only) +{ + EB_Error_Code error_code; + EB_Text_Context *context; + unsigned char c1, c2; + char *cache_p; + const EB_Hook *hook; + unsigned char *candidate_p; + size_t candidate_length; + size_t cache_rest_length; + size_t in_step; + unsigned int argv[EB_MAX_ARGV]; + int argc; + + pthread_mutex_lock(&cache_mutex); + LOG(("in: eb_read_text_internal(book=%d, appendix=%d, \ +text_max_length=%ld, forward=%d)", + (int)book->code, (appendix != NULL) ? (int)appendix->code : 0, + (long)text_max_length, forward_only)); + + /* + * Initialize variables. + */ + context = &book->text_context; + context->out = text; + context->out_rest_length = text_max_length; + if (context->is_candidate) { + candidate_length = strlen(context->candidate); + candidate_p = (unsigned char *)context->candidate + candidate_length; + } else { + candidate_length = 0; + candidate_p = NULL; + } + + /* + * If unprocessed string are rest in `context->unprocessed', + * copy them to `context->out'. + */ + if (context->unprocessed != NULL) { + if (!forward_only) { + if (context->out_rest_length < context->unprocessed_size) + goto succeeded; + memcpy(context->out, context->unprocessed, + context->unprocessed_size); + context->out += context->unprocessed_size; + context->out_rest_length -= context->unprocessed_size; + } + free(context->unprocessed); + context->unprocessed = NULL; + context->unprocessed_size = 0; + } + + /* + * Return immediately if text-end-flag has been set. + */ + if (context->text_status != EB_TEXT_STATUS_CONTINUED) + goto succeeded; + + /* + * Check for cache data. + * If cache data is not what we need, discard it. + */ + if (book->code == cache_book_code + && cache_location <= context->location + && context->location < cache_location + cache_length) { + cache_p = cache_buffer + (context->location - cache_location); + cache_rest_length = cache_length + - (context->location - cache_location); + } else { + cache_book_code = EB_BOOK_NONE; + cache_p = cache_buffer; + cache_length = 0; + cache_rest_length = 0; + } + + for (;;) { + in_step = 0; + context->out_step = 0; + argc = 1; + + /* + * If it reaches to the near of the end of the cache buffer, + * then moves remaind cache text to the beginning of the cache + * buffer, and reads a next chunk from a file. + */ + if (cache_rest_length < SIZE_FEW_REST && !context->file_end_flag) { + ssize_t read_result; + + if (0 < cache_rest_length) + memmove(cache_buffer, cache_p, cache_rest_length); + if (zio_lseek(&book->subbook_current->text_zio, + context->location + cache_rest_length, SEEK_SET) == -1) { + error_code = EB_ERR_FAIL_SEEK_TEXT; + goto failed; + } + + read_result = zio_read(&book->subbook_current->text_zio, + cache_buffer + cache_rest_length, + EB_SIZE_PAGE - cache_rest_length); + if (read_result < 0) { + error_code = EB_ERR_FAIL_READ_TEXT; + goto failed; + } else if (read_result != EB_SIZE_PAGE - cache_rest_length) + context->file_end_flag = 1; + + cache_book_code = book->code; + cache_location = context->location; + cache_length = cache_rest_length + read_result; + cache_p = cache_buffer; + cache_rest_length = cache_length; + } + + /* + * Get 1 byte from the buffer. + */ + if (cache_rest_length < 1) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + c1 = eb_uint1(cache_p); + + if (c1 == 0x1f) { + hook = &null_hook; + + /* + * This is escape sequences. + */ + if (cache_rest_length < 2) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + argv[0] = eb_uint2(cache_p); + c2 = eb_uint1(cache_p + 1); + + switch (c2) { + case 0x02: + /* beginning of text */ + in_step = 2; + break; + + case 0x03: + /* end of text (don't set `in_step') */ + context->text_status = EB_TEXT_STATUS_HARD_STOP; + if (forward_only) { + error_code = EB_ERR_END_OF_CONTENT; + goto failed; + } + goto succeeded; + + case 0x04: + /* beginning of NARROW */ + in_step = 2; + hook = hookset->hooks + EB_HOOK_BEGIN_NARROW; + context->narrow_flag = 1; + break; + + case 0x05: + /* end of NARROW */ + in_step = 2; + hook = hookset->hooks + EB_HOOK_END_NARROW; + context->narrow_flag = 0; + break; + + case 0x06: + /* beginning of subscript */ + in_step = 2; + hook = hookset->hooks + EB_HOOK_BEGIN_SUBSCRIPT; + break; + + case 0x07: + /* end of subscript */ + in_step = 2; + hook = hookset->hooks + EB_HOOK_END_SUBSCRIPT; + break; + + case 0x09: + /* set indent */ + in_step = 4; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + argc = 2; + argv[1] = eb_uint2(cache_p + 2); + + if (0 < context->printable_count + && context->code == EB_TEXT_MAIN_TEXT) { + if (eb_is_stop_code(book, appendix, argv[0], argv[1])) { + context->text_status = EB_TEXT_STATUS_SOFT_STOP; + goto succeeded; + } + } + + hook = hookset->hooks + EB_HOOK_SET_INDENT; + break; + + case 0x0a: + /* newline */ + in_step = 2; + if (context->code == EB_TEXT_HEADING) { + context->text_status = EB_TEXT_STATUS_SOFT_STOP; + context->location += in_step; + goto succeeded; + } + hook = hookset->hooks + EB_HOOK_NEWLINE; + break; + + case 0x0b: + /* beginning of unicode */ + in_step = 2; + hook = hookset->hooks + EB_HOOK_BEGIN_UNICODE; + break; + + case 0x0c: + /* end of unicode */ + in_step = 2; + hook = hookset->hooks + EB_HOOK_END_UNICODE; + break; + + case 0x0e: + /* beginning of superscript */ + in_step = 2; + hook = hookset->hooks + EB_HOOK_BEGIN_SUPERSCRIPT; + break; + + case 0x0f: + /* end of superscript */ + in_step = 2; + hook = hookset->hooks + EB_HOOK_END_SUPERSCRIPT; + break; + + case 0x10: + /* beginning of newline prohibition */ + in_step = 2; + hook = hookset->hooks + EB_HOOK_BEGIN_NO_NEWLINE; + break; + + case 0x11: + /* end of newline prohibition */ + in_step = 2; + hook = hookset->hooks + EB_HOOK_END_NO_NEWLINE; + break; + + case 0x12: + /* beginning of emphasis */ + in_step = 2; + hook = hookset->hooks + EB_HOOK_BEGIN_EMPHASIS; + break; + + case 0x13: + /* end of emphasis */ + in_step = 2; + hook = hookset->hooks + EB_HOOK_END_EMPHASIS; + break; + + case 0x14: + in_step = 4; + context->skip_code = 0x15; + break; + + case 0x1a: case 0x1b: case 0x1e: case 0x1f: + /* emphasis; described in JIS X 4081-1996 */ + in_step = 4; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + /* Some old EB books don't take an argument. */ + if (book->disc_code != EB_DISC_EPWING + && eb_uint1(cache_p + 2) >= 0x1f) + in_step = 2; + break; + + case 0x1c: + if (book->character_code == EB_CHARCODE_JISX0208_GB2312) { + /* beginning of EBXA-C gaiji */ + in_step = 2; + hook = hookset->hooks + EB_HOOK_BEGIN_EBXAC_GAIJI; + context->ebxac_gaiji_flag = 1; + } else { + in_step = 4; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + /* Some old EB books don't take an argument. */ + if (book->disc_code != EB_DISC_EPWING + && eb_uint1(cache_p + 2) >= 0x1f) + in_step = 2; + } + break; + + case 0x1d: + if (book->character_code == EB_CHARCODE_JISX0208_GB2312) { + /* end of EBXA-C gaiji */ + in_step = 2; + hook = hookset->hooks + EB_HOOK_END_EBXAC_GAIJI; + context->ebxac_gaiji_flag = 0; + } else { + in_step = 4; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + /* Some old EB books don't take an argument. */ + if (book->disc_code != EB_DISC_EPWING + && eb_uint1(cache_p + 2) >= 0x1f) + in_step = 2; + } + break; + + case 0x32: + /* beginning of reference to monochrome graphic */ + in_step = 2; + argc = 4; + argv[1] = 0; + argv[2] = 0; + argv[3] = 0; + hook = hookset->hooks + EB_HOOK_BEGIN_MONO_GRAPHIC; + break; + + case 0x39: + /* beginning of MPEG movie */ + in_step = 46; + argc = 6; + argv[1] = eb_uint4(cache_p + 2); + argv[2] = eb_uint4(cache_p + 22); + argv[3] = eb_uint4(cache_p + 26); + argv[4] = eb_uint4(cache_p + 30); + argv[5] = eb_uint4(cache_p + 34); + hook = hookset->hooks + EB_HOOK_BEGIN_MPEG; + break; + + case 0x3c: + /* beginning of inline color graphic */ + in_step = 20; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + argc = 4; + argv[1] = eb_uint2(cache_p + 2); + argv[2] = eb_bcd4(cache_p + 14); + argv[3] = eb_bcd2(cache_p + 18); + if (argv[1] >> 8 == 0x00) + hook = hookset->hooks + EB_HOOK_BEGIN_IN_COLOR_BMP; + else + hook = hookset->hooks + EB_HOOK_BEGIN_IN_COLOR_JPEG; + break; + + case 0x35: case 0x36: case 0x37: case 0x38: case 0x3a: + case 0x3b: case 0x3d: case 0x3e: case 0x3f: + in_step = 2; + context->skip_code = eb_uint1(cache_p + 1) + 0x20; + break; + + case 0x41: + /* beginning of keyword */ + in_step = 4; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + argc = 2; + argv[1] = eb_uint2(cache_p + 2); + + if (0 < context->printable_count + && context->code == EB_TEXT_MAIN_TEXT) { + if (eb_is_stop_code(book, appendix, argv[0], argv[1])) { + context->text_status = EB_TEXT_STATUS_SOFT_STOP; + goto succeeded; + } + } + if (context->auto_stop_code < 0) + context->auto_stop_code = eb_uint2(cache_p + 2); + + hook = hookset->hooks + EB_HOOK_BEGIN_KEYWORD; + break; + + case 0x42: + /* beginning of reference */ + in_step = 4; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + if (eb_uint1(cache_p + 2) != 0x00) + in_step -= 2; + hook = hookset->hooks + EB_HOOK_BEGIN_REFERENCE; + break; + + case 0x43: + /* beginning of an entry of a candidate */ + in_step = 2; + if (context->skip_code == SKIP_CODE_NONE) { + context->candidate[0] = '\0'; + context->is_candidate = 1; + candidate_length = 0; + candidate_p = (unsigned char *)context->candidate; + } + hook = hookset->hooks + EB_HOOK_BEGIN_CANDIDATE; + break; + + case 0x44: + /* beginning of monochrome graphic */ + in_step = 12; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + argc = 4; + argv[1] = eb_uint2(cache_p + 2); + argv[2] = eb_bcd4(cache_p + 4); + argv[3] = eb_bcd4(cache_p + 8); + if (0 < argv[2] && 0 < argv[3]) + hook = hookset->hooks + EB_HOOK_BEGIN_MONO_GRAPHIC; + break; + + case 0x45: + /* beginning of graphic block */ + in_step = 4; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + if (eb_uint1(cache_p + 2) != 0x1f) { + argc = 2; + argv[1] = eb_bcd4(cache_p + 2); + } else { + in_step = 2; + } + break; + + case 0x4a: + /* beginning of WAVE sound */ + in_step = 18; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + argc = 6; + argv[1] = eb_uint4(cache_p + 2); + argv[2] = eb_bcd4(cache_p + 6); + argv[3] = eb_bcd2(cache_p + 10); + argv[4] = eb_bcd4(cache_p + 12); + argv[5] = eb_bcd2(cache_p + 16); + hook = hookset->hooks + EB_HOOK_BEGIN_WAVE; + break; + + case 0x4b: + /* beginning of paged reference */ + in_step = 8; + if (cache_rest_length < in_step + 2) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + argc = 3; + argv[1] = eb_bcd4(cache_p + 2); + argv[2] = eb_bcd2(cache_p + 6); + if (cache_p[8]==0x1f && cache_p[9]==0x6b) { + context->text_status = EB_TEXT_STATUS_SOFT_STOP; + hook = hookset->hooks + EB_HOOK_GRAPHIC_REFERENCE; + in_step = 10; + } else { + hook = hookset->hooks + EB_HOOK_BEGIN_GRAPHIC_REFERENCE; + } + break; + + case 0x4c: + /* beginning of image page */ + in_step = 4; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + hook = hookset->hooks + EB_HOOK_BEGIN_IMAGE_PAGE; + break; + + case 0x4d: + /* beginning of color graphic (BMP or JPEG) */ + in_step = 20; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + argc = 4; + argv[1] = eb_uint2(cache_p + 2); + argv[2] = eb_bcd4(cache_p + 14); + argv[3] = eb_bcd2(cache_p + 18); + if (argv[1] >> 8 == 0x00) + hook = hookset->hooks + EB_HOOK_BEGIN_COLOR_BMP; + else + hook = hookset->hooks + EB_HOOK_BEGIN_COLOR_JPEG; + break; + + case 0x4f: + /* beginning of clickable area */ + in_step = 34; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + argc = 7; + argv[1] = eb_bcd2(cache_p + 8); + argv[2] = eb_bcd2(cache_p + 10); + argv[3] = eb_bcd2(cache_p + 12); + argv[4] = eb_bcd2(cache_p + 14); + argv[5] = eb_bcd4(cache_p + 28); + argv[6] = eb_bcd2(cache_p + 32); + hook = hookset->hooks + EB_HOOK_BEGIN_CLICKABLE_AREA; + break; + + case 0x49: case 0x4e: + + in_step = 2; + context->skip_code = eb_uint1(cache_p + 1) + 0x20; + break; + + case 0x52: + /* end of reference to monochrome graphic */ + in_step = 8; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + argc = 3; + argv[1] = eb_bcd4(cache_p + 2); + argv[2] = eb_bcd2(cache_p + 6); + hook = hookset->hooks + EB_HOOK_END_MONO_GRAPHIC; + break; + + case 0x53: + /* end of EB sound */ + in_step = 10; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + break; + + case 0x59: + /* end of MPEG movie */ + in_step = 2; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + hook = hookset->hooks + EB_HOOK_END_MPEG; + break; + + case 0x5c: + /* end of inline color graphic */ + in_step = 2; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + hook = hookset->hooks + EB_HOOK_END_IN_COLOR_GRAPHIC; + break; + + case 0x61: + /* end of keyword */ + in_step = 2; + hook = hookset->hooks + EB_HOOK_END_KEYWORD; + break; + + case 0x62: + /* end of reference */ + in_step = 8; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + argc = 3; + argv[1] = eb_bcd4(cache_p + 2); + argv[2] = eb_bcd2(cache_p + 6); + hook = hookset->hooks + EB_HOOK_END_REFERENCE; + break; + + case 0x63: + /* end of an entry of a candidate */ + in_step = 8; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + argc = 3; + argv[1] = eb_bcd4(cache_p + 2); + argv[2] = eb_bcd2(cache_p + 6); + if (argv[1] == 0 && argv[2] == 0) + hook = hookset->hooks + EB_HOOK_END_CANDIDATE_LEAF; + else + hook = hookset->hooks + EB_HOOK_END_CANDIDATE_GROUP; + break; + + case 0x64: + /* end of monochrome graphic */ + in_step = 8; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + argc = 3; + argv[1] = eb_bcd4(cache_p + 2); + argv[2] = eb_bcd2(cache_p + 6); + hook = hookset->hooks + EB_HOOK_END_MONO_GRAPHIC; + break; + + case 0x6b: + /* end of paged reference */ + in_step = 2; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + hook = hookset->hooks + EB_HOOK_END_GRAPHIC_REFERENCE; + break; + + case 0x6a: + /* end of WAVE sound */ + in_step = 2; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + hook = hookset->hooks + EB_HOOK_END_WAVE; + break; + + case 0x6c: + /* end of image page */ + in_step = 2; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + context->text_status = EB_TEXT_STATUS_SOFT_STOP; + hook = hookset->hooks + EB_HOOK_END_IMAGE_PAGE; + break; + + case 0x6d: + /* end of color graphic (BMP or JPEG) */ + in_step = 2; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + hook = hookset->hooks + EB_HOOK_END_COLOR_GRAPHIC; + break; + + case 0x6f: + /* end of clickable area */ + in_step = 2; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + hook = hookset->hooks + EB_HOOK_END_CLICKABLE_AREA; + break; + + case 0x70: case 0x71: case 0x72: case 0x73: case 0x74: case 0x75: + case 0x76: case 0x77: case 0x78: case 0x79: case 0x7a: case 0x7b: + case 0x7c: case 0x7d: case 0x7e: case 0x7f: + case 0x80: case 0x81: case 0x82: case 0x83: case 0x84: case 0x85: + case 0x86: case 0x87: case 0x88: case 0x89: case 0x8a: case 0x8b: + case 0x8c: case 0x8d: case 0x8e: case 0x8f: + in_step = 2; + context->skip_code = eb_uint1(cache_p + 1) + 0x20; + break; + + case 0xe0: + /* character modification */ + in_step = 4; + if (cache_rest_length < in_step) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + argc = 2; + argv[1] = eb_uint2(cache_p + 2); + hook = hookset->hooks + EB_HOOK_BEGIN_DECORATION; + + /* Some old EB books don't take an argument. */ + if (book->disc_code != EB_DISC_EPWING + && eb_uint1(cache_p + 2) >= 0x1f) { + in_step = 2; + hook = &null_hook; + } + break; + + case 0xe1: + in_step = 2; + hook = hookset->hooks + EB_HOOK_END_DECORATION; + break; + + case 0xe4: case 0xe6: case 0xe8: case 0xea: case 0xec: case 0xee: + case 0xf0: case 0xf2: case 0xf4: case 0xf6: case 0xf8: case 0xfa: + case 0xfc: case 0xfe: + in_step = 2; + context->skip_code = eb_uint1(cache_p + 1) + 0x01; + break; + + default: + in_step = 2; + if (context->skip_code == eb_uint1(cache_p + 1)) + context->skip_code = SKIP_CODE_NONE; + break; + } + + if (context->skip_code == SKIP_CODE_NONE + && hook->function != NULL + && !forward_only) { + error_code = hook->function(book, appendix, container, + hook->code, argc, argv); + if (error_code != EB_SUCCESS) + goto failed; + } + + /* + * Post process. Clean a candidate. + */ + if (c2 == 0x63) { + /* end of an entry of candidate */ + context->is_candidate = 0; + } + + } else if (book->character_code == EB_CHARCODE_ISO8859_1) { + /* + * The book is mainly written in ISO 8859 1. + */ + context->printable_count++; + + if ((0x20 <= c1 && c1 < 0x7f) || (0xa0 <= c1 && c1 <= 0xff)) { + /* + * This is an ISO 8859 1 character. + */ + in_step = 1; + argv[0] = eb_uint1(cache_p); + + if (context->skip_code == SKIP_CODE_NONE) { + if (context->is_candidate + && candidate_length < EB_MAX_WORD_LENGTH) { + *candidate_p++ = c1 | 0x80; + *candidate_p = '\0'; + candidate_length++; + } + + hook = hookset->hooks + EB_HOOK_ISO8859_1; + if (forward_only) { + ; /* do nothing */ + } else if (hook->function == NULL) { + error_code = eb_write_text_byte1(book, c1); + if (error_code != EB_SUCCESS) + goto failed; + } else { + error_code = hook->function(book, appendix, container, + EB_HOOK_ISO8859_1, argc, argv); + if (error_code != EB_SUCCESS) + goto failed; + } + } + } else { + /* + * This is a local character. + */ + if (cache_rest_length < 2) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + in_step = 2; + argv[0] = eb_uint2(cache_p); + if (context->skip_code == SKIP_CODE_NONE) { + hook = hookset->hooks + EB_HOOK_NARROW_FONT; + if (forward_only) { + ; /* do nothing */ + } else if (hook->function == NULL) { + error_code = eb_write_text_byte1(book, c1); + if (error_code != EB_SUCCESS) + goto failed; + } else { + error_code = hook->function(book, appendix, container, + EB_HOOK_NARROW_FONT, argc, argv); + if (error_code != EB_SUCCESS) + goto failed; + } + } + } + + } else { + /* + * The book is written in JIS X 0208 or JIS X 0208 + GB 2312. + */ + context->printable_count++; + in_step = 2; + + if (cache_rest_length < 2) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + c2 = eb_uint1(cache_p + 1); + + if (context->skip_code != SKIP_CODE_NONE) { + /* nothing to be done. */ + } else if (0x20 < c1 && c1 < 0x7f && 0x20 < c2 && c2 < 0x7f) { + /* + * This is a JIS X 0208 KANJI character. + */ + argv[0] = eb_uint2(cache_p) | 0x8080; + + if (context->is_candidate + && candidate_length < EB_MAX_WORD_LENGTH - 1) { + *candidate_p++ = c1 | 0x80; + *candidate_p++ = c2 | 0x80; + *candidate_p = '\0'; + candidate_length += 2; + } + + if (context->ebxac_gaiji_flag) { + hook = hookset->hooks + EB_HOOK_EBXAC_GAIJI; + if (forward_only) { + ; /* do nothing */ + } else if (hook->function == NULL) { + error_code = eb_write_text_byte2(book, c1 | 0x80, + c2 | 0x80); + if (error_code != EB_SUCCESS) + goto failed; + } else { + error_code = hook->function(book, appendix, container, + EB_HOOK_EBXAC_GAIJI, 0, argv); + if (error_code != EB_SUCCESS) + goto failed; + } + } else if (context->narrow_flag) { + hook = hookset->hooks + EB_HOOK_NARROW_JISX0208; + if (forward_only) { + ; /* do nothing */ + } else if (hook->function == NULL) { + error_code = eb_write_text_byte2(book, c1 | 0x80, + c2 | 0x80); + if (error_code != EB_SUCCESS) + goto failed; + } else { + error_code = hook->function(book, appendix, container, + EB_HOOK_NARROW_JISX0208, 0, argv); + if (error_code != EB_SUCCESS) + goto failed; + } + } else { + hook = hookset->hooks + EB_HOOK_WIDE_JISX0208; + if (forward_only) { + ; /* do nothing */ + } else if (hook->function == NULL) { + error_code = eb_write_text_byte2(book, c1 | 0x80, + c2 | 0x80); + if (error_code != EB_SUCCESS) + goto failed; + } else { + error_code = hook->function(book, appendix, container, + EB_HOOK_WIDE_JISX0208, argc, argv); + if (error_code != EB_SUCCESS) + goto failed; + } + } + } else if (0x20 < c1 && c1 < 0x7f && 0xa0 < c2 && c2 < 0xff) { + /* + * This is a GB 2312 HANJI character. + */ + argv[0] = eb_uint2(cache_p) | 0x8000; + + if (context->is_candidate + && candidate_length < EB_MAX_WORD_LENGTH - 1) { + *candidate_p++ = c1 | 0x80; + *candidate_p++ = c2; + *candidate_p = '\0'; + candidate_length += 2; + } + + hook = hookset->hooks + EB_HOOK_GB2312; + if (forward_only) { + ; /* do nothing */ + } else if (hook->function == NULL) { + error_code = eb_write_text_byte2(book, c1 | 0x80, c2); + if (error_code != EB_SUCCESS) + goto failed; + } else { + error_code = hook->function(book, appendix, container, + EB_HOOK_GB2312, 0, argv); + if (error_code != EB_SUCCESS) + goto failed; + } + } else if (0xa0 < c1 && c1 < 0xff && 0x20 < c2 && c2 < 0x7f) { + /* + * This is a local character. + */ + argv[0] = eb_uint2(cache_p); + + if (context->narrow_flag) { + hook = hookset->hooks + EB_HOOK_NARROW_FONT; + if (forward_only) { + ; /* do nothing */ + } else if (hook->function == NULL) { + error_code = eb_write_text_byte2(book, c1, c2); + if (error_code != EB_SUCCESS) + goto failed; + } else { + error_code = hook->function(book, appendix, container, + EB_HOOK_NARROW_FONT, argc, argv); + if (error_code != EB_SUCCESS) + goto failed; + } + } else { + hook = hookset->hooks + EB_HOOK_WIDE_FONT; + if (forward_only) { + ; /* do nothing */ + } else if (hook->function == NULL) { + error_code = eb_write_text_byte2(book, c1, c2); + if (error_code != EB_SUCCESS) + goto failed; + } else { + error_code = hook->function(book, appendix, container, + EB_HOOK_WIDE_FONT, argc, argv); + if (error_code != EB_SUCCESS) + goto failed; + } + } + } + } + + /* + * Update variables. + */ + cache_p += in_step; + cache_rest_length -= in_step; + context->location += in_step; + in_step = 0; + + /* + * Break if an unprocessed character is remained. + */ + if (context->unprocessed != NULL) + break; + /* + * Break if EB_TEXT_STATUS_SOFT_STOP is set. + */ + if (context->text_status == EB_TEXT_STATUS_SOFT_STOP) + break; + } + + succeeded: + if (!forward_only) { + *text_length = (context->out - text); + *(context->out) = '\0'; + } + + LOG(("out: eb_read_text_internal(text_length=%ld) = %s", + (text_length == NULL) ? 0L : (long)*text_length, + eb_error_string(EB_SUCCESS))); + pthread_mutex_unlock(&cache_mutex); + + return EB_SUCCESS; + + /* + * An error occurs... + * Discard cache if read error occurs. + */ + failed: + if (!forward_only) { + *text_length = -1; + *text = '\0'; + } + if (error_code == EB_ERR_FAIL_READ_TEXT) + cache_book_code = EB_BOOK_NONE; + LOG(("out: eb_read_text_internal() = %s", eb_error_string(error_code))); + pthread_mutex_unlock(&cache_mutex); + return error_code; +} + + +/* + * Check whether an escape sequence is stop-code or not. + */ +static int +eb_is_stop_code(EB_Book *book, EB_Appendix *appendix, unsigned int code0, + unsigned int code1) +{ + int result; + + if (appendix == NULL + || appendix->subbook_current == NULL + || appendix->subbook_current->stop_code0 == 0) { + result = (code0 == 0x1f41 + && code1 == book->text_context.auto_stop_code); + } else { + result = (code0 == appendix->subbook_current->stop_code0 + && code1 == appendix->subbook_current->stop_code1); + } + + return result; +} + + +/* + * Have the current text context reached the end of text? + */ +int +eb_is_text_stopped(EB_Book *book) +{ + int is_stopped = 0; + + eb_lock(book); + LOG(("in: eb_is_text_stopped(book=%d)", (int)book->code)); + + if (book->subbook_current != NULL) { + if (book->text_context.code == EB_TEXT_HEADING + || book->text_context.code == EB_TEXT_MAIN_TEXT + || book->text_context.code == EB_TEXT_OPTIONAL_TEXT) { + if (book->text_context.text_status != EB_TEXT_STATUS_CONTINUED + && book->text_context.unprocessed == NULL) { + is_stopped = 1; + } + } + } + + LOG(("out: eb_is_text_stopped() = %d", is_stopped)); + return is_stopped; +} + + +/* + * Write a byte to a text buffer. + */ +EB_Error_Code +eb_write_text_byte1(EB_Book *book, int byte1) +{ + EB_Error_Code error_code; + char stream[1]; + + LOG(("in: eb_write_text_byte1(book=%d, byte1=%d)", + (int)book->code, byte1)); + + /* + * If the text buffer has enough space to write `byte1', + * save the byte in `book->text_context.unprocessed'. + */ + if (book->text_context.unprocessed != NULL + || book->text_context.out_rest_length < 1) { + *(unsigned char *)stream = byte1; + error_code = eb_write_text(book, stream, 1); + if (error_code != EB_SUCCESS) + goto failed; + } else { + *(book->text_context.out) = byte1; + book->text_context.out++; + book->text_context.out_rest_length--; + book->text_context.out_step++; + } + + LOG(("out: eb_write_text_byte1() = %s", eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_write_text_byte1() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Write two bytes to a text buffer for output. + */ +EB_Error_Code +eb_write_text_byte2(EB_Book *book, int byte1, int byte2) +{ + EB_Error_Code error_code; + char stream[2]; + + LOG(("in: eb_write_text_byte2(book=%d, byte1=%d, byte2=%d)", + (int)book->code, byte1, byte2)); + + /* + * If the text buffer has enough space to write `byte1' and `byte2', + * save the bytes in `book->text_context.unprocessed'. + */ + if (book->text_context.unprocessed != NULL + || book->text_context.out_rest_length < 2) { + *(unsigned char *)stream = byte1; + *(unsigned char *)(stream + 1) = byte2; + error_code = eb_write_text(book, stream, 2); + if (error_code != EB_SUCCESS) + goto failed; + } else { + *(book->text_context.out) = byte1; + book->text_context.out++; + *(book->text_context.out) = byte2; + book->text_context.out++; + book->text_context.out_rest_length -= 2; + book->text_context.out_step += 2; + } + + LOG(("out: eb_write_text_byte2() = %s", eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_write_text_byte2() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Write a string to a text buffer. + */ +EB_Error_Code +eb_write_text_string(EB_Book *book, const char *string) +{ + EB_Error_Code error_code; + size_t string_length; + + LOG(("in: eb_write_text_string(book=%d, string=%s)", + (int)book->code, eb_quoted_string(string))); + + /* + * If the text buffer has enough space to write `sting', + * save the string in `book->text_context.unprocessed'. + */ + string_length = strlen(string); + + if (book->text_context.unprocessed != NULL + || book->text_context.out_rest_length < string_length) { + error_code = eb_write_text(book, string, string_length); + if (error_code != EB_SUCCESS) + goto failed; + } else { + memcpy(book->text_context.out, string, string_length); + book->text_context.out += string_length; + book->text_context.out_rest_length -= string_length; + book->text_context.out_step += string_length; + } + + LOG(("out: eb_write_text_string() = %s", eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_write_text_string() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Write a stream with `length' bytes to a text buffer. + */ +EB_Error_Code +eb_write_text(EB_Book *book, const char *stream, size_t stream_length) +{ + EB_Error_Code error_code; + char *reallocated; + + LOG(("in: eb_write_text(book=%d, stream=%s)", + (int)book->code, eb_quoted_stream(stream, stream_length))); + + /* + * If the text buffer has enough space to write `stream', + * save the stream in `book->text_context.unprocessed'. + */ + if (book->text_context.unprocessed != NULL) { + reallocated = (char *)realloc(book->text_context.unprocessed, + book->text_context.unprocessed_size + stream_length); + if (reallocated == NULL) { + free(book->text_context.unprocessed); + book->text_context.unprocessed = NULL; + book->text_context.unprocessed_size = 0; + error_code = EB_ERR_MEMORY_EXHAUSTED; + goto failed; + } + memcpy(reallocated + book->text_context.unprocessed_size, stream, + stream_length); + book->text_context.unprocessed = reallocated; + book->text_context.unprocessed_size += stream_length; + + } else if (book->text_context.out_rest_length < stream_length) { + book->text_context.unprocessed + = (char *)malloc(book->text_context.out_step + stream_length); + if (book->text_context.unprocessed == NULL) { + error_code = EB_ERR_MEMORY_EXHAUSTED; + goto failed; + } + book->text_context.unprocessed_size + = book->text_context.out_step + stream_length; + memcpy(book->text_context.unprocessed, + book->text_context.out - book->text_context.out_step, + book->text_context.out_step); + memcpy(book->text_context.unprocessed + book->text_context.out_step, + stream, stream_length); + book->text_context.out -= book->text_context.out_step; + book->text_context.out_step = 0; + + } else { + memcpy(book->text_context.out, stream, stream_length); + book->text_context.out += stream_length; + book->text_context.out_rest_length -= stream_length; + book->text_context.out_step += stream_length; + } + + LOG(("out: eb_write_text() = %s", eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_write_text() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Get the current candidate word for multi search. + */ +const char * +eb_current_candidate(EB_Book *book) +{ + LOG(("in: eb_current_candidate(book=%d)", (int)book->code)); + + if (!book->text_context.is_candidate) + book->text_context.candidate[0] = '\0'; + + LOG(("out: eb_current_candidate() = %s", + eb_quoted_string(book->text_context.candidate))); + + return book->text_context.candidate; +} + + +/* + * Forward text position to the next paragraph. + */ +EB_Error_Code +eb_forward_text(EB_Book *book, EB_Appendix *appendix) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_forward_text(book=%d, appendix=%d)", (int)book->code, + (appendix != NULL) ? (int)appendix->code : 0)); + + /* + * Current subbook must have been set and START file must exist. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + if (zio_file(&book->subbook_current->text_zio) < 0) { + error_code = EB_ERR_NO_TEXT; + goto failed; + } + + if (book->text_context.code == EB_TEXT_SEEKED) { + book->text_context.code = EB_TEXT_MAIN_TEXT; + } else if (book->text_context.code == EB_TEXT_INVALID) { + error_code = EB_ERR_NO_PREV_SEEK; + goto failed; + } else if (book->text_context.code != EB_TEXT_MAIN_TEXT + && book->text_context.code != EB_TEXT_OPTIONAL_TEXT) { + error_code = EB_ERR_DIFF_CONTENT; + goto failed; + } + + if (book->text_context.text_status == EB_TEXT_STATUS_SOFT_STOP) { + book->text_context.text_status = EB_TEXT_STATUS_CONTINUED; + goto succeeded; + } else if (book->text_context.text_status == EB_TEXT_STATUS_HARD_STOP) { + error_code = EB_ERR_END_OF_CONTENT; + goto failed; + } + + /* + * Forward text. + */ + error_code = eb_read_text_internal(book, appendix, &eb_default_hookset, + NULL, EB_SIZE_PAGE, NULL, NULL, 1); + if (error_code != EB_SUCCESS) + goto failed; + + /* + * Unlock the book and hookset. + */ + succeeded: + eb_reset_text_context(book); + LOG(("out: eb_forward_text() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + if (error_code != EB_ERR_END_OF_CONTENT) + eb_invalidate_text_context(book); + LOG(("out: eb_forward_text() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Forward heading position to the next paragraph. + * (for keyword search.) + */ +EB_Error_Code +eb_forward_heading(EB_Book *book) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_forward_heading(book=%d)", (int)book->code)); + + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + if (zio_file(&book->subbook_current->text_zio) < 0) { + error_code = EB_ERR_NO_TEXT; + goto failed; + } + + if (book->text_context.code == EB_TEXT_SEEKED) { + book->text_context.code = EB_TEXT_HEADING; + } else if (book->text_context.code == EB_TEXT_INVALID) { + error_code = EB_ERR_NO_PREV_SEEK; + goto failed; + } else if (book->text_context.code != EB_TEXT_HEADING) { + error_code = EB_ERR_DIFF_CONTENT; + goto failed; + } + + if (book->text_context.text_status == EB_TEXT_STATUS_SOFT_STOP) { + book->text_context.text_status = EB_TEXT_STATUS_CONTINUED; + goto succeeded; + } else if (book->text_context.text_status == EB_TEXT_STATUS_HARD_STOP) { + error_code = EB_ERR_END_OF_CONTENT; + goto failed; + } + + /* + * Forward text. + */ + error_code = eb_read_text_internal(book, NULL, &eb_default_hookset, + NULL, EB_SIZE_PAGE, NULL, NULL, 1); + if (error_code != EB_SUCCESS) + goto failed; + + eb_reset_text_context(book); + + /* + * Unlock cache data. + */ + succeeded: + LOG(("out: eb_forward_heading() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + if (error_code != EB_ERR_END_OF_CONTENT) + eb_invalidate_text_context(book); + LOG(("out: eb_forward_heading() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Backward text position to the previous paragraph. + */ +EB_Error_Code +eb_backward_text(EB_Book *book, EB_Appendix *appendix) +{ + EB_Error_Code error_code; + EB_Text_Context saved_context; + off_t current_location; + off_t forward_location; + off_t read_location; + off_t backward_location = -1; + char text_buffer[EB_SIZE_PAGE]; + char *text_buffer_p; + ssize_t read_result; + int stop_code0, stop_code1; + + eb_lock(&book->lock); + LOG(("in: eb_backward_text(book=%d, appendix=%d)", (int)book->code, + (appendix != NULL) ? (int)appendix->code : 0)); + + /* + * Current subbook must have been set and START file must exist. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + if (zio_file(&book->subbook_current->text_zio) < 0) { + error_code = EB_ERR_NO_TEXT; + goto failed; + } + + if (book->text_context.code == EB_TEXT_SEEKED) { + book->text_context.code = EB_TEXT_MAIN_TEXT; + } else if (book->text_context.code == EB_TEXT_INVALID) { + error_code = EB_ERR_NO_PREV_SEEK; + goto failed; + } else if (book->text_context.code != EB_TEXT_MAIN_TEXT + && book->text_context.code != EB_TEXT_OPTIONAL_TEXT) { + error_code = EB_ERR_DIFF_CONTENT; + goto failed; + } + + /* + * Forward text to get auto-stop-code and location where the current + * text stops. + */ + if (book->text_context.text_status != EB_TEXT_STATUS_CONTINUED) { + forward_location = book->text_context.location; + } else { + memcpy(&saved_context, &book->text_context, sizeof(EB_Text_Context)); + error_code = eb_read_text_internal(book, NULL, &eb_default_hookset, + NULL, EB_SIZE_PAGE, NULL, NULL, 1); + if (error_code != EB_SUCCESS && error_code != EB_ERR_END_OF_CONTENT) + goto failed; + forward_location = book->text_context.location; + saved_context.auto_stop_code = book->text_context.auto_stop_code; + memcpy(&book->text_context, &saved_context, sizeof(EB_Text_Context)); + } + + /* + * Determine stop-code. + */ + if (appendix == NULL + || appendix->subbook_current == NULL + || appendix->subbook_current->stop_code0 == 0) { + stop_code0 = 0x1f41; + stop_code1 = book->text_context.auto_stop_code; + } else { + stop_code0 = appendix->subbook_current->stop_code0; + stop_code1 = appendix->subbook_current->stop_code1; + } + + /* + * If the text locator has pointed to `0x1f02' (beginning of text), + * we cannot backward. + */ + if (zio_lseek(&book->subbook_current->text_zio, + book->text_context.location, SEEK_SET) == -1) { + error_code = EB_ERR_FAIL_SEEK_TEXT; + goto failed; + } + if (zio_read(&book->subbook_current->text_zio, text_buffer, 2) != 2) { + error_code = EB_ERR_FAIL_READ_TEXT; + goto failed; + } + if (eb_uint2(text_buffer) == 0x1f02) { + error_code = EB_ERR_END_OF_CONTENT; + goto failed; + } + + /* + * Backward text. + */ + current_location = book->text_context.location; + + while (0 < book->text_context.location) { + size_t backward_distance; + int i; + + /* + * Seek and read text. + * + * Since a stop code occupies 4 bytes and we start scanning + * stop-code at preceding byte of the current location, we read + * text in front of the current location and following 3 bytes. + * + * start scanning + * | current location + * | | + * [..] [..] [..] [1F] [41] [00] [01] + * =================== + * may be stop-code + */ + if (book->text_context.location < EB_SIZE_PAGE + 3) + read_location = 0; + else + read_location = book->text_context.location - EB_SIZE_PAGE + 3; + backward_distance = book->text_context.location - read_location; + + if (zio_lseek(&book->subbook_current->text_zio, read_location, + SEEK_SET) == -1) { + error_code = EB_ERR_FAIL_SEEK_TEXT; + goto failed; + } + + memset(text_buffer, 0x00, EB_SIZE_PAGE); + read_result = zio_read(&book->subbook_current->text_zio, text_buffer, + EB_SIZE_PAGE); + if (read_result < 0 || read_result < backward_distance) { + error_code = EB_ERR_FAIL_READ_TEXT; + goto failed; + } + + /* + * Scan stop-code. + */ + text_buffer_p = text_buffer + backward_distance - 1; + i = backward_distance - 1; + + while (0 <= i) { + if (eb_uint2(text_buffer_p) == 0x1f02) { + book->text_context.location = read_location + i; + if (current_location <= book->text_context.location + 2) { + error_code = EB_ERR_END_OF_CONTENT; + goto failed; + } + backward_location = book->text_context.location; + goto loop_end; + } + if (book->text_context.code != EB_TEXT_MAIN_TEXT + || eb_uint2(text_buffer_p) != stop_code0 + || eb_uint2(text_buffer_p + 2) != stop_code1) { + text_buffer_p--; + i--; + continue; + } + + eb_reset_text_context(book); + book->text_context.location = read_location + i; + error_code = eb_read_text_internal(book, appendix, + &eb_default_hookset, NULL, EB_SIZE_PAGE, NULL, NULL, 1); + if (error_code != EB_SUCCESS + && error_code != EB_ERR_END_OF_CONTENT) + goto failed; + + if (book->text_context.location >= current_location - 4 + && book->text_context.location <= current_location + 4 + && backward_location < 0) + forward_location = current_location; + if (book->text_context.location >= forward_location - 4 + && book->text_context.location <= forward_location + 4) + backward_location = read_location + i; + else if (book->text_context.location < forward_location) + goto loop_end; + + text_buffer_p--; + i--; + } + + book->text_context.location = read_location - 1; + } + + loop_end: + if (backward_location < 0) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + eb_reset_text_context(book); + + /* + * Unlock the book and hookset. + */ + LOG(("out: eb_forward_text() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_invalidate_text_context(book); + LOG(("out: eb_backward_text() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + diff --git a/eb/search.c b/eb/search.c new file mode 100644 index 0000000..2155d4b --- /dev/null +++ b/eb/search.c @@ -0,0 +1,1656 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "text.h" +#include "build-post.h" + +/* + * Page-ID macros. + */ +#define PAGE_ID_IS_LEAF_LAYER(page_id) (((page_id) & 0x80) == 0x80) +#define PAGE_ID_IS_LAYER_START(page_id) (((page_id) & 0x40) == 0x40) +#define PAGE_ID_IS_LAYER_END(page_id) (((page_id) & 0x20) == 0x20) +#define PAGE_ID_HAVE_GROUP_ENTRY(page_id) (((page_id) & 0x10) == 0x10) + +/* + * The maximum number of hit entries for tomporary hit lists. + * This is used in eb_hit_list(). + */ +#define EB_TMP_MAX_HITS 64 + +/* + * Book-code of the book in which you want to search a word. + */ +static EB_Book_Code cache_book_code = EB_BOOK_NONE; + +/* + * Cache buffer for the current page. + */ +static char cache_buffer[EB_SIZE_PAGE]; + +/* + * Cache buffer for the current page. + */ +static int cache_page; + +/* + * Mutex for cache variables. + */ +#ifdef ENABLE_PTHREAD +static pthread_mutex_t cache_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif + +/* + * Unexported functions. + */ +static EB_Error_Code eb_hit_list_word(EB_Book *book, + EB_Search_Context *context, int max_hit_count, EB_Hit *hit_list, + int *hit_count); +static EB_Error_Code eb_hit_list_keyword(EB_Book *book, + EB_Search_Context *context, int max_hit_count, EB_Hit *hit_list, + int *hit_count); +static EB_Error_Code eb_hit_list_multi(EB_Book *book, + EB_Search_Context *context, int max_hit_count, EB_Hit *hit_list, + int *hit_count); +static void eb_and_hit_lists(EB_Hit and_list[EB_TMP_MAX_HITS], + int *and_count, int max_and_count, int hit_list_count, + EB_Hit hit_lists[EB_NUMBER_OF_SEARCH_CONTEXTS][EB_TMP_MAX_HITS], + int hit_counts[EB_NUMBER_OF_SEARCH_CONTEXTS]); + + +/* + * Intialize search contexts of `book'. + */ +void +eb_initialize_search_contexts(EB_Book *book) +{ + EB_Search_Context *context; + int i; + + LOG(("in: eb_initialize_search_context(book=%d)", (int)book->code)); + + for (i = 0, context = book->search_contexts; + i < EB_NUMBER_OF_SEARCH_CONTEXTS; i++, context++) { + context->code = EB_SEARCH_NONE; + context->compare_pre = NULL; + context->compare_single = NULL; + context->compare_group = NULL; + context->comparison_result = -1; + context->word[0] = '\0'; + context->canonicalized_word[0] = '\0'; + context->page = 0; + context->offset = 0; + context->page_id = 0; + context->entry_count = 0; + context->entry_index = 0; + context->entry_length = 0; + context->entry_arrangement = EB_ARRANGE_INVALID; + context->in_group_entry = 0; + context->keyword_heading.page = 0; + context->keyword_heading.offset = 0; + } + + LOG(("out: eb_initialize_search_context()")); +} + + +/* + * Finalize search contexts of `book'. + */ +void +eb_finalize_search_contexts(EB_Book *book) +{ + LOG(("in+out: eb_finalize_search_context(book=%d)", (int)book->code)); + + /* nothing to be done */ +} + + +/* + * Reset search context of `book'. + */ +void +eb_reset_search_contexts(EB_Book *book) +{ + LOG(("in: eb_reset_search_context(book=%d)", (int)book->code)); + + eb_initialize_search_contexts(book); + + LOG(("out: eb_reset_search_context()")); +} + + +/* + * Intialize a search element. + */ +void +eb_initialize_search(EB_Search *search) +{ + search->index_id = 0; + search->start_page = 0; + search->end_page = 0; + search->candidates_page = 0; + search->katakana = EB_INDEX_STYLE_CONVERT; + search->lower = EB_INDEX_STYLE_CONVERT; + search->mark = EB_INDEX_STYLE_DELETE; + search->long_vowel = EB_INDEX_STYLE_CONVERT; + search->double_consonant = EB_INDEX_STYLE_CONVERT; + search->contracted_sound = EB_INDEX_STYLE_CONVERT; + search->voiced_consonant = EB_INDEX_STYLE_CONVERT; + search->small_vowel = EB_INDEX_STYLE_CONVERT; + search->p_sound = EB_INDEX_STYLE_CONVERT; + search->space = EB_INDEX_STYLE_DELETE; + search->label[0] = '\0'; +} + + +/* + * Finalize a search element. + */ +void +eb_finalize_search(EB_Search *search) +{ + /* nothing to be done */ +} + + +/* + * Initialize all search elements in the current subbook. + */ +void +eb_initialize_searches(EB_Book *book) +{ + EB_Subbook *subbook; + EB_Multi_Search *multi; + EB_Search *entry; + int i, j; + + LOG(("in: eb_initialize_searches(book=%d)", (int)book->code)); + + subbook = book->subbook_current; + + eb_initialize_search(&subbook->word_alphabet); + eb_initialize_search(&subbook->word_asis); + eb_initialize_search(&subbook->word_kana); + eb_initialize_search(&subbook->endword_alphabet); + eb_initialize_search(&subbook->endword_asis); + eb_initialize_search(&subbook->endword_kana); + eb_initialize_search(&subbook->keyword); + eb_initialize_search(&subbook->cross); + eb_initialize_search(&subbook->menu); + eb_initialize_search(&subbook->image_menu); + eb_initialize_search(&subbook->copyright); + eb_initialize_search(&subbook->text); + eb_initialize_search(&subbook->sound); + + for (i = 0, multi = subbook->multis; i < EB_MAX_MULTI_SEARCHES; + i++, multi++) { + eb_initialize_search(&multi->search); + multi->title[0] = '\0'; + multi->entry_count = 0; + for (j = 0, entry = multi->entries; + j < EB_MAX_MULTI_ENTRIES; j++, entry++) { + eb_initialize_search(entry); + } + } + + LOG(("out: eb_initialize_searches(book=%d)", (int)book->code)); +} + + +/* + * Finalize all search elements in the current subbook. + */ +void +eb_finalize_searches(EB_Book *book) +{ + EB_Subbook *subbook; + EB_Multi_Search *multi; + EB_Search *entry; + int i, j; + + LOG(("in: eb_finalize_searches(book=%d)", (int)book->code)); + + subbook = book->subbook_current; + + eb_finalize_search(&subbook->word_alphabet); + eb_finalize_search(&subbook->word_asis); + eb_finalize_search(&subbook->word_kana); + eb_finalize_search(&subbook->endword_alphabet); + eb_finalize_search(&subbook->endword_asis); + eb_finalize_search(&subbook->endword_kana); + eb_finalize_search(&subbook->keyword); + eb_finalize_search(&subbook->menu); + eb_finalize_search(&subbook->image_menu); + eb_finalize_search(&subbook->copyright); + eb_finalize_search(&subbook->text); + eb_finalize_search(&subbook->sound); + + for (i = 0, multi = subbook->multis; i < EB_MAX_KEYWORDS; + i++, multi++) { + eb_finalize_search(&multi->search); + multi->entry_count = 0; + for (j = 0, entry = multi->entries; + j < multi->entry_count; j++, entry++) { + eb_finalize_search(entry); + } + } + + LOG(("out: eb_finalize_searches()")); +} + + +/* + * Pre-search for a word described in the current search context. + * It descends intermediate indexes and reached to a leaf page that + * may have the word. + * If succeeded, 0 is returned. Otherwise -1 is returned. + */ +EB_Error_Code +eb_presearch_word(EB_Book *book, EB_Search_Context *context) +{ + EB_Error_Code error_code; + int next_page; + int index_depth; + char *cache_p; + + pthread_mutex_lock(&cache_mutex); + LOG(("in: eb_presearch_word(book=%d)", (int)book->code)); + + /* + * Discard cache data. + */ + cache_book_code = EB_BOOK_NONE; + + /* + * Search the word in intermediate indexes. + * Find a page number of the leaf index page. + */ + for (index_depth = 0; index_depth < EB_MAX_INDEX_DEPTH; index_depth++) { + next_page = context->page; + + /* + * Seek and read a page. + */ + if (zio_lseek(&book->subbook_current->text_zio, + ((off_t) context->page - 1) * EB_SIZE_PAGE, SEEK_SET) < 0) { + cache_book_code = EB_BOOK_NONE; + error_code = EB_ERR_FAIL_SEEK_TEXT; + goto failed; + } + if (zio_read(&book->subbook_current->text_zio, cache_buffer, + EB_SIZE_PAGE) != EB_SIZE_PAGE) { + cache_book_code = EB_BOOK_NONE; + error_code = EB_ERR_FAIL_READ_TEXT; + goto failed; + } + + /* + * Get some data from the read page. + */ + context->page_id = eb_uint1(cache_buffer); + context->entry_length = eb_uint1(cache_buffer + 1); + if (context->entry_length == 0) + context->entry_arrangement = EB_ARRANGE_VARIABLE; + else + context->entry_arrangement = EB_ARRANGE_FIXED; + context->entry_count = eb_uint2(cache_buffer + 2); + context->offset = 4; + cache_p = cache_buffer + 4; + + LOG(("aux: eb_presearch_word(page=%d, page_id=0x%02x, \ +entry_length=%d, entry_arrangement=%d, entry_count=%d)", + context->page, context->page_id, context->entry_length, + context->entry_arrangement, context->entry_count)); + + /* + * Exit the loop if it reached to the leaf index. + */ + if (PAGE_ID_IS_LEAF_LAYER(context->page_id)) + break; + + /* + * Search a page of next level index. + */ + for (context->entry_index = 0; + context->entry_index < context->entry_count; + context->entry_index++) { + if (EB_SIZE_PAGE < context->offset + context->entry_length + 4) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + if (context->compare_pre(context->canonicalized_word, cache_p, + context->entry_length) <= 0) { + next_page = eb_uint4(cache_p + context->entry_length); + break; + } + cache_p += context->entry_length + 4; + context->offset += context->entry_length + 4; + } + if (context->entry_count <= context->entry_index + || context->page == next_page) { + context->comparison_result = -1; + goto succeeded; + } + context->page = next_page; + } + + /* + * Check for the index depth. + */ + if (index_depth == EB_MAX_INDEX_DEPTH) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + /* + * Update search context and cache information. + */ + context->entry_index = 0; + context->comparison_result = 1; + context->in_group_entry = 0; + cache_book_code = book->code; + cache_page = context->page; + + succeeded: + LOG(("out: eb_presearch_word() = %s", eb_error_string(EB_SUCCESS))); + pthread_mutex_unlock(&cache_mutex); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_presearch_word() = %s", eb_error_string(error_code))); + pthread_mutex_unlock(&cache_mutex); + return error_code; +} + +/* + * Get hit entries of a submitted search request. + */ +EB_Error_Code +eb_hit_list(EB_Book *book, int max_hit_count, EB_Hit *hit_list, int *hit_count) +{ + EB_Error_Code error_code; + EB_Search_Context temporary_context; + EB_Hit temporary_hit_lists[EB_NUMBER_OF_SEARCH_CONTEXTS][EB_TMP_MAX_HITS]; + int temporary_hit_counts[EB_NUMBER_OF_SEARCH_CONTEXTS]; + int more_hit_count; + int i; + + /* + * Lock cache data and the book. + */ + pthread_mutex_lock(&cache_mutex); + eb_lock(&book->lock); + LOG(("in: eb_hit_list(book=%d, max_hit_count=%d)", (int)book->code, + max_hit_count)); + + if (max_hit_count == 0) + goto succeeded; + + *hit_count = 0; + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Get a list of hit entries. + */ + switch (book->search_contexts->code) { + case EB_SEARCH_EXACTWORD: + case EB_SEARCH_WORD: + case EB_SEARCH_ENDWORD: + /* + * In case of exactword, word of endword search. + */ + error_code = eb_hit_list_word(book, book->search_contexts, + max_hit_count, hit_list, hit_count); + if (error_code != EB_SUCCESS) + goto failed; + break; + + case EB_SEARCH_KEYWORD: + case EB_SEARCH_CROSS: + /* + * In case of keyword or cross search. + */ + for (;;) { + int search_is_over = 0; + + for (i = 0; i < EB_MAX_KEYWORDS; i++) { + if (book->search_contexts[i].code != EB_SEARCH_KEYWORD + && book->search_contexts[i].code != EB_SEARCH_CROSS) + break; + memcpy(&temporary_context, book->search_contexts + i, + sizeof(EB_Search_Context)); + error_code = eb_hit_list_keyword(book, &temporary_context, + EB_TMP_MAX_HITS, temporary_hit_lists[i], + temporary_hit_counts + i); + if (error_code != EB_SUCCESS) + goto failed; + if (temporary_hit_counts[i] == 0) { + search_is_over = 1; + break; + } + } + if (search_is_over) + break; + + eb_and_hit_lists(hit_list + *hit_count, &more_hit_count, + max_hit_count - *hit_count, i, temporary_hit_lists, + temporary_hit_counts); + + for (i = 0; i < EB_MAX_MULTI_ENTRIES; i++) { + if (book->search_contexts[i].code != EB_SEARCH_KEYWORD + && book->search_contexts[i].code != EB_SEARCH_CROSS) + break; + error_code = eb_hit_list_keyword(book, + book->search_contexts + i, temporary_hit_counts[i], + temporary_hit_lists[i], temporary_hit_counts + i); + if (error_code != EB_SUCCESS) + goto failed; + } + + *hit_count += more_hit_count; + if (max_hit_count <= *hit_count) + break; + } + break; + + case EB_SEARCH_MULTI: + /* + * In case of multi search. + */ + for (;;) { + int search_is_over = 0; + + for (i = 0; i < EB_MAX_MULTI_ENTRIES; i++) { + if (book->search_contexts[i].code != EB_SEARCH_MULTI) + break; + memcpy(&temporary_context, book->search_contexts + i, + sizeof(EB_Search_Context)); + error_code = eb_hit_list_multi(book, &temporary_context, + EB_TMP_MAX_HITS, temporary_hit_lists[i], + temporary_hit_counts + i); + if (error_code != EB_SUCCESS) + goto failed; + if (temporary_hit_counts[i] == 0) { + search_is_over = 1; + break; + } + } + if (search_is_over) + break; + + eb_and_hit_lists(hit_list + *hit_count, &more_hit_count, + max_hit_count - *hit_count, i, temporary_hit_lists, + temporary_hit_counts); + + for (i = 0; i < EB_MAX_MULTI_ENTRIES; i++) { + if (book->search_contexts[i].code != EB_SEARCH_MULTI) + break; + error_code = eb_hit_list_multi(book, + book->search_contexts + i, temporary_hit_counts[i], + temporary_hit_lists[i], temporary_hit_counts + i); + if (error_code != EB_SUCCESS) + goto failed; + } + + *hit_count += more_hit_count; + if (max_hit_count <= *hit_count) + break; + } + break; + + default: + /* not reached */ + error_code = EB_ERR_NO_PREV_SEARCH; + goto failed; + } + + /* + * Unlock cache data and the book. + */ + succeeded: + LOG(("out: eb_hit_list(hit_count=%d) = %s", + *hit_count, eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + pthread_mutex_unlock(&cache_mutex); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *hit_count = 0; + LOG(("out: eb_hit_list() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + pthread_mutex_unlock(&cache_mutex); + return error_code; +} + + +/* + * Get hit entries of a submitted exactword/word/endword search request. + */ +static EB_Error_Code +eb_hit_list_word(EB_Book *book, EB_Search_Context *context, int max_hit_count, + EB_Hit *hit_list, int *hit_count) +{ + EB_Error_Code error_code; + EB_Hit *hit; + int group_id; + char *cache_p; + + LOG(("in: eb_hit_list_word(book=%d, max_hit_count=%d)", (int)book->code, + max_hit_count)); + + hit = hit_list; + *hit_count = 0; + + /* + * If the result of previous comparison is negative value, all + * matched entries have been found. + */ + if (context->comparison_result < 0 || max_hit_count <= 0) + goto succeeded; + + for (;;) { + /* + * Read a page to search, if the page is not on the cache buffer. + * + * Cache may be missed by the two reasons: + * 1. the search process reaches to the end of an index page, + * and tries to read the next page. + * 2. Someone else used the cache buffer. + * + * At the case of 1, the search process reads the page and update + * the search context. At the case of 2. it reads the page but + * must not update the context! + */ + if (cache_book_code != book->code || cache_page != context->page) { + if (zio_lseek(&book->subbook_current->text_zio, + ((off_t) context->page - 1) * EB_SIZE_PAGE, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_TEXT; + goto failed; + } + if (zio_read(&book->subbook_current->text_zio, + cache_buffer, EB_SIZE_PAGE) != EB_SIZE_PAGE) { + error_code = EB_ERR_FAIL_READ_TEXT; + goto failed; + } + + /* + * Update search context. + */ + if (context->entry_index == 0) { + context->page_id = eb_uint1(cache_buffer); + context->entry_length = eb_uint1(cache_buffer + 1); + if (context->entry_length == 0) + context->entry_arrangement = EB_ARRANGE_VARIABLE; + else + context->entry_arrangement = EB_ARRANGE_FIXED; + context->entry_count = eb_uint2(cache_buffer + 2); + context->entry_index = 0; + context->offset = 4; + } + + cache_book_code = book->code; + cache_page = context->page; + } + + cache_p = cache_buffer + context->offset; + + LOG(("aux: eb_hit_list_word(page=%d, page_id=0x%02x, \ +entry_length=%d, entry_arrangement=%d, entry_count=%d)", + context->page, context->page_id, context->entry_length, + context->entry_arrangement, context->entry_count)); + + if (!PAGE_ID_IS_LEAF_LAYER(context->page_id)) { + /* + * Not a leaf index. It is an error. + */ + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + if (!PAGE_ID_HAVE_GROUP_ENTRY(context->page_id) + && context->entry_arrangement == EB_ARRANGE_FIXED) { + /* + * The leaf index doesn't have a group entry. + * Find text and heading locations. + */ + while (context->entry_index < context->entry_count) { + if (EB_SIZE_PAGE + < context->offset + context->entry_length + 12) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + /* + * Compare word and pattern. + * If matched, add it to a hit list. + */ + context->comparison_result + = context->compare_single(context->word, cache_p, + context->entry_length); + if (context->comparison_result == 0) { + hit->heading.page + = eb_uint4(cache_p + context->entry_length + 6); + hit->heading.offset + = eb_uint2(cache_p + context->entry_length + 10); + hit->text.page + = eb_uint4(cache_p + context->entry_length); + hit->text.offset + = eb_uint2(cache_p + context->entry_length + 4); + hit++; + *hit_count += 1; + } + context->entry_index++; + context->offset += context->entry_length + 12; + cache_p += context->entry_length + 12; + + if (context->comparison_result < 0 + || max_hit_count <= *hit_count) + goto succeeded; + } + + } else if (!PAGE_ID_HAVE_GROUP_ENTRY(context->page_id) + && context->entry_arrangement == EB_ARRANGE_VARIABLE) { + + /* + * The leaf index doesn't have a group entry. + * Find text and heading locations. + */ + while (context->entry_index < context->entry_count) { + if (EB_SIZE_PAGE < context->offset + 1) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + context->entry_length = eb_uint1(cache_p); + if (EB_SIZE_PAGE + < context->offset + context->entry_length + 13) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + /* + * Compare word and pattern. + * If matched, add it to a hit list. + */ + context->comparison_result + = context->compare_single(context->word, cache_p + 1, + context->entry_length); + if (context->comparison_result == 0) { + hit->heading.page + = eb_uint4(cache_p + context->entry_length + 7); + hit->heading.offset + = eb_uint2(cache_p + context->entry_length + 11); + hit->text.page + = eb_uint4(cache_p + context->entry_length + 1); + hit->text.offset + = eb_uint2(cache_p + context->entry_length + 5); + hit++; + *hit_count += 1; + } + context->entry_index++; + context->offset += context->entry_length + 13; + cache_p += context->entry_length + 13; + + if (context->comparison_result < 0 + || max_hit_count <= *hit_count) + goto succeeded; + } + + } else { + /* + * The leaf index have a group entry. + * Find text and heading locations. + */ + while (context->entry_index < context->entry_count) { + if (EB_SIZE_PAGE < context->offset + 2) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + group_id = eb_uint1(cache_p); + + if (group_id == 0x00) { + /* + * 0x00 -- Single entry. + */ + context->entry_length = eb_uint1(cache_p + 1); + if (EB_SIZE_PAGE + < context->offset + context->entry_length + 14) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + /* + * Compare word and pattern. + * If matched, add it to a hit list. + */ + context->comparison_result + = context->compare_single(context->canonicalized_word, + cache_p + 2, context->entry_length); + if (context->comparison_result == 0) { + hit->heading.page + = eb_uint4(cache_p + context->entry_length + 8); + hit->heading.offset + = eb_uint2(cache_p + context->entry_length + 12); + hit->text.page + = eb_uint4(cache_p + context->entry_length + 2); + hit->text.offset + = eb_uint2(cache_p + context->entry_length + 6); + hit++; + *hit_count += 1; + } + context->in_group_entry = 0; + context->offset += context->entry_length + 14; + cache_p += context->entry_length + 14; + + } else if (group_id == 0x80) { + /* + * 0x80 -- Start of group entry. + */ + context->entry_length = eb_uint1(cache_p + 1); + if (EB_SIZE_PAGE + < context->offset + context->entry_length + 4) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + context->comparison_result + = context->compare_single(context->canonicalized_word, + cache_p + 4, context->entry_length); + context->in_group_entry = 1; + cache_p += context->entry_length + 4; + context->offset += context->entry_length + 4; + + } else if (group_id == 0xc0) { + /* + * Element of the group entry + */ + context->entry_length = eb_uint1(cache_p + 1); + if (EB_SIZE_PAGE < context->offset + 14) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + /* + * Compare word and pattern. + * If matched, add it to a hit list. + */ + if (context->comparison_result == 0 + && context->in_group_entry + && context->compare_group(context->word, cache_p + 2, + context->entry_length) == 0) { + hit->heading.page + = eb_uint4(cache_p + context->entry_length + 8); + hit->heading.offset + = eb_uint2(cache_p + context->entry_length + 12); + hit->text.page + = eb_uint4(cache_p + context->entry_length + 2); + hit->text.offset + = eb_uint2(cache_p + context->entry_length + 6); + hit++; + *hit_count += 1; + } + context->offset += context->entry_length + 14; + cache_p += context->entry_length + 14; + + } else { + /* + * Unknown group ID. + */ + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + context->entry_index++; + if (context->comparison_result < 0 + || max_hit_count <= *hit_count) + goto succeeded; + } + } + + /* + * Go to a next page if available. + */ + if (PAGE_ID_IS_LAYER_END(context->page_id)) { + context->comparison_result = -1; + goto succeeded; + } + context->page++; + context->entry_index = 0; + } + + succeeded: + LOG(("out: eb_hit_list_word(hit_count=%d) = %s", + *hit_count, eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + * Discard cache if read error occurs. + */ + failed: + if (error_code == EB_ERR_FAIL_READ_TEXT) + cache_book_code = EB_BOOK_NONE; + *hit_count = 0; + LOG(("out: eb_hit_list_word() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Get hit entries of a submitted keyword search request. + */ +static EB_Error_Code +eb_hit_list_keyword(EB_Book *book, EB_Search_Context *context, + int max_hit_count, EB_Hit *hit_list, int *hit_count) +{ + EB_Error_Code error_code; + EB_Text_Context text_context; + EB_Hit *hit; + int group_id; + char *cache_p; + + LOG(("in: eb_hit_list_keyword(book=%d, max_hit_count=%d)", + (int)book->code, max_hit_count)); + + hit = hit_list; + *hit_count = 0; + + /* + * Backup the text context in `book'. + */ + memcpy(&text_context, &book->text_context, sizeof(EB_Text_Context)); + + /* + * Seek text file. + */ + if (context->in_group_entry && context->comparison_result == 0) { + error_code = eb_seek_text(book, &context->keyword_heading); + if (error_code != EB_SUCCESS) + goto failed; + } + + /* + * If the result of previous comparison is negative value, all + * matched entries have been found. + */ + if (context->comparison_result < 0 || max_hit_count <= 0) + goto succeeded; + + for (;;) { + /* + * Read a page to search, if the page is not on the cache buffer. + * + * Cache may be missed by the two reasons: + * 1. the search process reaches to the end of an index page, + * and tries to read the next page. + * 2. Someone else used the cache buffer. + * + * At the case of 1, the search process reads the page and update + * the search context. At the case of 2. it reads the page but + * must not update the context! + */ + if (cache_book_code != book->code || cache_page != context->page) { + if (zio_lseek(&book->subbook_current->text_zio, + ((off_t) context->page - 1) * EB_SIZE_PAGE, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_TEXT; + goto failed; + } + if (zio_read(&book->subbook_current->text_zio, cache_buffer, + EB_SIZE_PAGE) != EB_SIZE_PAGE) { + error_code = EB_ERR_FAIL_READ_TEXT; + goto failed; + } + + /* + * Update search context. + */ + if (context->entry_index == 0) { + context->page_id = eb_uint1(cache_buffer); + context->entry_length = eb_uint1(cache_buffer + 1); + if (context->entry_length == 0) + context->entry_arrangement = EB_ARRANGE_VARIABLE; + else + context->entry_arrangement = EB_ARRANGE_FIXED; + context->entry_count = eb_uint2(cache_buffer + 2); + context->entry_index = 0; + context->offset = 4; + } + + cache_book_code = book->code; + cache_page = context->page; + } + + cache_p = cache_buffer + context->offset; + + LOG(("aux: eb_hit_list_keyword(page=%d, page_id=0x%02x, \ +entry_length=%d, entry_arrangement=%d, entry_count=%d)", + context->page, context->page_id, context->entry_length, + context->entry_arrangement, context->entry_count)); + + if (!PAGE_ID_IS_LEAF_LAYER(context->page_id)) { + /* + * Not a leaf index. It is an error. + */ + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + if (!PAGE_ID_HAVE_GROUP_ENTRY(context->page_id) + && context->entry_arrangement == EB_ARRANGE_FIXED) { + /* + * The leaf index doesn't have a group entry. + * Find text and heading locations. + */ + while (context->entry_index < context->entry_count) { + if (EB_SIZE_PAGE + < context->offset + context->entry_length + 12) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + /* + * Compare word and pattern. + * If matched, add it to a hit list. + */ + context->comparison_result + = context->compare_single(context->word, cache_p, + context->entry_length); + if (context->comparison_result == 0) { + hit->heading.page + = eb_uint4(cache_p + context->entry_length + 6); + hit->heading.offset + = eb_uint2(cache_p + context->entry_length + 10); + hit->text.page + = eb_uint4(cache_p + context->entry_length); + hit->text.offset + = eb_uint2(cache_p + context->entry_length + 4); + hit++; + *hit_count += 1; + } + context->entry_index++; + context->offset += context->entry_length + 12; + cache_p += context->entry_length + 12; + + if (context->comparison_result < 0 + || max_hit_count <= *hit_count) + goto succeeded; + } + + } else if (!PAGE_ID_HAVE_GROUP_ENTRY(context->page_id) + && context->entry_arrangement == EB_ARRANGE_VARIABLE) { + /* + * The leaf index doesn't have a group entry. + * Find text and heading locations. + */ + while (context->entry_index < context->entry_count) { + if (EB_SIZE_PAGE < context->offset + 1) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + context->entry_length = eb_uint1(cache_p); + if (EB_SIZE_PAGE + < context->offset + context->entry_length + 13) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + /* + * Compare word and pattern. + * If matched, add it to a hit list. + */ + context->comparison_result + = context->compare_single(context->word, cache_p + 1, + context->entry_length); + if (context->comparison_result == 0) { + hit->heading.page + = eb_uint4(cache_p + context->entry_length + 7); + hit->heading.offset + = eb_uint2(cache_p + context->entry_length + 11); + hit->text.page + = eb_uint4(cache_p + context->entry_length + 1); + hit->text.offset + = eb_uint2(cache_p + context->entry_length + 5); + hit++; + *hit_count += 1; + } + context->entry_index++; + context->offset += context->entry_length + 13; + cache_p += context->entry_length + 13; + + if (context->comparison_result < 0 + || max_hit_count <= *hit_count) + goto succeeded; + } + + } else { + /* + * The leaf index have a group entry. + * Find text and heading locations. + */ + while (context->entry_index < context->entry_count) { + if (EB_SIZE_PAGE < context->offset + 2) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + group_id = eb_uint1(cache_p); + + if (group_id == 0x00) { + /* + * 0x00 -- Single entry. + */ + context->entry_length = eb_uint1(cache_p + 1); + if (EB_SIZE_PAGE + < context->offset + context->entry_length + 14) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + /* + * Compare word and pattern. + * If matched, add it to a hit list. + */ + context->comparison_result + = context->compare_single(context->canonicalized_word, + cache_p + 2, context->entry_length); + if (context->comparison_result == 0) { + hit->heading.page + = eb_uint4(cache_p + context->entry_length + 8); + hit->heading.offset + = eb_uint2(cache_p + context->entry_length + 12); + hit->text.page + = eb_uint4(cache_p + context->entry_length + 2); + hit->text.offset + = eb_uint2(cache_p + context->entry_length + 6); + hit++; + *hit_count += 1; + } + context->in_group_entry = 0; + context->offset += context->entry_length + 14; + cache_p += context->entry_length + 14; + + } else if (group_id == 0x80) { + /* + * 0x80 -- Start of group entry. + */ + context->entry_length = eb_uint1(cache_p + 1); + if (EB_SIZE_PAGE + < context->offset + context->entry_length + 12) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + context->comparison_result + = context->compare_single(context->word, cache_p + 6, + context->entry_length); + context->keyword_heading.page + = eb_uint4(cache_p + context->entry_length + 6); + context->keyword_heading.offset + = eb_uint2(cache_p + context->entry_length + 10); + context->in_group_entry = 1; + cache_p += context->entry_length + 12; + context->offset += context->entry_length + 12; + + if (context->comparison_result == 0) { + error_code + = eb_seek_text(book, &context->keyword_heading); + if (error_code != EB_SUCCESS) + goto failed; + } + + } else if (group_id == 0xc0) { + /* + * Element of the group entry. + */ + if (EB_SIZE_PAGE < context->offset + 7) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + /* + * Compare word and pattern. + * If matched, add it to a hit list. + */ + if (context->in_group_entry + && context->comparison_result == 0) { + error_code + = eb_tell_text(book, &context->keyword_heading); + if (error_code != EB_SUCCESS) + goto failed; + hit->heading.page = context->keyword_heading.page; + hit->heading.offset = context->keyword_heading.offset; + hit->text.page = eb_uint4(cache_p + 1); + hit->text.offset = eb_uint2(cache_p + 5); + hit++; + *hit_count += 1; + error_code = eb_forward_heading(book); + if (error_code != EB_SUCCESS) + goto failed; + } + context->offset += 7; + cache_p += 7; + + } else { + /* + * Unknown group ID. + */ + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + context->entry_index++; + if (context->comparison_result < 0 + || max_hit_count <= *hit_count) + goto succeeded; + } + } + + /* + * Go to a next page if available. + */ + if (PAGE_ID_IS_LAYER_END(context->page_id)) { + context->comparison_result = -1; + goto succeeded; + } + context->page++; + context->entry_index = 0; + } + + succeeded: + if (context->in_group_entry && context->comparison_result == 0) { + error_code = eb_tell_text(book, &context->keyword_heading); + if (error_code != EB_SUCCESS) + goto failed; + } + + /* + * Restore the text context in `book'. + */ + memcpy(&book->text_context, &text_context, sizeof(EB_Text_Context)); + LOG(("out: eb_hit_list_keyword(hit_count=%d) = %s", + *hit_count, eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + * Discard cache if read error occurs. + */ + failed: + if (error_code == EB_ERR_FAIL_READ_TEXT) + cache_book_code = EB_BOOK_NONE; + *hit_count = 0; + memcpy(&book->text_context, &text_context, sizeof(EB_Text_Context)); + LOG(("out: eb_hit_list_keyword() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Get hit entries of a submitted multi search request. + */ +static EB_Error_Code +eb_hit_list_multi(EB_Book *book, EB_Search_Context *context, int max_hit_count, + EB_Hit *hit_list, int *hit_count) +{ + EB_Error_Code error_code; + EB_Hit *hit; + int group_id; + char *cache_p; + + LOG(("in: eb_hit_list_multi(book=%d, max_hit_count=%d)", (int)book->code, + max_hit_count)); + + hit = hit_list; + *hit_count = 0; + + /* + * If the result of previous comparison is negative value, all + * matched entries have been found. + */ + if (context->comparison_result < 0 || max_hit_count <= 0) + goto succeeded; + + for (;;) { + /* + * Read a page to search, if the page is not on the cache buffer. + * + * Cache may be missed by the two reasons: + * 1. the search process reaches to the end of an index page, + * and tries to read the next page. + * 2. Someone else used the cache buffer. + * + * At the case of 1, the search process reads the page and update + * the search context. At the case of 2. it reads the page but + * must not update the context! + */ + if (cache_book_code != book->code || cache_page != context->page) { + if (zio_lseek(&book->subbook_current->text_zio, + ((off_t) context->page - 1) * EB_SIZE_PAGE, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_TEXT; + goto failed; + } + if (zio_read(&book->subbook_current->text_zio, cache_buffer, + EB_SIZE_PAGE) != EB_SIZE_PAGE) { + error_code = EB_ERR_FAIL_READ_TEXT; + goto failed; + } + + /* + * Update search context. + */ + if (context->entry_index == 0) { + context->page_id = eb_uint1(cache_buffer); + context->entry_length = eb_uint1(cache_buffer + 1); + if (context->entry_length == 0) + context->entry_arrangement = EB_ARRANGE_VARIABLE; + else + context->entry_arrangement = EB_ARRANGE_FIXED; + context->entry_count = eb_uint2(cache_buffer + 2); + context->entry_index = 0; + context->offset = 4; + } + + cache_book_code = book->code; + cache_page = context->page; + } + + cache_p = cache_buffer + context->offset; + + LOG(("aux: eb_hit_list_multi(page=%d, page_id=0x%02x, \ +entry_length=%d, entry_arrangement=%d, entry_count=%d)", + context->page, context->page_id, context->entry_length, + context->entry_arrangement, context->entry_count)); + + if (!PAGE_ID_IS_LEAF_LAYER(context->page_id)) { + /* + * Not a leaf index. It is an error. + */ + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + if (!PAGE_ID_HAVE_GROUP_ENTRY(context->page_id) + && context->entry_arrangement == EB_ARRANGE_FIXED) { + /* + * The leaf index doesn't have a group entry. + * Find text and heading locations. + */ + while (context->entry_index < context->entry_count) { + if (EB_SIZE_PAGE + < context->offset + context->entry_length + 13) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + /* + * Compare word and pattern. + * If matched, add it to a hit list. + */ + context->comparison_result + = context->compare_single(context->word, cache_p, + context->entry_length); + if (context->comparison_result == 0) { + hit->heading.page + = eb_uint4(cache_p + context->entry_length + 6); + hit->heading.offset + = eb_uint2(cache_p + context->entry_length + 10); + hit->text.page + = eb_uint4(cache_p + context->entry_length); + hit->text.offset + = eb_uint2(cache_p + context->entry_length + 4); + hit++; + *hit_count += 1; + } + context->entry_index++; + context->offset += context->entry_length + 12; + cache_p += context->entry_length + 12; + + if (context->comparison_result < 0 + || max_hit_count <= *hit_count) + goto succeeded; + } + + } else if (!PAGE_ID_HAVE_GROUP_ENTRY(context->page_id) + && context->entry_arrangement == EB_ARRANGE_VARIABLE) { + /* + * The leaf index doesn't have a group entry. + * Find text and heading locations. + */ + while (context->entry_index < context->entry_count) { + if (EB_SIZE_PAGE < context->offset + 1) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + context->entry_length = eb_uint1(cache_p); + if (EB_SIZE_PAGE + < context->offset + context->entry_length + 13) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + /* + * Compare word and pattern. + * If matched, add it to a hit list. + */ + context->comparison_result + = context->compare_single(context->word, cache_p + 1, + context->entry_length); + if (context->comparison_result == 0) { + hit->heading.page + = eb_uint4(cache_p + context->entry_length + 7); + hit->heading.offset + = eb_uint2(cache_p + context->entry_length + 11); + hit->text.page + = eb_uint4(cache_p + context->entry_length + 1); + hit->text.offset + = eb_uint2(cache_p + context->entry_length + 5); + hit++; + *hit_count += 1; + } + context->entry_index++; + context->offset += context->entry_length + 13; + cache_p += context->entry_length + 13; + + if (context->comparison_result < 0 + || max_hit_count <= *hit_count) + goto succeeded; + } + + } else { + /* + * The leaf index have a group entry. + * Find text and heading locations. + */ + while (context->entry_index < context->entry_count) { + if (EB_SIZE_PAGE < context->offset + 2) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + group_id = eb_uint1(cache_p); + + if (group_id == 0x00) { + /* + * 0x00 -- Single entry. + */ + context->entry_length = eb_uint1(cache_p + 1); + if (EB_SIZE_PAGE + < context->offset + context->entry_length + 14) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + /* + * Compare word and pattern. + * If matched, add it to a hit list. + */ + context->comparison_result + = context->compare_single(context->canonicalized_word, + cache_p + 2, context->entry_length); + if (context->comparison_result == 0) { + hit->heading.page + = eb_uint4(cache_p + context->entry_length + 8); + hit->heading.offset + = eb_uint2(cache_p + context->entry_length + 12); + hit->text.page + = eb_uint4(cache_p + context->entry_length + 2); + hit->text.offset + = eb_uint2(cache_p + context->entry_length + 6); + hit++; + *hit_count += 1; + } + context->in_group_entry = 0; + context->offset += context->entry_length + 14; + cache_p += context->entry_length + 14; + + } else if (group_id == 0x80) { + /* + * 0x80 -- Start of group entry. + */ + context->entry_length = eb_uint1(cache_p + 1); + if (EB_SIZE_PAGE + < context->offset + context->entry_length + 6) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + context->comparison_result + = context->compare_single(context->word, cache_p + 6, + context->entry_length); + context->in_group_entry = 1; + cache_p += context->entry_length + 6; + context->offset += context->entry_length + 6; + + } else if (group_id == 0xc0) { + /* + * Element of the group entry. + */ + if (EB_SIZE_PAGE < context->offset + 13) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + /* + * Compare word and pattern. + * If matched, add it to a hit list. + */ + if (context->in_group_entry + && context->comparison_result == 0) { + hit->heading.page = eb_uint4(cache_p + 7); + hit->heading.offset = eb_uint2(cache_p + 11); + hit->text.page = eb_uint4(cache_p + 1); + hit->text.offset = eb_uint2(cache_p + 5); + hit++; + *hit_count += 1; + } + context->offset += 13; + cache_p += 13; + + } else { + /* + * Unknown group ID. + */ + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + context->entry_index++; + if (context->comparison_result < 0 + || max_hit_count <= *hit_count) + goto succeeded; + } + } + + /* + * Go to a next page if available. + */ + if (PAGE_ID_IS_LAYER_END(context->page_id)) { + context->comparison_result = -1; + goto succeeded; + } + context->page++; + context->entry_index = 0; + } + + succeeded: + LOG(("out: eb_hit_list_multi(hit_count=%d) = %s", + *hit_count, eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + * Discard cache if read error occurs. + */ + failed: + if (error_code == EB_ERR_FAIL_READ_TEXT) + cache_book_code = EB_BOOK_NONE; + *hit_count = 0; + LOG(("out: eb_hit_list_multi() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Do AND operation of hit lists. + * and_list = hit_lists[0] AND hit_lists[1] AND ... + */ +static void +eb_and_hit_lists(EB_Hit and_list[EB_TMP_MAX_HITS], int *and_count, + int max_and_count, int hit_list_count, + EB_Hit hit_lists[EB_NUMBER_OF_SEARCH_CONTEXTS][EB_TMP_MAX_HITS], + int hit_counts[EB_NUMBER_OF_SEARCH_CONTEXTS]) +{ + int hit_indexes[EB_NUMBER_OF_SEARCH_CONTEXTS]; + int greatest_list; + int greatest_page; + int greatest_offset; + int current_page; + int current_offset; + int equal_count; + int increment_count; + int i; + + LOG(("in: eb_and_hit_lists(max_and_count=%d, hit_list_count=%d)", + max_and_count, hit_list_count)); + + /* + * Initialize indexes for the hit_lists[]. + */ + for (i = 0; i < hit_list_count; i++) + hit_indexes[i] = 0; + + /* + * Generate the new list `and_list'. + */ + *and_count = 0; + while (*and_count < max_and_count) { + /* + * Initialize variables. + */ + greatest_list = -1; + greatest_page = 0; + greatest_offset = 0; + current_page = 0; + current_offset = 0; + equal_count = 0; + + /* + * Compare the current elements of the lists. + */ + for (i = 0; i < hit_list_count; i++) { + /* + * If we have been reached to the tail of the hit_lists[i], + * skip the list. + */ + if (hit_counts[i] <= hit_indexes[i]) + continue; + + /* + * Compare {current_page, current_offset} and {greatest_page, + * greatest_offset}. + */ + current_page = hit_lists[i][hit_indexes[i]].text.page; + current_offset = hit_lists[i][hit_indexes[i]].text.offset; + + if (greatest_list == -1) { + greatest_page = current_page; + greatest_offset = current_offset; + greatest_list = i; + equal_count++; + } else if (greatest_page < current_page) { + greatest_page = current_page; + greatest_offset = current_offset; + greatest_list = i; + } else if (current_page == greatest_page + && greatest_offset < current_offset) { + greatest_page = current_page; + greatest_offset = current_offset; + greatest_list = i; + } else if (current_page == greatest_page + && current_offset == greatest_offset) { + equal_count++; + } + } + + if (equal_count == hit_list_count) { + /* + * All the current elements of the lists point to the same + * position. This is hit element. Increase indexes of all + * lists. + */ + memcpy(and_list + *and_count, hit_lists[0] + hit_indexes[0], + sizeof(EB_Hit)); + *and_count += 1; + for (i = 0; i < hit_list_count; i++) { + if (hit_counts[i] <= hit_indexes[i]) + continue; + hit_indexes[i]++; + } + } else { + /* + * This is not hit element. Increase indexes of all lists + * except for greatest element(s). If there is no list + * whose index is incremented, our job has been completed. + */ + increment_count = 0; + for (i = 0; i < hit_list_count; i++) { + if (hit_counts[i] <= hit_indexes[i]) + continue; + current_page = hit_lists[i][hit_indexes[i]].text.page; + current_offset = hit_lists[i][hit_indexes[i]].text.offset; + if (current_page != greatest_page + || current_offset != greatest_offset) { + hit_indexes[i]++; + increment_count++; + } + } + if (increment_count == 0) + break; + } + } + + /* + * Update hit_counts[]. + * The hit counts of the lists are set to the current indexes. + */ + for (i = 0; i < hit_list_count; i++) + hit_counts[i] = hit_indexes[i]; + + LOG(("out: eb_and_hit_lists(and_count=%d)", *and_count)); +} diff --git a/eb/setword.c b/eb/setword.c new file mode 100644 index 0000000..0a66f7e --- /dev/null +++ b/eb/setword.c @@ -0,0 +1,1311 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "build-post.h" + +/* + * Unexported functions. + */ +static void eb_fix_word(EB_Book *book, const EB_Search *search, char *word, + char *canonicalized_word); +static EB_Error_Code eb_convert_latin(EB_Book *book, const char *input_word, + char *word, EB_Word_Code *word_code); +static EB_Error_Code eb_convert_euc_jp(EB_Book *book, const char *input_word, + char *word, EB_Word_Code *word_code); +static void eb_convert_katakana_jis(char *word); +static void eb_convert_hiragana_jis(char *word); +static void eb_convert_lower_latin(char *word); +static void eb_convert_lower_jis(char *word); +static void eb_delete_marks_jis(char *word); +static void eb_convert_long_vowels_jis(char *word); +static void eb_delete_long_vowels_jis(char *word); +static void eb_convert_double_consonants_jis(char *word); +static void eb_convert_contracted_sounds_jis(char *word); +static void eb_convert_small_vowels_jis(char *word); +static void eb_convert_voiced_consonants_jis(char *word); +static void eb_convert_p_sounds_jis(char *word); +static void eb_delete_spaces_latin(char *word); +static void eb_delete_spaces_jis(char *word); +static void eb_reverse_word_latin(char *word); +static void eb_reverse_word_jis(char *word); + + +/* + * Make a fixed word and a cannonicalized word for `WORD SEARCH'. + * + * If `inputword' is a KANA word, EB_WORD_KANA is returned. + * If `inputword' is a alphabetic word, EB_WORD_ALPHABET is returned. + * Otherwise, -1 is returned. It means that an error occurs. + */ +EB_Error_Code +eb_set_word(EB_Book *book, const char *input_word, char *word, + char *canonicalized_word, EB_Word_Code *word_code) +{ + EB_Error_Code error_code; + const EB_Search *search; + + LOG(("in: eb_set_word(book=%d, input_word=%s)", (int)book->code, + eb_quoted_string(input_word))); + + /* + * Make a fixed word and a canonicalized word from `input_word'. + */ + if (book->character_code == EB_CHARCODE_ISO8859_1) + error_code = eb_convert_latin(book, input_word, word, word_code); + else + error_code = eb_convert_euc_jp(book, input_word, word, word_code); + if (error_code != EB_SUCCESS) + goto failed; + strcpy(canonicalized_word, word); + + /* + * Determine search method. + */ + switch (*word_code) { + case EB_WORD_ALPHABET: + if (book->subbook_current->word_alphabet.start_page != 0) + search = &book->subbook_current->word_alphabet; + else if (book->subbook_current->word_asis.start_page != 0) + search = &book->subbook_current->word_asis; + else { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + break; + + case EB_WORD_KANA: + if (book->subbook_current->word_kana.start_page != 0) + search = &book->subbook_current->word_kana; + else if (book->subbook_current->word_asis.start_page != 0) + search = &book->subbook_current->word_asis; + else { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + break; + + case EB_WORD_OTHER: + if (book->subbook_current->word_asis.start_page != 0) + search = &book->subbook_current->word_asis; + else { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + break; + + default: + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + + /* + * Fix the word. + */ + eb_fix_word(book, search, word, canonicalized_word); + + LOG(("out: eb_set_word(word=%s, canonicalized_word=%s, word_code=%d) = %s", + eb_quoted_string(word), eb_quoted_string(canonicalized_word), + (int)*word_code, eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *word = '\0'; + *canonicalized_word = '\0'; + *word_code = EB_WORD_INVALID; + LOG(("out: eb_set_word() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Make a fixed word and a cannonicalized word for `ENDWORD SEARCH'. + * + * If `input_word' is a KANA word, EB_WORD_KANA is retuend. + * If `input_word' is a alphabetic word, EB_WORD_ALPHABET is retuend. + * Otherwise, -1 is returned. It means that an error occurs. + */ +EB_Error_Code +eb_set_endword(EB_Book *book, const char *input_word, char *word, + char *canonicalized_word, EB_Word_Code *word_code) +{ + EB_Error_Code error_code; + const EB_Search *search; + + LOG(("in: eb_set_endword(book=%d, input_word=%s)", (int)book->code, + eb_quoted_string(input_word))); + + /* + * Make a fixed word and a canonicalized word from `input_word'. + */ + if (book->character_code == EB_CHARCODE_ISO8859_1) + error_code = eb_convert_latin(book, input_word, word, word_code); + else + error_code = eb_convert_euc_jp(book, input_word, word, word_code); + if (error_code != EB_SUCCESS) + goto failed; + strcpy(canonicalized_word, word); + + /* + * Determine search method. + */ + switch (*word_code) { + case EB_WORD_ALPHABET: + if (book->subbook_current->endword_alphabet.start_page != 0) + search = &book->subbook_current->endword_alphabet; + else if (book->subbook_current->endword_asis.start_page != 0) + search = &book->subbook_current->endword_asis; + else { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + break; + + case EB_WORD_KANA: + if (book->subbook_current->endword_kana.start_page != 0) + search = &book->subbook_current->endword_kana; + else if (book->subbook_current->endword_asis.start_page != 0) + search = &book->subbook_current->endword_asis; + else { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + break; + + case EB_WORD_OTHER: + if (book->subbook_current->endword_asis.start_page != 0) + search = &book->subbook_current->endword_asis; + else { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + break; + + default: + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + + /* + * Fix the word. + */ + eb_fix_word(book, search, word, canonicalized_word); + + /* + * Reverse the word. + */ + if (book->character_code == EB_CHARCODE_ISO8859_1) { + eb_reverse_word_latin(word); + eb_reverse_word_latin(canonicalized_word); + } else { + eb_reverse_word_jis(word); + eb_reverse_word_jis(canonicalized_word); + } + + LOG(("out: eb_set_endword(word=%s, canonicalized_word=%s, word_code=%d) \ += %s", + eb_quoted_string(word), eb_quoted_string(canonicalized_word), + (int)*word_code, eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *word = '\0'; + *canonicalized_word = '\0'; + *word_code = EB_WORD_INVALID; + LOG(("out: eb_set_endword() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Make a fixed word and a cannonicalized word for `KEYWORD SEARCH' + * or `CROSS SEARCH'. + * + * If `inputword' is a KANA word, EB_WORD_KANA is returned. + * If `inputword' is a alphabetic word, EB_WORD_ALPHABET is returned. + * Otherwise, -1 is returned. It means that an error occurs. + */ +EB_Error_Code +eb_set_keyword(EB_Book *book, const char *input_word, char *word, + char *canonicalized_word, EB_Word_Code *word_code) +{ + EB_Error_Code error_code; + + LOG(("in: eb_set_keyword(book=%d, input_word=%s)", (int)book->code, + eb_quoted_string(input_word))); + + /* + * Make a fixed word and a canonicalized word from `input_word'. + */ + if (book->character_code == EB_CHARCODE_ISO8859_1) + error_code = eb_convert_latin(book, input_word, word, word_code); + else + error_code = eb_convert_euc_jp(book, input_word, word, word_code); + if (error_code != EB_SUCCESS) + goto failed; + strcpy(canonicalized_word, word); + + /* + * Fix the word. + */ + eb_fix_word(book, &book->subbook_current->keyword, word, + canonicalized_word); + + LOG(("out: eb_set_keyword(word=%s, canonicalized_word=%s, word_code=%d) \ += %s", + eb_quoted_string(word), eb_quoted_string(canonicalized_word), + (int)*word_code, eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *word = '\0'; + *canonicalized_word = '\0'; + *word_code = EB_WORD_INVALID; + LOG(("out: eb_set_keyword() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Make a fixed word and a cannonicalized word for `MULTI SEARCH'. + * + * If `inputword' is a KANA word, EB_WORD_KANA is returned. + * If `inputword' is a alphabetic word, EB_WORD_ALPHABET is returned. + * Otherwise, -1 is returned. It means that an error occurs. + */ +EB_Error_Code +eb_set_multiword(EB_Book *book, EB_Multi_Search_Code multi_id, + EB_Multi_Entry_Code entry_id, const char *input_word, char *word, + char *canonicalized_word, EB_Word_Code *word_code) +{ + EB_Error_Code error_code; + EB_Search *search; + + LOG(("in: eb_set_multiword(book=%d, input_word=%s)", (int)book->code, + eb_quoted_string(input_word))); + + /* + * Make a fixed word and a canonicalized word from `input_word'. + */ + if (book->character_code == EB_CHARCODE_ISO8859_1) + error_code = eb_convert_latin(book, input_word, word, word_code); + else + error_code = eb_convert_euc_jp(book, input_word, word, word_code); + if (error_code != EB_SUCCESS) + goto failed; + strcpy(canonicalized_word, word); + + /* + * Fix the word. + */ + search = &book->subbook_current->multis[multi_id].entries[entry_id]; + eb_fix_word(book, search, word, canonicalized_word); + + LOG(("out: eb_set_multiword(word=%s, canonicalized_word=%s, word_code=%d) \ += %s", + eb_quoted_string(word), eb_quoted_string(canonicalized_word), + (int)*word_code, eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *word = '\0'; + *canonicalized_word = '\0'; + *word_code = EB_WORD_INVALID; + LOG(("out: eb_set_multiword() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Fix `canonicalized_word' and `word' according with `book->character_code' + * and `search'. + */ +static void +eb_fix_word(EB_Book *book, const EB_Search *search, char *word, + char *canonicalized_word) +{ + LOG(("in: eb_fix_word(book=%d, word=%s, canonicalized_word=%s)", + (int)book->code, eb_quoted_string(word), + eb_quoted_string(canonicalized_word))); + + if (search->index_id == 0xa1 && search->candidates_page != 0) + return; + + if (book->character_code == EB_CHARCODE_ISO8859_1) { + if (search->space == EB_INDEX_STYLE_DELETE) + eb_delete_spaces_latin(canonicalized_word); + + if (search->lower == EB_INDEX_STYLE_CONVERT) + eb_convert_lower_latin(canonicalized_word); + + } else { + if (search->space == EB_INDEX_STYLE_DELETE) + eb_delete_spaces_jis(canonicalized_word); + + if (search->katakana == EB_INDEX_STYLE_CONVERT) + eb_convert_katakana_jis(canonicalized_word); + else if (search->katakana == EB_INDEX_STYLE_REVERSED_CONVERT) + eb_convert_hiragana_jis(canonicalized_word); + + if (search->lower == EB_INDEX_STYLE_CONVERT) + eb_convert_lower_jis(canonicalized_word); + + if (search->mark == EB_INDEX_STYLE_DELETE) + eb_delete_marks_jis(canonicalized_word); + + if (search->long_vowel == EB_INDEX_STYLE_CONVERT) + eb_convert_long_vowels_jis(canonicalized_word); + else if (search->long_vowel == EB_INDEX_STYLE_DELETE) + eb_delete_long_vowels_jis(canonicalized_word); + + if (search->double_consonant == EB_INDEX_STYLE_CONVERT) + eb_convert_double_consonants_jis(canonicalized_word); + + if (search->contracted_sound == EB_INDEX_STYLE_CONVERT) + eb_convert_contracted_sounds_jis(canonicalized_word); + + if (search->small_vowel == EB_INDEX_STYLE_CONVERT) + eb_convert_small_vowels_jis(canonicalized_word); + + if (search->voiced_consonant == EB_INDEX_STYLE_CONVERT) + eb_convert_voiced_consonants_jis(canonicalized_word); + + if (search->p_sound == EB_INDEX_STYLE_CONVERT) + eb_convert_p_sounds_jis(canonicalized_word); + } + + if (search->index_id != 0x70 && search->index_id != 0x90) + strcpy(word, canonicalized_word); + + LOG(("out: eb_fix_word(word=%s, canonicalized_word=%s)", + eb_quoted_string(word), eb_quoted_string(canonicalized_word))); +} + + +/* + * Convert `input_word' to ISO 8859 1 and put it into `word'. + * + * If `input_word' is a valid string to search, EB_WORD_ALPHABET is returned. + * Otherwise, -1 is returned. + */ +static EB_Error_Code +eb_convert_latin(EB_Book *book, const char *input_word, char *word, + EB_Word_Code *word_code) +{ + EB_Error_Code error_code; + unsigned char *wp = (unsigned char *) word; + const unsigned char *inp = (const unsigned char *) input_word; + const unsigned char *tail; + unsigned char c1; + int word_length = 0; + + LOG(("in: eb_convert_latin(book=%d, input_word=%s)", (int)book->code, + eb_quoted_string(input_word))); + + /* + * Find the tail of `input_word'. + */ + tail = (const unsigned char *) input_word + strlen(input_word) - 1; + while ((const unsigned char *)input_word <= tail + && (*tail == ' ' || *tail == '\t')) + tail--; + tail++; + + /* + * Ignore spaces and tabs in the beginning of `input_word'. + */ + while (*inp == ' ' || *inp == '\t') + inp++; + + while (inp < tail) { + /* + * Check for the length of the word. + * If exceeds, return with an error code. + */ + if (EB_MAX_WORD_LENGTH < word_length + 1) { + error_code = EB_ERR_TOO_LONG_WORD; + goto failed; + } + + c1 = *inp++; + + /* + * Tabs are translated to spaces. + */ + if (c1 == '\t') + c1 = ' '; + + *wp++ = c1; + + /* + * Skip successive spaces and tabs. + */ + if (c1 == ' ') { + while (*inp == '\t' || *inp == ' ') + inp++; + } + + word_length++; + } + *wp = '\0'; + + if (word_length == 0) { + error_code = EB_ERR_EMPTY_WORD; + goto failed; + } + *word_code = EB_WORD_ALPHABET; + + LOG(("out: eb_convert_latin(word=%s, word_code=%d) = %s", + eb_quoted_string(word), (int)*word_code, eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *word = '\0'; + *word_code = EB_WORD_INVALID; + LOG(("out: eb_convert_latin() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Table used to convert JIS X 0208 to ASCII. + */ +static const unsigned int jisx0208_table[] = { + /* 0x20 -- 0x2f */ + 0x2121, 0x212a, 0x2149, 0x2174, 0x2170, 0x2173, 0x2175, 0x2147, + 0x214a, 0x214b, 0x2176, 0x215c, 0x2124, 0x215d, 0x2125, 0x213f, + /* 0x30 -- 0x3f */ + 0x2330, 0x2331, 0x2332, 0x2333, 0x2334, 0x2335, 0x2336, 0x2337, + 0x2338, 0x2339, 0x2127, 0x2128, 0x2163, 0x2161, 0x2164, 0x2129, + /* 0x40 -- 0x4f */ + 0x2177, 0x2341, 0x2342, 0x2343, 0x2344, 0x2345, 0x2346, 0x2347, + 0x2348, 0x2349, 0x234a, 0x234b, 0x234c, 0x234d, 0x234e, 0x234f, + /* 0x50 -- 0x5f */ + 0x2350, 0x2351, 0x2352, 0x2353, 0x2354, 0x2355, 0x2356, 0x2357, + 0x2358, 0x2359, 0x235a, 0x214e, 0x2140, 0x214f, 0x2130, 0x2132, + /* 0x60 -- 0x6f */ + 0x2146, 0x2361, 0x2362, 0x2363, 0x2364, 0x2365, 0x2366, 0x2367, + 0x2368, 0x2369, 0x236a, 0x236b, 0x236c, 0x236d, 0x236e, 0x236f, + /* 0x70 -- 0x7e */ + 0x2370, 0x2371, 0x2372, 0x2373, 0x2374, 0x2375, 0x2376, 0x2377, + 0x2378, 0x2379, 0x237a, 0x2150, 0x2143, 0x2151, 0x2141 +}; + +/* + * Table used to convert JIS X 0201 KATAKANA to JIS X 0208. + */ +static const unsigned int jisx0201_table[] = { + /* 0xa0 -- 0xaf */ + 0x0000, 0x2123, 0x2156, 0x2157, 0x2122, 0x2126, 0x2572, 0x2521, + 0x2523, 0x2525, 0x2527, 0x2529, 0x2563, 0x2565, 0x2567, 0x2543, + /* 0xb0 -- 0xbf */ + 0x213c, 0x2522, 0x2524, 0x2526, 0x2528, 0x252a, 0x252b, 0x252d, + 0x252f, 0x2531, 0x2533, 0x2535, 0x2537, 0x2539, 0x253b, 0x253d, + /* 0xc0 -- 0xcf */ + 0x253f, 0x2541, 0x2544, 0x2546, 0x2548, 0x254a, 0x254b, 0x254c, + 0x254d, 0x254e, 0x254f, 0x2552, 0x2555, 0x2558, 0x255b, 0x255e, + /* 0xd0 -- 0xdf */ + 0x255f, 0x2560, 0x2561, 0x2562, 0x2564, 0x2566, 0x2568, 0x2569, + 0x256a, 0x256b, 0x256c, 0x256d, 0x256f, 0x2573, 0x212b, 0x212c +}; + +/* + * Convert `input_word' to JIS X0208 and put it into `word'. + * + * If `input_word' is a valid string to search, EB_WORD_ALPHABET or + * EB_WORD_KANA is returned. + * Otherwise, -1 is returned. + */ +static EB_Error_Code +eb_convert_euc_jp(EB_Book *book, const char *input_word, char *word, + EB_Word_Code *word_code) +{ + EB_Error_Code error_code; + unsigned char *wp = (unsigned char *) word; + const unsigned char *inp = (const unsigned char *) input_word; + const unsigned char *tail; + unsigned char c1 = 0, c2 = 0; + int kana_count = 0; + int alphabet_count = 0; + int kanji_count = 0; + int word_length = 0; + + LOG(("in: eb_convert_euc_jp(book=%d, input_word=%s)", (int)book->code, + eb_quoted_string(input_word))); + + /* + * Find the tail of `input_word'. + */ + tail = (const unsigned char *) input_word + strlen(input_word) - 1; + for (;;) { + if (inp < tail && (*tail == ' ' || *tail == '\t')) + tail--; + else if (inp < tail - 1 && *tail == 0xa1 && *(tail - 1) == 0xa1) + tail -= 2; + else + break; + } + tail++; + + /* + * Ignore spaces and tabs in the beginning of `input_word'. + */ + for (;;) { + if (*inp == ' ' || *inp == '\t') + inp++; + else if (*inp == 0xa1 && *(inp + 1) == 0xa1) + inp += 2; + else + break; + } + + while (inp < tail) { + /* + * Check for the length of the word. + * If exceeds, return with an error code. + */ + if (EB_MAX_WORD_LENGTH < word_length + 2) { + error_code = EB_ERR_TOO_LONG_WORD; + goto failed; + } + + /* + * Tabs are translated to spaces. + */ + c1 = *inp++; + if (c1 == '\t') + c1 = ' '; + + if (0x20 <= c1 && c1 <= 0x7e) { + /* + * `c1' is a character in ASCII. + */ + unsigned int c = jisx0208_table[c1 - 0x20]; + c1 = c >> 8; + c2 = c & 0xff; + } else if (0xa1 <= c1 && c1 <= 0xfe) { + /* + * `c1' is a character in JIS X 0208, or local character. + */ + c2 = *inp++; + + if (0xa1 <= c2 && c2 <= 0xfe) { + c1 &= 0x7f; + c2 &= 0x7f; + } else if (c2 < 0x20 || 0x7e < c2) { + error_code = EB_ERR_BAD_WORD; + goto failed; + } + } else if (c1 == 0x8e) { + /* + * `c1' is SS2. + */ + if (c2 < 0xa1 || 0xdf < c2) { + error_code = EB_ERR_BAD_WORD; + goto failed; + } + c2 = jisx0201_table[c2 - 0xa0]; + c1 = 0x25; + } else { + error_code = EB_ERR_BAD_WORD; + goto failed; + } + + /* + * The following characters are recognized as alphabet. + * 2330 - 2339: `0' .. `9' + * 2341 - 235a: `A' .. `Z' + * 2361 - 237a: `a' .. `z' (convert to upper cases) + */ + *wp++ = c1; + *wp++ = c2; + + if (c1 == 0x23) + alphabet_count++; + else if (c1 == 0x24 || c1 == 0x25) + kana_count++; + else if (c1 != 0x21) + kanji_count++; + + word_length += 2; + } + *wp = '\0'; + + if (word_length == 0) { + error_code = EB_ERR_EMPTY_WORD; + goto failed; + } + if (alphabet_count == 0 && kana_count != 0 && kanji_count == 0) + *word_code = EB_WORD_KANA; + else if (alphabet_count != 0 && kana_count == 0 && kanji_count == 0) + *word_code = EB_WORD_ALPHABET; + else + *word_code = EB_WORD_OTHER; + + LOG(("out: eb_convert_euc_jp(word=%s, word_code=%d) = %s", + eb_quoted_string(word), (int)*word_code, eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *word = '\0'; + *word_code = EB_WORD_INVALID; + LOG(("out: eb_convert_euc_jp() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Convert KATAKANA to HIRAGANA in `word'. + */ +static void +eb_convert_katakana_jis(char *word) +{ + unsigned char *wp = (unsigned char *) word; + unsigned char c1, c2; + + LOG(("in: eb_convert_katakana_jis(word=%s)", eb_quoted_string(word))); + + while (*wp != '\0' && *(wp + 1) != '\0') { + c1 = *wp; + c2 = *(wp + 1); + + if (c1 == 0x25 && 0x21 <= c2 && c2 <= 0x76) { + /* + * This is a KATAKANA. Convert to corresponding HIRAGANA. + */ + *wp = 0x24; + } + wp += 2; + } + *wp = '\0'; + + LOG(("out: eb_convert_katakana_jis()")); +} + + +/* + * Convert HIRAGANA to KATAKANA in `word'. + */ +static void +eb_convert_hiragana_jis(char *word) +{ + unsigned char *wp = (unsigned char *) word; + unsigned char c1, c2; + + LOG(("in: eb_convert_hiragana_jis(word=%s)", eb_quoted_string(word))); + + while (*wp != '\0' && *(wp + 1) != '\0') { + c1 = *wp; + c2 = *(wp + 1); + + if (c1 == 0x24 && 0x21 <= c2 && c2 <= 0x76) { + /* + * This is a HIRAGANA. Convert to corresponding KATAKANA. + */ + *wp = 0x25; + } + wp += 2; + } + *wp = '\0'; + + LOG(("out: eb_convert_hiragana_jis()")); +} + + +/* + * Convert lower case to upper case in `word'. + */ +static void +eb_convert_lower_latin(char *word) +{ + unsigned char *wp = (unsigned char *) word; + + LOG(("in: eb_convert_lower_latin(word=%s)", eb_quoted_string(word))); + + while (*wp != '\0') { + if (('a' <= *wp && *wp <= 'z') + || (0xe0 <= *wp && *wp <= 0xf6) || (0xf8 <= *wp && *wp <= 0xfe)) { + /* + * This is a lower case letter. Convert to upper case. + */ + *wp -= 0x20; + } + wp++; + } + *wp = '\0'; + + LOG(("out: eb_convert_lower_latin()")); +} + + +/* + * Convert lower case to upper case in `word'. + */ +static void +eb_convert_lower_jis(char *word) +{ + unsigned char *wp = (unsigned char *) word; + unsigned char c1, c2; + + LOG(("in: eb_convert_lower_jis(word=%s)", eb_quoted_string(word))); + + while (*wp != '\0' && *(wp + 1) != '\0') { + c1 = *wp; + c2 = *(wp + 1); + + if (c1 == 0x23 && 0x61 <= c2 && c2 <= 0x7a) { + /* + * This is a lower case letter. Convert to upper case. + */ + *(wp + 1) = c2 - 0x20; + } + wp += 2; + } + *wp = '\0'; + + LOG(("out: eb_convert_lower_jis()")); +} + + +/* + * Delete some marks in `word'. + */ +static void +eb_delete_marks_jis(char *word) +{ + unsigned char *in_wp = (unsigned char *) word; + unsigned char *out_wp = (unsigned char *) word; + unsigned char c1, c2; + + LOG(("in: eb_delete_marks_jis(word=%s)", eb_quoted_string(word))); + + while (*in_wp != '\0' && *(in_wp + 1) != '\0') { + c1 = *in_wp; + c2 = *(in_wp + 1); + + if (c1 != 0x21 + || (c2 != 0x26 && c2 != 0x3e && c2 != 0x47 && c2 != 0x5d)) { + /* + * This is not a character to be deleted. + */ + *out_wp = c1; + *(out_wp + 1) = c2; + out_wp += 2; + } + in_wp += 2; + } + *out_wp = '\0'; + + LOG(("out: eb_delete_marks_jis()")); +} + + +/* + * The table is used to convert long vowel marks. + */ +static const char long_vowel_table[] = { + 0x22, /* a(21) -> A(22) */ 0x22, /* A(22) -> A(22) */ + 0x24, /* i(23) -> I(24) */ 0x24, /* I(24) -> I(24) */ + 0x26, /* u(25) -> U(26) */ 0x26, /* U(26) -> U(26) */ + 0x28, /* e(27) -> E(28) */ 0x28, /* E(28) -> E(28) */ + 0x2a, /* o(29) -> O(2a) */ 0x2a, /* O(2a) -> O(2a) */ + 0x22, /* KA(2b) -> A(22) */ 0x22, /* GA(2c) -> A(22) */ + 0x24, /* KI(2d) -> I(24) */ 0x24, /* GI(2e) -> I(24) */ + 0x26, /* KU(2f) -> U(26) */ 0x26, /* GU(30) -> U(26) */ + 0x28, /* KE(31) -> E(28) */ 0x28, /* GE(32) -> E(28) */ + 0x2a, /* KO(33) -> O(2a) */ 0x2a, /* GO(34) -> O(2a) */ + 0x22, /* SA(35) -> A(22) */ 0x22, /* ZA(36) -> A(22) */ + 0x24, /* SI(37) -> I(24) */ 0x24, /* ZI(38) -> I(24) */ + 0x26, /* SU(39) -> U(26) */ 0x26, /* ZU(3a) -> U(26) */ + 0x28, /* SE(3b) -> E(28) */ 0x28, /* ZE(3c) -> E(28) */ + 0x2a, /* SO(3d) -> O(2a) */ 0x2a, /* ZO(3e) -> O(2a) */ + 0x22, /* TA(3f) -> A(22) */ 0x22, /* DA(40) -> A(22) */ + 0x24, /* TI(41) -> I(24) */ 0x24, /* DI(42) -> I(24) */ + 0x26, /* tu(43) -> U(26) */ 0x26, /* TU(44) -> U(26) */ + 0x26, /* DU(45) -> U(26) */ 0x28, /* TE(46) -> E(28) */ + 0x28, /* DE(47) -> E(28) */ 0x2a, /* TO(48) -> O(2a) */ + 0x2a, /* DO(49) -> O(2a) */ 0x22, /* NA(4a) -> A(22) */ + 0x24, /* NI(4b) -> I(24) */ 0x26, /* NU(4c) -> U(26) */ + 0x28, /* NE(4d) -> E(28) */ 0x2a, /* NO(4e) -> O(2a) */ + 0x22, /* HA(4f) -> A(22) */ 0x22, /* BA(50) -> A(22) */ + 0x22, /* PA(51) -> A(22) */ 0x24, /* HI(52) -> I(24) */ + 0x24, /* BI(53) -> I(24) */ 0x24, /* PI(54) -> I(24) */ + 0x26, /* HU(55) -> U(26) */ 0x26, /* BU(56) -> U(26) */ + 0x26, /* PU(57) -> U(26) */ 0x28, /* HE(58) -> E(28) */ + 0x28, /* BE(59) -> E(28) */ 0x28, /* PE(5a) -> E(28) */ + 0x2a, /* HO(5b) -> O(2a) */ 0x2a, /* BO(5c) -> O(2a) */ + 0x2a, /* PO(5d) -> O(2a) */ 0x22, /* MA(5e) -> A(22) */ + 0x24, /* MI(5f) -> I(24) */ 0x26, /* MU(60) -> U(26) */ + 0x28, /* ME(61) -> E(28) */ 0x2a, /* MO(62) -> O(2a) */ + 0x22, /* ya(63) -> A(22) */ 0x22, /* YA(64) -> A(22) */ + 0x26, /* yu(65) -> U(26) */ 0x26, /* YU(66) -> U(26) */ + 0x2a, /* yo(67) -> O(2a) */ 0x2a, /* YO(68) -> O(2a) */ + 0x22, /* RA(69) -> A(22) */ 0x24, /* RI(6a) -> I(24) */ + 0x26, /* RU(6b) -> U(26) */ 0x28, /* RE(6c) -> E(28) */ + 0x2a, /* RO(6d) -> O(2a) */ 0x22, /* wa(6e) -> A(22) */ + 0x22, /* WA(6f) -> A(22) */ 0x24, /* WI(70) -> I(24) */ + 0x28, /* WE(71) -> E(28) */ 0x2a, /* WO(72) -> O(2a) */ + 0x73, /* N (73) -> N(73) */ 0x26, /* VU(74) -> U(26) */ + 0x22, /* ka(75) -> A(22) */ 0x28 /* ke(76) -> E(28) */ +}; + + +/* + * Convert long vowel marks in `word' to the previous vowels. + */ +static void +eb_convert_long_vowels_jis(char *word) +{ + unsigned char *wp = (unsigned char *) word; + unsigned char c1, c2; + unsigned char previous_c1 = '\0', previous_c2 = '\0'; + + LOG(("in: eb_convert_long_vowels_jis(word=%s)", eb_quoted_string(word))); + + while (*wp != '\0' && *(wp + 1) != '\0') { + c1 = *wp; + c2 = *(wp + 1); + + if (c1 == 0x21 && c2 == 0x3c) { + /* + * The is a long vowel mark. + * Convert to a vowel of the prev_ KANA character. + * If prev_ character is not KANA, the conversion is + * not done. + */ + if ((previous_c1 == 0x24 || previous_c1 == 0x25) + && 0x21 <= previous_c2 && previous_c2 <= 0x76) { + *wp = previous_c1; + *(wp + 1) = long_vowel_table[previous_c2 - 0x21]; + } + } + previous_c1 = c1; + previous_c2 = c2; + wp += 2; + } + *wp = '\0'; + + LOG(("out: eb_convert_long_vowels_jis()")); +} + + +/* + * Delete long vowel marks in `word'. + */ +static void +eb_delete_long_vowels_jis(char *word) +{ + unsigned char *in_wp = (unsigned char *) word; + unsigned char *out_wp = (unsigned char *) word; + unsigned char c1, c2; + + LOG(("in: eb_delete_long_vowels_jis(word=%s)", eb_quoted_string(word))); + + while (*in_wp != '\0' && *(in_wp + 1) != '\0') { + c1 = *in_wp; + c2 = *(in_wp + 1); + + if (c1 != 0x21 || c2 != 0x3c) { + /* + * The is not a long vowel mark. + */ + *out_wp = c1; + *(out_wp + 1) = c2; + out_wp += 2; + } + in_wp += 2; + } + *out_wp = '\0'; + + LOG(("out: eb_delete_long_vowels_jis()")); +} + + +/* + * Convert the double consonant mark `tu' to `TU'. + */ +static void +eb_convert_double_consonants_jis(char *word) +{ + unsigned char *wp = (unsigned char *) word; + unsigned char c1, c2; + + LOG(("in: eb_convert_double_consonants_jis(word=%s)", + eb_quoted_string(word))); + + while (*wp != '\0' && *(wp + 1) != '\0') { + c1 = *wp; + c2 = *(wp + 1); + + if ((c1 == 0x24 || c1 == 0x25) && c2 == 0x43) { + /* + * This is a double sound mark. Convert to the corresponding + * sound mark. + */ + *(wp + 1) = c2 + 1; + } + wp += 2; + } + *wp = '\0'; + + LOG(("out: eb_convert_double_consonants_jis()")); +} + + +/* + * Convert the contracted sound marks to the corresponding + * non-contracted sound marks. + * (`ya', `yu', `yo', `wa', `ka', `ke' -> `YA', `YU', `YO', `WA', `KA', `KE') + */ +static void +eb_convert_contracted_sounds_jis(char *word) +{ + unsigned char *wp = (unsigned char *) word; + unsigned char c1, c2; + + LOG(("in: eb_convert_contracted_sounds_jis(word=%s)", + eb_quoted_string(word))); + + while (*wp != '\0' && *(wp + 1) != '\0') { + c1 = *wp; + c2 = *(wp + 1); + + if (c1 == 0x24 || c1 == 0x25) { + /* + * This is HIRAGANA or KANAKANA. + * If this is a contracted sound mark, convert to the + * corresponding uncontracted sound mark. + */ + if (c2 == 0x63 || c2 == 0x65 || c2 == 0x67 || c2 == 0x6e) + *(wp + 1) = c2 + 1; + else if (c2 == 0x75) + *(wp + 1) = 0x2b; + else if (c2 == 0x76) + *(wp + 1) = 0x31; + } + wp += 2; + } + *wp = '\0'; + + LOG(("in: eb_convert_contracted_sounds_jis()")); +} + + +/* + * Convert the small vowels to the normal vowels. + * (`a', `i', `u', `e', `o' -> `A', `I', `U', `E', `O') + */ +static void +eb_convert_small_vowels_jis(char *word) +{ + unsigned char *wp = (unsigned char *) word; + unsigned char c1, c2; + + LOG(("in: eb_convert_small_vowels_jis(word=%s)", eb_quoted_string(word))); + + while (*wp != '\0' && *(wp + 1) != '\0') { + c1 = *wp; + c2 = *(wp + 1); + + if (c1 == 0x24 || c1 == 0x25) { + /* + * This is HIRAGANA or KANAKANA. + * If this is a small vowel mark, convert to a normal vowel. + */ + if (c2 == 0x21 || c2 == 0x23 || c2 == 0x25 || c2 == 0x27 + || c2 == 0x29) + *(wp + 1) = c2 + 1; + } + wp += 2; + } + *wp = '\0'; + + LOG(("out: eb_convert_small_vowels_jis()")); +} + + +/* + * The table is used to convert voiced consonant marks. + */ +static const char voiced_consonant_table[] = { + 0x21, /* a(21) -> a(22) */ 0x22, /* A(22) -> A(22) */ + 0x23, /* i(23) -> i(24) */ 0x24, /* I(24) -> I(24) */ + 0x25, /* u(25) -> u(26) */ 0x26, /* U(26) -> U(26) */ + 0x27, /* e(27) -> e(28) */ 0x28, /* E(28) -> E(28) */ + 0x29, /* o(29) -> o(2a) */ 0x2a, /* O(2a) -> O(2a) */ + 0x2b, /* KA(2b) -> KA(2b) */ 0x2b, /* GA(2c) -> KA(2b) */ + 0x2d, /* KI(2d) -> KI(2d) */ 0x2d, /* GI(2e) -> KI(2d) */ + 0x2f, /* KU(2f) -> KU(2f) */ 0x2f, /* GU(30) -> KU(2f) */ + 0x31, /* KE(31) -> KE(31) */ 0x31, /* GE(32) -> KE(31) */ + 0x33, /* KO(33) -> KO(33) */ 0x33, /* GO(34) -> KO(33) */ + 0x35, /* SA(35) -> SA(35) */ 0x35, /* ZA(36) -> SA(35) */ + 0x37, /* SI(37) -> SI(37) */ 0x37, /* ZI(38) -> SI(37) */ + 0x39, /* SU(39) -> SU(39) */ 0x39, /* ZU(3a) -> SU(39) */ + 0x3b, /* SE(3b) -> SE(3b) */ 0x3b, /* ZE(3c) -> SE(3b) */ + 0x3d, /* SO(3d) -> SO(3d) */ 0x3d, /* ZO(3e) -> SO(3d) */ + 0x3f, /* TA(3f) -> TA(3f) */ 0x3f, /* DA(40) -> TA(3f) */ + 0x41, /* TI(41) -> TI(41) */ 0x41, /* DI(42) -> TI(41) */ + 0x43, /* tu(43) -> TU(43) */ 0x44, /* TU(44) -> TU(44) */ + 0x44, /* DU(45) -> TU(44) */ 0x46, /* TE(46) -> TE(46) */ + 0x46, /* DE(47) -> TE(46) */ 0x48, /* TO(48) -> TO(48) */ + 0x48, /* DO(49) -> TO(48) */ 0x4a, /* NA(4a) -> NA(4a) */ + 0x4b, /* NI(4b) -> NI(4b) */ 0x4c, /* NU(4c) -> NU(4c) */ + 0x4d, /* NE(4d) -> NE(4d) */ 0x4e, /* NO(4e) -> NO(4e) */ + 0x4f, /* HA(4f) -> HA(4f) */ 0x4f, /* BA(50) -> HA(4f) */ + 0x51, /* PA(51) -> PA(51) */ 0x52, /* HI(52) -> HI(52) */ + 0x52, /* BI(53) -> HI(52) */ 0x54, /* PI(54) -> PU(54) */ + 0x55, /* HU(55) -> HU(55) */ 0x55, /* BU(56) -> HU(55) */ + 0x57, /* PU(57) -> PU(57) */ 0x58, /* HE(58) -> HE(58) */ + 0x58, /* BE(59) -> HE(58) */ 0x5a, /* PE(5a) -> PE(5a) */ + 0x5b, /* HO(5b) -> HO(5b) */ 0x5b, /* BO(5c) -> HO(5b) */ + 0x5d, /* PO(5d) -> PO(5d) */ 0x5e, /* MA(5e) -> MA(5e) */ + 0x5f, /* MI(5f) -> MI(5f) */ 0x60, /* MU(60) -> MU(60) */ + 0x61, /* ME(61) -> ME(61) */ 0x62, /* MO(62) -> MO(62) */ + 0x64, /* ya(63) -> ya(63) */ 0x64, /* YA(64) -> YA(64) */ + 0x66, /* yu(65) -> yu(65) */ 0x66, /* YU(66) -> YU(66) */ + 0x68, /* yo(67) -> yo(67) */ 0x68, /* YO(68) -> YO(68) */ + 0x69, /* RA(69) -> TA(69) */ 0x6a, /* RI(6a) -> RI(6a) */ + 0x6b, /* RU(6b) -> RU(6b) */ 0x6c, /* RE(6c) -> RE(6c) */ + 0x6d, /* RO(6d) -> RO(6d) */ 0x6e, /* wa(6e) -> wa(6e) */ + 0x6f, /* WA(6f) -> WA(6f) */ 0x70, /* WI(70) -> WI(70) */ + 0x71, /* WE(71) -> WE(71) */ 0x72, /* WO(72) -> WO(72) */ + 0x73, /* N(73) -> N(73) */ 0x26, /* VU(74) -> U(26) */ + 0x75, /* ka(75) -> ka(75) */ 0x76 /* ke(76) -> ke(76) */ +}; + +/* + * Convert the contracted sound marks to the corresponding + * non-contracted sound marks (e.g. `GA' to `KA'). + */ +static void +eb_convert_voiced_consonants_jis(char *word) +{ + unsigned char *wp = (unsigned char *) word; + unsigned char c1, c2; + + LOG(("in: eb_convert_voiced_consonants_jis(word=%s)", + eb_quoted_string(word))); + + while (*wp != '\0' && *(wp + 1) != '\0') { + c1 = *wp; + c2 = *(wp + 1); + + if ((c1 == 0x24 || c1 == 0x25) && 0x21 <= c2 && c2 <= 0x76) { + /* + * This is a voiced constonat mark. Convert to the + * corresponding unvoiced constonant mark. + */ + *(wp + 1) = voiced_consonant_table[c2 - 0x21]; + } + wp += 2; + } + *wp = '\0'; + + LOG(("out: eb_convert_voiced_consonants_jis()")); +} + + +/* + * Convert the p sound marks + * (`PA', `PI', `PU', `PE', `PO' -> `HA', `HI', `HU', `HE', `HO') + */ +static void +eb_convert_p_sounds_jis(char *word) +{ + unsigned char *wp = (unsigned char *) word; + unsigned char c1, c2; + + LOG(("in: eb_convert_p_sounds_jis(word=%s)", eb_quoted_string(word))); + + while (*wp != '\0' && *(wp + 1) != '\0') { + c1 = *wp; + c2 = *(wp + 1); + + if (c1 == 0x24 || c1 == 0x25) { + /* + * This is HIRAGANA or KANAKANA. + * If this is a p-sound mark, convert to the corresponding + * unvoiced consonant mark. + */ + if (c2 == 0x51 || c2 == 0x54 || c2 == 0x57 || c2 == 0x5a + || c2 == 0x5d) + *(wp + 1) = c2 - 2; + } + wp += 2; + } + *wp = '\0'; + + LOG(("out: eb_convert_p_sounds_jis()")); +} + + +/* + * Delete spaces in `word'. + */ +static void +eb_delete_spaces_latin(char *word) +{ + unsigned char *in_wp = (unsigned char *) word; + unsigned char *out_wp = (unsigned char *) word; + + LOG(("in: eb_delete_space_latin(word=%s)", eb_quoted_string(word))); + + while (*in_wp != '\0') { + if (*in_wp != ' ') { + /* + * This is not a space character of ISO 8859 1. + */ + *out_wp = *in_wp; + out_wp++; + } + in_wp++; + } + *out_wp = '\0'; + + LOG(("out: eb_delete_space_latin()")); +} + + +/* + * Delete spaces in `word'. + */ +static void +eb_delete_spaces_jis(char *word) +{ + unsigned char *in_wp = (unsigned char *) word; + unsigned char *out_wp = (unsigned char *) word; + unsigned char c1, c2; + + LOG(("in: eb_delete_space_jis(word=%s)", eb_quoted_string(word))); + + while (*in_wp != '\0' && *(in_wp + 1) != '\0') { + c1 = *in_wp; + c2 = *(in_wp + 1); + + if (c1 != 0x21 || c2 != 0x21) { + /* + * This is not a space character of JIS X 0208. + */ + *out_wp = c1; + *(out_wp + 1) = c2; + out_wp += 2; + } + in_wp += 2; + } + *out_wp = '\0'; + + LOG(("out: eb_delete_space_jis()")); +} + + +/* + * Reverse a word for ENDWORD SEARCH. + * + * `word' is a word to reverse. It must be an alphabetic word. + * The reversed word is also put into `word'. + */ +static void +eb_reverse_word_latin(char *word) +{ + char *p1, *p2; + int word_length; + char c; + + LOG(("in: eb_reverse_word_latin(word=%s)", eb_quoted_string(word))); + + word_length = strlen(word); + if (word_length == 0) + return; + for (p1 = word, p2 = word + word_length - 1; p1 < p2; p1++, p2--) { + c = *p1; + *p1 = *p2; + *p2 = c; + } + + LOG(("out: eb_reverse_word_latin()")); +} + + +/* + * Reverse a word for ENDWORD SEARCH. + * + * `word' is a word to reverse. It must be a KANA word. + * The reversed word is also put into `word'. + */ +static void +eb_reverse_word_jis(char *word) +{ + char *p1, *p2; + int word_length; + char c; + + LOG(("in: eb_reverse_word_jis(word=%s)", eb_quoted_string(word))); + + word_length = strlen(word); + if (word_length % 2 == 1) { + *(word + word_length - 1) = '\0'; + word_length--; + } + for (p1 = word, p2 = word + word_length - 2; p1 < p2; p1 += 2, p2 -= 2) { + c = *p1; + *p1 = *p2; + *p2 = c; + c = *(p1 + 1); + *(p1 + 1) = *(p2 + 1); + *(p2 + 1) = c; + } + + LOG(("out: eb_reverse_word_jis()")); +} + diff --git a/eb/stamp-widealt-h b/eb/stamp-widealt-h new file mode 100644 index 0000000..9788f70 --- /dev/null +++ b/eb/stamp-widealt-h @@ -0,0 +1 @@ +timestamp diff --git a/eb/stamp-widefont-h b/eb/stamp-widefont-h new file mode 100644 index 0000000..9788f70 --- /dev/null +++ b/eb/stamp-widefont-h @@ -0,0 +1 @@ +timestamp diff --git a/eb/stopcode.c b/eb/stopcode.c new file mode 100644 index 0000000..ba71452 --- /dev/null +++ b/eb/stopcode.c @@ -0,0 +1,113 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "appendix.h" +#include "text.h" +#include "build-post.h" + +/* + * Examine whether the current subbook in `appendix' has a stop-code. + */ +int +eb_have_stop_code(EB_Appendix *appendix) +{ + eb_lock(&appendix->lock); + LOG(("in: eb_have_stop_code(appendix=%d)", (int)appendix->code)); + + /* + * Current subbook must have been set. + */ + if (appendix->subbook_current == NULL) + goto failed; + + if (appendix->subbook_current->stop_code0 == 0) + goto failed; + + LOG(("out: eb_have_stop_code() = %d", 1)); + eb_unlock(&appendix->lock); + + return 1; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_have_stop_code() = %d", 0)); + eb_unlock(&appendix->lock); + return 0; +} + + +/* + * Return the stop-code of the current subbook in `appendix'. + */ +EB_Error_Code +eb_stop_code(EB_Appendix *appendix, int *stop_code) +{ + EB_Error_Code error_code; + + eb_lock(&appendix->lock); + LOG(("in: eb_stop_code(appendix=%d)", (int)appendix->code)); + + /* + * Current subbook must have been set. + */ + if (appendix->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_APPSUB; + goto failed; + } + + if (appendix->subbook_current->stop_code0 == 0) { + error_code = EB_ERR_NO_STOPCODE; + goto failed; + } + + stop_code[0] = appendix->subbook_current->stop_code0; + stop_code[1] = appendix->subbook_current->stop_code1; + + LOG(("out: eb_stop_code(stop_code=%d,%d) = %s", + stop_code[0], stop_code[1], eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + stop_code[0] = -1; + stop_code[1] = -1; + LOG(("out: eb_stop_code() = %s", eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + diff --git a/eb/strcasecmp.c b/eb/strcasecmp.c new file mode 100644 index 0000000..469f071 --- /dev/null +++ b/eb/strcasecmp.c @@ -0,0 +1,117 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * This program requires the following Autoconf macros: + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#else + +/* Define to empty if the keyword `const' does not work. */ +/* #define const */ + +/* Define if `size_t' is not defined. */ +/* #define size_t unsigned */ + +#endif /* not HAVE_CONFIG_H */ + +#include + +/* + * Compare strings. + * Cases in the strings are insensitive. + */ +int +eb_strcasecmp(const char *string1, const char *string2) +{ + const unsigned char *string1_p = (const unsigned char *)string1; + const unsigned char *string2_p = (const unsigned char *)string2; + int c1, c2; + + while (*string1_p != '\0') { + if ('a' <= *string1_p && *string1_p <= 'z') + c1 = *string1_p - ('a' - 'A'); + else + c1 = *string1_p; + + if ('a' <= *string2_p && *string2_p <= 'z') + c2 = *string2_p - ('a' - 'A'); + else + c2 = *string2_p; + + if (c1 != c2) + return c1 - c2; + + string1_p++; + string2_p++; + } + + return -(*string2_p); +} + + +/* + * Compare strings within `n' characters. + * Cases in the strings are insensitive. + */ +int +eb_strncasecmp(const char *string1, const char *string2, size_t n) +{ + const unsigned char *string1_p = (const unsigned char *)string1; + const unsigned char *string2_p = (const unsigned char *)string2; + size_t i = n; + int c1, c2; + + if (i <= 0) + return 0; + + while (*string1_p != '\0') { + if ('a' <= *string1_p && *string1_p <= 'z') + c1 = *string1_p - ('a' - 'A'); + else + c1 = *string1_p; + + if ('a' <= *string2_p && *string2_p <= 'z') + c2 = *string2_p - ('a' - 'A'); + else + c2 = *string2_p; + + if (c1 != c2) + return c1 - c2; + + string1_p++; + string2_p++; + i--; + if (i <= 0) + return 0; + } + + return -(*string2_p); +} diff --git a/eb/subbook.c b/eb/subbook.c new file mode 100644 index 0000000..8f2a4b8 --- /dev/null +++ b/eb/subbook.c @@ -0,0 +1,1142 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "binary.h" +#include "font.h" +#include "build-post.h" + +/* + * Unexported functions. + */ +static EB_Error_Code eb_load_subbook(EB_Book *book); +static EB_Error_Code eb_load_subbook_indexes(EB_Book *book); +static EB_Error_Code eb_set_subbook_eb(EB_Book *book, + EB_Subbook_Code subbook_code); +static EB_Error_Code eb_set_subbook_epwing(EB_Book *book, + EB_Subbook_Code subbook_code); + + +/* + * Initialize all subbooks in `book'. + */ +void +eb_initialize_subbooks(EB_Book *book) +{ + EB_Subbook *subbook; + EB_Subbook *saved_subbook_current; + int i; + + LOG(("in: eb_initialize_subbooks(book=%d)", (int)book->code)); + + saved_subbook_current = book->subbook_current; + + for (i = 0, subbook = book->subbooks; i < book->subbook_count; + i++, subbook++) { + book->subbook_current = subbook; + + subbook->initialized = 0; + subbook->index_page = 1; + subbook->code = i; + zio_initialize(&subbook->text_zio); + zio_initialize(&subbook->graphic_zio); + zio_initialize(&subbook->sound_zio); + zio_initialize(&subbook->movie_zio); + subbook->title[0] = '\0'; + subbook->directory_name[0] = '\0'; + subbook->data_directory_name[0] = '\0'; + subbook->gaiji_directory_name[0] = '\0'; + subbook->movie_directory_name[0] = '\0'; + + subbook->text_file_name[0] = '\0'; + subbook->graphic_file_name[0] = '\0'; + subbook->sound_file_name[0] = '\0'; + + subbook->text_hint_zio_code = ZIO_PLAIN; + subbook->graphic_hint_zio_code = ZIO_PLAIN; + subbook->sound_hint_zio_code = ZIO_PLAIN; + + subbook->search_title_page = 0; + eb_initialize_searches(book); + subbook->multi_count = 0; + + eb_initialize_fonts(book); + subbook->narrow_current = NULL; + subbook->wide_current = NULL; + } + + book->subbook_current = saved_subbook_current; + + LOG(("out: eb_initialize_subbooks()")); +} + + +/* + * Finalize all subbooks in `book'. + */ +void +eb_finalize_subbooks(EB_Book *book) +{ + EB_Subbook *subbook; + EB_Subbook *saved_subbook_current; + int i; + + LOG(("in: eb_finalize_subbooks(book=%d)", (int)book->code)); + + saved_subbook_current = book->subbook_current; + + for (i = 0, subbook = book->subbooks; i < book->subbook_count; + i++, subbook++) { + book->subbook_current = subbook; + + zio_finalize(&subbook->text_zio); + zio_finalize(&subbook->graphic_zio); + zio_finalize(&subbook->sound_zio); + zio_finalize(&subbook->movie_zio); + + eb_finalize_searches(book); + eb_finalize_fonts(book); + + subbook->narrow_current = NULL; + subbook->wide_current = NULL; + } + + book->subbook_current = saved_subbook_current; + + LOG(("out: eb_finalize_subbooks()")); +} + + +/* + * Get information about the current subbook. + */ +static EB_Error_Code +eb_load_subbook(EB_Book *book) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + + LOG(("in: eb_load_subbook(book=%d)", (int)book->code)); + + subbook = book->subbook_current; + + /* + * Current subbook must have been set. + */ + if (subbook == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Reset contexts. + */ + eb_reset_search_contexts(book); + eb_reset_text_context(book); + eb_reset_binary_context(book); + + /* + * If the subbook has already initialized, return immediately. + */ + if (subbook->initialized) + goto succeeded; + + if (0 <= zio_file(&subbook->text_zio)) { + /* + * Read index information. + */ + error_code = eb_load_subbook_indexes(book); + if (error_code != EB_SUCCESS) + goto failed; + + /* + * Read mutli search information. + */ + error_code = eb_load_multi_searches(book); + if (error_code != EB_SUCCESS) + goto failed; + error_code = eb_load_multi_titles(book); + if (error_code != EB_SUCCESS) + goto failed; + + /* + * Rewind the file descriptor of the start file. + */ + if (zio_lseek(&subbook->text_zio, + ((off_t) subbook->index_page - 1) * EB_SIZE_PAGE, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_TEXT; + goto failed; + } + } + + succeeded: + LOG(("out: eb_load_subbook() = %s", eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_load_subbook() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Get information about all subbooks in the book. + */ +EB_Error_Code +eb_load_all_subbooks(EB_Book *book) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + int i; + + eb_lock(&book->lock); + LOG(("in: eb_load_all_subbooks(book=%d)", (int)book->code)); + + /* + * The book must have been bound. + */ + if (book->path == NULL) { + error_code = EB_ERR_UNBOUND_BOOK; + goto failed; + } + + /* + * Initialize each subbook. + */ + for (i = 0, subbook = book->subbooks; i < book->subbook_count; + i++, subbook++) { + error_code = eb_set_subbook(book, subbook->code); + if (error_code != EB_SUCCESS) + goto failed; + } + eb_unset_subbook(book); + + LOG(("out: eb_load_all_subbooks() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_unset_subbook(book); + LOG(("out: eb_load_all_subbooks() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Get index information in the current subbook. + * + * If succeeds, the number of indexes is returned. + * Otherwise, -1 is returned. + */ +static EB_Error_Code +eb_load_subbook_indexes(EB_Book *book) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + EB_Search search; + char buffer[EB_SIZE_PAGE]; + char *buffer_p; + int index_count; + int availability; + int global_availability; + EB_Search sebxa_zip_index; + EB_Search sebxa_zip_text; + int i; + + LOG(("in: eb_load_subbook_indexes(book=%d)", (int)book->code)); + + eb_initialize_search(&sebxa_zip_index); + eb_initialize_search(&sebxa_zip_text); + + subbook = book->subbook_current; + + /* + * Read the index table in the subbook. + */ + if (zio_lseek(&subbook->text_zio, + ((off_t) subbook->index_page - 1) * EB_SIZE_PAGE, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_TEXT; + goto failed; + } + if (zio_read(&subbook->text_zio, buffer, EB_SIZE_PAGE) != EB_SIZE_PAGE) { + error_code = EB_ERR_FAIL_READ_TEXT; + goto failed; + } + + /* + * Get start page numbers of the indexes in the subbook. + */ + index_count = eb_uint1(buffer + 1); + if (EB_SIZE_PAGE / 16 - 1 <= index_count) { + error_code = EB_ERR_UNEXP_TEXT; + goto failed; + } + + /* + * Get availavility flag of the index information. + */ + global_availability = eb_uint1(buffer + 4); + if (0x02 < global_availability) + global_availability = 0; + + /* + * Set each search method information. + */ + for (i = 0, buffer_p = buffer + 16; i < index_count; i++, buffer_p += 16) { + /* + * Set index style. + */ + eb_initialize_search(&search); + + search.index_id = eb_uint1(buffer_p); + search.start_page = eb_uint4(buffer_p + 2); + search.end_page = search.start_page + eb_uint4(buffer_p + 6) - 1; + + /* + * Set canonicalization flags. + */ + availability = eb_uint1(buffer_p + 10); + if ((global_availability == 0x00 && availability == 0x02) + || global_availability == 0x02) { + unsigned int flags; + + flags = eb_uint3(buffer_p + 11); + search.katakana = (flags & 0xc00000) >> 22; + search.lower = (flags & 0x300000) >> 20; + if ((flags & 0x0c0000) >> 18 == 0) + search.mark = EB_INDEX_STYLE_DELETE; + else + search.mark = EB_INDEX_STYLE_ASIS; + search.long_vowel = (flags & 0x030000) >> 16; + search.double_consonant = (flags & 0x00c000) >> 14; + search.contracted_sound = (flags & 0x003000) >> 12; + search.small_vowel = (flags & 0x000c00) >> 10; + search.voiced_consonant = (flags & 0x000300) >> 8; + search.p_sound = (flags & 0x0000c0) >> 6; + + } else if (search.index_id == 0x70 || search.index_id == 0x90) { + search.katakana = EB_INDEX_STYLE_CONVERT; + search.lower = EB_INDEX_STYLE_CONVERT; + search.mark = EB_INDEX_STYLE_DELETE; + search.long_vowel = EB_INDEX_STYLE_CONVERT; + search.double_consonant = EB_INDEX_STYLE_CONVERT; + search.contracted_sound = EB_INDEX_STYLE_CONVERT; + search.small_vowel = EB_INDEX_STYLE_CONVERT; + search.voiced_consonant = EB_INDEX_STYLE_CONVERT; + search.p_sound = EB_INDEX_STYLE_CONVERT; + + } else { + search.katakana = EB_INDEX_STYLE_ASIS; + search.lower = EB_INDEX_STYLE_CONVERT; + search.mark = EB_INDEX_STYLE_ASIS; + search.long_vowel = EB_INDEX_STYLE_ASIS; + search.double_consonant = EB_INDEX_STYLE_ASIS; + search.contracted_sound = EB_INDEX_STYLE_ASIS; + search.small_vowel = EB_INDEX_STYLE_ASIS; + search.voiced_consonant = EB_INDEX_STYLE_ASIS; + search.p_sound = EB_INDEX_STYLE_ASIS; + } + + if (book->character_code == EB_CHARCODE_ISO8859_1 + || search.index_id == 0x72 + || search.index_id == 0x92) { + search.space = EB_INDEX_STYLE_ASIS; + } else { + search.space = EB_INDEX_STYLE_DELETE; + } + + /* + * Identify search method. + */ + switch (search.index_id) { + case 0x00: + memcpy(&subbook->text, &search, sizeof(EB_Search)); + break; + case 0x01: + memcpy(&subbook->menu, &search, sizeof(EB_Search)); + break; + case 0x02: + memcpy(&subbook->copyright, &search, sizeof(EB_Search)); + break; + case 0x10: + memcpy(&subbook->image_menu, &search, sizeof(EB_Search)); + break; + case 0x16: + if (book->disc_code == EB_DISC_EPWING) + subbook->search_title_page = search.start_page; + break; + case 0x21: + if (book->disc_code == EB_DISC_EB + && zio_mode(&subbook->text_zio) == ZIO_PLAIN) + memcpy(&sebxa_zip_text, &search, sizeof(EB_Search)); + break; + case 0x22: + if (book->disc_code == EB_DISC_EB + && zio_mode(&subbook->text_zio) == ZIO_PLAIN) + memcpy(&sebxa_zip_index, &search, sizeof(EB_Search)); + break; + case 0x70: + memcpy(&subbook->endword_kana, &search, sizeof(EB_Search)); + break; + case 0x71: + memcpy(&subbook->endword_asis, &search, sizeof(EB_Search)); + break; + case 0x72: + memcpy(&subbook->endword_alphabet, &search, sizeof(EB_Search)); + break; + case 0x80: + memcpy(&subbook->keyword, &search, sizeof(EB_Search)); + break; + case 0x81: + memcpy(&subbook->cross, &search, sizeof(EB_Search)); + break; + case 0x90: + memcpy(&subbook->word_kana, &search, sizeof(EB_Search)); + break; + case 0x91: + memcpy(&subbook->word_asis, &search, sizeof(EB_Search)); + break; + case 0x92: + memcpy(&subbook->word_alphabet, &search, sizeof(EB_Search)); + break; + case 0xd8: + memcpy(&subbook->sound, &search, sizeof(EB_Search)); + break; + case 0xf1: + if (book->disc_code == EB_DISC_EB) { + subbook->wide_fonts[EB_FONT_16].page = search.start_page; + subbook->wide_fonts[EB_FONT_16].font_code = EB_FONT_16; + } + break; + case 0xf2: + if (book->disc_code == EB_DISC_EB) { + subbook->narrow_fonts[EB_FONT_16].page = search.start_page; + subbook->narrow_fonts[EB_FONT_16].font_code = EB_FONT_16; + } + break; + case 0xf3: + if (book->disc_code == EB_DISC_EB) { + subbook->wide_fonts[EB_FONT_24].page = search.start_page; + subbook->wide_fonts[EB_FONT_24].font_code = EB_FONT_24; + } + break; + case 0xf4: + if (book->disc_code == EB_DISC_EB) { + subbook->narrow_fonts[EB_FONT_24].page = search.start_page; + subbook->narrow_fonts[EB_FONT_24].font_code = EB_FONT_24; + } + break; + case 0xf5: + if (book->disc_code == EB_DISC_EB) { + subbook->wide_fonts[EB_FONT_30].page = search.start_page; + subbook->wide_fonts[EB_FONT_30].font_code = EB_FONT_30; + } + break; + case 0xf6: + if (book->disc_code == EB_DISC_EB) { + subbook->narrow_fonts[EB_FONT_30].page = search.start_page; + subbook->narrow_fonts[EB_FONT_30].font_code = EB_FONT_30; + } + break; + case 0xf7: + if (book->disc_code == EB_DISC_EB) { + subbook->wide_fonts[EB_FONT_48].page = search.start_page; + subbook->wide_fonts[EB_FONT_48].font_code = EB_FONT_48; + } + break; + case 0xf8: + if (book->disc_code == EB_DISC_EB) { + subbook->narrow_fonts[EB_FONT_48].page = search.start_page; + subbook->narrow_fonts[EB_FONT_48].font_code = EB_FONT_48; + } + break; + case 0xff: + if (subbook->multi_count < EB_MAX_MULTI_SEARCHES) { + memcpy(&subbook->multis[subbook->multi_count].search, &search, + sizeof(EB_Search)); + subbook->multi_count++; + } + break; + } + + eb_finalize_search(&sebxa_zip_text); + } + + /* + * Set S-EBXA compression flag. + */ + if (book->disc_code == EB_DISC_EB + && zio_mode(&subbook->text_zio) == ZIO_PLAIN + && subbook->text.start_page != 0 + && sebxa_zip_index.start_page != 0 + && sebxa_zip_text.start_page != 0) { + zio_set_sebxa_mode(&subbook->text_zio, + (sebxa_zip_index.start_page - 1) * EB_SIZE_PAGE, + (sebxa_zip_text.start_page - 1) * EB_SIZE_PAGE, + (subbook->text.start_page - 1) * EB_SIZE_PAGE, + subbook->text.end_page * EB_SIZE_PAGE - 1); + } + + eb_finalize_search(&sebxa_zip_index); + eb_finalize_search(&sebxa_zip_text); + + LOG(("out: eb_load_subbook_indexes() = %s", eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_finalize_search(&sebxa_zip_index); + eb_finalize_search(&sebxa_zip_text); + LOG(("out: eb_load_subbook_indexes() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Make a subbook list in the book. + */ +EB_Error_Code +eb_subbook_list(EB_Book *book, EB_Subbook_Code *subbook_list, + int *subbook_count) +{ + EB_Error_Code error_code; + EB_Subbook_Code *list_p; + int i; + + eb_lock(&book->lock); + LOG(("in: eb_subbook_list(book=%d)", (int)book->code)); + + /* + * The book must have been bound. + */ + if (book->path == NULL) { + error_code = EB_ERR_UNBOUND_BOOK; + goto failed; + } + + for (i = 0, list_p = subbook_list; i < book->subbook_count; i++, list_p++) + *list_p = i; + *subbook_count = book->subbook_count; + + LOG(("out: eb_subbook_list(subbook_count=%d) = %s", *subbook_count, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *subbook_count = 0; + LOG(("out: eb_subbook_list() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Return a subbook-code of the current subbook. + */ +EB_Error_Code +eb_subbook(EB_Book *book, EB_Subbook_Code *subbook_code) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_subbook(book=%d)", (int)book->code)); + + /* + * The current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + *subbook_code = book->subbook_current->code; + + LOG(("out: eb_subbook(subbook_code=%d) = %s", *subbook_code, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *subbook_code = EB_SUBBOOK_INVALID; + LOG(("out: eb_subbook() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Return a title of the current subbook. + */ +EB_Error_Code +eb_subbook_title(EB_Book *book, char *title) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_subbook_title(book=%d)", (int)book->code)); + + /* + * The current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + strcpy(title, book->subbook_current->title); + + LOG(("out: eb_subbook_title(title=%s) = %s", title, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *title = '\0'; + LOG(("out: eb_subbook_title() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Return a title of the specified subbook `subbook_code'. + */ +EB_Error_Code +eb_subbook_title2(EB_Book *book, EB_Subbook_Code subbook_code, char *title) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_subbook_title2(book=%d, subbook_code=%d)", + (int)book->code, (int)subbook_code)); + + /* + * The book must have been bound. + */ + if (book->path == NULL) { + error_code = EB_ERR_UNBOUND_BOOK; + goto failed; + } + + /* + * Check for the subbook-code. + */ + if (subbook_code < 0 || book->subbook_count <= subbook_code) { + error_code = EB_ERR_NO_SUCH_SUB; + goto failed; + } + + strcpy(title, (book->subbooks + subbook_code)->title); + + LOG(("out: eb_subbook_title2(title=%s) = %s", title, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *title = '\0'; + LOG(("out: eb_subbook_title2() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Return a directory name of the current subbook. + */ +EB_Error_Code +eb_subbook_directory(EB_Book *book, char *directory) +{ + EB_Error_Code error_code; + char *p; + + eb_lock(&book->lock); + LOG(("in: eb_subbook_directory(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Copy directory name. + * Upper letters are converted to lower letters. + */ + strcpy(directory, book->subbook_current->directory_name); + for (p = directory; *p != '\0'; p++) { + if ('A' <= *p && *p <= 'Z') + *p = ASCII_TOLOWER(*p); + } + + LOG(("out: eb_subbook_directory(directory=%s) = %s", directory, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *directory = '\0'; + LOG(("out: eb_subbook_directory() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Return a directory name of the specified subbook `subbook_code'. + */ +EB_Error_Code +eb_subbook_directory2(EB_Book *book, EB_Subbook_Code subbook_code, + char *directory) +{ + EB_Error_Code error_code; + char *p; + + eb_lock(&book->lock); + LOG(("in: eb_subbook_directory2(book=%d, subbook_code=%d)", + (int)book->code, (int)subbook_code)); + + /* + * The book must have been bound. + */ + if (book->path == NULL) { + error_code = EB_ERR_UNBOUND_BOOK; + goto failed; + } + + /* + * Check for the subbook-code. + */ + if (subbook_code < 0 || book->subbook_count <= subbook_code) { + error_code = EB_ERR_NO_SUCH_SUB; + goto failed; + } + + /* + * Copy directory name. + * Upper letters are converted to lower letters. + */ + strcpy(directory, (book->subbooks + subbook_code)->directory_name); + for (p = directory; *p != '\0'; p++) { + if ('A' <= *p && *p <= 'Z') + *p = ASCII_TOLOWER(*p); + } + + LOG(("out: eb_subbook_directory2(directory=%s) = %s", directory, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *directory = '\0'; + LOG(("out: eb_subbook_directory2() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Set the subbook `subbook_code' as the current subbook. + */ +EB_Error_Code +eb_set_subbook(EB_Book *book, EB_Subbook_Code subbook_code) +{ + EB_Error_Code error_code = EB_SUCCESS; + + eb_lock(&book->lock); + LOG(("in: eb_set_subbook(book=%d, subbook_code=%d)", + (int)book->code, (int)subbook_code)); + + /* + * The book must have been bound. + */ + if (book->path == NULL) { + error_code = EB_ERR_UNBOUND_BOOK; + goto failed; + } + + /* + * Check for the subbook-code. + */ + if (subbook_code < 0 || book->subbook_count <= subbook_code) { + error_code = EB_ERR_NO_SUCH_SUB; + goto failed; + } + + /* + * If the subbook has already been set as the current subbook, + * there is nothing to be done. + * Otherwise close the previous subbook. + */ + if (book->subbook_current != NULL) { + if (book->subbook_current->code == subbook_code) + goto succeeded; + eb_unset_subbook(book); + } + + /* + * Set the current subbook. + */ + book->subbook_current = book->subbooks + subbook_code; + + /* + * Dispatch. + */ + if (book->disc_code == EB_DISC_EB) + error_code = eb_set_subbook_eb(book, subbook_code); + else + error_code = eb_set_subbook_epwing(book, subbook_code); + if (error_code != EB_SUCCESS) + goto failed; + + /* + * Load the subbook. + */ + error_code = eb_load_subbook(book); + if (error_code != EB_SUCCESS) + goto failed; + + /* + * Load font files. + */ + eb_load_font_headers(book); + + succeeded: + book->subbook_current->initialized = 1; + LOG(("out: eb_set_subbook() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return error_code; + + /* + * An error occurs... + */ + failed: + if (book->subbook_current != NULL) { + zio_close(&book->subbook_current->text_zio); + zio_close(&book->subbook_current->graphic_zio); + zio_close(&book->subbook_current->sound_zio); + zio_close(&book->subbook_current->movie_zio); + } + book->subbook_current = NULL; + LOG(("out: eb_set_subbook() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Set the subbook `subbook_code' as the current subbook. + */ +static EB_Error_Code +eb_set_subbook_eb(EB_Book *book, EB_Subbook_Code subbook_code) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + char text_path_name[EB_MAX_PATH_LENGTH + 1]; + char graphic_path_name[EB_MAX_PATH_LENGTH + 1]; + Zio_Code text_zio_code; + Zio_Code graphic_zio_code; + + LOG(("in: eb_set_subbook_eb(book=%d, subbook_code=%d)", + (int)book->code, (int)subbook_code)); + + subbook = book->subbook_current; + + /* + * Open a text file if exists. + */ + text_zio_code = ZIO_INVALID; + + if (subbook->initialized) { + if (zio_mode(&subbook->text_zio) != ZIO_INVALID) + text_zio_code = ZIO_REOPEN; + } else { + eb_canonicalize_file_name(subbook->text_file_name); + if (eb_find_file_name2(book->path, subbook->directory_name, + EB_FILE_NAME_START, subbook->text_file_name) == EB_SUCCESS) { + eb_path_name_zio_code(subbook->text_file_name, ZIO_PLAIN, + &text_zio_code); + } + } + + if (text_zio_code != ZIO_INVALID) { + eb_compose_path_name2(book->path, subbook->directory_name, + subbook->text_file_name, text_path_name); + if (zio_open(&subbook->text_zio, text_path_name, text_zio_code) < 0) { + error_code = EB_ERR_FAIL_OPEN_TEXT; + goto failed; + } + text_zio_code = zio_mode(&subbook->text_zio); + } + + /* + * Open a graphic file if exists. + */ + graphic_zio_code = ZIO_INVALID; + + if (subbook->initialized) { + if (zio_mode(&subbook->graphic_zio) != ZIO_INVALID) + graphic_zio_code = ZIO_REOPEN; + } else if (text_zio_code != ZIO_INVALID) { + strcpy(subbook->graphic_file_name, subbook->text_file_name); + graphic_zio_code = text_zio_code; + } + + if (graphic_zio_code != ZIO_INVALID) { + eb_compose_path_name2(book->path, subbook->directory_name, + subbook->graphic_file_name, graphic_path_name); + if (zio_open(&subbook->graphic_zio, graphic_path_name, + graphic_zio_code) < 0) { + error_code = EB_ERR_FAIL_OPEN_BINARY; + goto failed; + } + graphic_zio_code = zio_mode(&subbook->graphic_zio); + } + + LOG(("out: eb_set_subbook_eb() = %s", eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_set_subbook_eb() = %s", eb_error_string(error_code))); + return error_code; +} + +/* + * Set the subbook `subbook_code' as the current subbook. + */ +static EB_Error_Code +eb_set_subbook_epwing(EB_Book *book, EB_Subbook_Code subbook_code) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + char text_path_name[EB_MAX_PATH_LENGTH + 1]; + char graphic_path_name[EB_MAX_PATH_LENGTH + 1]; + char sound_path_name[EB_MAX_PATH_LENGTH + 1]; + Zio_Code text_zio_code; + Zio_Code graphic_zio_code; + Zio_Code sound_zio_code; + + LOG(("in: eb_set_subbook_epwing(book=%d, subbook_code=%d)", + (int)book->code, (int)subbook_code)); + + subbook = book->subbook_current; + + if (!subbook->initialized) { + /* + * Adjust directory names. + */ + strcpy(subbook->data_directory_name, EB_DIRECTORY_NAME_DATA); + eb_fix_directory_name2(book->path, subbook->directory_name, + subbook->data_directory_name); + + strcpy(subbook->gaiji_directory_name, EB_DIRECTORY_NAME_GAIJI); + eb_fix_directory_name2(book->path, subbook->directory_name, + subbook->gaiji_directory_name); + + strcpy(subbook->movie_directory_name, EB_DIRECTORY_NAME_MOVIE); + eb_fix_directory_name2(book->path, subbook->directory_name, + subbook->movie_directory_name); + } + + /* + * Open a text file if exists. + * + * If a subbook has stream data only, its index_page has been set + * to 0. In this case, we must not try to open a text file of + * the subbook, since the text file may be for another subbook. + * Remember that subbooks can share a `data' sub-directory. + */ + text_zio_code = ZIO_INVALID; + + if (subbook->initialized) { + if (zio_mode(&subbook->text_zio) != ZIO_INVALID) + text_zio_code = ZIO_REOPEN; + } else if (subbook->index_page > 0) { + eb_canonicalize_file_name(subbook->text_file_name); + if (eb_find_file_name3(book->path, subbook->directory_name, + subbook->data_directory_name, subbook->text_file_name, + subbook->text_file_name) == EB_SUCCESS) { + eb_path_name_zio_code(subbook->text_file_name, + subbook->text_hint_zio_code, &text_zio_code); + } + } + + if (text_zio_code != ZIO_INVALID) { + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->data_directory_name, subbook->text_file_name, + text_path_name); + if (zio_open(&subbook->text_zio, text_path_name, text_zio_code) < 0) { + subbook = NULL; + error_code = EB_ERR_FAIL_OPEN_TEXT; + goto failed; + } + text_zio_code = zio_mode(&subbook->text_zio); + } + + /* + * Open a graphic file if exists. + */ + graphic_zio_code = ZIO_INVALID; + + if (subbook->initialized) { + if (zio_mode(&subbook->graphic_zio) != ZIO_INVALID) + graphic_zio_code = ZIO_REOPEN; + } else if (text_zio_code != ZIO_INVALID) { + eb_canonicalize_file_name(subbook->graphic_file_name); + if (eb_find_file_name3(book->path, subbook->directory_name, + subbook->data_directory_name, subbook->graphic_file_name, + subbook->graphic_file_name) == EB_SUCCESS) { + eb_path_name_zio_code(subbook->graphic_file_name, + subbook->graphic_hint_zio_code, &graphic_zio_code); + } + } + + if (graphic_zio_code != ZIO_INVALID) { + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->data_directory_name, subbook->graphic_file_name, + graphic_path_name); + if (zio_open(&subbook->graphic_zio, graphic_path_name, + graphic_zio_code) < 0) { + error_code = EB_ERR_FAIL_OPEN_BINARY; + goto failed; + } + graphic_zio_code = zio_mode(&subbook->graphic_zio); + } + + /* + * Open a sound file if exists. + */ + sound_zio_code = ZIO_INVALID; + + if (subbook->initialized) { + if (zio_mode(&subbook->sound_zio) != ZIO_INVALID) + sound_zio_code = ZIO_REOPEN; + } else if (text_zio_code != ZIO_INVALID) { + eb_canonicalize_file_name(subbook->sound_file_name); + if (eb_find_file_name3(book->path, subbook->directory_name, + subbook->data_directory_name, subbook->sound_file_name, + subbook->sound_file_name) == EB_SUCCESS) { + eb_path_name_zio_code(subbook->sound_file_name, + subbook->sound_hint_zio_code, &sound_zio_code); + } + } + + if (sound_zio_code != ZIO_INVALID) { + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->data_directory_name, subbook->sound_file_name, + sound_path_name); + if (zio_open(&subbook->sound_zio, sound_path_name, + sound_zio_code) < 0) { + error_code = EB_ERR_FAIL_OPEN_BINARY; + goto failed; + } + sound_zio_code = zio_mode(&subbook->sound_zio); + } + + LOG(("out: eb_set_subbook_epwing() = %s", eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_set_subbook_epwing() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Unset the current subbook. + */ +void +eb_unset_subbook(EB_Book *book) +{ + eb_lock(&book->lock); + LOG(("in: eb_unset_subbook(book=%d)", (int)book->code)); + + /* + * Close the file of the current subbook. + */ + if (book->subbook_current != NULL) { + eb_unset_font(book); + eb_unset_binary(book); + zio_close(&book->subbook_current->text_zio); + zio_close(&book->subbook_current->graphic_zio); + zio_close(&book->subbook_current->sound_zio); + zio_close(&book->subbook_current->movie_zio); + book->subbook_current = NULL; + } + + LOG(("out: eb_unset_subbook()")); + eb_unlock(&book->lock); +} + + diff --git a/eb/text.c b/eb/text.c new file mode 100644 index 0000000..97f7e3b --- /dev/null +++ b/eb/text.c @@ -0,0 +1,121 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "build-post.h" + +/* + * Examine whether the current subbook in `book' has text body. + * or not. + */ +int +eb_have_text(EB_Book *book) +{ + eb_lock(&book->lock); + LOG(("in: eb_have_text(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) + goto failed; + + /* + * Check for the index page of text. + */ + if (book->subbook_current->text.start_page == 0) + goto failed; + + LOG(("out: eb_have_text() = %d", 1)); + eb_unlock(&book->lock); + + return 1; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_have_text() = %d", 0)); + eb_unlock(&book->lock); + return 0; +} + + +/* + * Menu. + */ +EB_Error_Code +eb_text(EB_Book *book, EB_Position *position) +{ + EB_Error_Code error_code; + int page; + + eb_lock(&book->lock); + LOG(("in: eb_text(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Check for the page number of text. + */ + page = book->subbook_current->text.start_page; + if (page == 0) { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + + /* + * Copy the position to `position'. + */ + position->page = page; + position->offset = 0; + + LOG(("out: eb_text(position={%d,%d}) = %s", + position->page, position->offset, eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_text() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + diff --git a/eb/text.h b/eb/text.h new file mode 100644 index 0000000..caba03e --- /dev/null +++ b/eb/text.h @@ -0,0 +1,166 @@ +/* -*- C -*- + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef EB_TEXT_H +#define EB_TEXT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef EB_BUILD_LIBRARY +#include "defs.h" +#else +#include +#endif + +/* + * Hook codes. + * (When you add or remove a hook, update EB_NUMER_OF_HOOKS in defs.h.) + */ +#define EB_HOOK_NULL -1 +#define EB_HOOK_INITIALIZE 0 +#define EB_HOOK_BEGIN_NARROW 1 +#define EB_HOOK_END_NARROW 2 +#define EB_HOOK_BEGIN_SUBSCRIPT 3 +#define EB_HOOK_END_SUBSCRIPT 4 + +#define EB_HOOK_SET_INDENT 5 +#define EB_HOOK_NEWLINE 6 +#define EB_HOOK_BEGIN_SUPERSCRIPT 7 +#define EB_HOOK_END_SUPERSCRIPT 8 +#define EB_HOOK_BEGIN_NO_NEWLINE 9 + +#define EB_HOOK_END_NO_NEWLINE 10 +#define EB_HOOK_BEGIN_EMPHASIS 11 +#define EB_HOOK_END_EMPHASIS 12 +#define EB_HOOK_BEGIN_CANDIDATE 13 +#define EB_HOOK_END_CANDIDATE_GROUP 14 + +#define EB_HOOK_END_CANDIDATE_LEAF 15 +#define EB_HOOK_BEGIN_REFERENCE 16 +#define EB_HOOK_END_REFERENCE 17 +#define EB_HOOK_BEGIN_KEYWORD 18 +#define EB_HOOK_END_KEYWORD 19 + +#define EB_HOOK_NARROW_FONT 20 +#define EB_HOOK_WIDE_FONT 21 +#define EB_HOOK_ISO8859_1 22 +#define EB_HOOK_NARROW_JISX0208 23 +#define EB_HOOK_WIDE_JISX0208 24 + +#define EB_HOOK_GB2312 25 +#define EB_HOOK_BEGIN_MONO_GRAPHIC 26 +#define EB_HOOK_END_MONO_GRAPHIC 27 +#define EB_HOOK_BEGIN_GRAY_GRAPHIC 28 +#define EB_HOOK_END_GRAY_GRAPHIC 29 + +#define EB_HOOK_BEGIN_COLOR_BMP 30 +#define EB_HOOK_BEGIN_COLOR_JPEG 31 +#define EB_HOOK_BEGIN_IN_COLOR_BMP 32 +#define EB_HOOK_BEGIN_IN_COLOR_JPEG 33 +#define EB_HOOK_END_COLOR_GRAPHIC 34 + +#define EB_HOOK_END_IN_COLOR_GRAPHIC 35 +#define EB_HOOK_BEGIN_WAVE 36 +#define EB_HOOK_END_WAVE 37 +#define EB_HOOK_BEGIN_MPEG 38 +#define EB_HOOK_END_MPEG 39 + +#define EB_HOOK_BEGIN_GRAPHIC_REFERENCE 40 +#define EB_HOOK_END_GRAPHIC_REFERENCE 41 +#define EB_HOOK_GRAPHIC_REFERENCE 42 +#define EB_HOOK_BEGIN_DECORATION 43 +#define EB_HOOK_END_DECORATION 44 + +#define EB_HOOK_BEGIN_IMAGE_PAGE 45 +#define EB_HOOK_END_IMAGE_PAGE 46 +#define EB_HOOK_BEGIN_CLICKABLE_AREA 47 +#define EB_HOOK_END_CLICKABLE_AREA 48 + +#define EB_HOOK_BEGIN_UNICODE 49 +#define EB_HOOK_END_UNICODE 50 +#define EB_HOOK_BEGIN_EBXAC_GAIJI 51 +#define EB_HOOK_END_EBXAC_GAIJI 52 +#define EB_HOOK_EBXAC_GAIJI 53 + +/* + * Function declarations. + */ +/* hook.c */ +void eb_initialize_hookset(EB_Hookset *hookset); +void eb_finalize_hookset(EB_Hookset *hookset); +EB_Error_Code eb_set_hook(EB_Hookset *hookset, const EB_Hook *hook); +EB_Error_Code eb_set_hooks(EB_Hookset *hookset, const EB_Hook *hook); +EB_Error_Code eb_hook_euc_to_ascii(EB_Book *book, EB_Appendix *appendix, + void *container, EB_Hook_Code hook_code, int argc, + const unsigned int *argv); +EB_Error_Code eb_hook_stop_code(EB_Book *book, EB_Appendix *appendix, + void *container, EB_Hook_Code hook_code, int argc, + const unsigned int *argv); +EB_Error_Code eb_hook_narrow_character_text(EB_Book *book, + EB_Appendix *appendix, void *container, EB_Hook_Code hook_code, int argc, + const unsigned int *argv); +EB_Error_Code eb_hook_wide_character_text(EB_Book *book, + EB_Appendix *appendix, void *container, EB_Hook_Code hook_code, int argc, + const unsigned int *argv); +EB_Error_Code eb_hook_newline(EB_Book *book, EB_Appendix *appendix, + void *container, EB_Hook_Code hook_code, int argc, + const unsigned int *argv); +EB_Error_Code eb_hook_empty(EB_Book *book, EB_Appendix *appendix, + void *container, EB_Hook_Code hook_code, int argc, + const unsigned int *argv); + +/* readtext.c */ +EB_Error_Code eb_seek_text(EB_Book *book, const EB_Position *position); +EB_Error_Code eb_tell_text(EB_Book *book, EB_Position *position); +EB_Error_Code eb_read_text(EB_Book *book, EB_Appendix *appendix, + EB_Hookset *hookset, void *container, size_t text_max_length, char *text, + ssize_t *text_length); +EB_Error_Code eb_read_heading(EB_Book *book, EB_Appendix *appendix, + EB_Hookset *hookset, void *container, size_t text_max_length, char *text, + ssize_t *text_length); +EB_Error_Code eb_read_rawtext(EB_Book *book, size_t text_max_length, + char *text, ssize_t *text_length); +int eb_is_text_stopped(EB_Book *book); +EB_Error_Code eb_write_text_byte1(EB_Book *book, int byte1); +EB_Error_Code eb_write_text_byte2(EB_Book *book, int byte1, int byte2); +EB_Error_Code eb_write_text_string(EB_Book *book, const char *string); +EB_Error_Code eb_write_text(EB_Book *book, const char * stream, + size_t stream_length); +const char *eb_current_candidate(EB_Book *book); +EB_Error_Code eb_forward_text(EB_Book *book, EB_Appendix *appendix); +EB_Error_Code eb_backward_text(EB_Book *book, EB_Appendix *appendix); + +#ifdef __cplusplus +} +#endif + +#endif /* not EB_TEXT_H */ diff --git a/eb/urlparts.c b/eb/urlparts.c new file mode 100644 index 0000000..4ab1071 --- /dev/null +++ b/eb/urlparts.c @@ -0,0 +1,714 @@ +/* + * Copyright (c) 2000-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +/* + * Character type tests and conversions. + */ +#define ASCII_ISDIGIT(c) ('0' <= (c) && (c) <= '9') +#define ASCII_ISUPPER(c) ('A' <= (c) && (c) <= 'Z') +#define ASCII_ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define ASCII_ISALPHA(c) \ + (ASCII_ISUPPER(c) || ASCII_ISLOWER(c)) +#define ASCII_ISALNUM(c) \ + (ASCII_ISUPPER(c) || ASCII_ISLOWER(c) || ASCII_ISDIGIT(c)) +#define ASCII_ISXDIGIT(c) \ + (ASCII_ISDIGIT(c) || ('A' <= (c) && (c) <= 'F') || ('a' <= (c) && (c) <= 'f')) +#define ASCII_TOUPPER(c) (('a' <= (c) && (c) <= 'z') ? (c) - 0x20 : (c)) +#define ASCII_TOLOWER(c) (('A' <= (c) && (c) <= 'Z') ? (c) + 0x20 : (c)) + +#include "urlparts.h" + +/* + * Unexported functions. + */ +static void url_parts_canonicalize_path(char *path); +static void url_parts_expand_hex(char *string); +static void url_parts_convert_to_lower(char *string); + + +/* + * Initialize a query. + */ +void +url_parts_initialize(URL_Parts *parts) +{ + /* + * Set all URL parts and whole URL to NULL. + */ + parts->url = NULL; + parts->scheme = NULL; + parts->user = NULL; + parts->password = NULL; + parts->host = NULL; + parts->port = NULL; + parts->path = NULL; + parts->params = NULL; + parts->query = NULL; + parts->fragment = NULL; + + parts->buffer = NULL; +} + + +/* + * Finalize a query. + * All allocated memories in `queue' are also disposed. + */ +void +url_parts_finalize(URL_Parts *parts) +{ + /* + * Set all URL parts and whole URL to NULL. + */ + parts->scheme = NULL; + parts->user = NULL; + parts->password = NULL; + parts->host = NULL; + parts->port = NULL; + parts->path = NULL; + parts->params = NULL; + parts->query = NULL; + parts->fragment = NULL; + + /* + * Dispose memories assigned to `parts->url' and `parts->buffer'. + */ + if (parts->url != NULL) { + free(parts->url); + parts->url = NULL; + } + + if (parts->buffer != NULL) { + free(parts->buffer); + parts->buffer = NULL; + } +} + + +/* + * Return whole URL of a parsed URL. + */ +const char * +url_parts_url(URL_Parts *parts) +{ + return parts->url; +} + + +/* + * Return scheme part of a parsed URL. + */ +const char * +url_parts_scheme(URL_Parts *parts) +{ + return parts->scheme; +} + + +/* + * Return user part of a parsed URL. + */ +const char * +url_parts_user(URL_Parts *parts) +{ + return parts->user; +} + + +/* + * Return password part of a parsed URL. + */ +const char * +url_parts_password(URL_Parts *parts) +{ + return parts->password; +} + + +/* + * Return host part of a parsed URL. + */ +const char * +url_parts_host(URL_Parts *parts) +{ + return parts->host; +} + + +/* + * Return port part of a parsed URL. + */ +const char * +url_parts_port(URL_Parts *parts) +{ + return parts->port; +} + + +/* + * Return path part of a parsed URL. + */ +const char * +url_parts_path(URL_Parts *parts) +{ + return parts->path; +} + + +/* + * Return params part of a parsed URL. + */ +const char * +url_parts_params(URL_Parts *parts) +{ + return parts->params; +} + + +/* + * Return query part of a parsed URL. + */ +const char * +url_parts_query(URL_Parts *parts) +{ + return parts->query; +} + + +/* + * Return fragment part of a parsed URL. + */ +const char * +url_parts_fragment(URL_Parts *parts) +{ + return parts->fragment; +} + + +/* + * Parse an URL and fragment. + * + * `url' is an absolute or relative URL and optional fragment. + * The function resolves the `url' into 9 parts; scheme, user, password, + * host, port, path, params, query and fragment. + * + * [scheme ":"] ["//" [][":" password] "@"]["host" [":" port]] + * ["/" path] [";" params] ["?" query] ["#" fragment] + * + * The result is put into `parts'. This functions fails only when + * memory is exhausted. The function returns -1 in this case. + * It returns 0, upon successful. + */ +int +url_parts_parse(URL_Parts *parts, const char *url) +{ + char *separator; + char *url_p; + size_t url_length; + char *right_bracket; + + /* + * Re-initialize if `url' has already been used. + */ + if (parts->buffer != NULL) { + url_parts_finalize(parts); + url_parts_initialize(parts); + } + + /* + * Copy `url' to `parts->url' and `parts->buffer'. + */ + url_length = strlen(url); + parts->url = (char *)malloc(url_length + 1); + if (parts->url == NULL) + goto failed; + memcpy(parts->url, url, url_length + 1); + + parts->buffer = (char *)malloc(url_length + 1); + if (parts->buffer == NULL) + goto failed; + memcpy(parts->buffer, url, url_length + 1); + + /* + * Get a fragment. + */ + url_p = parts->buffer; + separator = strchr(url_p, '#'); + if (separator != NULL) { + if (*(separator + 1) != '\0') + parts->fragment = separator + 1; + *separator = '\0'; + } + + /* + * Get a scheme name. + */ + separator = strchr(url_p, ':'); + if (separator != NULL) { + char *p; + + for (p = url_p; *p != ':'; p++) { + if (!ASCII_ISALNUM(*p) && *p != '+' && *p != '.' && *p != '-') + break; + } + if (*p == ':') { + parts->scheme = url_p; + *p = '\0'; + url_p = p + 1; + } + } + + /* + * Get a network location. + */ + if (*url_p == '/' && *(url_p + 1) == '/') { + char *netloc = NULL; + char *hostport = NULL; + char *userpass = NULL; + char *p1, *p2; + + /* + * Shift left 2 characters to insert a terminator ('\0') for + * the network location, and a missed slash (`/'). + * + * "//www.foo.co.jp/path..." --> "www.foo.co.jp\0\0/path..." + * "//www.foo.co.jp\0" --> "www.foo.co.jp\0/\0" + */ + netloc = url_p; + for (p1 = url_p + 2, p2 = url_p; + *p1 != '/' && *p1 != '\0'; p1++, p2++) + *p2 = *p1; + *p2++ = '\0'; + if (*p1 != '\0') + url_p = p1; + else { + *p2 = '/'; + url_p = p2; + } + + /* + * Separate `netloc' into ":" and ":". + */ + separator = strchr(netloc, '@'); + if (separator != NULL) { + if (separator != netloc) + userpass = netloc; + if (*(separator + 1) != '\0') + hostport = separator + 1; + *separator = '\0'; + } else { + hostport = netloc; + userpass = NULL; + } + + /* + * Get user and password. + */ + if (userpass != NULL) { + separator = strchr(userpass, ':'); + if (separator != NULL) { + if (separator != userpass) + parts->user = userpass; + if (*(separator + 1) != '\0') + parts->password = separator + 1; + *separator = '\0'; + } else { + parts->user = userpass; + } + } + + /* + * Get host and port. + * IPv6 address is enclosed in `[' and `]'. + */ + if (*hostport == '[') { + right_bracket = strchr(hostport + 1, ']'); + if (right_bracket == NULL) + separator = NULL; + else { + if (*(right_bracket + 1) == ':' + || *(right_bracket + 1) == '\0') { + hostport++; + *right_bracket = '\0'; + } + separator = strchr(right_bracket + 1, ':'); + } + } else { + separator = strchr(hostport, ':'); + } + + if (separator != NULL) { + if (separator != hostport) + parts->host = hostport; + if (*(separator + 1) != '\0') + parts->port = separator + 1; + *separator = '\0'; + } else { + parts->host = hostport; + } + } + + /* + * Parse query. + */ + separator = strchr(url_p, '?'); + if (separator != NULL) { + if (*(separator + 1) != '\0') + parts->query = separator + 1; + *separator = '\0'; + } + + /* + * Parse parameters. + * The part is deleted if present. + */ + separator = strchr(url_p, ';'); + if (separator != NULL) { + if (*(separator + 1) != '\0') + parts->params = separator + 1; + *separator = '\0'; + } + + /* + * Parse path. + */ + if (*url_p != '\0') + parts->path = url_p; + + /* + * Normalize parts. + */ + if (parts->scheme != NULL) { + url_parts_expand_hex(parts->scheme); + url_parts_convert_to_lower(parts->scheme); + } + if (parts->user != NULL) { + url_parts_expand_hex(parts->user); + } + if (parts->password != NULL) { + url_parts_expand_hex(parts->password); + } + if (parts->host != NULL) { + url_parts_expand_hex(parts->host); + url_parts_convert_to_lower(parts->host); + } + if (parts->port != NULL) { + url_parts_expand_hex(parts->port); + } + if (parts->path != NULL) { + url_parts_expand_hex(parts->path); + url_parts_canonicalize_path(parts->path); + } + if (parts->params != NULL) { + url_parts_expand_hex(parts->params); + } + if (parts->query != NULL) { + url_parts_expand_hex(parts->query); + } + if (parts->fragment != NULL) { + url_parts_expand_hex(parts->fragment); + } + + return 0; + + /* + * An error occurs... + */ + failed: + url_parts_finalize(parts); + return -1; +} + + +/* + * Canonicalize the path in URL. + * + * Replace "." and ".." segments in the path. + * All occurrences of "." segment are removed. + * All occurrences of "/.." segments where is not + * equal to "..", are removed. This process is repeated until no + * match pattern remains. + * + * For example: + * "/A/./a.html" ---> "/A/a.html" + * "/A/../a.html" ---> "/a.html" + * "/A/B/C/../../a.html" ---> "/A/a.html" + * "/../a.html" ---> "/../a.html" (*1) + * + * (*1) If a correspondig parent segment is not exist in the path, + * we don't remove "/..". + */ +static void +url_parts_canonicalize_path(char *path) +{ + char *source = path; + char *destination = path; + char *unfixed_root = path; + char *slash; + + while (*source != '\0') { + if (*source != '/') { + *destination++ = *source++; + continue; + } + + /* + * `*source' is slash (`/'). + */ + if (*(source + 1) == '/') { + /* + * "//" -- Ignore 2nd slash ("/"). + */ + source++; + } else if (*(source + 1) == '.' + && *(source + 2) == '/') { + /* + * "/./" -- Current segment itself. Removed. + */ + if (unfixed_root != destination) { + source += 2; + } else { + *destination++ = *source++; + *destination++ = *source++; + unfixed_root += 2; + } + } else if (*(source + 1) == '.' && *(source + 2) == '.' + && *(source + 3) == '/') { + /* + * "/../" -- Back to the parent segment. + */ + if (unfixed_root != destination) { + source += 3; + *destination = '\0'; + slash = strrchr(unfixed_root, '/'); + if (slash != NULL) + destination = slash; + else + destination = path; + } else { + *destination++ = *source++; + *destination++ = *source++; + *destination++ = *source++; + unfixed_root += 3; + } + } else { + /* + * "/" -- Single "/". + */ + *destination++ = *source++; + } + } + *destination = '\0'; + + slash = strrchr(unfixed_root, '/'); + if (slash != NULL + && slash != unfixed_root + && *(slash + 1) == '.' && *(slash + 2) == '\0') { + /* + * The path is end with "/.", Remove ".". + * After the canonicalization, the path is end with "/". + */ + *(slash + 1) = '\0'; + } else if (slash != NULL + && slash != unfixed_root + && *(slash + 1) == '.' && *(slash + 2) == '.' + && *(slash + 3) == '\0') { + /* + * The path is end with "/..", Back to the parent segment. + * After the canonicalization, the path is end with "/". + */ + *slash = '\0'; + slash = strrchr(unfixed_root, '/'); + if (slash == NULL) { + *path = '/'; + *(path + 1) = '\0'; + } else + *(slash + 1) = '\0'; + } +} + +/* + * All characters except for the followings are expandable characters. + * Converting "%" to that character doesn't affect URL parsing. + * + * unsafe ::= CTL | SP | <"> | "#" | "%" | "<" | ">" + * reserved ::= ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" + * + * `expandable_hex_table[]' is used to examine whether a character is + * expandable or not. + */ +static const char expandable_hex_table[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 ... 0x0f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 ... 0x1f */ + 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, /* !"#$%&'()*+,-./ */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */ + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* @ABCDEFGHIJKLMNO */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* PQRSTUVWXYZ[\]^_ */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* `abcdefghijklmno */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* pqrstuvwxyz{|}~ */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x80 ... 0x8f */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x90 ... 0x9f */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xa0 ... 0xaf */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xb0 ... 0xbf */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xc0 ... 0xcf */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xd0 ... 0xdf */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xe0 ... 0xef */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xf0 ... 0xff */ +}; + +/* + * Expand all "%" in an URL part to original characters. + */ +static void +url_parts_expand_hex(char *string) +{ + char *source = string; + char *destination = string; + int hex1; + int hex2; + int c; + + while (*source != '\0') { + /* + * "%" occurs. + * Unescape it if the character is not unsafe or reserved. + */ + if (*source == '%' + && ASCII_ISXDIGIT(*(source + 1)) + && ASCII_ISXDIGIT(*(source + 2))) { + hex1 = *(source + 1); + hex2 = *(source + 2); + c = 0; + + if ('0' <= hex1 && hex1 <= '9') + c += (hex1 - '0') << 4; + else if ('A' <= hex1 && hex1 <= 'F') + c += (hex1 - 'A' + 0x0a) << 4; + else if ('a' <= hex1 && hex1 <= 'f') + c += (hex1 - 'a' + 0x0a) << 4; + + if ('0' <= hex2 && hex2 <= '9') + c += (hex2 - '0'); + else if ('A' <= hex2 && hex2 <= 'F') + c += (hex2 - 'A' + 0x0a); + else if ('a' <= hex2 && hex2 <= 'f') + c += (hex2 - 'a' + 0x0a); + + if (expandable_hex_table[c]) + *(unsigned char *)destination++ = c; + else { + *destination++ = '%'; + *destination++ = hex1; + *destination++ = hex2; + } + source += 3; + + } else + *destination++ = *source++; + } + + *destination = '\0'; +} + + +/* + * Convert upper case letters in a stinrg `string' to lower case. + * This function is for the `scheme' and `host' parts in an URL, + * since they are case insensitive, + */ +static void +url_parts_convert_to_lower(char *string) +{ + char *p; + + for (p = string; *p != '\0'; p++) { + if (ASCII_ISUPPER(*p)) + *p = 'a' + (*p - 'A'); + } +} + + +void +url_parts_print(URL_Parts *parts) +{ + printf("url parts = {\n"); + if (parts->scheme != NULL) + printf(" scheme = %s\n", parts->scheme); + if (parts->user != NULL) + printf(" user = %s\n", parts->user); + if (parts->password != NULL) + printf(" password = %s\n", parts->password); + if (parts->host != NULL) + printf(" host = %s\n", parts->host); + if (parts->port != NULL) + printf(" port = %s\n", parts->port); + if (parts->path != NULL) + printf(" path = %s\n", parts->path); + if (parts->params != NULL) + printf(" params = %s\n", parts->params); + if (parts->query != NULL) + printf(" query = %s\n", parts->query); + if (parts->fragment != NULL) + printf(" fragment = %s\n", parts->fragment); + printf("}\n"); + fflush(stdout); +} + +/* + * Main for test. + */ +#ifdef TEST + +int +main(int argc, char *argv[]) +{ + URL_Parts url; + int i; + + if (argc < 2) { + fprintf(stderr, "usage: %s URL\n", argv[0]); + exit(1); + } + + url_parts_initialize(&url); + url_parts_parse(&url, argv[1]); + url_parts_print(&url); + fflush(stdout); + url_parts_finalize(&url); +} + +#endif diff --git a/eb/urlparts.h b/eb/urlparts.h new file mode 100644 index 0000000..b3fb863 --- /dev/null +++ b/eb/urlparts.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2000-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef URLPARTS_H +#define URLPARTS_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +/* + * URL Parts. + */ +typedef struct { + char *url; + char *scheme; + char *user; + char *password; + char *host; + char *port; + char *path; + char *params; + char *query; + char *fragment; + char *buffer; +} URL_Parts; + +/* + * Function Declarations. + */ +void url_parts_initialize(URL_Parts *parts); +void url_parts_finalize(URL_Parts *parts); +const char *url_parts_url(URL_Parts *parts); +const char *url_parts_scheme(URL_Parts *parts); +const char *url_parts_user(URL_Parts *parts); +const char *url_parts_password(URL_Parts *parts); +const char *url_parts_host(URL_Parts *parts); +const char *url_parts_port(URL_Parts *parts); +const char *url_parts_path(URL_Parts *parts); +const char *url_parts_params(URL_Parts *parts); +const char *url_parts_query(URL_Parts *parts); +const char *url_parts_fragment(URL_Parts *parts); +int url_parts_parse(URL_Parts *, const char *parts); +void url_parts_print(URL_Parts *parts); + +#endif /* not URLPARTS_H */ diff --git a/eb/widealt.c b/eb/widealt.c new file mode 100644 index 0000000..f16e937 --- /dev/null +++ b/eb/widealt.c @@ -0,0 +1,629 @@ +/* automatically generated from narwalt.c. */ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "appendix.h" +#include "build-post.h" + +/* + * Unexported functions. + */ +static EB_Error_Code eb_wide_character_text_jis(EB_Appendix *appendix, + int character_number, char *text); +static EB_Error_Code eb_wide_character_text_latin(EB_Appendix *appendix, + int character_number, char *text); + +/* + * Hash macro for cache data. + */ +#define EB_HASH_ALT_CACHE(c) ((c) & 0x0f) + + +/* + * Examine whether the current subbook in `book' has a wide font + * alternation or not. + */ +int +eb_have_wide_alt(EB_Appendix *appendix) +{ + eb_lock(&appendix->lock); + LOG(("in: eb_have_wide_alt(appendix=%d)", (int)appendix->code)); + + /* + * Current subbook must have been set. + */ + if (appendix->subbook_current == NULL) + goto failed; + + if (appendix->subbook_current->wide_page == 0) + goto failed; + + LOG(("out: eb_have_wide_alt() = %d", 1)); + eb_unlock(&appendix->lock); + + return 1; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_have_wide_alt() = %d", 0)); + eb_unlock(&appendix->lock); + return 0; +} + + +/* + * Look up the character number of the start of the wide font alternation + * of the current subbook in `book'. + */ +EB_Error_Code +eb_wide_alt_start(EB_Appendix *appendix, int *start) +{ + EB_Error_Code error_code; + + eb_lock(&appendix->lock); + LOG(("in: eb_wide_alt_start(appendix=%d)", (int)appendix->code)); + + /* + * Current subbook must have been set. + */ + if (appendix->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_APPSUB; + goto failed; + } + + if (appendix->subbook_current->wide_page == 0) { + error_code = EB_ERR_NO_ALT; + goto failed; + } + + *start = appendix->subbook_current->wide_start; + + LOG(("out: eb_wide_alt_start(start=%d) = %s", *start, + eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *start = -1; + LOG(("out: eb_wide_alt_start() = %s", eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + +/* + * Return the character number of the end of the wide font alternation + * of the current subbook in `book'. + */ +EB_Error_Code +eb_wide_alt_end(EB_Appendix *appendix, int *end) +{ + EB_Error_Code error_code; + + eb_lock(&appendix->lock); + LOG(("in: eb_wide_alt_end(appendix=%d)", (int)appendix->code)); + + /* + * Current subbook must have been set. + */ + if (appendix->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_APPSUB; + goto failed; + } + + if (appendix->subbook_current->wide_page == 0) { + error_code = EB_ERR_NO_ALT; + goto failed; + } + + *end = appendix->subbook_current->wide_end; + + LOG(("out: eb_wide_alt_end(end=%d) = %s", *end, + eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *end = -1; + LOG(("out: eb_wide_alt_end() = %s", eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + +/* + * Get the alternation text of the character number `character_number'. + */ +EB_Error_Code +eb_wide_alt_character_text(EB_Appendix *appendix, int character_number, + char *text) +{ + EB_Error_Code error_code; + + eb_lock(&appendix->lock); + LOG(("in: eb_wide_alt_character_text(appendix=%d, character_number=%d)", + (int)appendix->code, character_number)); + + /* + * Current subbook must have been set. + */ + if (appendix->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_APPSUB; + goto failed; + } + + /* + * The wide font must exist in the current subbook. + */ + if (appendix->subbook_current->wide_page == 0) { + error_code = EB_ERR_NO_ALT; + goto failed; + } + + if (appendix->subbook_current->character_code == EB_CHARCODE_ISO8859_1) { + error_code = eb_wide_character_text_latin(appendix, + character_number, text); + } else { + error_code = eb_wide_character_text_jis(appendix, character_number, + text); + } + if (error_code != EB_SUCCESS) + goto failed; + + LOG(("out: eb_wide_alt_character_text(text=%s) = %s", + eb_quoted_string(text), eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *text = '\0'; + LOG(("out: eb_wide_alt_character_text() = %s", + eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + +/* + * Get the alternation text of the character number `character_number'. + */ +static EB_Error_Code +eb_wide_character_text_jis(EB_Appendix *appendix, int character_number, + char *text) +{ + EB_Error_Code error_code; + int start; + int end; + off_t location; + EB_Alternation_Cache *cachep; + + LOG(("in: eb_wide_alt_character_text_jis(appendix=%d, \ +character_number=%d)", + (int)appendix->code, character_number)); + + start = appendix->subbook_current->wide_start; + end = appendix->subbook_current->wide_end; + + /* + * Check for `character_number'. Is it in a font? + * This test works correctly even when the font doesn't exist in + * the current subbook because `start' and `end' have set to -1 + * in the case. + */ + if (character_number < start + || end < character_number + || (character_number & 0xff) < 0x21 + || 0x7e < (character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + + /* + * Calculate the location of alternation data. + */ + location + = (appendix->subbook_current->wide_page - 1) * EB_SIZE_PAGE + + (((character_number >> 8) - (start >> 8)) * 0x5e + + (character_number & 0xff) - (start & 0xff)) + * (EB_MAX_ALTERNATION_TEXT_LENGTH + 1); + + /* + * Check for the cache data. + */ + cachep = appendix->wide_cache + EB_HASH_ALT_CACHE(character_number); + if (cachep->character_number == character_number) { + memcpy(text, cachep->text, EB_MAX_ALTERNATION_TEXT_LENGTH + 1); + goto succeeded; + } + + /* + * Read the alternation data. + */ + if (zio_lseek(&appendix->subbook_current->zio, location, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_APP; + goto failed; + } + cachep->character_number = -1; + if (zio_read(&appendix->subbook_current->zio, cachep->text, + EB_MAX_ALTERNATION_TEXT_LENGTH + 1) + != EB_MAX_ALTERNATION_TEXT_LENGTH + 1) { + error_code = EB_ERR_FAIL_READ_APP; + goto failed; + } + + /* + * Update cache data. + */ + memcpy(text, cachep->text, EB_MAX_ALTERNATION_TEXT_LENGTH + 1); + cachep->text[EB_MAX_ALTERNATION_TEXT_LENGTH] = '\0'; + cachep->character_number = character_number; + + succeeded: + LOG(("out: eb_wide_alt_character_text_jis(text=%s) = %s", + eb_quoted_string(text), eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *text = '\0'; + LOG(("out: eb_wide_alt_character_text_jis() = %s", + eb_error_string(error_code))); + return error_code; +} + + +/* + * Get the alternation text of the character number `character_number'. + */ +static EB_Error_Code +eb_wide_character_text_latin(EB_Appendix *appendix, int character_number, + char *text) +{ + EB_Error_Code error_code; + int start; + int end; + off_t location; + EB_Alternation_Cache *cache_p; + + LOG(("in: eb_wide_alt_character_text_latin(appendix=%d, \ +character_number=%d)", + (int)appendix->code, character_number)); + + start = appendix->subbook_current->wide_start; + end = appendix->subbook_current->wide_end; + + /* + * Check for `character_number'. Is it in a font? + * This test works correctly even when the font doesn't exist in + * the current subbook because `start' and `end' have set to -1 + * in the case. + */ + if (character_number < start + || end < character_number + || (character_number & 0xff) < 0x01 + || 0xfe < (character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + + /* + * Calculate the location of alternation data. + */ + location + = (appendix->subbook_current->wide_page - 1) * EB_SIZE_PAGE + + (((character_number >> 8) - (start >> 8)) * 0xfe + + (character_number & 0xff) - (start & 0xff)) + * (EB_MAX_ALTERNATION_TEXT_LENGTH + 1); + + /* + * Check for the cache data. + */ + cache_p = appendix->wide_cache + EB_HASH_ALT_CACHE(character_number); + if (cache_p->character_number == character_number) { + memcpy(text, cache_p->text, EB_MAX_ALTERNATION_TEXT_LENGTH + 1); + goto succeeded; + } + + /* + * Read the alternation data. + */ + if (zio_lseek(&appendix->subbook_current->zio, location, SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_APP; + goto failed; + } + cache_p->character_number = -1; + if (zio_read(&appendix->subbook_current->zio, cache_p->text, + EB_MAX_ALTERNATION_TEXT_LENGTH + 1) + != EB_MAX_ALTERNATION_TEXT_LENGTH + 1) { + error_code = EB_ERR_FAIL_READ_APP; + goto failed; + } + + /* + * Update cache data. + */ + memcpy(text, cache_p->text, EB_MAX_ALTERNATION_TEXT_LENGTH + 1); + cache_p->text[EB_MAX_ALTERNATION_TEXT_LENGTH] = '\0'; + cache_p->character_number = character_number; + + succeeded: + LOG(("out: eb_wide_alt_character_text_latin(text=%s) = %s", + eb_quoted_string(text), eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *text = '\0'; + LOG(("out: eb_wide_alt_character_text_latin() = %s", + eb_error_string(error_code))); + return error_code; +} + + +/* + * Return next `n'th character number from `*character_number'. + */ +EB_Error_Code +eb_forward_wide_alt_character(EB_Appendix *appendix, int n, + int *character_number) +{ + EB_Error_Code error_code; + int start; + int end; + int i; + + if (n < 0) { + return eb_backward_wide_alt_character(appendix, -n, + character_number); + } + + eb_lock(&appendix->lock); + LOG(("in: eb_forward_wide_alt_character(appendix=%d, n=%d, \ +character_number=%d)", + (int)appendix->code, n, *character_number)); + + /* + * Current subbook must have been set. + */ + if (appendix->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_APPSUB; + goto failed; + } + + /* + * The wide font must exist in the current subbook. + */ + if (appendix->subbook_current->wide_page == 0) { + error_code = EB_ERR_NO_ALT; + goto failed; + } + + start = appendix->subbook_current->wide_start; + end = appendix->subbook_current->wide_end; + + if (appendix->subbook_current->character_code == EB_CHARCODE_ISO8859_1) { + /* + * Check for `*character_number'. (ISO 8859 1) + */ + if (*character_number < start + || end < *character_number + || (*character_number & 0xff) < 0x01 + || 0xfe < (*character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + + /* + * Get character number. (ISO 8859 1) + */ + for (i = 0; i < n; i++) { + if (0xfe <= (*character_number & 0xff)) + *character_number += 3; + else + *character_number += 1; + if (end < *character_number) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + } + } else { + /* + * Check for `*character_number'. (JIS X 0208) + */ + if (*character_number < start + || end < *character_number + || (*character_number & 0xff) < 0x21 + || 0x7e < (*character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + + /* + * Get character number. (JIS X 0208) + */ + for (i = 0; i < n; i++) { + if (0x7e <= (*character_number & 0xff)) + *character_number += 0xa3; + else + *character_number += 1; + if (end < *character_number) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + } + } + + LOG(("out: eb_forkward_wide_alt_character(character_number=%d) = %s", + *character_number, eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *character_number = -1; + LOG(("out: eb_forward_wide_alt_character() = %s", + eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + +/* + * Return previous `n'th character number from `*character_number'. + */ +EB_Error_Code +eb_backward_wide_alt_character(EB_Appendix *appendix, int n, + int *character_number) +{ + EB_Error_Code error_code; + int start; + int end; + int i; + + if (n < 0) { + return eb_forward_wide_alt_character(appendix, -n, character_number); + } + + eb_lock(&appendix->lock); + LOG(("in: eb_backward_wide_alt_character(appendix=%d, n=%d, \ +character_number=%d)", + (int)appendix->code, n, *character_number)); + + /* + * Current subbook must have been set. + */ + if (appendix->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_APPSUB; + goto failed; + } + + /* + * The wide font must exist in the current subbook. + */ + if (appendix->subbook_current->wide_page == 0) { + error_code = EB_ERR_NO_ALT; + goto failed; + } + + start = appendix->subbook_current->wide_start; + end = appendix->subbook_current->wide_end; + + if (appendix->subbook_current->character_code == EB_CHARCODE_ISO8859_1) { + /* + * Check for `*character_number'. (ISO 8859 1) + */ + if (*character_number < start + || end < *character_number + || (*character_number & 0xff) < 0x01 + || 0xfe < (*character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + + /* + * Get character number. (ISO 8859 1) + */ + for (i = 0; i < n; i++) { + if ((*character_number & 0xff) <= 0x01) + *character_number -= 3; + else + *character_number -= 1; + if (*character_number < start) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + } + } else { + /* + * Check for `*character_number'. (JIS X 0208) + */ + if (*character_number < start + || end < *character_number + || (*character_number & 0xff) < 0x21 + || 0x7e < (*character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + + /* + * Get character number. (JIS X 0208) + */ + for (i = 0; i < n; i++) { + if ((*character_number & 0xff) <= 0x21) + *character_number -= 0xa3; + else + *character_number -= 1; + if (*character_number < start) { + error_code = EB_ERR_NO_SUCH_CHAR_TEXT; + goto failed; + } + } + } + + LOG(("out: eb_backward_wide_alt_character(character_number=%d) = %s", + *character_number, eb_error_string(EB_SUCCESS))); + eb_unlock(&appendix->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *character_number = -1; + LOG(("out: eb_backward_wide_alt_character() = %s", + eb_error_string(error_code))); + eb_unlock(&appendix->lock); + return error_code; +} + + diff --git a/eb/widefont.c b/eb/widefont.c new file mode 100644 index 0000000..5e81188 --- /dev/null +++ b/eb/widefont.c @@ -0,0 +1,1100 @@ +/* automatically generated from narwfont.c. */ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "font.h" +#include "build-post.h" + +/* + * Unexported functions. + */ +static EB_Error_Code eb_wide_character_bitmap_jis(EB_Book *book, + int character_number, char *bitmap); +static EB_Error_Code eb_wide_character_bitmap_latin(EB_Book *book, + int character_number, char *bitmap); + + +/* + * Open a font file. + */ +EB_Error_Code +eb_open_wide_font_file(EB_Book *book, EB_Font_Code font_code) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + EB_Font *wide_font; + char font_path_name[EB_MAX_PATH_LENGTH + 1]; + Zio_Code zio_code; + + LOG(("in: eb_open_wide_font(book=%d, font_code=%d)", + (int)book->code, (int)font_code)); + + subbook = book->subbook_current; + wide_font = subbook->wide_fonts + font_code; + + if (wide_font->font_code == EB_FONT_INVALID) { + error_code = EB_ERR_FAIL_OPEN_FONT; + goto failed; + } + if (0 <= zio_file(&wide_font->zio)) + goto succeeded; + + /* + * If the book is EBWING, open the wide font file. + * (In EB books, font data are stored in the `START' file.) + */ + zio_code = ZIO_INVALID; + + if (book->disc_code == EB_DISC_EB) { + if (wide_font->initialized) { + if (zio_mode(&wide_font->zio) != ZIO_INVALID) + zio_code = ZIO_REOPEN; + } else { + zio_code = zio_mode(&subbook->text_zio); + } + eb_compose_path_name2(book->path, subbook->directory_name, + subbook->text_file_name, font_path_name); + + } else { + if (wide_font->initialized) { + if (zio_mode(&wide_font->zio) != ZIO_INVALID) + zio_code = ZIO_REOPEN; + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->gaiji_directory_name, wide_font->file_name, + font_path_name); + } else { + eb_canonicalize_file_name(wide_font->file_name); + if (eb_find_file_name3(book->path, subbook->directory_name, + subbook->gaiji_directory_name, wide_font->file_name, + wide_font->file_name) != EB_SUCCESS) { + error_code = EB_ERR_FAIL_OPEN_FONT; + goto failed; + } + + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->gaiji_directory_name, wide_font->file_name, + font_path_name); + eb_path_name_zio_code(font_path_name, ZIO_PLAIN, &zio_code); + } + } + + if (zio_code != ZIO_INVALID + && zio_open(&wide_font->zio, font_path_name, zio_code) < 0) { + error_code = EB_ERR_FAIL_OPEN_FONT; + goto failed; + } + + succeeded: + LOG(("out: eb_open_wide_font_file(file=%d) = %s", + zio_file(&wide_font->zio), eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_open_wide_font_file() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Read font header. + */ +EB_Error_Code +eb_load_wide_font_header(EB_Book *book, EB_Font_Code font_code) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + EB_Font *wide_font; + char buffer[16]; + int character_count; + Zio *zio; + + LOG(("in: eb_load_wide_font_header(book=%d, font_code=%d)", + (int)book->code, (int)font_code)); + + subbook = book->subbook_current; + wide_font = subbook->wide_fonts + font_code; + zio = &wide_font->zio; + + if (wide_font->initialized) + goto succeeded; + + /* + * Read information from the text file. + */ + if (zio_lseek(zio, ((off_t) wide_font->page - 1) * EB_SIZE_PAGE, + SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_FONT; + goto failed; + } + if (zio_read(zio, buffer, 16) != 16) { + error_code = EB_ERR_FAIL_READ_FONT; + goto failed; + } + + /* + * If the number of characters (`character_count') is 0, the font + * is unavailable. We return EB_ERR_NO_SUCH_FONT. + */ + character_count = eb_uint2(buffer + 12); + if (character_count == 0) { + zio_close(zio); + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + /* + * Set the information. + */ + wide_font->start = eb_uint2(buffer + 10); + if (book->character_code == EB_CHARCODE_ISO8859_1) { + wide_font->end = wide_font->start + + ((character_count / 0xfe) << 8) + (character_count % 0xfe) - 1; + if (0xfe < (wide_font->end & 0xff)) + wide_font->end += 3; + } else { + wide_font->end = wide_font->start + + ((character_count / 0x5e) << 8) + (character_count % 0x5e) - 1; + if (0x7e < (wide_font->end & 0xff)) + wide_font->end += 0xa3; + } + + if (book->character_code == EB_CHARCODE_ISO8859_1) { + if ((wide_font->start & 0xff) < 0x01 + || 0xfe < (wide_font->start & 0xff) + || wide_font->start < 0x0001 + || 0x1efe < wide_font->end) { + error_code = EB_ERR_UNEXP_FONT; + goto failed; + } + } else { + if ((wide_font->start & 0xff) < 0x21 + || 0x7e < (wide_font->start & 0xff) + || wide_font->start < 0xa121 + || 0xfe7e < wide_font->end) { + error_code = EB_ERR_UNEXP_FONT; + goto failed; + } + } + + succeeded: + LOG(("out: eb_load_wide_font_header()", eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_load_wide_font_header()", eb_error_string(error_code))); + return error_code; +} + + +/* + * Read font glyph data. + */ +EB_Error_Code +eb_load_wide_font_glyphs(EB_Book *book, EB_Font_Code font_code) +{ + EB_Error_Code error_code; + EB_Subbook *subbook; + EB_Font *wide_font; + int character_count; + size_t glyph_size; + size_t total_glyph_size; + Zio *zio; + + LOG(("in: eb_load_wide_font_glyphs(book=%d, font_code=%d)", + (int)book->code, (int)font_code)); + + subbook = book->subbook_current; + wide_font = subbook->wide_fonts + font_code; + zio = &wide_font->zio; + + if (wide_font->glyphs != NULL) + goto succeeded; + + /* + * Calculate size of glyph data (`total_glyph_size'). + * + * Set the number of local defined characters to `character_count'. + * Set the number of character glpyhs in a page to `page_glyph_count'. + * Set size of glyph data to `total_glyph_size'. + */ + if (book->character_code == EB_CHARCODE_ISO8859_1) { + character_count + = ((wide_font->end >> 8) - (wide_font->start >> 8)) * 0xfe + + ((wide_font->end & 0xff) - (wide_font->start & 0xff)) + 1; + } else { + character_count + = ((wide_font->end >> 8) - (wide_font->start >> 8)) * 0x5e + + ((wide_font->end & 0xff) - (wide_font->start & 0xff)) + 1; + } + + eb_wide_font_size2(font_code, &glyph_size); + total_glyph_size + = (character_count / (1024 / glyph_size)) * 1024 + + (character_count % (1024 / glyph_size)) * glyph_size; + + /* + * Allocate memory for glyph data. + */ + wide_font->glyphs = (char *) malloc(total_glyph_size); + if (wide_font->glyphs == NULL) { + error_code = EB_ERR_MEMORY_EXHAUSTED; + goto failed; + } + + /* + * Read glyphs. + */ + if (zio_lseek(zio, (off_t) wide_font->page * EB_SIZE_PAGE, SEEK_SET) + < 0) { + error_code = EB_ERR_FAIL_SEEK_FONT; + goto failed; + } + if (zio_read(zio, wide_font->glyphs, total_glyph_size) + != total_glyph_size) { + error_code = EB_ERR_FAIL_READ_FONT; + goto failed; + } + + succeeded: + LOG(("out: eb_load_wide_font_glyphs()", eb_error_string(EB_SUCCESS))); + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_load_wide_font_glyphs()", eb_error_string(error_code))); + if (wide_font->glyphs != NULL) { + free(wide_font->glyphs); + wide_font->glyphs = NULL; + } + return error_code; +} + + +/* + * Examine whether the current subbook in `book' has a wide font. + */ +int +eb_have_wide_font(EB_Book *book) +{ + int i; + + eb_lock(&book->lock); + LOG(("in: eb_have_wide_font(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) + goto failed; + + /* + * If the wide font has already set, the subbook has wide fonts. + */ + if (book->subbook_current->wide_current != NULL) + goto succeeded; + + /* + * Scan the font table. + */ + for (i = 0; i < EB_MAX_FONTS; i++) { + if (book->subbook_current->wide_fonts[i].font_code + != EB_FONT_INVALID) + break; + } + + if (EB_MAX_FONTS <= i) + goto failed; + + succeeded: + LOG(("out: eb_have_wide_font() = %d", 1)); + eb_unlock(&book->lock); + return 1; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_have_wide_font() = %d", 0)); + eb_unlock(&book->lock); + return 0; +} + + +/* + * Get width of the font `font_code' in the current subbook of `book'. + */ +EB_Error_Code +eb_wide_font_width(EB_Book *book, int *width) +{ + EB_Error_Code error_code; + EB_Font_Code font_code; + + eb_lock(&book->lock); + LOG(("in: eb_wide_font_width(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * The wide font must exist in the current subbook. + */ + if (book->subbook_current->wide_current == NULL) { + error_code = EB_ERR_NO_CUR_FONT; + goto failed; + } + + /* + * Calculate width. + */ + font_code = book->subbook_current->wide_current->font_code; + error_code = eb_wide_font_width2(font_code, width); + if (error_code != EB_SUCCESS) + goto failed; + + LOG(("out: eb_wide_font_width(width=%d) = %s", (int)*width, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *width = 0; + LOG(("out: eb_wide_font_width() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Get width of the font `font_code'. + */ +EB_Error_Code +eb_wide_font_width2(EB_Font_Code font_code, int *width) +{ + EB_Error_Code error_code; + + LOG(("in: eb_wide_font_width2(font_code=%d)", (int)font_code)); + + switch (font_code) { + case EB_FONT_16: + *width = EB_WIDTH_WIDE_FONT_16; + break; + case EB_FONT_24: + *width = EB_WIDTH_WIDE_FONT_24; + break; + case EB_FONT_30: + *width = EB_WIDTH_WIDE_FONT_30; + break; + case EB_FONT_48: + *width = EB_WIDTH_WIDE_FONT_48; + break; + default: + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + LOG(("out: eb_wide_font_width2(width=%d) = %s", *width, + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *width = 0; + LOG(("out: eb_wide_font_width2() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Get the bitmap size of the font `font_code' in the current subbook + * of `book'. + */ +EB_Error_Code +eb_wide_font_size(EB_Book *book, size_t *size) +{ + EB_Error_Code error_code; + EB_Font_Code font_code; + int width; + int height; + + eb_lock(&book->lock); + LOG(("in: eb_wide_font_size(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * The wide font must exist in the current subbook. + */ + if (book->subbook_current->wide_current == NULL) { + error_code = EB_ERR_NO_CUR_FONT; + goto failed; + } + + /* + * Calculate size. + */ + font_code = book->subbook_current->wide_current->font_code; + error_code = eb_wide_font_width2(font_code, &width); + if (error_code != EB_SUCCESS) + goto failed; + error_code = eb_font_height2(font_code, &height); + if (error_code != EB_SUCCESS) + goto failed; + *size = (width / 8) * height; + + LOG(("out: eb_wide_font_size(size=%ld) = %s", (long)*size, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *size = 0; + LOG(("out: eb_wide_font_size() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Get the bitmap size of a character in `font_code' of the current + * subbook. + */ +EB_Error_Code +eb_wide_font_size2(EB_Font_Code font_code, size_t *size) +{ + EB_Error_Code error_code; + + LOG(("in: eb_wide_font_size2(font_code=%d)", (int)font_code)); + + switch (font_code) { + case EB_FONT_16: + *size = EB_SIZE_WIDE_FONT_16; + break; + case EB_FONT_24: + *size = EB_SIZE_WIDE_FONT_24; + break; + case EB_FONT_30: + *size = EB_SIZE_WIDE_FONT_30; + break; + case EB_FONT_48: + *size = EB_SIZE_WIDE_FONT_48; + break; + default: + error_code = EB_ERR_NO_SUCH_FONT; + goto failed; + } + + LOG(("out: eb_wide_font_size2(size=%ld) = %s", (long)*size, + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *size = 0; + LOG(("out: eb_wide_font_size2() = %s", eb_error_string(error_code))); + return error_code; +} + + +/* + * Get the character number of the start of the wide font of the current + * subbook in `book'. + */ +EB_Error_Code +eb_wide_font_start(EB_Book *book, int *start) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_wide_font_start(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * The wide font must exist in the current subbook. + */ + if (book->subbook_current->wide_current == NULL) { + error_code = EB_ERR_NO_CUR_FONT; + goto failed; + } + + *start = book->subbook_current->wide_current->start; + + LOG(("out: eb_wide_font_start(start=%d) = %s", *start, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_wide_font_start() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Get the character number of the end of the wide font of the current + * subbook in `book'. + */ +EB_Error_Code +eb_wide_font_end(EB_Book *book, int *end) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_wide_font_end(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * The wide font must exist in the current subbook. + */ + if (book->subbook_current->wide_current == NULL) { + error_code = EB_ERR_NO_CUR_FONT; + goto failed; + } + + *end = book->subbook_current->wide_current->end; + + LOG(("out: eb_wide_font_end(end=%d) = %s", *end, + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_wide_font_end() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Get bitmap data of the character with character number `character_number' + * in the current wide font of the current subbook in `book'. + */ +EB_Error_Code +eb_wide_font_character_bitmap(EB_Book *book, int character_number, + char *bitmap) +{ + EB_Error_Code error_code; + + eb_lock(&book->lock); + LOG(("in: eb_wide_font_character_bitmap(book=%d, character_number=%d)", + (int)book->code, character_number)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * The wide font must exist in the current subbook. + */ + if (book->subbook_current->wide_current == NULL) { + error_code = EB_ERR_NO_CUR_FONT; + goto failed; + } + + if (book->character_code == EB_CHARCODE_ISO8859_1) { + error_code = eb_wide_character_bitmap_latin(book, character_number, + bitmap); + } else { + error_code = eb_wide_character_bitmap_jis(book, character_number, + bitmap); + } + if (error_code != EB_SUCCESS) + goto failed; + + LOG(("out: eb_wide_font_character_bitmap() = %s", + eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *bitmap = '\0'; + LOG(("out: eb_wide_font_character_bitmap() = %s", + eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Get bitmap data of the character with character number `character_number' + * in the current wide font of the current subbook in `book'. + */ +static EB_Error_Code +eb_wide_character_bitmap_jis(EB_Book *book, int character_number, + char *bitmap) +{ + EB_Error_Code error_code; + EB_Font *wide_current; + int start; + int end; + int character_index; + off_t offset; + size_t size; + Zio *zio; + + LOG(("in: eb_wide_font_character_bitmap_jis(book=%d, \ +character_number=%d)", + (int)book->code, character_number)); + + start = book->subbook_current->wide_current->start; + end = book->subbook_current->wide_current->end; + wide_current = book->subbook_current->wide_current; + + /* + * Check for `character_number'. Is it in a range of bitmaps? + * This test works correctly even when the font doesn't exist in + * the current subbook because `start' and `end' have set to -1 + * in the case. + */ + if (character_number < start + || end < character_number + || (character_number & 0xff) < 0x21 + || 0x7e < (character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + + /* + * Calculate the size and the location of bitmap data. + */ + error_code = eb_wide_font_size(book, &size); + if (error_code != EB_SUCCESS) + goto failed; + + character_index = ((character_number >> 8) - (start >> 8)) * 0x5e + + ((character_number & 0xff) - (start & 0xff)); + offset + = (character_index / (1024 / size)) * 1024 + + (character_index % (1024 / size)) * size; + + /* + * Read bitmap data. + */ + if (wide_current->glyphs == NULL) { + zio = &wide_current->zio; + + if (zio_lseek(zio, + (off_t) wide_current->page * EB_SIZE_PAGE + offset, + SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_FONT; + goto failed; + } + if (zio_read(zio, bitmap, size) != size) { + error_code = EB_ERR_FAIL_READ_FONT; + goto failed; + } + } else { + memcpy(bitmap, wide_current->glyphs + offset, size); + } + + LOG(("out: eb_wide_font_character_bitmap_jis() = %s", + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *bitmap = '\0'; + LOG(("out: eb_wide_font_character_bitmap_jis() = %s", + eb_error_string(error_code))); + return error_code; +} + + +/* + * Get bitmap data of the character with character number `character_number' + * in the current wide font of the current subbook in `book'. + */ +static EB_Error_Code +eb_wide_character_bitmap_latin(EB_Book *book, int character_number, + char *bitmap) +{ + EB_Error_Code error_code; + EB_Font *wide_current; + int start; + int end; + int character_index; + off_t offset; + size_t size; + Zio *zio; + + LOG(("in: eb_wide_font_character_bitmap_latin(book=%d, \ +character_number=%d)", + (int)book->code, character_number)); + + start = book->subbook_current->wide_current->start; + end = book->subbook_current->wide_current->end; + wide_current = book->subbook_current->wide_current; + + /* + * Check for `ch'. Is it in a range of bitmaps? + * This test works correctly even when the font doesn't exist in + * the current subbook because `start' and `end' have set to -1 + * in the case. + */ + if (character_number < start + || end < character_number + || (character_number & 0xff) < 0x01 + || 0xfe < (character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + + /* + * Calculate the size and the location of bitmap data. + */ + error_code = eb_wide_font_size(book, &size); + if (error_code != EB_SUCCESS) + goto failed; + + character_index = ((character_number >> 8) - (start >> 8)) * 0xfe + + ((character_number & 0xff) - (start & 0xff)); + offset + = (character_index / (1024 / size)) * 1024 + + (character_index % (1024 / size)) * size; + + /* + * Read bitmap data. + */ + if (wide_current->glyphs == NULL) { + zio = &wide_current->zio; + + if (zio_lseek(zio, + (off_t) wide_current->page * EB_SIZE_PAGE + offset, + SEEK_SET) < 0) { + error_code = EB_ERR_FAIL_SEEK_FONT; + goto failed; + } + if (zio_read(zio, bitmap, size) != size) { + error_code = EB_ERR_FAIL_READ_FONT; + goto failed; + } + } else { + memcpy(bitmap, wide_current->glyphs + offset, size); + } + + LOG(("out: eb_wide_font_character_bitmap_latin() = %s", + eb_error_string(EB_SUCCESS))); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *bitmap = '\0'; + LOG(("out: eb_wide_font_character_bitmap_latin() = %s", + eb_error_string(error_code))); + return error_code; +} + + +/* + * Return next `n'th character number from `character_number'. + */ +EB_Error_Code +eb_forward_wide_font_character(EB_Book *book, int n, int *character_number) +{ + EB_Error_Code error_code; + int start; + int end; + int i; + + if (n < 0) + return eb_backward_wide_font_character(book, -n, character_number); + + eb_lock(&book->lock); + LOG(("in: eb_forward_wide_font_character(book=%d, n=%d, \ +character_number=%d)", + (int)book->code, n, *character_number)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * The wide font must exist in the current subbook. + */ + if (book->subbook_current->wide_current == NULL) { + error_code = EB_ERR_NO_CUR_FONT; + goto failed; + } + + start = book->subbook_current->wide_current->start; + end = book->subbook_current->wide_current->end; + + if (book->character_code == EB_CHARCODE_ISO8859_1) { + /* + * Check for `*character_number'. (ISO 8859 1) + */ + if (*character_number < start + || end < *character_number + || (*character_number & 0xff) < 0x01 + || 0xfe < (*character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + + /* + * Get character number. (ISO 8859 1) + */ + for (i = 0; i < n; i++) { + if (0xfe <= (*character_number & 0xff)) + *character_number += 3; + else + *character_number += 1; + if (end < *character_number) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + } + } else { + /* + * Check for `*character_number'. (JIS X 0208) + */ + if (*character_number < start + || end < *character_number + || (*character_number & 0xff) < 0x21 + || 0x7e < (*character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + + /* + * Get character number. (JIS X 0208) + */ + for (i = 0; i < n; i++) { + if (0x7e <= (*character_number & 0xff)) + *character_number += 0xa3; + else + *character_number += 1; + if (end < *character_number) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + } + } + + LOG(("out: eb_forward_wide_font_character(character_number=%d) = %s", + *character_number, eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *character_number = -1; + LOG(("out: eb_forward_wide_font_character() = %s", + eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + +/* + * Return previous `n'th character number from `*character_number'. + */ +EB_Error_Code +eb_backward_wide_font_character(EB_Book *book, int n, int *character_number) +{ + EB_Error_Code error_code; + int start; + int end; + int i; + + if (n < 0) + return eb_forward_wide_font_character(book, -n, character_number); + + eb_lock(&book->lock); + LOG(("in: eb_backward_wide_font_character(book=%d, n=%d, \ +character_number=%d)", + (int)book->code, n, *character_number)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * The wide font must exist in the current subbook. + */ + if (book->subbook_current->wide_current == NULL) { + error_code = EB_ERR_NO_CUR_FONT; + goto failed; + } + + start = book->subbook_current->wide_current->start; + end = book->subbook_current->wide_current->end; + + if (book->character_code == EB_CHARCODE_ISO8859_1) { + /* + * Check for `*character_number'. (ISO 8859 1) + */ + if (*character_number < start + || end < *character_number + || (*character_number & 0xff) < 0x01 + || 0xfe < (*character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + + /* + * Get character number. (ISO 8859 1) + */ + for (i = 0; i < n; i++) { + if ((*character_number & 0xff) <= 0x01) + *character_number -= 3; + else + *character_number -= 1; + if (*character_number < start) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + } + } else { + /* + * Check for `*character_number'. (JIS X 0208) + */ + if (*character_number < start + || end < *character_number + || (*character_number & 0xff) < 0x21 + || 0x7e < (*character_number & 0xff)) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + + /* + * Get character number. (JIS X 0208) + */ + for (i = 0; i < n; i++) { + if ((*character_number & 0xff) <= 0x21) + *character_number -= 0xa3; + else + *character_number -= 1; + if (*character_number < start) { + error_code = EB_ERR_NO_SUCH_CHAR_BMP; + goto failed; + } + } + } + + LOG(("out: eb_backward_wide_font_character(character_number=%d) = %s", + *character_number, eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + *character_number = -1; + LOG(("out: eb_backward_wide_font_character() = %s", + eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} + + diff --git a/eb/word.c b/eb/word.c new file mode 100644 index 0000000..5a872ed --- /dev/null +++ b/eb/word.c @@ -0,0 +1,185 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "build-pre.h" +#include "eb.h" +#include "error.h" +#include "build-post.h" + +/* + * Examine whether the current subbook in `book' supports `WORD SEARCH' + * or not. + */ +int +eb_have_word_search(EB_Book *book) +{ + eb_lock(&book->lock); + LOG(("in: eb_have_word_search(book=%d)", (int)book->code)); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) + goto failed; + + if (book->subbook_current->word_alphabet.start_page == 0 + && book->subbook_current->word_asis.start_page == 0 + && book->subbook_current->word_kana.start_page == 0) + goto failed; + + LOG(("out: eb_have_word_search() = %d", 1)); + eb_unlock(&book->lock); + + return 1; + + /* + * An error occurs... + */ + failed: + LOG(("out: eb_have_word_search() = %d", 0)); + eb_unlock(&book->lock); + return 0; +} + + +/* + * Word search. + */ +EB_Error_Code +eb_search_word(EB_Book *book, const char *input_word) +{ + EB_Error_Code error_code; + EB_Word_Code word_code; + EB_Search_Context *context; + + eb_lock(&book->lock); + LOG(("in: eb_search_word(book=%d, input_word=%s)", (int)book->code, + eb_quoted_string(input_word))); + + /* + * Current subbook must have been set. + */ + if (book->subbook_current == NULL) { + error_code = EB_ERR_NO_CUR_SUB; + goto failed; + } + + /* + * Initialize search context. + */ + eb_reset_search_contexts(book); + context = book->search_contexts; + context->code = EB_SEARCH_WORD; + + /* + * Make a fixed word and a canonicalized word to search from + * `input_word'. + */ + error_code = eb_set_word(book, input_word, context->word, + context->canonicalized_word, &word_code); + if (error_code != EB_SUCCESS) + goto failed; + + /* + * Get a page number. + */ + switch (word_code) { + case EB_WORD_ALPHABET: + if (book->subbook_current->word_alphabet.start_page != 0) + context->page = book->subbook_current->word_alphabet.start_page; + else if (book->subbook_current->word_asis.start_page != 0) + context->page = book->subbook_current->word_asis.start_page; + else { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + break; + + case EB_WORD_KANA: + if (book->subbook_current->word_kana.start_page != 0) + context->page = book->subbook_current->word_kana.start_page; + else if (book->subbook_current->word_asis.start_page != 0) + context->page = book->subbook_current->word_asis.start_page; + else { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + break; + + case EB_WORD_OTHER: + if (book->subbook_current->word_asis.start_page != 0) + context->page = book->subbook_current->word_asis.start_page; + else { + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + break; + + default: + error_code = EB_ERR_NO_SUCH_SEARCH; + goto failed; + } + + /* + * Choose comparison functions. + */ + if (book->character_code == EB_CHARCODE_ISO8859_1) { + context->compare_pre = eb_pre_match_word; + context->compare_single = eb_match_word; + context->compare_group = eb_match_word; + } else if (context->page == book->subbook_current->word_kana.start_page) { + context->compare_pre = eb_pre_match_word; + context->compare_single = eb_match_word_kana_single; + context->compare_group = eb_match_word_kana_group; + } else { + context->compare_pre = eb_pre_match_word; + context->compare_single = eb_match_word; + context->compare_group = eb_match_word_kana_group; + } + + /* + * Pre-search. + */ + error_code = eb_presearch_word(book, context); + if (error_code != EB_SUCCESS) + goto failed; + + LOG(("out: eb_search_word() = %s", eb_error_string(EB_SUCCESS))); + eb_unlock(&book->lock); + + return EB_SUCCESS; + + /* + * An error occurs... + */ + failed: + eb_reset_search_contexts(book); + LOG(("out: eb_search_word() = %s", eb_error_string(error_code))); + eb_unlock(&book->lock); + return error_code; +} diff --git a/eb/zio.c b/eb/zio.c new file mode 100644 index 0000000..160337f --- /dev/null +++ b/eb/zio.c @@ -0,0 +1,2087 @@ +/* -*- C -*- + * Copyright (c) 1998-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef ENABLE_PTHREAD +#include +#endif + +#include + +#include "zio.h" +#ifdef ENABLE_EBNET +#include "ebnet.h" +#endif + +/* + * Flags for open(). + */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + +/* + * The maximum length of path name. + */ +#ifndef PATH_MAX +#ifdef MAXPATHLEN +#define PATH_MAX MAXPATHLEN +#else /* not MAXPATHLEN */ +#define PATH_MAX 1024 +#endif /* not MAXPATHLEN */ +#endif /* not PATH_MAX */ + +/* + * Mutual exclusion lock of Pthreads. + */ +#ifndef ENABLE_PTHREAD +#define pthread_mutex_lock(m) +#define pthread_mutex_unlock(m) +#endif + +/* + * Debug message handler. + */ +#ifdef EB_BUILD_LIBRARY +extern int eb_log_flag; +extern void eb_log(const char *, ...); +#define LOG(x) do {if (eb_log_flag) eb_log x;} while (0) +#else +#define LOG(x) +#endif + +/* + * Get an unsigned value from an octet stream buffer. + */ +#define zio_uint1(p) (*(const unsigned char *)(p)) + +#define zio_uint2(p) ((*(const unsigned char *)(p) << 8) \ + + (*(const unsigned char *)((p) + 1))) + +#define zio_uint3(p) ((*(const unsigned char *)(p) << 16) \ + + (*(const unsigned char *)((p) + 1) << 8) \ + + (*(const unsigned char *)((p) + 2))) + +#define zio_uint4(p) (((off_t) *(const unsigned char *)(p) << 24) \ + + (*(const unsigned char *)((p) + 1) << 16) \ + + (*(const unsigned char *)((p) + 2) << 8) \ + + (*(const unsigned char *)((p) + 3))) + +#define zio_uint5(p) (((off_t) (*(const unsigned char *)(p)) << 32) \ + + ((off_t) (*(const unsigned char *)((p) + 1)) << 24) \ + + (*(const unsigned char *)((p) + 2) << 16) \ + + (*(const unsigned char *)((p) + 3) << 8) \ + + (*(const unsigned char *)((p) + 4))) + +/* + * Test whether the path is URL with the `ebnet' scheme. + */ +#define is_ebnet_url(p) \ + ( ((p)[0] == 'E' || (p)[0] == 'e') \ + && ((p)[1] == 'B' || (p)[1] == 'b') \ + && ((p)[2] == 'N' || (p)[2] == 'n') \ + && ((p)[3] == 'E' || (p)[3] == 'e') \ + && ((p)[4] == 'T' || (p)[4] == 't') \ + && (p)[5] == ':' && (p)[6] == '/' && (p)[7] == '/') + +/* + * Size of a page (The term `page' means `block' in JIS X 4081). + */ +#define ZIO_SIZE_PAGE 2048 + +/* + * Size of a cache buffer. + * It must be large enough to memory an uncompressed slice. + * + * (In EBZIP and EPWING compressions, the size of uncompressed slice + * is 2048. In S-EBXA compression, the size is 4096.) + */ +#define ZIO_CACHE_BUFFER_SIZE (ZIO_SIZE_PAGE << ZIO_MAX_EBZIP_LEVEL) + +/* + * NULL Zio ID. + */ +#define ZIO_ID_NONE -1 + +/* + * Buffer for caching uncompressed data. + */ +static char *cache_buffer = NULL; + +/* + * Zio ID which caches data in `cache_buffer'. + */ +static int cache_zio_id = ZIO_ID_NONE; + +/* + * Offset of the beginning of the cached data `cache_buffer'. + */ +static off_t cache_location; + +/* + * Zio object counter. + */ +static int zio_counter = 0; + +/* + * Mutex for cache variables. + */ +#ifdef ENABLE_PTHREAD +static pthread_mutex_t zio_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif + +/* + * Test whether `off_t' represents a large integer. + */ +#define off_t_is_large \ + ((((off_t) 1 << 41) + ((off_t) 1 << 40) + 1) % 9999991 == 7852006) + +/* + * Unexported function. + */ +static int zio_reopen(Zio *zio, const char *file_name); +static int zio_open_plain(Zio *zio, const char *file_name); +static int zio_open_ebzip(Zio *zio, const char *file_name); +static int zio_open_epwing(Zio *zio, const char *file_name); +static int zio_open_epwing6(Zio *zio, const char *file_name); +static int zio_make_epwing_huffman_tree(Zio *zio, int leaf_count); +static ssize_t zio_read_ebzip(Zio *zio, char *buffer, size_t length); +static ssize_t zio_read_epwing(Zio *zio, char *buffer, size_t length); +static ssize_t zio_read_sebxa(Zio *zio, char *buffer, size_t length); +static int zio_unzip_slice_ebzip1(Zio *zio, char *out_buffer, + size_t zipped_slice_size); +static int zio_unzip_slice_epwing(Zio *zio, char *out_buffer); +static int zio_unzip_slice_epwing6(Zio *zio, char *out_buffer); +static int zio_unzip_slice_sebxa(Zio *zio, char *out_buffer); +static int zio_open_raw(Zio *zio, const char *file_name); +static void zio_close_raw(Zio *zio); +static off_t zio_lseek_raw(Zio *zio, off_t offset, int whence); +static ssize_t zio_read_raw(Zio *zio, void *buffer, size_t length); + + +/* + * Initialize cache buffer. + */ +int +zio_initialize_library(void) +{ + pthread_mutex_lock(&zio_mutex); + LOG(("in: zio_initialize_library()")); + + /* + * Allocate memory for cache buffer. + */ + if (cache_buffer == NULL) { + cache_buffer = (char *) malloc(ZIO_CACHE_BUFFER_SIZE); + if (cache_buffer == NULL) + goto failed; + } + + LOG(("out: zio_initialize_library() = %d", 0)); + pthread_mutex_unlock(&zio_mutex); + return 0; + + /* + * An error occurs... + */ + failed: + LOG(("out: zio_initialize_library() = %d", -1)); + pthread_mutex_unlock(&zio_mutex); + return -1; +} + + +/* + * Clear cache buffer. + */ +void +zio_finalize_library(void) +{ + pthread_mutex_lock(&zio_mutex); + LOG(("in: zio_finalize_library()")); + + if (cache_buffer != NULL) + free(cache_buffer); + cache_buffer = NULL; + cache_zio_id = ZIO_ID_NONE; + + LOG(("out: zio_finalize_library()")); + pthread_mutex_unlock(&zio_mutex); +} + + +/* + * Initialize `zio'. + */ +void +zio_initialize(Zio *zio) +{ + LOG(("in: zio_initialize()")); + + zio->id = -1; + zio->file = -1; + zio->huffman_nodes = NULL; + zio->huffman_root = NULL; + zio->code = ZIO_INVALID; + zio->file_size = 0; + zio->is_ebnet = 0; + + LOG(("out: zio_initialize()")); +} + + +/* + * Finalize `zio'. + */ +void +zio_finalize(Zio *zio) +{ + LOG(("in: zio_finalize(zio=%d)", (int)zio->id)); + + zio_close(zio); + if (zio->huffman_nodes != NULL) + free(zio->huffman_nodes); + + zio->id = -1; + zio->huffman_nodes = NULL; + zio->huffman_root = NULL; + zio->code = ZIO_INVALID; + + LOG(("out: zio_finalize()")); +} + + +/* + * Set S-EBXA compression mode. + */ +int +zio_set_sebxa_mode(Zio *zio, off_t index_location, off_t index_base, + off_t zio_start_location, off_t zio_end_location) +{ + LOG(("in: zio_set_sebxa_mode(zio=%d, index_location=%ld, index_base=%ld, \ +zio_start_location=%ld, zio_end_location=%ld)", + (int)zio->id, (long)index_location, (long)index_base, + (long)zio_start_location, (long)zio_end_location)); + + if (zio->code != ZIO_PLAIN) + goto failed; + + zio->code = ZIO_SEBXA; + zio->index_location = index_location; + zio->index_base = index_base; + zio->zio_start_location = zio_start_location; + zio->zio_end_location = zio_end_location; + zio->file_size = zio_end_location; + + LOG(("out: zio_set_sebxa_mode() = %d", 0)); + return 0; + + /* + * An error occurs... + */ + failed: + LOG(("out: zio_set_sebxa_mode() = %d", -1)); + return -1; +} + +/* + * Open `file'. + */ +int +zio_open(Zio *zio, const char *file_name, Zio_Code zio_code) +{ + int result; + + LOG(("in: zio_open(zio=%d, file_name=%s, zio_code=%d)", + (int)zio->id, file_name, zio_code)); + + if (0 <= zio->file) { + if (zio_code == ZIO_REOPEN) { + result = 0; + goto succeeded; + } + zio_finalize(zio); + zio_initialize(zio); + } + + switch (zio_code) { + case ZIO_REOPEN: + result = zio_reopen(zio, file_name); + break; + case ZIO_PLAIN: + result = zio_open_plain(zio, file_name); + break; + case ZIO_EBZIP1: + result = zio_open_ebzip(zio, file_name); + break; + case ZIO_EPWING: + result = zio_open_epwing(zio, file_name); + break; + case ZIO_EPWING6: + result = zio_open_epwing6(zio, file_name); + break; + case ZIO_SEBXA: + result = zio_open_plain(zio, file_name); + break; + default: + result = -1; + } + + succeeded: + LOG(("out: zio_open() = %d", result)); + return result; +} + + +/* + * Reopen a file. + */ +static int +zio_reopen(Zio *zio, const char *file_name) +{ + LOG(("in: zio_reopen(zio=%d, file_name=%s)", (int)zio->id, file_name)); + + if (zio->code == ZIO_INVALID) + goto failed; + + if (zio_open_raw(zio, file_name) < 0) { + zio->code = ZIO_INVALID; + goto failed; + } + zio->location = 0; + + LOG(("out: zio_reopen() = %d", zio->file)); + return zio->file; + + /* + * An error occurs... + */ + failed: + LOG(("out: zio_reopen() = %d", -1)); + return -1; +} + + +/* + * Open an non-compressed file. + */ +static int +zio_open_plain(Zio *zio, const char *file_name) +{ + LOG(("in: zio_open_plain(zio=%d, file_name=%s)", (int)zio->id, file_name)); + + if (zio_open_raw(zio, file_name) < 0) + goto failed; + + zio->code = ZIO_PLAIN; + zio->slice_size = ZIO_SIZE_PAGE; + zio->file_size = zio_lseek_raw(zio, 0, SEEK_END); + if (zio->file_size < 0 || zio_lseek_raw(zio, 0, SEEK_SET) < 0) + goto failed; + + /* + * Assign ID. + */ + pthread_mutex_lock(&zio_mutex); + zio->id = zio_counter++; + pthread_mutex_unlock(&zio_mutex); + + LOG(("out: zio_open_plain(zio=%d) = %d", (int)zio->id, zio->file)); + return zio->file; + + /* + * An error occurs... + */ + failed: + if (0 <= zio->file) + zio_close_raw(zio); + zio->file = -1; + zio->code = ZIO_INVALID; + + LOG(("out: zio_open_plain() = %d", -1)); + return -1; +} + + +/* + * Open an EBZIP compression file. + */ +static int +zio_open_ebzip(Zio *zio, const char *file_name) +{ + char header[ZIO_SIZE_EBZIP_HEADER]; + int ebzip_mode; + + LOG(("in: zio_open_ebzip(zio=%d, file_name=%s)", (int)zio->id, file_name)); + + /* + * Try to open a `*.ebz' file. + */ + if (zio_open_raw(zio, file_name) < 0) + goto failed; + + /* + * Read header part of the ebzip'ped file. + */ + if (zio_read_raw(zio, header, ZIO_SIZE_EBZIP_HEADER) + != ZIO_SIZE_EBZIP_HEADER) + goto failed; + ebzip_mode = zio_uint1(header + 5) >> 4; + zio->code = ZIO_EBZIP1; + zio->zip_level = zio_uint1(header + 5) & 0x0f; + zio->slice_size = ZIO_SIZE_PAGE << zio->zip_level; + zio->file_size = zio_uint5(header + 9); + zio->crc = zio_uint4(header + 14); + zio->mtime = zio_uint4(header + 18); + zio->location = 0; + + if (zio->file_size < (off_t) 1 << 16) + zio->index_width = 2; + else if (zio->file_size < (off_t) 1 << 24) + zio->index_width = 3; + else if (zio->file_size < (off_t) 1 << 32 || !off_t_is_large) + zio->index_width = 4; + else + zio->index_width = 5; + + /* + * Check zio header information. + */ + if (memcmp(header, "EBZip", 5) != 0 + || ZIO_SIZE_PAGE << ZIO_MAX_EBZIP_LEVEL < zio->slice_size) + goto failed; + + if (off_t_is_large) { + if (ebzip_mode != 1 && ebzip_mode != 2) + goto failed; + } else { + if (ebzip_mode != 1) + goto failed; + } + + /* + * Assign ID. + */ + pthread_mutex_lock(&zio_mutex); + zio->id = zio_counter++; + pthread_mutex_unlock(&zio_mutex); + + LOG(("out: zio_open_ebzip(zio=%d) = %d", (int)zio->id, zio->file)); + return zio->file; + + /* + * An error occurs... + */ + failed: + if (0 <= zio->file) + zio_close_raw(zio); + zio->file = -1; + zio->code = ZIO_INVALID; + LOG(("out: zio_open_ebzip() = %d", -1)); + return -1; +} + + +/* + * The buffer size must be 512 bytes, the number of 8 bit nodes. + */ +#define ZIO_EPWING_BUFFER_SIZE 512 + +/* + * Open an EPWING compression file. + */ +static int +zio_open_epwing(Zio *zio, const char *file_name) +{ + int leaf16_count; + int leaf_count; + char buffer[ZIO_EPWING_BUFFER_SIZE]; + char *buffer_p; + ssize_t read_length; + Zio_Huffman_Node *tail_node_p; + int i; + + LOG(("in: zio_open_epwing(zio=%d, file_name=%s)", (int)zio->id, + file_name)); + + zio->code = ZIO_EPWING; + zio->huffman_nodes = NULL; + + /* + * Open `HONMON2'. + */ + if (zio_open_raw(zio, file_name) < 0) + goto failed; + + /* + * Read a header of `HONMON2' (32 bytes). + * When `frequencies_length' is shorter than 512, we assumes the + * file is broken. + */ + if (zio_read_raw(zio, buffer, 32) != 32) + goto failed; + zio->location = 0; + zio->slice_size = ZIO_SIZE_PAGE; + zio->index_location = zio_uint4(buffer); + zio->index_length = zio_uint4(buffer + 4); + zio->frequencies_location = zio_uint4(buffer + 8); + zio->frequencies_length = zio_uint4(buffer + 12); + leaf16_count = (zio->frequencies_length - (256 * 2)) / 4; + leaf_count = leaf16_count + 256 + 1; + if (zio->index_length < 36 || zio->frequencies_length < 512) + goto failed; + + /* + * Check for the length of an uncompressed file. + * + * If the index of the non-first page in the last index group + * is 0x0000, we assumes the data corresponding with the index + * doesn't exist. + */ + if (zio_lseek_raw(zio, zio->index_location + + ((off_t) zio->index_length - 36) / 36 * 36, SEEK_SET) < 0) + goto failed; + if (zio_read_raw(zio, buffer, 36) != 36) + goto failed; + zio->file_size = ((off_t) zio->index_length / 36) * (ZIO_SIZE_PAGE * 16); + for (i = 1, buffer_p = buffer + 4 + 2; i < 16; i++, buffer_p += 2) { + if (zio_uint2(buffer_p) == 0) + break; + } + zio->file_size -= ZIO_SIZE_PAGE * (16 - i); + + /* + * Allocate memory for huffman nodes. + */ + zio->huffman_nodes = (Zio_Huffman_Node *) malloc(sizeof(Zio_Huffman_Node) + * leaf_count * 2); + if (zio->huffman_nodes == NULL) + goto failed; + tail_node_p = zio->huffman_nodes; + + /* + * Make leafs for 16bit character. + */ + read_length = ZIO_EPWING_BUFFER_SIZE - (ZIO_EPWING_BUFFER_SIZE % 4); + if (zio_lseek_raw(zio, zio->frequencies_location, SEEK_SET) < 0) + goto failed; + if (zio_read_raw(zio, buffer, read_length) != read_length) + goto failed; + + buffer_p = buffer; + for (i = 0; i < leaf16_count; i++) { + if (buffer + read_length <= buffer_p) { + if (zio_read_raw(zio, buffer, read_length) != read_length) + goto failed; + buffer_p = buffer; + } + tail_node_p->type = ZIO_HUFFMAN_NODE_LEAF16; + tail_node_p->value = zio_uint2(buffer_p); + tail_node_p->frequency = zio_uint2(buffer_p + 2); + tail_node_p->left = NULL; + tail_node_p->right = NULL; + buffer_p += 4; + tail_node_p++; + } + + /* + * Make leafs for 8bit character. + */ + if (zio_lseek_raw(zio, zio->frequencies_location + leaf16_count * 4, + SEEK_SET) < 0) + goto failed; + if (zio_read_raw(zio, buffer, 512) != 512) + goto failed; + + buffer_p = buffer; + for (i = 0; i < 256; i++) { + tail_node_p->type = ZIO_HUFFMAN_NODE_LEAF8; + tail_node_p->value = i; + tail_node_p->frequency = zio_uint2(buffer_p); + tail_node_p->left = NULL; + tail_node_p->right = NULL; + buffer_p += 2; + tail_node_p++; + } + + /* + * Make a leaf for the end-of-page character. + */ + tail_node_p->type = ZIO_HUFFMAN_NODE_EOF; + tail_node_p->value = 256; + tail_node_p->frequency = 1; + tail_node_p++; + + /* + * Make a huffman tree. + */ + if (zio_make_epwing_huffman_tree(zio, leaf_count) < 0) + goto failed; + + /* + * Assign ID. + */ + pthread_mutex_lock(&zio_mutex); + zio->id = zio_counter++; + pthread_mutex_unlock(&zio_mutex); + + LOG(("out: zio_open_epwing(zio=%d) = %d", (int)zio->id, zio->file)); + return zio->file; + + /* + * An error occurs... + */ + failed: + if (0 <= zio->file) + zio_close_raw(zio); + if (zio->huffman_nodes != NULL) + free(zio->huffman_nodes); + zio->file = -1; + zio->huffman_nodes = NULL; + zio->huffman_root = NULL; + zio->code = ZIO_INVALID; + + LOG(("out: zio_open_epwing() = %d", -1)); + return -1; +} + + +/* + * Open an EPWING compression file. + */ +static int +zio_open_epwing6(Zio *zio, const char *file_name) +{ + int leaf32_count; + int leaf16_count; + int leaf_count; + char buffer[ZIO_EPWING_BUFFER_SIZE]; + char *buffer_p; + ssize_t read_length; + Zio_Huffman_Node *tail_node_p; + int i; + + LOG(("in: zio_open_epwing6(zio=%d, file_name=%s)", (int)zio->id, + file_name)); + + zio->code = ZIO_EPWING6; + zio->huffman_nodes = NULL; + + /* + * Open `HONMON2'. + */ + if (zio_open_raw(zio, file_name) < 0) + goto failed; + + /* + * Read a header of `HONMON2' (48 bytes). + * When `frequencies_length' is shorter than 512, we assumes the + * file is broken. + */ + if (zio_read_raw(zio, buffer, 48) != 48) + goto failed; + zio->location = 0; + zio->slice_size = ZIO_SIZE_PAGE; + zio->index_location = zio_uint4(buffer); + zio->index_length = zio_uint4(buffer + 4); + zio->frequencies_location = zio_uint4(buffer + 8); + zio->frequencies_length = zio_uint4(buffer + 12); + leaf16_count = 0x400; + leaf32_count = (zio->frequencies_length - (leaf16_count * 4) - (256 * 2)) + / 6; + leaf_count = leaf32_count + leaf16_count + 256 + 1; + if (zio->index_length < 36 || zio->frequencies_length < 512) + goto failed; + + /* + * Check for the length of an uncompressed file. + * + * If the index of the non-first page in the last index group + * is 0x0000, we assumes the data corresponding with the index + * doesn't exist. + */ + if (zio_lseek_raw(zio, zio->index_location + + ((off_t) zio->index_length - 36) / 36 * 36, SEEK_SET) < 0) + goto failed; + if (zio_read_raw(zio, buffer, 36) != 36) + goto failed; + zio->file_size = ((off_t) zio->index_length / 36) * (ZIO_SIZE_PAGE * 16); + for (i = 1, buffer_p = buffer + 4 + 2; i < 16; i++, buffer_p += 2) { + if (zio_uint2(buffer_p) == 0) + break; + } + zio->file_size -= ZIO_SIZE_PAGE * (16 - i); + + /* + * Allocate memory for huffman nodes. + */ + zio->huffman_nodes = (Zio_Huffman_Node *) malloc(sizeof(Zio_Huffman_Node) + * leaf_count * 2); + if (zio->huffman_nodes == NULL) + goto failed; + tail_node_p = zio->huffman_nodes; + + /* + * Make leafs for 32bit character. + */ + read_length = ZIO_EPWING_BUFFER_SIZE - (ZIO_EPWING_BUFFER_SIZE % 6); + if (zio_lseek_raw(zio, zio->frequencies_location, SEEK_SET) < 0) + goto failed; + if (zio_read_raw(zio, buffer, read_length) != read_length) + goto failed; + + buffer_p = buffer; + for (i = 0; i < leaf32_count; i++) { + if (buffer + read_length <= buffer_p) { + if (zio_read_raw(zio, buffer, read_length) != read_length) + goto failed; + buffer_p = buffer; + } + tail_node_p->type = ZIO_HUFFMAN_NODE_LEAF32; + tail_node_p->value = zio_uint4(buffer_p); + tail_node_p->frequency = zio_uint2(buffer_p + 4); + tail_node_p->left = NULL; + tail_node_p->right = NULL; + buffer_p += 6; + tail_node_p++; + } + + /* + * Make leafs for 16bit character. + */ + read_length = ZIO_EPWING_BUFFER_SIZE - (ZIO_EPWING_BUFFER_SIZE % 4); + if (zio_lseek_raw(zio, zio->frequencies_location + leaf32_count * 6, + SEEK_SET) < 0) + goto failed; + if (zio_read_raw(zio, buffer, read_length) != read_length) + goto failed; + + buffer_p = buffer; + for (i = 0; i < leaf16_count; i++) { + if (buffer + read_length <= buffer_p) { + if (zio_read_raw(zio, buffer, read_length) != read_length) + goto failed; + buffer_p = buffer; + } + tail_node_p->type = ZIO_HUFFMAN_NODE_LEAF16; + tail_node_p->value = zio_uint2(buffer_p); + tail_node_p->frequency = zio_uint2(buffer_p + 2); + tail_node_p->left = NULL; + tail_node_p->right = NULL; + buffer_p += 4; + tail_node_p++; + } + + /* + * Make leafs for 8bit character. + */ + if (zio_lseek_raw(zio, zio->frequencies_location + leaf32_count * 6 + + leaf16_count * 4, SEEK_SET) < 0) + goto failed; + if (zio_read_raw(zio, buffer, 512) != 512) + goto failed; + + buffer_p = buffer; + for (i = 0; i < 256; i++) { + tail_node_p->type = ZIO_HUFFMAN_NODE_LEAF8; + tail_node_p->value = i; + tail_node_p->frequency = zio_uint2(buffer_p); + tail_node_p->left = NULL; + tail_node_p->right = NULL; + buffer_p += 2; + tail_node_p++; + } + + /* + * Make a leaf for the end-of-page character. + */ + tail_node_p->type = ZIO_HUFFMAN_NODE_EOF; + tail_node_p->value = 256; + tail_node_p->frequency = 1; + tail_node_p++; + + /* + * Make a huffman tree. + */ + if (zio_make_epwing_huffman_tree(zio, leaf_count) < 0) + goto failed; + + /* + * Assign ID. + */ + pthread_mutex_lock(&zio_mutex); + zio->id = zio_counter++; + pthread_mutex_unlock(&zio_mutex); + + LOG(("out: zio_open_epwing6(zio=%d) = %d", (int)zio->id, zio->file)); + return zio->file; + + /* + * An error occurs... + */ + failed: + if (0 <= zio->file) + zio_close_raw(zio); + if (zio->huffman_nodes != NULL) + free(zio->huffman_nodes); + zio->file = -1; + zio->huffman_nodes = NULL; + zio->huffman_root = NULL; + zio->code = ZIO_INVALID; + + LOG(("out: zio_open_epwing6() = %d", -1)); + return -1; +} + + +/* + * Make a huffman tree for decompressing EPWING compression data. + */ +static int +zio_make_epwing_huffman_tree(Zio *zio, int leaf_count) +{ + Zio_Huffman_Node *target_node; + Zio_Huffman_Node *most_node; + Zio_Huffman_Node *node_p; + Zio_Huffman_Node temporary_node; + Zio_Huffman_Node *least_node_p; + Zio_Huffman_Node *tail_node_p; + int i; + int j; + + LOG(("in: zio_make_epwing_huffman_tree(zio=%d, leaf_count=%d)", + (int)zio->id, leaf_count)); + + tail_node_p = zio->huffman_nodes + leaf_count; + + /* + * Sort the leaf nodes in frequency order. + */ + for (i = 0; i < leaf_count - 1; i++) { + target_node = zio->huffman_nodes + i; + most_node = target_node; + node_p = zio->huffman_nodes + i + 1; + + for (j = i + 1; j < leaf_count; j++) { + if (most_node->frequency < node_p->frequency) + most_node = node_p; + node_p++; + } + + temporary_node.type = most_node->type; + temporary_node.value = most_node->value; + temporary_node.frequency = most_node->frequency; + + most_node->type = target_node->type; + most_node->value = target_node->value; + most_node->frequency = target_node->frequency; + + target_node->type = temporary_node.type; + target_node->value = temporary_node.value; + target_node->frequency = temporary_node.frequency; + } + + /* + * Make intermediate nodes of the huffman tree. + * The number of intermediate nodes of the tree is - 1. + */ + for (i = 1; i < leaf_count; i++) { + /* + * Initialize a new intermediate node. + */ + tail_node_p->type = ZIO_HUFFMAN_NODE_INTERMEDIATE; + tail_node_p->left = NULL; + tail_node_p->right = NULL; + + /* + * Find for a least frequent node. + * That node becomes a left child of the new intermediate node. + */ + least_node_p = NULL; + for (node_p = zio->huffman_nodes; node_p < tail_node_p; node_p++) { + if (node_p->frequency == 0) + continue; + if (least_node_p == NULL + || node_p->frequency <= least_node_p->frequency) + least_node_p = node_p; + } + if (least_node_p == NULL) + goto failed; + tail_node_p->left = least_node_p; + tail_node_p->frequency = least_node_p->frequency; + least_node_p->frequency = 0; + + /* + * Find for a next least frequent node. + * That node becomes a right child of the new intermediate node. + */ + least_node_p = NULL; + for (node_p = zio->huffman_nodes; node_p < tail_node_p; node_p++) { + if (node_p->frequency == 0) + continue; + if (least_node_p == NULL + || node_p->frequency <= least_node_p->frequency) + least_node_p = node_p; + } + if (least_node_p == NULL) + goto failed; + tail_node_p->right = least_node_p; + tail_node_p->frequency += least_node_p->frequency; + least_node_p->frequency = 0; + + tail_node_p++; + } + + /* + * Set a root node of the huffman tree. + */ + zio->huffman_root = tail_node_p - 1; + + LOG(("out: zio_make_epwing_huffman_tree() = %d", 0)); + return 0; + + /* + * An error occurs... + */ + failed: + LOG(("out: zio_make_epwing_huffman_tree() = %d", -1)); + return -1; +} + + +/* + * Close `zio'. + */ +void +zio_close(Zio *zio) +{ + pthread_mutex_lock(&zio_mutex); + LOG(("in: zio_close(zio=%d)", (int)zio->id)); + + /* + * If contents of the file is cached, clear the cache. + */ + if (0 <= zio->file) + zio_close_raw(zio); + zio->file = -1; + + LOG(("out: zio_close()")); + pthread_mutex_unlock(&zio_mutex); +} + + +/* + * Return file descriptor of `zio'. + */ +int +zio_file(Zio *zio) +{ + LOG(("in+out: zio_file(zio=%d) = %d", (int)zio->id, zio->file)); + + return zio->file; +} + + +/* + * Return compression mode of `zio'. + */ +Zio_Code +zio_mode(Zio *zio) +{ + LOG(("in+out: zio_mode(zio=%d) = %d", (int)zio->id, zio->code)); + + return zio->code; +} + + +/* + * Seek `zio'. + */ +off_t +zio_lseek(Zio *zio, off_t location, int whence) +{ + off_t result; + + LOG(("in: zio_lseek(zio=%d, location=%ld, whence=%d)", + (int)zio->id, (long)location, whence)); + + if (zio->file < 0) + goto failed; + + if (zio->code == ZIO_PLAIN) { + /* + * If `zio' is not compressed, simply call lseek(). + */ + result = zio_lseek_raw(zio, location, whence); + } else { + /* + * Calculate new location according with `whence'. + */ + switch (whence) { + case SEEK_SET: + zio->location = location; + break; + case SEEK_CUR: + zio->location = zio->location + location; + break; + case SEEK_END: + zio->location = zio->file_size - location; + break; + default: +#ifdef EINVAL + errno = EINVAL; +#endif + goto failed; + } + + /* + * Adjust location. + */ + if (zio->location < 0) + zio->location = 0; + if (zio->file_size < zio->location) + zio->location = zio->file_size; + + /* + * Update `zio->location'. + * (We don't actually seek the file.) + */ + result = zio->location; + } + + LOG(("out: zio_lseek() = %ld", (long)result)); + return result; + + /* + * An error occurs... + */ + failed: + LOG(("out: zio_lseek() = %ld", (long)-1)); + return -1; +} + + +/* + * Read data from `zio' file. + */ +ssize_t +zio_read(Zio *zio, char *buffer, size_t length) +{ + ssize_t read_length; + + pthread_mutex_lock(&zio_mutex); + LOG(("in: zio_read(zio=%d, length=%ld)", (int)zio->id, (long)length)); + + /* + * If the zio `file' is not compressed, call read() and return. + */ + if (zio->file < 0) + goto failed; + + switch (zio->code) { + case ZIO_PLAIN: + read_length = zio_read_raw(zio, buffer, length); + break; + case ZIO_EBZIP1: + read_length = zio_read_ebzip(zio, buffer, length); + break; + case ZIO_EPWING: + case ZIO_EPWING6: + read_length = zio_read_epwing(zio, buffer, length); + break; + case ZIO_SEBXA: + read_length = zio_read_sebxa(zio, buffer, length); + break; + default: + goto failed; + } + + LOG(("out: zio_read() = %ld", (long)read_length)); + pthread_mutex_unlock(&zio_mutex); + + return read_length; + + /* + * An error occurs... + */ + failed: + LOG(("out: zio_read() = %ld", (long)-1)); + return -1; +} + + +/* + * Read data from the `zio' file compressed with the ebzip compression + * format. + */ +static ssize_t +zio_read_ebzip(Zio *zio, char *buffer, size_t length) +{ + char temporary_buffer[8]; + ssize_t read_length = 0; + size_t zipped_slice_size; + off_t slice_location; + off_t next_slice_location; + int n; + + LOG(("in: zio_read_ebzip(zio=%d, length=%ld)", (int)zio->id, + (long)length)); + + /* + * Read data. + */ + while (read_length < length) { + if (zio->file_size <= zio->location) + goto succeeded; + + /* + * If data in `cache_buffer' is out of range, read data from + * `zio->file'. + */ + if (cache_zio_id != zio->id + || zio->location < cache_location + || cache_location + zio->slice_size <= zio->location) { + + cache_zio_id = ZIO_ID_NONE; + cache_location = zio->location - (zio->location % zio->slice_size); + + /* + * Get buffer location and size from index table in `zio->file'. + */ + if (zio_lseek_raw(zio, zio->location / zio->slice_size + * zio->index_width + ZIO_SIZE_EBZIP_HEADER, SEEK_SET) < 0) + goto failed; + if (zio_read_raw(zio, temporary_buffer, zio->index_width * 2) + != zio->index_width * 2) + goto failed; + + switch (zio->index_width) { + case 2: + slice_location = zio_uint2(temporary_buffer); + next_slice_location = zio_uint2(temporary_buffer + 2); + break; + case 3: + slice_location = zio_uint3(temporary_buffer); + next_slice_location = zio_uint3(temporary_buffer + 3); + break; + case 4: + slice_location = zio_uint4(temporary_buffer); + next_slice_location = zio_uint4(temporary_buffer + 4); + break; + case 5: + slice_location = zio_uint5(temporary_buffer); + next_slice_location = zio_uint5(temporary_buffer + 5); + break; + default: + goto failed; + } + zipped_slice_size = next_slice_location - slice_location; + + if (next_slice_location <= slice_location + || zio->slice_size < zipped_slice_size) + goto failed; + + /* + * Read a compressed slice from `zio->file' and uncompress it. + * The data is not compressed if its size is equals to + * slice size. + */ + if (zio_lseek_raw(zio, slice_location, SEEK_SET) < 0) + goto failed; + if (zio_unzip_slice_ebzip1(zio, cache_buffer, zipped_slice_size) + < 0) + goto failed; + + cache_zio_id = zio->id; + } + + /* + * Copy data from `cache_buffer' to `buffer'. + */ + n = zio->slice_size - (zio->location % zio->slice_size); + if (length - read_length < n) + n = length - read_length; + if (zio->file_size - zio->location < n) + n = zio->file_size - zio->location; + memcpy(buffer + read_length, + cache_buffer + (zio->location % zio->slice_size), n); + read_length += n; + zio->location += n; + } + + succeeded: + LOG(("out: zio_read_ebzip() = %ld", (long)read_length)); + return read_length; + + /* + * An error occurs... + */ + failed: + LOG(("out: zio_read_ebzip() = %ld", (long)-1)); + return -1; +} + + +/* + * Read data from the `zio' file compressed with the EPWING or EPWING V6 + * compression format. + */ +static ssize_t +zio_read_epwing(Zio *zio, char *buffer, size_t length) +{ + char temporary_buffer[36]; + ssize_t read_length = 0; + off_t page_location; + int n; + + LOG(("in: zio_read_epwing(zio=%d, length=%ld)", (int)zio->id, + (long)length)); + + /* + * Read data. + */ + while (read_length < length) { + if (zio->file_size <= zio->location) + goto succeeded; + + /* + * If data in `cache_buffer' is out of range, read data from the zio + * file. + */ + if (cache_zio_id != zio->id + || zio->location < cache_location + || cache_location + zio->slice_size <= zio->location) { + cache_zio_id = ZIO_ID_NONE; + cache_location = zio->location - (zio->location % zio->slice_size); + + /* + * Get page location from index table in `zio->file'. + */ + if (zio_lseek_raw(zio, zio->index_location + + zio->location / (ZIO_SIZE_PAGE * 16) * 36, SEEK_SET) < 0) + goto failed; + if (zio_read_raw(zio, temporary_buffer, 36) != 36) + goto failed; + page_location = zio_uint4(temporary_buffer) + + zio_uint2(temporary_buffer + 4 + + (zio->location / ZIO_SIZE_PAGE % 16) * 2); + + /* + * Read a compressed page from `zio->file' and uncompress it. + */ + if (zio_lseek_raw(zio, page_location, SEEK_SET) < 0) + goto failed; + if (zio->code == ZIO_EPWING) { + if (zio_unzip_slice_epwing(zio, cache_buffer) < 0) + goto failed; + } else { + if (zio_unzip_slice_epwing6(zio, cache_buffer) < 0) + goto failed; + } + + cache_zio_id = zio->id; + } + + /* + * Copy data from `cache_buffer' to `buffer'. + */ + n = ZIO_SIZE_PAGE - (zio->location % ZIO_SIZE_PAGE); + if (length - read_length < n) + n = length - read_length; + if (zio->file_size - zio->location < n) + n = zio->file_size - zio->location; + memcpy(buffer + read_length, + cache_buffer + (zio->location - cache_location), n); + read_length += n; + zio->location += n; + } + + succeeded: + LOG(("out: zio_read_epwing() = %ld", (long)read_length)); + return read_length; + + /* + * An error occurs... + */ + failed: + LOG(("out: zio_read_epwing() = %ld", (long)-1)); + return -1; +} + + +#define ZIO_SEBXA_SLICE_LENGTH 4096 + +/* + * Read data from the zio `file' compressed with the S-EBXA compression + * format. + */ +static ssize_t +zio_read_sebxa(Zio *zio, char *buffer, size_t length) +{ + char temporary_buffer[4]; + ssize_t read_length = 0; + off_t slice_location; + ssize_t n; + int slice_index; + + LOG(("in: zio_read_sebxa(zio=%d, length=%ld)", (int)zio->id, + (long)length)); + + /* + * Read data. + */ + while (read_length < length) { + if (zio->file_size <= zio->location) + goto succeeded; + + if (zio->location < zio->zio_start_location) { + /* + * Data is located in front of compressed text. + */ + if (zio->zio_start_location - zio->location < length - read_length) + n = zio->zio_start_location - zio->location; + else + n = length - read_length; + if (zio_lseek_raw(zio, zio->location, SEEK_SET) < 0) + goto failed; + if (zio_read_raw(zio, buffer, n) != n) + goto failed; + read_length += n; + + } else if (zio->zio_end_location <= zio->location) { + /* + * Data is located behind compressed text. + */ + if (zio_lseek_raw(zio, zio->location, SEEK_SET) < 0) + goto failed; + if (zio_read_raw(zio, buffer, length - read_length) + != length - read_length) + goto failed; + read_length = length; + + } else { + /* + * Data is located in compressed text. + * + * If data in `cache_buffer' is out of range, read data from + * `file'. + */ + if (cache_zio_id != zio->id + || zio->location < cache_location + || cache_location + ZIO_SEBXA_SLICE_LENGTH <= zio->location) { + + cache_zio_id = ZIO_ID_NONE; + cache_location = zio->location + - (zio->location % ZIO_SEBXA_SLICE_LENGTH); + + /* + * Get buffer location and size. + */ + slice_index = (zio->location - zio->zio_start_location) + / ZIO_SEBXA_SLICE_LENGTH; + if (slice_index == 0) + slice_location = zio->index_base; + else { + if (zio_lseek_raw(zio, ((off_t) slice_index - 1) * 4 + + zio->index_location, SEEK_SET) < 0) + goto failed; + if (zio_read_raw(zio, temporary_buffer, 4) != 4) + goto failed; + slice_location = zio->index_base + + zio_uint4(temporary_buffer); + } + + /* + * Read a compressed slice from `zio->file' and uncompress it. + */ + if (zio_lseek_raw(zio, slice_location, SEEK_SET) < 0) + goto failed; + if (zio_unzip_slice_sebxa(zio, cache_buffer) < 0) + goto failed; + + cache_zio_id = zio->id; + } + + /* + * Copy data from `cache_buffer' to `buffer'. + */ + n = ZIO_SEBXA_SLICE_LENGTH + - (zio->location % ZIO_SEBXA_SLICE_LENGTH); + if (length - read_length < n) + n = length - read_length; + if (zio->file_size - zio->location < n) + n = zio->file_size - zio->location; + memcpy(buffer + read_length, + cache_buffer + (zio->location - cache_location), n); + read_length += n; + zio->location += n; + } + } + + succeeded: + LOG(("out: zio_read_sebxa() = %ld", (long)read_length)); + return read_length; + + /* + * An error occurs... + */ + failed: + LOG(("out: zio_read_sebxa() = %ld", (long)-1)); + return -1; +} + + +/* + * Uncompress an ebzip'ped slice. + * + * If it succeeds, 0 is returned. Otherwise, -1 is returned. + */ +static int +zio_unzip_slice_ebzip1(Zio *zio, char *out_buffer, size_t zipped_slice_size) +{ + char in_buffer[ZIO_SIZE_PAGE]; + z_stream stream; + size_t read_length; + int z_result; + + LOG(("in: zio_unzip_slice_ebzip1(zio=%d, zipped_slice_size=%ld)", + (int)zio->id, (long)zipped_slice_size)); + + if (zio->slice_size == zipped_slice_size) { + /* + * The input slice is not compressed. + * Read the target page in the slice. + */ + if (zio_read_raw(zio, out_buffer, zipped_slice_size) != zipped_slice_size) + goto failed; + + } else { + /* + * The input slice is compressed. + * Read and uncompress the target page in the slice. + */ + stream.zalloc = NULL; + stream.zfree = NULL; + stream.opaque = NULL; + + if (inflateInit(&stream) != Z_OK) + goto failed; + + stream.next_in = (Bytef *) in_buffer; + stream.avail_in = 0; + stream.next_out = (Bytef *) out_buffer; + stream.avail_out = zio->slice_size; + + while (stream.total_out < zio->slice_size) { + if (0 < stream.avail_in) + memmove(in_buffer, stream.next_in, stream.avail_in); + + if (zipped_slice_size - stream.total_in < ZIO_SIZE_PAGE) { + read_length = zipped_slice_size - stream.total_in + - stream.avail_in; + } else { + read_length = ZIO_SIZE_PAGE - stream.avail_in; + } + + if (zio_read_raw(zio, in_buffer + stream.avail_in, + read_length) != read_length) + goto failed; + + stream.next_in = (Bytef *) in_buffer; + stream.avail_in += read_length; + stream.avail_out = zio->slice_size - stream.total_out; + + z_result = inflate(&stream, Z_SYNC_FLUSH); + if (z_result == Z_STREAM_END) { + break; + } else if (z_result != Z_OK && z_result != Z_BUF_ERROR) { + goto failed; + } + } + + inflateEnd(&stream); + } + + LOG(("out: zio_unzip_slice_ebzip1() = %d", 0)); + return 0; + + /* + * An error occurs... + */ + failed: + LOG(("out: zio_unzip_slice_ebzip1() = %d", -1)); + inflateEnd(&stream); + return -1; +} + + +/* + * Uncompress an EPWING compressed slice. + * The offset of `zio->file' must points to the beginning of the compressed + * slice. Uncompressed data are put into `out_buffer'. + * + * If it succeeds, 0 is returned. Otherwise, -1 is returned. + */ +static int +zio_unzip_slice_epwing(Zio *zio, char *out_buffer) +{ + Zio_Huffman_Node *node_p; + int bit; + char in_buffer[ZIO_SIZE_PAGE]; + unsigned char *in_buffer_p; + ssize_t in_read_length; + int in_bit_index; + unsigned char *out_buffer_p; + size_t out_length; + + LOG(("in: zio_unzip_slice_epwing(zio=%d)", (int)zio->id)); + + in_buffer_p = (unsigned char *)in_buffer; + in_bit_index = 7; + in_read_length = 0; + out_buffer_p = (unsigned char *)out_buffer; + out_length = 0; + + for (;;) { + /* + * Descend the huffman tree until reached to the leaf node. + */ + node_p = zio->huffman_root; + while (node_p->type == ZIO_HUFFMAN_NODE_INTERMEDIATE) { + + /* + * If no data is left in the input buffer, read next chunk. + */ + if ((unsigned char *)in_buffer + in_read_length <= in_buffer_p) { + in_read_length = zio_read_raw(zio, in_buffer, ZIO_SIZE_PAGE); + if (in_read_length <= 0) + goto failed; + in_buffer_p = (unsigned char *)in_buffer; + } + + /* + * Step to a child. + */ + bit = (*in_buffer_p >> in_bit_index) & 0x01; + + if (bit == 1) + node_p = node_p->left; + else + node_p = node_p->right; + if (node_p == NULL) + goto failed; + + if (0 < in_bit_index) + in_bit_index--; + else { + in_bit_index = 7; + in_buffer_p++; + } + } + + if (node_p->type == ZIO_HUFFMAN_NODE_EOF) { + /* + * Fill the rest of the output buffer with NUL, + * when we meet an EOF mark before decode ZIO_SIZE_PAGE bytes. + */ + if (out_length < ZIO_SIZE_PAGE) { + memset(out_buffer_p, '\0', ZIO_SIZE_PAGE - out_length); + out_length = ZIO_SIZE_PAGE; + } + break; + + } else if (node_p->type == ZIO_HUFFMAN_NODE_LEAF16) { + /* + * The leaf is leaf16, decode 2 bytes character. + */ + if (ZIO_SIZE_PAGE <= out_length) + goto failed; + else if (ZIO_SIZE_PAGE <= out_length + 1) { + *out_buffer_p++ = (node_p->value >> 8) & 0xff; + out_length++; + } else { + *out_buffer_p++ = (node_p->value >> 8) & 0xff; + *out_buffer_p++ = node_p->value & 0xff; + out_length += 2; + } + } else { + /* + * The leaf is leaf8, decode 1 byte character. + */ + if (ZIO_SIZE_PAGE <= out_length) + goto failed; + else { + *out_buffer_p++ = node_p->value; + out_length++; + } + } + } + + LOG(("out: zio_unzip_slice_epwing() = %d", 0)); + return 0; + + /* + * An error occurs... + */ + failed: + LOG(("out: zio_unzip_slice_epwing() = %d", -1)); + return -1; +} + + +/* + * Uncompress an EPWING V6 compressed slice. + * The offset of `zio->file' must points to the beginning of the compressed + * slice. Uncompressed data are put into `out_buffer'. + * + * If it succeeds, 0 is returned. Otherwise, -1 is returned. + */ +static int +zio_unzip_slice_epwing6(Zio *zio, char *out_buffer) +{ + Zio_Huffman_Node *node_p; + int bit; + char in_buffer[ZIO_SIZE_PAGE]; + unsigned char *in_buffer_p; + ssize_t in_read_length; + int in_bit_index; + unsigned char *out_buffer_p; + size_t out_length; + int compression_type; + + LOG(("in: zio_unzip_slice_epwing6(zio=%d)", (int)zio->id)); + + in_buffer_p = (unsigned char *)in_buffer; + in_bit_index = 7; + in_read_length = 0; + out_buffer_p = (unsigned char *)out_buffer; + out_length = 0; + + /* + * Get compression type. + */ + if (zio_read_raw(zio, in_buffer, 1) != 1) + goto failed; + compression_type = zio_uint1(in_buffer); + + /* + * If compression type is not 0, this page is not compressed. + */ + if (compression_type != 0) { + if (zio_read_raw(zio, out_buffer, ZIO_SIZE_PAGE) != ZIO_SIZE_PAGE) + goto failed; + goto succeeded; + } + + while (out_length < ZIO_SIZE_PAGE) { + /* + * Descend the huffman tree until reached to the leaf node. + */ + node_p = zio->huffman_root; + while (node_p->type == ZIO_HUFFMAN_NODE_INTERMEDIATE) { + + /* + * If no data is left in the input buffer, read next chunk. + */ + if ((unsigned char *)in_buffer + in_read_length <= in_buffer_p) { + in_read_length = zio_read_raw(zio, in_buffer, ZIO_SIZE_PAGE); + if (in_read_length <= 0) + goto failed; + in_buffer_p = (unsigned char *)in_buffer; + } + + /* + * Step to a child. + */ + bit = (*in_buffer_p >> in_bit_index) & 0x01; + + if (bit == 1) + node_p = node_p->left; + else + node_p = node_p->right; + if (node_p == NULL) + goto failed; + + if (0 < in_bit_index) + in_bit_index--; + else { + in_bit_index = 7; + in_buffer_p++; + } + } + + if (node_p->type == ZIO_HUFFMAN_NODE_EOF) { + /* + * Fill the rest of the output buffer with NUL, + * when we meet an EOF mark before decode ZIO_SIZE_PAGE bytes. + */ + if (out_length < ZIO_SIZE_PAGE) { + memset(out_buffer_p, '\0', ZIO_SIZE_PAGE - out_length); + out_length = ZIO_SIZE_PAGE; + } + break; + + } else if (node_p->type == ZIO_HUFFMAN_NODE_LEAF32) { + /* + * The leaf is leaf32, decode 4 bytes character. + */ + if (ZIO_SIZE_PAGE <= out_length + 1) { + *out_buffer_p++ = (node_p->value >> 24) & 0xff; + out_length++; + } else if (ZIO_SIZE_PAGE <= out_length + 2) { + *out_buffer_p++ = (node_p->value >> 24) & 0xff; + *out_buffer_p++ = (node_p->value >> 16) & 0xff; + out_length += 2; + } else if (ZIO_SIZE_PAGE <= out_length + 3) { + *out_buffer_p++ = (node_p->value >> 24) & 0xff; + *out_buffer_p++ = (node_p->value >> 16) & 0xff; + *out_buffer_p++ = (node_p->value >> 8) & 0xff; + out_length += 3; + } else { + *out_buffer_p++ = (node_p->value >> 24) & 0xff; + *out_buffer_p++ = (node_p->value >> 16) & 0xff; + *out_buffer_p++ = (node_p->value >> 8) & 0xff; + *out_buffer_p++ = node_p->value & 0xff; + out_length += 4; + } + } else if (node_p->type == ZIO_HUFFMAN_NODE_LEAF16) { + /* + * The leaf is leaf16, decode 2 bytes character. + */ + if (ZIO_SIZE_PAGE <= out_length + 1) { + *out_buffer_p++ = (node_p->value >> 8) & 0xff; + out_length++; + } else { + *out_buffer_p++ = (node_p->value >> 8) & 0xff; + *out_buffer_p++ = node_p->value & 0xff; + out_length += 2; + } + } else { + /* + * The leaf is leaf8, decode 1 byte character. + */ + *out_buffer_p++ = node_p->value; + out_length++; + } + } + + succeeded: + LOG(("out: zio_unzip_slice_epwing6() = %d", 0)); + return 0; + + /* + * An error occurs... + */ + failed: + LOG(("out: zio_unzip_slice_epwing6() = %d", -1)); + return -1; +} + +/* + * Uncompress an S-EBXA compressed slice. + * The offset of `zio->file' must points to the beginning of the compressed + * slice. Uncompressed data are put into `out_buffer'. + * + * If it succeeds, 0 is returned. Otherwise, -1 is returned. + */ +static int +zio_unzip_slice_sebxa(Zio *zio, char *out_buffer) +{ + char in_buffer[ZIO_SEBXA_SLICE_LENGTH]; + unsigned char *in_buffer_p; + size_t in_read_rest; + unsigned char *out_buffer_p; + size_t out_length; + int compression_flags[8]; + int copy_offset; + int copy_length; + int i, j; + + LOG(("in: zio_unzip_slice_sebxa(zio=%d)", (int)zio->id)); + + in_buffer_p = (unsigned char *)in_buffer; + in_read_rest = 0; + out_buffer_p = (unsigned char *)out_buffer; + out_length = 0; + + for (;;) { + /* + * If no data is left in the input buffer, read next chunk. + */ + if (in_read_rest <= 0) { + in_read_rest = zio_read_raw(zio, in_buffer, + ZIO_SEBXA_SLICE_LENGTH); + if (in_read_rest <= 0) + goto failed; + in_buffer_p = (unsigned char *)in_buffer; + } + + /* + * The current input byte is recognized as compression flags + * for next 8 chunks. + */ + compression_flags[0] = !(*in_buffer_p & 0x01); + compression_flags[1] = !(*in_buffer_p & 0x02); + compression_flags[2] = !(*in_buffer_p & 0x04); + compression_flags[3] = !(*in_buffer_p & 0x08); + compression_flags[4] = !(*in_buffer_p & 0x10); + compression_flags[5] = !(*in_buffer_p & 0x20); + compression_flags[6] = !(*in_buffer_p & 0x40); + compression_flags[7] = !(*in_buffer_p & 0x80); + in_buffer_p++; + in_read_rest--; + + /* + * Decode 8 chunks. + */ + for (i = 0; i < 8; i++) { + if (compression_flags[i]) { + /* + * This chunk is compressed. + * Copy `copy_length' bytes from `copy_p' to the current + * point. + */ + unsigned char *copy_p; + unsigned char c0, c1; + + if (in_read_rest <= 1) + goto failed; + + /* + * Get 2 bytes from the current input, and recognize + * them as following: + * + * *in_buffer_p *(in_bufer_p + 1) + * bit pattern: [AAAA|BBBB] [CCCC|DDDD] + * + * copy_offset = ([CCCCAAAABBBB] + 18) % 4096 + * copy_length = [DDDD] + 3 + */ + c0 = *(unsigned char *)in_buffer_p; + c1 = *((unsigned char *)in_buffer_p + 1); + copy_offset = (((c1 & 0xf0) << 4) + c0 + 18) + % ZIO_SEBXA_SLICE_LENGTH; + copy_length = (c1 & 0x0f) + 3; + + if (ZIO_SEBXA_SLICE_LENGTH < out_length + copy_length) + copy_length = ZIO_SEBXA_SLICE_LENGTH - out_length; + + copy_p = (unsigned char *)out_buffer + copy_offset; + for (j = 0; j < copy_length; j++) { + if (copy_p < out_buffer_p) + *out_buffer_p++ = *copy_p; + else + *out_buffer_p++ = 0x00; + copy_p++; + if (ZIO_SEBXA_SLICE_LENGTH <= + copy_p - (unsigned char *)out_buffer) + copy_p -= ZIO_SEBXA_SLICE_LENGTH; + } + + in_read_rest -= 2; + in_buffer_p += 2; + out_length += copy_length; + + } else { + /* + * This chunk is not compressed. + * Put the current input byte as a decoded value. + */ + if (in_read_rest <= 0) + goto failed; + in_read_rest -= 1; + *out_buffer_p++ = *in_buffer_p++; + out_length += 1; + } + + /* + * Return if the slice has been uncompressed. + */ + if (ZIO_SEBXA_SLICE_LENGTH <= out_length) + goto succeeded; + } + } + + succeeded: + LOG(("out: zio_unzip_slice_sebxa() = %d", 0)); + return 0; + + /* + * An error occurs... + */ + failed: + LOG(("out: zio_unzip_slice_sebxa() = %d", -1)); + return -1; +} + + +/* + * Low-level open function. + * + * If `file_name' is ebnet URL, it calls ebnet_open(). Otherwise it + * calls the open() system call. + * + * Like open(), it returns file descrptor or -1. + */ +static int +zio_open_raw(Zio *zio, const char *file_name) +{ +#ifdef ENABLE_EBNET + if (is_ebnet_url(file_name)) { + zio->is_ebnet = 1; + zio->file = ebnet_open(file_name); + } else { + zio->is_ebnet = 0; + zio->file = open(file_name, O_RDONLY | O_BINARY); + } +#else + zio->file = open(file_name, O_RDONLY | O_BINARY); +#endif + + return zio->file; +} + + +/* + * Low-level close function. + * + * If `zio->file' is socket, it calls ebnet_close(). Otherwise it calls + * the close() system call. + */ +static void +zio_close_raw(Zio *zio) +{ +#ifdef ENABLE_EBNET + if (zio->is_ebnet) + ebnet_close(zio->file); + else + close(zio->file); +#else + close(zio->file); +#endif +} + + +/* + * Low-level seek function. + * + * If `zio->file' is socket, it calls ebnet_close(). Otherwise it calls + * the close() system call. + */ +static off_t +zio_lseek_raw(Zio *zio, off_t offset, int whence) +{ + off_t result; + + if (zio->is_ebnet) { +#ifdef ENABLE_EBNET + result = ebnet_lseek(zio->file, offset, whence); +#else + result = -1; +#endif + } else { + result = lseek(zio->file, offset, whence); + } + + return result; +} + + +/* + * Low-level read function. + * + * If `zio->file' is socket, it calls ebnet_read(). Otherwise it calls + * the read() system call. + */ +static ssize_t +zio_read_raw(Zio *zio, void *buffer, size_t length) +{ + char *buffer_p = buffer; + ssize_t result; + + LOG(("in: zio_read_raw(file=%d, length=%ld)", zio->file, (long)length)); + + if (zio->is_ebnet) { + /* + * Read from a remote server. + */ +#ifdef ENABLE_EBNET + result = ebnet_read(&zio->file, buffer, length); +#else + result = -1; +#endif + } else { + /* + * Read from a local file. + */ + ssize_t rest_length = length; + ssize_t n; + + while (0 < rest_length) { + errno = 0; + n = read(zio->file, buffer_p, rest_length); + if (n < 0) { + if (errno == EINTR) + continue; + goto failed; + } else if (n == 0) + break; + else { + rest_length -= n; + buffer_p += n; + } + } + + result = length - rest_length; + } + + LOG(("out: zio_read_raw() = %ld", (long)result)); + return result; + + /* + * An error occurs... + */ + failed: + LOG(("out: zio_read_raw() = %ld", (long)-1)); + return -1; +} + + diff --git a/eb/zio.h b/eb/zio.h new file mode 100644 index 0000000..0cb7bbd --- /dev/null +++ b/eb/zio.h @@ -0,0 +1,237 @@ +/* -*- C -*- + * Copyright (c) 2001-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef ZIO_H +#define ZIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * Header size of the ebzip compression file. + */ +#define ZIO_SIZE_EBZIP_HEADER 22 + +/* + * Margin size for ebzip compression buffer. + * (Since compressed data is larger than original in the worst case, + * we must add margin to a compression buffer.) + */ +#define ZIO_SIZE_EBZIP_MARGIN 1024 + +/* + * Maximum ebzio compression level. + */ +#define ZIO_MAX_EBZIP_LEVEL 5 + +/* + * Huffman node types. + */ +#define ZIO_HUFFMAN_NODE_INTERMEDIATE 0 +#define ZIO_HUFFMAN_NODE_EOF 1 +#define ZIO_HUFFMAN_NODE_LEAF8 2 +#define ZIO_HUFFMAN_NODE_LEAF16 3 +#define ZIO_HUFFMAN_NODE_LEAF32 4 + +/* + * Compression type codes. + */ +#define ZIO_PLAIN 0 +#define ZIO_EBZIP1 1 +#define ZIO_EPWING 2 +#define ZIO_EPWING6 3 +#define ZIO_SEBXA 4 +#define ZIO_INVALID -1 +#define ZIO_REOPEN -2 + +/* + * Compression type. + */ +typedef int Zio_Code; + +/* + * A node of static Huffman tree. + */ +typedef struct Zio_Huffman_Node_Struct Zio_Huffman_Node; + +struct Zio_Huffman_Node_Struct { + /* + * node type (ITNERMEDIATE, LEAF8, LEAF16, LEAF32 or EOF). + */ + int type; + + /* + * Value of a leaf node. + */ + unsigned int value; + + /* + * Frequency of a node. + */ + int frequency; + + /* + * Left child. + */ + Zio_Huffman_Node *left; + + /* + * Right child. + */ + Zio_Huffman_Node *right; +}; + +/* + * Compression information of a book. + */ +typedef struct Zio_Struct Zio; + +struct Zio_Struct { + /* + * ID. + */ + int id; + + /* + * Zio type. (PLAIN, EBZIP, EPWING, EPWING6 or SEBXA) + */ + Zio_Code code; + + /* + * File descriptor. + */ + int file; + + /* + * Current location. + */ + off_t location; + + /* + * Size of an uncompressed file. + */ + off_t file_size; + + /* + * Slice size of an EBZIP compressed file. + */ + size_t slice_size; + + /* + * Compression level. (EBZIP compression only) + */ + int zip_level; + + /* + * Length of an index. (EBZIP compression only) + */ + int index_width; + + /* + * Adler-32 check sum of an uncompressed file. (EBZIP compression only) + */ + unsigned int crc; + + /* + * mtime of an uncompressed file. (EBZIP compression only) + */ + time_t mtime; + + /* + * Location of an index table. (EPWING and S-EBXA compression only) + */ + off_t index_location; + + /* + * Length of an index table. (EPWING and S-EBXA compression only) + */ + size_t index_length; + + /* + * Location of a frequency table. (EPWING compression only) + */ + off_t frequencies_location; + + /* + * Length of a frequency table. (EPWING compression only) + */ + size_t frequencies_length; + + /* + * Huffman tree nodes. (EPWING compression only) + */ + Zio_Huffman_Node *huffman_nodes; + + /* + * Root node of a Huffman tree. (EPWING compression only) + */ + Zio_Huffman_Node *huffman_root; + + /* + * Region of compressed pages. (S-EBXA compression only) + */ + off_t zio_start_location; + off_t zio_end_location; + + /* + * Add this value to offset written in index. (S-EBXA compression only) + */ + off_t index_base; + + /* + * ebnet mode flag. + */ + int is_ebnet; +}; + +/* + * Function declarations. + */ +/* zio.c */ +int zio_initialize_library(void); +void zio_finalize_library(void); +void zio_initialize(Zio *zio); +void zio_finalize(Zio *zio); +int zio_set_sebxa_mode(Zio *zio, off_t index_location, off_t index_base, + off_t zio_start_location, off_t zio_end_location); +int zio_open(Zio *zio, const char *file_name, Zio_Code zio_code); +void zio_close(Zio *zio); +int zio_file(Zio *zio); +Zio_Code zio_mode(Zio *zio); +off_t zio_lseek(Zio *zio, off_t offset, int whence); +ssize_t zio_read(Zio *zio, char *buffer, size_t length); + +#ifdef __cplusplus +} +#endif + +#endif /* not ZIO_H */ diff --git a/ebappendix/Makefile.am b/ebappendix/Makefile.am new file mode 100644 index 0000000..509bcb6 --- /dev/null +++ b/ebappendix/Makefile.am @@ -0,0 +1,16 @@ +bin_SCRIPTS = ebappendix + +EXTRA_DIST = ebappendix.in +CLEANFILES = ebappendix ebappendix.tmp + +ebappendix: ebappendix.in $(top_srcdir)/libebutils/getopt_long.pl Makefile + rm -f ebappendix + sed -e 's;\@PERL\@;$(PERL);' \ + $(srcdir)/ebappendix.in | sed '/^$$/q' > ebappendix.tmp + cat $(top_srcdir)/libebutils/getopt_long.pl >> ebappendix.tmp + sed -e 's;\@VERSION\@;$(VERSION);' \ + -e 's;\@MAILING_ADDRESS\@;$(MAILING_ADDRESS);' \ + $(srcdir)/ebappendix.in | sed '1,/^$$/d' >> ebappendix.tmp + cp ebappendix.tmp ebappendix + chmod +x ebappendix + rm -f ebappendix.tmp diff --git a/ebappendix/Makefile.in b/ebappendix/Makefile.in new file mode 100644 index 0000000..df0303d --- /dev/null +++ b/ebappendix/Makefile.in @@ -0,0 +1,401 @@ +# Makefile.in generated by automake 1.10.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = ebappendix +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/in6addr.m4 $(top_srcdir)/m4/largefile.m4 \ + $(top_srcdir)/m4/lcmessage.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/sockaddrin6.m4 \ + $(top_srcdir)/m4/sockinttypes.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +binSCRIPT_INSTALL = $(INSTALL_SCRIPT) +SCRIPTS = $(bin_SCRIPTS) +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +EBCONF_EBINCS = @EBCONF_EBINCS@ +EBCONF_EBLIBS = @EBCONF_EBLIBS@ +EBCONF_INTLINCS = @EBCONF_INTLINCS@ +EBCONF_INTLLIBS = @EBCONF_INTLLIBS@ +EBCONF_ZLIBINCS = @EBCONF_ZLIBINCS@ +EBCONF_ZLIBLIBS = @EBCONF_ZLIBLIBS@ +EB_VERSION_MAJOR = @EB_VERSION_MAJOR@ +EB_VERSION_MINOR = @EB_VERSION_MINOR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_EBNET = @ENABLE_EBNET@ +ENABLE_NLS = @ENABLE_NLS@ +ENABLE_PTHREAD = @ENABLE_PTHREAD@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +ICONVINCS = @ICONVINCS@ +ICONVLIBS = @ICONVLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLINCS = @INTLINCS@ +INTLLIBS = @INTLLIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBEB_VERSION_INFO = @LIBEB_VERSION_INFO@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAILING_ADDRESS = @MAILING_ADDRESS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_CPPFLAGS = @PTHREAD_CPPFLAGS@ +PTHREAD_LDFLAGS = @PTHREAD_LDFLAGS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +ZLIBDEPS = @ZLIBDEPS@ +ZLIBINCS = @ZLIBINCS@ +ZLIBLIBS = @ZLIBLIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgdocdir = @pkgdocdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +bin_SCRIPTS = ebappendix +EXTRA_DIST = ebappendix.in +CLEANFILES = ebappendix ebappendix.tmp +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ebappendix/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu ebappendix/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binSCRIPTS: $(bin_SCRIPTS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_SCRIPTS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f $$d$$p; then \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " $(binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f"; \ + else :; fi; \ + done + +uninstall-binSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(bin_SCRIPTS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(SCRIPTS) +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: install-binSCRIPTS + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binSCRIPTS + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binSCRIPTS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + uninstall uninstall-am uninstall-binSCRIPTS + + +ebappendix: ebappendix.in $(top_srcdir)/libebutils/getopt_long.pl Makefile + rm -f ebappendix + sed -e 's;\@PERL\@;$(PERL);' \ + $(srcdir)/ebappendix.in | sed '/^$$/q' > ebappendix.tmp + cat $(top_srcdir)/libebutils/getopt_long.pl >> ebappendix.tmp + sed -e 's;\@VERSION\@;$(VERSION);' \ + -e 's;\@MAILING_ADDRESS\@;$(MAILING_ADDRESS);' \ + $(srcdir)/ebappendix.in | sed '1,/^$$/d' >> ebappendix.tmp + cp ebappendix.tmp ebappendix + chmod +x ebappendix + rm -f ebappendix.tmp +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/ebappendix/ebappendix.in b/ebappendix/ebappendix.in new file mode 100644 index 0000000..901d5d5 --- /dev/null +++ b/ebappendix/ebappendix.in @@ -0,0 +1,753 @@ +#! @PERL@ + +# +# Copyright (c) 1997-2006 Motoyuki Kasahara +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +require 5.005; +use File::Basename; + +# Program name, program version and mailing address. +my $progname='ebappendix'; +my $version = '@VERSION@'; +my $mailing_address = '@MAILING_ADDRESS@'; + +# Help message. +my $help = "Usage: $progname [option...] [input-directory] +Options: + -b BOOK-TYPE --book-type BOOK-TYPE + make an appendix as BOOK-TYPE; eb or epwing + (default: depend on \`catalog(s).app\') + -d --debug --verbose debug mode + -h --help output this help, then exit + -n --no-catalog don't output a catalog file + -o DIRECTORY --output-directory DIRECTORY + output files to DIRECTORY + (default: .) + -t --test only check for input files + -v --version output version number, then exit + +Argument: + input-directory input files at this directory + (default: .) + +Report bugs to $mailing_address. +"; + +# `try ...' message. +my $tryhelp = "try \`$0 --help\' for more information\n"; + +# Disc type: `eb' or `epwing'. +my $disc = ''; + +# Read files on the directory. +my $indir = '.'; + +# Create files under the directory. +my $outdir = '.'; + +# The maximum number of subbooks in a book. +my $max_subbooks = 50; + +# Subbook list. +my @subbooks = (); + +# The maximum length of an alternation text for a character. +my $maxlen_alt = 31; + +# The maximum length of a subbook name. +my $maxlen_subname = 8; + +# Page size. +my $size_page = 2048; + +# File mode for mkdir. +my $dirmode = umask ^ 0777; + +# Test mode flag. +my $check_only = 0; + +# Debug mode flag. +my $debug = 0; + +# No-catalog mode. +my $no_catalog = 0; + +# Show help then exit. +my $help_only = 0; + +# Show version then exit. +my $version_only = 0; + +# Command line options. +@long_options = ('-b --book-type required-argument', + '-d --debug --verbose no-argument', + '-h --help no-argument', + '-n --no-catalog no-argument', + '-o --output-directory required-argument', + '-t --test no-argument', + '-v --version no-argument'); + +# +# Parse command line options. +# +&getopt_initialize(@long_options); +while (($optname, $optarg) = &getopt_long) { + if ($optname eq '-b') { + if ($optarg !~ /^(eb|epwing)$/i) { + warn "$0: unknown book type \`$optarg\'\n"; + die $tryhelp; + } + $disc = lc($optarg); + } elsif ($optname eq '-d') { + $debug = 1; + } elsif ($optname eq '-h') { + print $help; + exit(0); + } elsif ($optname eq '-n') { + $no_catalog = 1; + } elsif ($optname eq '-o') { + $outdir = $optarg; + } elsif ($optname eq '-v') { + print "$progname (EB Library) version $version\n"; + print $copyright; + exit(0); + } elsif ($optname eq '-t') { + $check_only = 1; + } else { + die $tryhelp; + } +} + +$indir = shift if (0 < @ARGV); +if (@ARGV != 0) { + warn "$0: too many arguments\n"; + die $tryhelp; +} + +# +# Remove a slash (`/') in the tail of the directory names. +# +$indir =~ s/\/$//; +$outdir =~ s/\/$//; + +# +# Compose filenames. +# +my $infile = find_file($indir, 'catalog.app', 'undef'); +if (!defined($infile)) { + $infile = find_file($indir, 'catalogs.app', 'undef'); +} +if (!defined($infile)) { + die "catalog(s).app: no such file\n"; +} + +if ($disc ne 'eb' && $disc ne 'epwing') { + if (basename($infile) =~ /^catalog\.app/i) { + $disc = 'eb'; + } else { + $disc = 'epwing'; + } +} + +my $outfile; +if ($disc eq 'eb') { + $outfile = find_file($outdir, 'catalog', 'default'); +} else { + $outfile = find_file($outdir, 'catalogs', 'default'); +} + +# +# Open the `CATALOG(S).APP' file to read. +# +if (!open(CATALOG_APP, $infile)) { + die "$infile: cannot open the file, $!\n"; +} + +# +# Read a subbook list from `CATALOG(S).APP'. +# +while () { + s/^\s+//; + s/\s+$//; + next if (/^$/ || /^\#/); + push(@subbooks, lc($_)); +} + +# +# Checks for subbook names. +# +die "$infile: no subbooks described\n" if (@subbooks == 0); +die "$infile: too many subbooks\n" if ($max_subbooks < @subbooks); +foreach my $sub (@subbooks) { + die "$infile: invalid subbook name \`$sub\'\n" + if ($sub !~ /\w{1,$maxlen_subname}/); +} + +# +# Close the file `CATALOG(S).APP'. +# +close(CATALOG_APP); + +# +# Create the `CATALOG(S)' file. +# +if (!$check_only && !$no_catalog) { + # + # Open the `CATALOG(S)' file to write. + # + if (!open(CATALOG, "> $outfile")) { + die "$outfile: cannot open the file, $!\n"; + } + + # + # Write the number of subbooks in the book. + # + print CATALOG "\0", pack('C', scalar(@subbooks)), "\0" x 14; + + # + # Write subbook names. + # + for (my $i = 0; $i < @subbooks; $i++) { + if ($disc eq 'eb') { + print CATALOG pack('C', $i + 1), "\0"; + print CATALOG "\0" x 30; + print CATALOG uc($subbooks[$i]); + print CATALOG "\0" x ($maxlen_subname - length($subbooks[$i])); + } else { + print CATALOG pack('C', $i + 1), "\0"; + print CATALOG "\0" x 80; + print CATALOG uc($subbooks[$i]); + print CATALOG "\0" x ($maxlen_subname - length($subbooks[$i])); + print CATALOG "\0" x 74; + } + } + + # + # Close the `CATALOG(S)' file. + # + close(CATALOG); +} + +# +# Create `APPENDIX (or FUROKU)' files. +# +foreach my $sub (@subbooks) { + # + # Compose filenames. + # + $infile = find_file($indir, "$sub.app"); + die "$sub.app: no such file\n" if (!defined($infile)); + + if ($disc eq 'eb') { + $outfile = find_file($outdir, "$sub/appendix", 'default'); + } else { + $outfile = find_file($outdir, "$sub/data/furoku", 'default'); + } + $outfile =~ s|//+|/|g; + + # + # Open the `.APP' file to read. + # + if (!open(SUBBOOK_APP, $infile)) { + warn "$infile: cannot open the file, $!\n"; + next; + } + warn "$infile: debug: opened\n" if ($debug); + + my $narrow_def = 0; + my $narrow_start = 0; + my $narrow_start_def = 0; + my $narrow_end = 0; + my $narrow_end_def = 0; + my $narrow_len = 0; + my %narrow_alt = (); + my %narrow_lineno = (); + + my $wide_def = 0; + my $wide_start = 0; + my $wide_start_def = 0; + my $wide_end = 0; + my $wide_end_def = 0; + my $wide_len = 0; + my %wide_alt = (); + my %wide_lineno = (); + + my @stop = (); + my $stop_def = 0; + my $code = 'JISX0208'; + my $code_def = 0; + my $block = ''; + + my $start = \$narrow_start; + my $start_def = \$narrow_start_def; + my $end = \$narrow_end; + my $end_def = \$narrow_end_def; + my $alt = \%narrow_alt; + my $lineno = \%narrow_lineno; + + # + # Parse each line in `.APP'. + # + while () { + s/^\s+//; + s/\s+$//; + next if (/^$/ || /^\#/); + + my ($key, $arg) = split(/[ \t]+/, $_, 2); + + if ($key eq 'begin') { + # + # `begin ...' + # + die "$infile:$.: unexpected \`$key\'\n" if ($block ne ''); + die "$infile:$.: missing argument to \`$key\'\n" if ($arg eq ''); + + if ($arg eq 'narrow') { + # + # `begin narrow' + # + die "$infile:$.: block \`$arg\' is redefined\n" + if (0 < $narrow_def++); + + $block = $arg; + $start = \$narrow_start; + $start_def = \$narrow_start_def; + $end = \$narrow_end; + $end_def = \$narrow_end_def; + $alt = \%narrow_alt; + $lineno = \%narrow_lineno; + warn "$infile:$.: debug: $key $arg\n" if ($debug); + + } elsif ($arg eq 'wide') { + # + # `begin wide' + # + die "$infile:$.: block \`$arg\' is redefined\n" + if (0 < $wide_def++); + + $block = $arg; + $start = \$wide_start; + $start_def = \$wide_start_def; + $end = \$wide_end; + $end_def = \$wide_end_def; + $alt = \%wide_alt; + $lineno = \%wide_lineno; + warn "$infile:$.: debug: $key $arg\n" if ($debug); + + } else { + die "$infile:$.: invalid argument \`$arg\'\n"; + } + + } elsif ($key eq 'end') { + # + # `end' + # + die "$infile:$.: unexpected \`$key\'\n" if ($block eq ''); + die "$infile:$.: not allowed argument to \`$key\'\n" + if ($arg ne ''); + + $block = ''; + warn "$infile:$.: debug: $key\n" if ($debug); + + } elsif ($key eq 'range-start') { + # + # `range-start' + # + die "$infile:$.: unexpected \`$key\'\n" + if ($block ne 'narrow' && $block ne 'wide'); + die "$infile:$.: incorrect hexadecimal number.\n" + if ($arg !~ /^0[xX]([0-9a-fA-F]{4})$/); + die "$infile:$.: \`$key\' is redefined\n" if (0 < $$start_def++); + + $$start = hex($1); + warn "$infile:$.: debug: $key $arg\n" if ($debug); + + } elsif ($key eq 'range-end') { + # + # `range-end' + # + die "$infile:$.: unexpected \`$key\'\n" + if ($block ne 'narrow' && $block ne 'wide'); + die "$infile:$.: incorrect hexadecimal number.\n" + if ($arg !~ /^0[xX]([0-9a-fA-F]{4})$/); + die "$infile:$.: \`$key\' is redefined\n" if (0 < $$end_def++); + + $$end = hex($1); + warn "$infile:$.: debug: $key $arg\n" if ($debug); + + } elsif ($key =~ /^0[xX]/) { + # + # `0x' + # + die "$infile:$.: unexpected \`$key\'\n" + if ($block ne 'narrow' && $block ne 'wide'); + die "$infile:$.: incorrect hexadecimal number.\n" + if ($key !~ /^0[xX]([0-9a-fA-F]{4})$/); + + my $ch = hex($1); + $arg = &convert_to_euc($arg); + my $len = length($arg); + + die "$infile:$.: alternation string too long\n" + if ($maxlen_alt < $len); + die "$infile:$.: character \`$key\' redefined\n" + if (defined($alt->{$ch})); + + $alt->{$ch} = $arg; + $lineno->{$ch} = $.; + warn "$infile:$.: debug: $key\n" if ($debug); + + } elsif ($key eq 'character-code') { + # + # `character-code' + # + die "$infile:$.: unexpected \`$key\'\n" if ($block ne ''); + die "$infile:$.: \`$key\' redefined\n" if (0 < $code_def++); + die "$infile:$.: invalid character code \`$arg\'\n" + if ($arg !~ /^(JISX0208|ISO8859-1)$/i); + $code = uc($arg); + warn "$infile:$.: debug: $key $arg\n" if ($debug); + + } elsif ($key eq 'stop-code') { + # + # `stop-code' + # + die "$infile:$.: unexpected \`$key\'\n" if ($block ne ''); + die "$infile:$.: \`$key\' redefined\n" if (0 < $stop_def++); + die "$infile:$.: invalid stop-code \`$arg\'\n" + if ($arg !~ /^0x1f(09|41)\s*0x([0-9a-f]{2})([0-9a-f]{2})$/i); + @stop = (0x1f, hex($1), hex($2), hex($3)); + warn "$infile:$.: debug: $key $arg\n" if ($debug); + + } else { + die "$infile:$.: unknown keyword \`$key\'\n"; + } + } + # End of parsing each line in `.APP'. + + # + # Close the `.APP' file. + # + close(SUBBOOK_APP); + warn "$infile: debug: closed\n" if ($debug); + + # + # Check for `character-code' definition. + # + die "$infile: missing \`character-code\'\n" + if ($code_def == 0 && ($narrow_def != 0 || $wide_def != 0)); + + # + # Check for the range of alternation. + # + if (0 < $narrow_def) { + die "$infile: missing \`range-start\' in the narrow block\n" + if ($narrow_start_def == 0); + die "$infile: missing \`range-end\' in the narrow block\n" + if ($narrow_end_def == 0); + + if ($code eq 'JISX0208') { + $narrow_len = (($narrow_end >> 8) - ($narrow_start >> 8)) * 0x5e + + (($narrow_end & 0xff) - ($narrow_start & 0xff)) + 1; + } else { + $narrow_len = (($narrow_end >> 8) - ($narrow_start >> 8)) * 0xfe + + (($narrow_end & 0xff) - ($narrow_start & 0xff)) + 1; + } + + if ($code eq 'JISX0208') { + while (my ($key, $arg) = each(%narrow_alt)) { + warn "$infile:$narrow_lineno{$key}: out of range\n" + if ($key < $narrow_start || $narrow_end < $key + || ($key & 0xff) < 0x21 || 0x7e < ($key & 0xff)); + } + } else { + while (my ($key, $arg) = each(%narrow_alt)) { + warn "$infile:$narrow_lineno{$key}: out of range\n" + if ($key < $narrow_start || $narrow_end < $key + || ($key & 0xff) < 0x01 || 0xfe < ($key & 0xff)); + } + } + } + + if (0 < $wide_def) { + die "$infile: missing \`range-start\' in the wide block\n" + if ($wide_start_def == 0); + die "$infile: missing \`range-end\' in the wide block\n" + if ($wide_end_def == 0); + + if ($code eq 'JISX0208') { + $wide_len = (($wide_end >> 8) - ($wide_start >> 8)) * 0x5e + + (($wide_end & 0xff) - ($wide_start & 0xff)) + 1; + } else { + $wide_len = (($wide_end >> 8) - ($wide_start >> 8)) * 0xfe + + (($wide_end & 0xff) - ($wide_start & 0xff)) + 1; + } + + if ($code eq 'JISX0208') { + while (my ($key, $arg) = each(%wide_alt)) { + warn "$infile:$wide_lineno{$key}: out of range\n" + if ($key < $wide_start || $wide_end < $key + || ($key & 0xff) < 0x21 || 0x7f < ($key & 0xff)); + } + } else { + while (my ($key, $arg) = each(%wide_alt)) { + warn "$infile:$wide_lineno{$key}: out of range\n" + if ($key < $wide_start || $wide_end < $key + || ($key & 0xff) < 0x01 || 0xfe < ($key & 0xff)); + } + } + } + + next if ($check_only); + + # + # Create a subdirectory for the subbook, if missing. + # + my $outsubdir = dirname($outfile); + if (mkinstalldirs($outsubdir, $dirmode)) { + warn "$outdir: debug: directory cleated\n" if ($debug); + } else { + die "$outdir: cannot create the directory, $!\n"; + } + + # + # Open the file `APPENDIX (or FUROKU)' to read. + # + if (!open(APPENDIX, "> $outfile")) { + die "$outfile: cannot open the file, $!\n"; + } + warn "$outfile: debug: opened\n" if ($debug); + + # + # Fill the index page with zero. + # + seek(APPENDIX, 0, 0); + print APPENDIX "\0" x $size_page; + + # + # Output alternation text for narrow font characters. + # + my $narrow_page = 0; + if (0 < $narrow_def) { + $narrow_page = int(1 + tell(APPENDIX) / $size_page); + + # + # Output alternation text. + # + my $i = $narrow_start; + while ($i <= $narrow_end) { + if (defined($narrow_alt{$i})) { + print APPENDIX $narrow_alt{$i}, "\0", + "\0" x ($maxlen_alt - length($narrow_alt{$i})); + } else { + print APPENDIX "\0" x 32; + } + printf STDERR "$outfile: debug: wrote 0x%04x\n", $i + if ($debug); + + if ($code eq 'JISX0208') { + $i += (($i & 0xff) < 0x7e) ? 1 : 0xa3; + } else { + $i += (($i & 0xff) < 0xfe) ? 1 : 3; + } + } + my $pad = $size_page - tell(APPENDIX) % $size_page; + print APPENDIX "\0" x $pad if ($pad != 0); + } + + # + # Output alternation text for wide font characters. + # + my $wide_page = 0; + if (0 < $wide_def) { + $wide_page = 1 + int(tell(APPENDIX) / $size_page); + + # + # Output alternation text. + # + my $i = $wide_start; + while ($i <= $wide_end) { + if (defined($wide_alt{$i})) { + print APPENDIX $wide_alt{$i}, "\0", + "\0" x ($maxlen_alt - length($wide_alt{$i})); + } else { + print APPENDIX "\0" x 32; + } + printf STDERR "$outfile: debug: wrote 0x%04x\n", $i + if ($debug); + + if ($code eq 'JISX0208') { + $i += (($i & 0xff) < 0x7e) ? 1 : 0xa3; + } else { + $i += (($i & 0xff) < 0xfe) ? 1 : 3; + } + } + my $pad = $size_page - tell(APPENDIX) % $size_page; + print APPENDIX "\0" x $pad if ($pad != 0); + } + + # + # Output a stop-code. + # + my $stop_page = 1 + int(tell(APPENDIX) / $size_page); + if (0 < $stop_def) { + print APPENDIX "\0\1", pack("C4", @stop); + warn "$outfile: debug: wrote stop-code\n" if ($debug); + } + my $pad = $size_page - tell(APPENDIX) % $size_page; + print APPENDIX "\0" x $pad if ($pad != 0); + + # + # Output an index page. + # + seek(APPENDIX, 0, 0); + print APPENDIX "\0\3", ($code eq 'JISX0208') ? "\0\002" : "\0\001", + "\0" x 12; + + if (0 < $narrow_def) { + print APPENDIX pack("N", $narrow_page), "\0" x 6, + pack("n n", $narrow_start, $narrow_len), "\0\0"; + } else { + print APPENDIX "\0" x 16; + } + + if (0 < $wide_def) { + print APPENDIX pack("N", $wide_page), "\0" x 6, + pack("n n", $wide_start, $wide_len), "\0\0"; + } else { + print APPENDIX "\0" x 16; + } + + if (0 < $stop_def) { + print APPENDIX pack("N", $stop_page), "\0" x 12; + } else { + print APPENDIX "\0" x 16; + } + + close(APPENDIX); + warn "$outfile: debug: closed\n" if ($debug); +} + +exit; + +# +# Find file $target under $dir. +# +sub find_file { + my ($dir, $target, $mode) = @_; + my $result = $dir; + my @target_entries = split(/\/+/, $target); + + for (my $i = 0; $i < @target_entries; $i++) { + my $found; + my $normalized_target_entry = lc($target_entries[$i]); + $normalized_target_entry =~ s/;\d$//; + $normalized_target_entry =~ s/\.$//; + + if (opendir(DIR, $result)) { + while (my $entry = readdir(DIR)) { + if ($i < @target_entries - 1) { + next if (! -d "$result/$entry"); + } else { + next if (! -f "$result/$entry"); + } + my $normalized_entry = lc($entry); + $normalized_entry =~ s/;\d$//; + $normalized_entry =~ s/\.$//; + if ($normalized_target_entry eq $normalized_entry) { + $found = $entry; + last; + } + } + closedir(DIR); + } + + if (defined($found)) { + $result = $result . '/' . $found; + } elsif ($mode eq 'undef') { + return undef; + } else { + $result = $result . '/' . $target_entries[$i]; + } + } + + return $result; +} + +sub dirname { + my ($dir) = @_; + my $result; + + if ($dir !~ /\//) { + $result = '.'; + } else { + $result = $dir; + $result =~ s/\/+[^\/]+$//; + } + + return $result; +} + +sub mkinstalldirs { + my ($dir, $mode) = @_; + my $path = ''; + + foreach my $d (split(/\/+/, $dir)) { + if ($path eq '') { + $path = ($dir =~ /^\//) ? '/' : $d; + } else { + $path = "$path/$d"; + } + next if (-d $path); + return 0 if (!mkdir($path, $mode)); + } + + return 1; +} + +# +# Convert a string to EUC JP. +# +sub convert_to_euc { + my ($s) = @_; + while ($s =~ /\033(\([BJ]|\$[\@B])/) { + $s =~ s/\033\$[\@B]([^\033]*)/&convert_to_euc_tr($1)/eg; + $s =~ s/\033\([BJ]([^\033]*)/$1/eg; + } + return $s; +} + +sub convert_to_euc_tr { + my ($s) = @_; + $s =~ tr/\041-\176/\241-\376/; + return $s; +} + +# Local Variables: +# mode: perl +# End: diff --git a/ebfont/Makefile.am b/ebfont/Makefile.am new file mode 100644 index 0000000..122e179 --- /dev/null +++ b/ebfont/Makefile.am @@ -0,0 +1,14 @@ +localedir = $(datadir)/locale + +LIBEB = $(top_builddir)/eb/libeb.la +LIBEBUTILS = $(top_builddir)/libebutils/libebutils.a + +bin_PROGRAMS = ebfont + +ebfont_SOURCES = ebfont.c +ebfont_LDADD = $(LIBEBUTILS) $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) $(ICONVLIBS) +ebfont_DEPENDENCIES = $(LIBEBUTILS) $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) \ + $(ICONVDEPS) + +INCLUDES = -I../libebutils -I$(top_srcdir)/libebutils -I$(top_srcdir) \ + $(INTLINCS) diff --git a/ebfont/Makefile.in b/ebfont/Makefile.in new file mode 100644 index 0000000..4c43489 --- /dev/null +++ b/ebfont/Makefile.in @@ -0,0 +1,502 @@ +# Makefile.in generated by automake 1.10.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = ebfont$(EXEEXT) +subdir = ebfont +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/in6addr.m4 $(top_srcdir)/m4/largefile.m4 \ + $(top_srcdir)/m4/lcmessage.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/sockaddrin6.m4 \ + $(top_srcdir)/m4/sockinttypes.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_ebfont_OBJECTS = ebfont.$(OBJEXT) +ebfont_OBJECTS = $(am_ebfont_OBJECTS) +am__DEPENDENCIES_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(ebfont_SOURCES) +DIST_SOURCES = $(ebfont_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +EBCONF_EBINCS = @EBCONF_EBINCS@ +EBCONF_EBLIBS = @EBCONF_EBLIBS@ +EBCONF_INTLINCS = @EBCONF_INTLINCS@ +EBCONF_INTLLIBS = @EBCONF_INTLLIBS@ +EBCONF_ZLIBINCS = @EBCONF_ZLIBINCS@ +EBCONF_ZLIBLIBS = @EBCONF_ZLIBLIBS@ +EB_VERSION_MAJOR = @EB_VERSION_MAJOR@ +EB_VERSION_MINOR = @EB_VERSION_MINOR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_EBNET = @ENABLE_EBNET@ +ENABLE_NLS = @ENABLE_NLS@ +ENABLE_PTHREAD = @ENABLE_PTHREAD@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +ICONVINCS = @ICONVINCS@ +ICONVLIBS = @ICONVLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLINCS = @INTLINCS@ +INTLLIBS = @INTLLIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBEB_VERSION_INFO = @LIBEB_VERSION_INFO@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAILING_ADDRESS = @MAILING_ADDRESS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_CPPFLAGS = @PTHREAD_CPPFLAGS@ +PTHREAD_LDFLAGS = @PTHREAD_LDFLAGS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +ZLIBDEPS = @ZLIBDEPS@ +ZLIBINCS = @ZLIBINCS@ +ZLIBLIBS = @ZLIBLIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = $(datadir)/locale +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgdocdir = @pkgdocdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +LIBEB = $(top_builddir)/eb/libeb.la +LIBEBUTILS = $(top_builddir)/libebutils/libebutils.a +ebfont_SOURCES = ebfont.c +ebfont_LDADD = $(LIBEBUTILS) $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) $(ICONVLIBS) +ebfont_DEPENDENCIES = $(LIBEBUTILS) $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) \ + $(ICONVDEPS) + +INCLUDES = -I../libebutils -I$(top_srcdir)/libebutils -I$(top_srcdir) \ + $(INTLINCS) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ebfont/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu ebfont/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +ebfont$(EXEEXT): $(ebfont_OBJECTS) $(ebfont_DEPENDENCIES) + @rm -f ebfont$(EXEEXT) + $(LINK) $(ebfont_OBJECTS) $(ebfont_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ebfont.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-binPROGRAMS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/ebfont/ebfont.c b/ebfont/ebfont.c new file mode 100644 index 0000000..44c23e0 --- /dev/null +++ b/ebfont/ebfont.c @@ -0,0 +1,1059 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef ENABLE_NLS +#ifdef HAVE_LOCALE_H +#include +#endif +#include +#endif + +#include "eb/eb.h" +#include "eb/error.h" +#include "eb/font.h" + +#include "getopt.h" +#include "getumask.h" +#include "makedir.h" +#include "ebutils.h" + +#ifndef HAVE_STRCASECMP +int strcasecmp(const char *, const char *); +int strncasecmp(const char *, const char *, size_t); +#endif + +#ifndef O_BINARY +#define O_BINARY 0 +#endif + +/* + * The maximum length of path name. + */ +#ifndef PATH_MAX +#ifdef MAXPATHLEN +#define PATH_MAX MAXPATHLEN +#else /* not MAXPATHLEN */ +#define PATH_MAX 1024 +#endif /* not MAXPATHLEN */ +#endif /* not PATH_MAX */ + +/* + * Tricks for gettext. + */ +#ifdef ENABLE_NLS +#define _(string) gettext(string) +#ifdef gettext_noop +#define N_(string) gettext_noop(string) +#else +#define N_(string) (string) +#endif +#else +#define _(string) (string) +#define N_(string) (string) +#endif + +/* + * Trick for difference of path notation between UNIX and DOS. + */ +#ifndef DOS_FILE_PATH +#define F_(path1, path2) (path1) +#else +#define F_(path1, path2) (path2) +#endif + +/* + * Command line options. + */ +static const char *short_options = "df:hi:o:S:v"; +static struct option long_options[] = { + {"debug", no_argument, NULL, 'd'}, + {"verbose", no_argument, NULL, 'd'}, + {"font-height", required_argument, NULL, 'f'}, + {"help", no_argument, NULL, 'h'}, + {"image-format", required_argument, NULL, 'i'}, + {"subbook", required_argument, NULL, 'S'}, + {"output-directory", required_argument, NULL, 'o'}, + {"version", no_argument, NULL, 'v'}, + {NULL, 0, NULL, 0} +}; + +/* + * Supported image formats. + */ +typedef int Image_Format_Code; + +typedef struct { + const char *name; + const char *suffix; + EB_Error_Code (*function)(const char *bitmap_data, int width, int height, + char *image_data, size_t *image_size); +} Image_Format; + +static Image_Format image_formats[] = { + {"xbm", "xbm", eb_bitmap_to_xbm}, + {"xpm", "xpm", eb_bitmap_to_xpm}, + {"gif", "gif", eb_bitmap_to_gif}, + {"bmp", "bmp", eb_bitmap_to_bmp}, + {"png", "png", eb_bitmap_to_png}, + {NULL, NULL, NULL} +}; + +#define MAX_IMAGE_FORMATS 5 +#define MAX_LENGTH_IMAGE_NAME 3 +#define MAX_LENGTH_IMAGE_SUFFIX 3 + +/* + * Program name and version. + */ +static const char *program_name = "ebfont"; +static const char *program_version = VERSION; +static const char *invoked_name; + +/* + * Debug flag. + */ +static int debug_flag; + +/* + * List of target subbook names. + */ +char subbook_name_list[EB_MAX_SUBBOOKS][EB_MAX_DIRECTORY_NAME_LENGTH + 1]; +int subbook_name_count = 0; + +/* + * List of target subbook codes. + */ +static EB_Subbook_Code subbook_list[EB_MAX_SUBBOOKS]; +static int subbook_count = 0; + +/* + * List of target font heights. + */ +static EB_Font_Code font_list[EB_MAX_FONTS]; +static int font_count = 0; + +/* + * Target Image formats. + */ +static Image_Format_Code image_list[MAX_IMAGE_FORMATS]; +static int image_count = 0; + +/* + * Defaults and limitations. + */ +#define DEFAULT_FONT_HEIGHT "16" +#define DEFAULT_IMAGE_FORMAT "xbm" +#define DEFAULT_BOOK_DIRECTORY "." +#define DEFAULT_OUTPUT_DIRECTORY "." + +#define MAX_LENGTH_FONT_NAME 2 +#define MAX_LENGTH_STRING 255 + +/* + * Unexported functions. + */ +static int parse_font_argument(const char *argument, EB_Font_Code *font_list, + int *font_count); +static int parse_image_argument(const char *argument, + Image_Format_Code *image_list, int *image_count); +static void output_help(void); +static int make_book_fonts(EB_Book *book, const char *out_path, + EB_Subbook_Code *subbook_list, int subbook_count, EB_Font_Code *font_list, + int font_count, Image_Format_Code *image_list, int image_count); +static int make_subbook_fonts(EB_Book *book, const char *subbook_path, + EB_Font_Code *font_list, int font_count, Image_Format_Code *image_list, + int image_count); +static int make_subbook_size_fonts(EB_Book *book, const char *font_path, + Image_Format_Code *image_list, int image_count); +static int make_subbook_size_image_fonts(EB_Book *book, const char *image_path, + Image_Format_Code image); +static int save_image_file(const char *file_name, const char *image_data, + size_t image_size); + + +int +main(int argc, char *argv[]) +{ + const char *book_path; + char out_path[PATH_MAX + 1]; + EB_Error_Code error_code; + EB_Book book; + int ch; + + invoked_name = argv[0]; + debug_flag = 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; + } + eb_initialize_book(&book); + + /* + * Parse command line options. + */ + for (;;) { + ch = getopt_long(argc, argv, short_options, long_options, NULL); + if (ch == -1) + break; + switch (ch) { + case 'd': + /* + * Option `-d'. Debug mode. + */ + debug_flag = 1; + break; + + case 'f': + /* + * Option `-f'. Generate fonts with HEIGHT. + */ + if (parse_font_argument(optarg, font_list, &font_count) < 0) { + output_try_help(invoked_name); + goto die; + } + break; + + case 'h': + /* + * Option `-h'. Display help message, then exit. + */ + output_help(); + exit(0); + + case 'i': + /* + * Option `-i'. Generate fonts as FORMAT. + */ + if (parse_image_argument(optarg, image_list, &image_count) < 0) { + output_try_help(invoked_name); + goto die; + } + break; + + case 'o': + /* + * Option `-o'. Output fonts under DIRECTORY. + * The file names of fonts are: + * "//fonts//{narrow,wide}/ + * ." + * + * : is `optarg'. + * : require EB_MAX_DIRECTORY_NAME_LENGTH characters. + * fonts: require 5 characters. + * : require 2 characters ("16", "24", "32", or "48"). + * {narrow,wide}: + * requre 6 characters (= strlen("narrow")). + * : requre 4 characters. ("0000" ... "ffff") + * : requre MAX_LENGTH_IMAGE_SUFFIX characters. + */ + if (PATH_MAX < strlen(optarg)) { + fprintf(stderr, _("%s: too long output directory path\n"), + invoked_name); + goto die; + } + strcpy(out_path, optarg); + canonicalize_path(out_path); + if (PATH_MAX < strlen(out_path) + 1 + EB_MAX_DIRECTORY_NAME_LENGTH + + 1 + 5 + 1 + 2 + 1 + 6 + 1 + 4 + 1 + + MAX_LENGTH_IMAGE_SUFFIX) { + 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) { + output_try_help(invoked_name); + goto die; + } + 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; + } + + if (image_count == 0) + parse_image_argument(DEFAULT_IMAGE_FORMAT, image_list, &image_count); + + if (font_count == 0) + parse_font_argument(DEFAULT_FONT_HEIGHT, font_list, &font_count); + + /* + * Set a book path. + */ + if (argc == optind) + book_path = DEFAULT_BOOK_DIRECTORY; + else + book_path = argv[optind]; + + /* + * Bind a book. + */ + error_code = eb_bind(&book, book_path); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s\n", invoked_name, + eb_error_message(error_code)); + goto die; + } + + /* + * For each targe subbook, convert a subbook-names to a subbook-codes. + * If no subbook is specified by `--subbook'(`-S'), set all subbooks + * as the target. + */ + if (subbook_name_count == 0) { + error_code = eb_subbook_list(&book, subbook_list, &subbook_count); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s\n", invoked_name, + eb_error_message(error_code)); + goto die; + } + } else { + int i; + EB_Subbook_Code sub; + + for (i = 0; i < subbook_name_count; i++) { + error_code = find_subbook(&book, subbook_name_list[i], &sub); + if (error_code != EB_SUCCESS) { + fprintf(stderr, _("%s: unknown subbook name `%s'\n"), + invoked_name, subbook_name_list[i]); + } + subbook_list[subbook_count++] = sub; + } + } + + /* + * Make image files for fonts in the book. + */ + if (make_book_fonts(&book, out_path, subbook_list, subbook_count, + font_list, font_count, image_list, image_count) < 0) + goto die; + + /* + * Dispose the book. + */ + eb_finalize_book(&book); + eb_finalize_library(); + + return 0; + + /* + * A critical error occurs... + */ + die: + fflush(stderr); + eb_finalize_book(&book); + eb_finalize_library(); + exit(1); +} + + +/* + * Parse an argument to option `--font-height (-f)' + */ +static int +parse_font_argument(const char *argument, EB_Font_Code *font_list, + int *font_count) +{ + const char *argument_p = argument; + char font_name[MAX_LENGTH_FONT_NAME + 1]; + char *font_name_p; + EB_Font_Code font_code; + int i; + + while (*argument_p != '\0') { + /* + * Take a next element in the argument. + */ + i = 0; + font_name_p = font_name; + while (*argument_p != ',' && *argument_p != '\0' + && i < MAX_LENGTH_FONT_NAME) { + *font_name_p = *argument_p; + i++; + font_name_p++; + argument_p++; + } + *font_name_p = '\0'; + if (*argument_p == ',') + argument_p++; + else if (*argument_p != '\0') { + fprintf(stderr, _("%s: unknown font height `%s...'\n"), + invoked_name, font_name); + goto failed; + } + + /* + * Check for the font name. + */ + if (strcmp(font_name, "16") == 0) + font_code = EB_FONT_16; + else if (strcmp(font_name, "24") == 0) + font_code = EB_FONT_24; + else if (strcmp(font_name, "30") == 0) + font_code = EB_FONT_30; + else if (strcmp(font_name, "48") == 0) + font_code = EB_FONT_48; + else { + fprintf(stderr, _("%s: unknown font height `%s'\n"), + invoked_name, font_name); + fflush(stderr); + goto failed; + } + + /* + * If the font name is not found in `font_list', it is added to + * the list. + */ + for (i = 0; i < *font_count; i++) { + if (*(font_list + i) == font_code) + break; + } + if (*font_count <= i) { + *(font_list + i) = font_code; + (*font_count)++; + } + } + + return 0; + + /* + * An error occurs... + */ + failed: + fflush(stderr); + return -1; +} + + +/* + * Parse an argument to option `--font-image-format (-i)' + */ +static int +parse_image_argument(const char *argument, Image_Format_Code *image_list, + int *image_count) +{ + const char *argument_p = argument; + char image_name[MAX_LENGTH_IMAGE_NAME + 1]; + char *image_name_p; + int image_code; + int i; + + while (*argument_p != '\0') { + /* + * Take a next element in the argument. + */ + i = 0; + image_name_p = image_name; + while (*argument_p != ',' && *argument_p != '\0' + && i < MAX_LENGTH_IMAGE_NAME) { + *image_name_p = *argument_p; + i++; + image_name_p++; + argument_p++; + } + *image_name_p = '\0'; + if (*argument_p == ',') + argument_p++; + else if (*argument_p != '\0') { + fprintf(stderr, _("%s: unknown image format name `%s...'\n"), + invoked_name, image_name); + goto failed; + } + + /* + * Check for the image-format name. + */ + for (i = 0; i < MAX_IMAGE_FORMATS; i++) { + if (strcasecmp((image_formats + i)->name, image_name) == 0) + break; + } + if (MAX_IMAGE_FORMATS <= i) { + fprintf(stderr, _("%s: unknown image format name `%s'\n"), + invoked_name, image_name); + goto failed; + } + image_code = i; + + /* + * If the image-format name is not found in `image_list', it + * is added to the list. + */ + for (i = 0; i < *image_count; i++) { + if (*(image_list + i) == image_code) + break; + } + if (*image_count <= i) { + *(image_list + i) = image_code; + (*image_count)++; + } + } + + return 0; + + /* + * An error occurs... + */ + failed: + fflush(stderr); + return -1; +} + + +/* + * Output help message to standard out, then exit. + */ +static void +output_help(void) +{ + printf(_("Usage: %s [option...] [book-directory]\n"), program_name); + printf(_("Options:\n")); + printf(_(" -d --debug --verbose degug mode\n")); + printf(_(" -f HEIGHT[,HEIGHT...] --font-height HEIGHT[,HEIGHT...]\n")); + printf(_(" generate fonts with HEIGHT; 16, 24, 30 or 48\n")); + printf(_(" (default: %s)\n"), + DEFAULT_FONT_HEIGHT); + printf(_(" -h --help display this help, then exit\n")); + printf(_(" -i FORMAT[,FORMAT...] --image-format FORMAT[,FORMAT...]\n")); + printf(_(" generate fonts as FORMAT;\n")); + printf(_(" xbm, xpm, gif, bmp or png\n")); + printf(_(" (default: %s)\n"), + DEFAULT_IMAGE_FORMAT); + printf(_(" -o DIRECTORY --output-directory DIRECTORY\n")); + printf(_(" output fonts under DIRECTORY\n")); + printf(_(" (default: %s)\n"), + DEFAULT_OUTPUT_DIRECTORY); + printf(_(" -S SUBBOOK[,SUBBOOK...] --subbook SUBBOOK[,SUBBOOK...]\n")); + printf(_(" target subbook\n")); + printf(_(" (default: all subbooks)\n")); + printf(_(" -v --version display version number, then exit\n")); + printf(_("\nArgument:\n")); + printf(_(" book-directory top directory of a CD-ROM book\n")); + printf(_(" (default: %s)\n"), + DEFAULT_BOOK_DIRECTORY); + printf(_("\nReport bugs to %s.\n"), MAILING_ADDRESS); + fflush(stdout); +} + + +/* + * Make font-files in the `book_path'. + */ +static int +make_book_fonts(EB_Book *book, const char *out_path, + EB_Subbook_Code *subbook_list, int subbook_count, EB_Font_Code *font_list, + int font_count, Image_Format_Code *image_list, int image_count) +{ + EB_Error_Code error_code; + char subbook_path[PATH_MAX + 1]; + char subbook_directory[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; + int i; + + /* + * If `book_path' represents "/", replace it to an empty string, + * or `file_name' starts with double slashes. + */ + if (strcmp(out_path, "/") == 0) + out_path++; + + for (i = 0; i < subbook_count; i++) { + /* + * Set the current subbook to `subbook_list[i]'. + */ + error_code = eb_set_subbook(book, subbook_list[i]); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s: subbook=%d\n", invoked_name, + eb_error_message(error_code), subbook_list[i]); + goto failed; + } + + /* + * Get directory name of the subbook. + */ + error_code = eb_subbook_directory(book, subbook_directory); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s: subbook=%d\n", invoked_name, + eb_error_message(error_code), subbook_list[i]); + goto failed; + } + + /* + * Output debug information. + */ + if (debug_flag) { + fprintf(stderr, "%s: debug: subbook %s\n", invoked_name, + subbook_directory); + } + + /* + * Make a directory for the subbook. + */ + sprintf(subbook_path, F_("%s/%s", "%s\\%s"), + out_path, subbook_directory); + if (make_missing_directory(subbook_path, 0777 ^ get_umask()) < 0) + goto failed; + + /* + * Make fonts in the subbook. + */ + if (make_subbook_fonts(book, subbook_path, font_list, font_count, + image_list, image_count) < 0) + goto failed; + } + + return 0; + + /* + * An error occurs... + */ + failed: + fflush(stderr); + return -1; +} + + +/* + * Make font-files in the current subbook. + */ +static int +make_subbook_fonts(EB_Book *book, const char *subbook_path, + EB_Font_Code *font_list, int font_count, Image_Format_Code *image_list, + int image_count) +{ + EB_Error_Code error_code; + char subbook_directory[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; + char font_path[PATH_MAX + 1]; + int font_height; + int i; + + /* + * Get the current subbook name. + */ + error_code = eb_subbook_directory(book, subbook_directory); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s\n", invoked_name, + eb_error_message(error_code)); + goto failed; + } + + if (debug_flag) { + fprintf(stderr, "%s: debug: subbook %s:\n", invoked_name, + subbook_directory); + } + + for (i = 0; i < font_count; i++) { + /* + * Set the current font to `font_list[i]'. + */ + if (!eb_have_font(book, font_list[i])) + continue; + error_code = eb_set_font(book, font_list[i]); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s: subbook=%s, font=%d\n", invoked_name, + eb_error_message(error_code), subbook_directory, i); + goto failed; + } + + /* + * Output debug information. + */ + if (debug_flag) { + fprintf(stderr, "%s: debug: font %d\n", invoked_name, + font_list[i]); + } + + /* + * Make a directory for the font. + */ + eb_font_height2(font_list[i], &font_height); + sprintf(font_path, F_("%s/%d", "%s\\%d"), subbook_path, font_height); + if (make_missing_directory(font_path, 0777 ^ get_umask()) < 0) + goto failed; + + /* + * Make font-files with the size. + */ + if (make_subbook_size_fonts(book, font_path, image_list, image_count) + < 0) + goto failed; + } + + return 0; + + /* + * An error occurs... + */ + failed: + fflush(stderr); + return -1; +} + + +/* + * Make font-files of the current font. + */ +static int +make_subbook_size_fonts(EB_Book *book, const char *font_path, + Image_Format_Code *image_list, int image_count) +{ + EB_Error_Code error_code; + char subbook_directory[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; + int i; + + /* + * Get the current subbook name. + */ + error_code = eb_subbook_directory(book, subbook_directory); + if (subbook_directory == NULL) { + fprintf(stderr, "%s: %s\n", invoked_name, + eb_error_message(error_code)); + goto failed; + } + + for (i = 0; i < image_count; i++) { + /* + * Output debug information. + */ + if (debug_flag) { + fprintf(stderr, "%s: debug: image %s\n", invoked_name, + image_formats[image_list[i]].name); + } + + /* + * Make font-files as the image format. + */ + if (make_subbook_size_image_fonts(book, font_path, image_list[i]) < 0) + goto failed; + } + + return 0; + + /* + * An error occurs... + */ + failed: + fflush(stderr); + return -1; +} + + +/* + * Make font-files of the current font as the image format. + */ +static int +make_subbook_size_image_fonts(EB_Book *book, const char *image_path, + Image_Format_Code image) +{ + EB_Error_Code error_code; + char subbook_directory[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; + char type_path[PATH_MAX + 1]; + char file_name[PATH_MAX + 1]; + char bitmap_data[EB_SIZE_WIDE_FONT_48]; + char image_data[EB_SIZE_FONT_IMAGE]; + size_t image_size; + int image_width; + int image_height; + int character_number; + + /* + * Get the current subbook name. + */ + error_code = eb_subbook_directory(book, subbook_directory); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s\n", invoked_name, + eb_error_message(error_code)); + goto failed; + } + + /* + * Get the current font size. + */ + error_code = eb_font_height(book, &image_height); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s: subbook=%s\n", invoked_name, + eb_error_message(error_code), subbook_directory); + goto failed; + } + + /* + * Make the bitmap files of narrow fonts. + */ + if (eb_have_narrow_font(book)) { + /* + * Get narrow font information. + */ + error_code = eb_narrow_font_width(book, &image_width); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s: subbook=%s, font=%d, type=narrow\n", + invoked_name, eb_error_message(error_code), subbook_directory, + image_height); + goto failed; + } + error_code = eb_narrow_font_start(book, &character_number); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s: subbook=%s, font=%d, type=narrow\n", + invoked_name, eb_error_message(error_code), subbook_directory, + image_height); + goto failed; + } + + /* + * Make a directory for the narrow font. + */ + sprintf(type_path, F_("%s/narrow", "%s\\narrow"), image_path); + if (make_missing_directory(type_path, 0777 ^ get_umask()) < 0) + goto failed; + + while (0 <= character_number) { + /* + * Output debug information. + */ + if (debug_flag) { + fprintf(stderr, "%s: debug: character %04x\n", invoked_name, + character_number); + } + + /* + * Generate a bitmap file for the character `character_number'. + */ + sprintf(file_name, F_("%s/%04x.%s", "%s\\%04x.%s"), + type_path, character_number, image_formats[image].suffix); + error_code = eb_narrow_font_character_bitmap(book, + character_number, bitmap_data); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s: subbook=%s, font=%d, type=narrow, \ +character=0x%04x\n", + invoked_name, eb_error_message(error_code), + subbook_directory, image_height, character_number); + goto failed; + } + + error_code = (image_formats[image].function)(bitmap_data, + image_width, image_height, image_data, &image_size); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s: subbook=%s, font=%d, type=narrow, \ +character=0x%04x\n", + invoked_name, eb_error_message(error_code), + subbook_directory, image_height, character_number); + goto failed; + } + if (save_image_file(file_name, image_data, image_size) < 0) + goto failed; + + /* + * Toward next charahacter. + */ + eb_forward_narrow_font_character(book, 1, &character_number); + } + } + + /* + * Make the bitmap files of wide fonts. + */ + if (eb_have_wide_font(book)) { + /* + * Get wide font information. + */ + error_code = eb_wide_font_width(book, &image_width); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s: subbook=%s, font=%d, type=wide\n", + invoked_name, eb_error_message(error_code), subbook_directory, + image_height); + goto failed; + } + error_code = eb_wide_font_start(book, &character_number); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s: subbook=%s, font=%d, type=wide\n", + invoked_name, eb_error_message(error_code), subbook_directory, + image_height); + goto failed; + } + + /* + * Make a directory for the wide font. + */ + sprintf(type_path, F_("%s/wide", "%s\\wide"), image_path); + if (make_missing_directory(type_path, 0777 ^ get_umask()) < 0) + goto failed; + + while (0 <= character_number) { + /* + * Output debug information. + */ + if (debug_flag) { + fprintf(stderr, "%s: debug: character %04x\n", invoked_name, + character_number); + } + + /* + * Generate a bitmap file for the character `character_number'. + */ + sprintf(file_name, F_("%s/%04x.%s", "%s\\%04x.%s"), + type_path, character_number, image_formats[image].suffix); + error_code = eb_wide_font_character_bitmap(book, character_number, + bitmap_data); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s: subbook=%s, font=%d, type=wide, \ +character=0x%04x\n", + invoked_name, eb_error_message(error_code), + subbook_directory, image_height, character_number); + goto failed; + } + + error_code = (image_formats[image].function)(bitmap_data, + image_width, image_height, image_data, &image_size); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s: subbook=%s, font=%d, type=narrow, \ +character=0x%04x\n", + invoked_name, eb_error_message(error_code), + subbook_directory, image_height, character_number); + goto failed; + } + if (save_image_file(file_name, image_data, image_size) < 0) + goto failed; + + /* + * Toward next charahacter. + */ + eb_forward_wide_font_character(book, 1, &character_number); + } + } + + return 0; + + /* + * An error occurs... + */ + failed: + fflush(stderr); + return -1; +} + + +/* + * Save an image file. + */ +static int +save_image_file(const char *file_name, const char *image_data, + size_t image_size) +{ + int file = -1; + +#ifdef O_CREAT + file = open(file_name, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, + 0666 ^ get_umask()); +#else + file = creat(file_name, 0666 ^ get_umask()); +#endif + + if (file < 0) { + fprintf(stderr, _("%s: failed to open the file, %s: %s\n"), + invoked_name, strerror(errno), file_name); + goto failed; + } + if (write(file, image_data, image_size) != image_size) { + fprintf(stderr, _("%s: failed to write to the file, %s: %s\n"), + invoked_name, strerror(errno), file_name); + goto failed; + } + if (close(file) < 0) { + fprintf(stderr, _("%s: failed to write to the file, %s: %s\n"), + invoked_name, strerror(errno), file_name); + file = -1; + goto failed; + } + + return 0; + + /* + * An error occurs... + */ + failed: + if (0 <= file && close(file) < 0) { + fprintf(stderr, _("%s: failed to close the file, %s: %s\n"), + invoked_name, strerror(errno), file_name); + } + + return -1; +} + diff --git a/ebinfo/Makefile.am b/ebinfo/Makefile.am new file mode 100644 index 0000000..98a532c --- /dev/null +++ b/ebinfo/Makefile.am @@ -0,0 +1,14 @@ +localedir = $(datadir)/locale + +LIBEB = $(top_builddir)/eb/libeb.la +LIBEBUTILS = $(top_builddir)/libebutils/libebutils.a + +bin_PROGRAMS = ebinfo + +ebinfo_SOURCES = ebinfo.c +ebinfo_LDADD = $(LIBEBUTILS) $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) $(ICONVLIBS) +ebinfo_DEPENDENCIES = $(LIBEBUTILS) $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) \ + $(ICONVDEPS) + +INCLUDES = -I../libebutils -I$(top_srcdir)/libebutils -I$(top_srcdir) \ + $(INTLINCS) diff --git a/ebinfo/Makefile.in b/ebinfo/Makefile.in new file mode 100644 index 0000000..eecdaa0 --- /dev/null +++ b/ebinfo/Makefile.in @@ -0,0 +1,502 @@ +# Makefile.in generated by automake 1.10.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = ebinfo$(EXEEXT) +subdir = ebinfo +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/in6addr.m4 $(top_srcdir)/m4/largefile.m4 \ + $(top_srcdir)/m4/lcmessage.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/sockaddrin6.m4 \ + $(top_srcdir)/m4/sockinttypes.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_ebinfo_OBJECTS = ebinfo.$(OBJEXT) +ebinfo_OBJECTS = $(am_ebinfo_OBJECTS) +am__DEPENDENCIES_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(ebinfo_SOURCES) +DIST_SOURCES = $(ebinfo_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +EBCONF_EBINCS = @EBCONF_EBINCS@ +EBCONF_EBLIBS = @EBCONF_EBLIBS@ +EBCONF_INTLINCS = @EBCONF_INTLINCS@ +EBCONF_INTLLIBS = @EBCONF_INTLLIBS@ +EBCONF_ZLIBINCS = @EBCONF_ZLIBINCS@ +EBCONF_ZLIBLIBS = @EBCONF_ZLIBLIBS@ +EB_VERSION_MAJOR = @EB_VERSION_MAJOR@ +EB_VERSION_MINOR = @EB_VERSION_MINOR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_EBNET = @ENABLE_EBNET@ +ENABLE_NLS = @ENABLE_NLS@ +ENABLE_PTHREAD = @ENABLE_PTHREAD@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +ICONVINCS = @ICONVINCS@ +ICONVLIBS = @ICONVLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLINCS = @INTLINCS@ +INTLLIBS = @INTLLIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBEB_VERSION_INFO = @LIBEB_VERSION_INFO@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAILING_ADDRESS = @MAILING_ADDRESS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_CPPFLAGS = @PTHREAD_CPPFLAGS@ +PTHREAD_LDFLAGS = @PTHREAD_LDFLAGS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +ZLIBDEPS = @ZLIBDEPS@ +ZLIBINCS = @ZLIBINCS@ +ZLIBLIBS = @ZLIBLIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = $(datadir)/locale +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgdocdir = @pkgdocdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +LIBEB = $(top_builddir)/eb/libeb.la +LIBEBUTILS = $(top_builddir)/libebutils/libebutils.a +ebinfo_SOURCES = ebinfo.c +ebinfo_LDADD = $(LIBEBUTILS) $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) $(ICONVLIBS) +ebinfo_DEPENDENCIES = $(LIBEBUTILS) $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) \ + $(ICONVDEPS) + +INCLUDES = -I../libebutils -I$(top_srcdir)/libebutils -I$(top_srcdir) \ + $(INTLINCS) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ebinfo/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu ebinfo/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +ebinfo$(EXEEXT): $(ebinfo_OBJECTS) $(ebinfo_DEPENDENCIES) + @rm -f ebinfo$(EXEEXT) + $(LINK) $(ebinfo_OBJECTS) $(ebinfo_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ebinfo.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-binPROGRAMS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/ebinfo/ebinfo.c b/ebinfo/ebinfo.c new file mode 100644 index 0000000..1e407fa --- /dev/null +++ b/ebinfo/ebinfo.c @@ -0,0 +1,622 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#include "eb/eb.h" +#include "eb/error.h" +#include "eb/font.h" +#include "eb/booklist.h" + +#include "getopt.h" +#include "ebutils.h" + +#ifdef ENABLE_NLS +#ifdef HAVE_LOCALE_H +#include +#endif +#include +#endif + +/* + * Tricks for gettext. + */ +#ifdef ENABLE_NLS +#define _(string) gettext(string) +#ifdef gettext_noop +#define N_(string) gettext_noop(string) +#else +#define N_(string) (string) +#endif +#else +#define _(string) (string) +#define N_(string) (string) +#endif + +/* + * Unexported functions. + */ +static void output_error_message(EB_Error_Code error_code); +static EB_Error_Code output_booklist(const char *url); +static EB_Error_Code output_information(const char *book_path, int multi_flag); +static EB_Error_Code output_multi_information(EB_Book *book); +static void output_help(void); + +/* + * Program name and version. + */ +static const char *program_name = "ebinfo"; +static const char *program_version = VERSION; +static const char *invoked_name; + +/* + * Command line options. + */ +static const char *short_options = "hlmv"; +static struct option long_options[] = { + {"help", no_argument, NULL, 'h'}, + {"book-list", no_argument, NULL, 'l'}, + {"multi-search", no_argument, NULL, 'm'}, + {"version", no_argument, NULL, 'v'}, + {NULL, 0, NULL, 0} +}; + +/* + * Default output directory + */ +#define DEFAULT_BOOK_DIRECTORY "." + +int +main(int argc, char *argv[]) +{ + EB_Error_Code error_code; + int ch; + char *book_path; + int booklist_flag; + int multi_flag; + + invoked_name = argv[0]; + + /* + * Initialize locale data. + */ +#ifdef ENABLE_NLS +#ifdef HAVE_SETLOCALE + setlocale(LC_ALL, ""); +#endif + bindtextdomain(TEXT_DOMAIN_NAME, LOCALEDIR); + textdomain(TEXT_DOMAIN_NAME); +#endif + + /* + * Parse command line options. + */ + multi_flag = 0; + booklist_flag = 0; + + 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 'l': + /* + * Option `-l'. Display book list on an EBNET server. + */ + booklist_flag = 1; + break; + + case 'm': + /* + * Option `-m'. Also output multi-search information. + */ + multi_flag = 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); + exit(1); + } + } + + /* + * Check the number of rest arguments. + */ + if (1 < argc - optind) { + fprintf(stderr, _("%s: too many arguments\n"), invoked_name); + output_try_help(invoked_name); + exit(1); + } + + /* + * Output information about the book. + */ + if (argc == optind) + book_path = DEFAULT_BOOK_DIRECTORY; + else + book_path = argv[optind]; + + if (booklist_flag) + error_code = output_booklist(book_path); + else + error_code = output_information(book_path, multi_flag); + if (error_code != EB_SUCCESS) + exit(1); + + return 0; +} + + +/* + * Output an error message to standard error. + */ +static void +output_error_message(EB_Error_Code error_code) +{ + fprintf(stderr, "%s: %s\n", invoked_name, eb_error_message(error_code)); + fflush(stderr); +} + + +/* + * Output a list of books that an EBNET server provides. + */ +static EB_Error_Code +output_booklist(const char *url) +{ + EB_BookList booklist; + EB_Error_Code error_code; + int book_count; + char *name; + char *title; + size_t name_length; + int i; + + error_code = eb_initialize_library(); + if (error_code != EB_SUCCESS) { + output_error_message(error_code); + return error_code; + } + + eb_initialize_booklist(&booklist); + + error_code = eb_bind_booklist(&booklist, url); + if (error_code != EB_SUCCESS) { + output_error_message(error_code); + return error_code; + } + + printf("%-20s %s\n", _("Name"), _("Title")); + + error_code = eb_booklist_book_count(&booklist, &book_count); + if (error_code != EB_SUCCESS) { + output_error_message(error_code); + return error_code; + } + + for (i = 0; i < book_count; i++) { + error_code = eb_booklist_book_name(&booklist, i, &name); + if (error_code != EB_SUCCESS) { + output_error_message(error_code); + break; + } + error_code = eb_booklist_book_title(&booklist, i, &title); + if (error_code != EB_SUCCESS) { + output_error_message(error_code); + break; + } + + name_length = strlen(name); + + printf("%-20s ", name); + fputs_eucjp_to_locale(title, stdout); + if (4 < name_length && strcmp(name + name_length - 4, ".app") == 0) + fputs(" (appendix)", stdout); + fputc('\n', stdout); + } + + eb_finalize_booklist(&booklist); + eb_finalize_library(); + + return EB_SUCCESS; +} + + +/* + * Output information about the book at `path'. + * If `multi_flag' is enabled, multi-search information are also output. + */ +static EB_Error_Code +output_information(const char *book_path, int multi_flag) +{ + EB_Book book; + EB_Error_Code return_code = EB_SUCCESS; + EB_Error_Code error_code; + EB_Disc_Code disc_code; + EB_Character_Code character_code; + EB_Subbook_Code subbook_list[EB_MAX_SUBBOOKS]; + EB_Font_Code font_list[EB_MAX_FONTS]; + char title[EB_MAX_TITLE_LENGTH + 1]; + char directory[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; + int font_height, font_start, font_end; + int subbook_count; + int font_count; + int i, j; + + /* + * Start to use a book. + */ + error_code = eb_initialize_library(); + if (error_code != EB_SUCCESS) { + output_error_message(error_code); + return_code = error_code; + goto failed; + } + eb_initialize_book(&book); + error_code = eb_bind(&book, book_path); + if (error_code != EB_SUCCESS) { + output_error_message(error_code); + return_code = error_code; + goto failed; + } + + /* + * Output disc type. + */ + error_code = eb_disc_type(&book, &disc_code); + if (error_code != EB_SUCCESS) { + output_error_message(error_code); + return_code = error_code; + goto failed; + } + printf(_("disc type: ")); + if (disc_code == EB_DISC_EB) + printf("EB/EBG/EBXA/EBXA-C/S-EBXA\n"); + else + printf("EPWING\n"); + + /* + * Output character code. + */ + error_code = eb_character_code(&book, &character_code); + if (error_code != EB_SUCCESS) { + output_error_message(error_code); + return_code = error_code; + goto failed; + } + printf(_("character code: ")); + switch (character_code) { + case EB_CHARCODE_ISO8859_1: + printf("ISO 8859-1\n"); + break; + case EB_CHARCODE_JISX0208: + printf("JIS X 0208\n"); + break; + case EB_CHARCODE_JISX0208_GB2312: + printf("JIS X 0208 + GB 2312\n"); + break; + default: + printf(_("unknown\n")); + break; + } + + /* + * Output the number of subbooks in the book. + */ + error_code = eb_subbook_list(&book, subbook_list, &subbook_count); + if (error_code != EB_SUCCESS) { + output_error_message(error_code); + return_code = error_code; + goto failed; + } + printf(_("the number of subbooks: %d\n\n"), subbook_count); + + /* + * Output information about each subbook. + */ + for (i = 0; i < subbook_count; i++) { + printf(_("subbook %d:\n"), i + 1); + + /* + * Output a title of the subbook. + */ + error_code = eb_subbook_title2(&book, subbook_list[i], title); + if (error_code != EB_SUCCESS) { + return_code = error_code; + continue; + } + printf(_(" title: "), title); + fputs_eucjp_to_locale(title, stdout); + fputc('\n', stdout); + + /* + * Output a directory name of the subbook. + */ + error_code = eb_subbook_directory2(&book, subbook_list[i], directory); + if (error_code != EB_SUCCESS) { + return_code = error_code; + continue; + } + printf(_(" directory: %s\n"), directory); + + /* + * Set the current subbook to `i'. + */ + error_code = eb_set_subbook(&book, subbook_list[i]); + if (error_code != EB_SUCCESS) { + output_error_message(error_code); + return_code = error_code; + continue; + } + + /* + * Output supported methods. + */ + printf(_(" search methods: ")); + if (eb_have_word_search(&book)) + fputs(_("word "), stdout); + if (eb_have_endword_search(&book)) + fputs(_("endword "), stdout); + if (eb_have_keyword_search(&book)) + fputs(_("keyword "), stdout); + if (eb_have_cross_search(&book)) + fputs(_("cross "), stdout); + if (eb_have_multi_search(&book)) + fputs(_("multi "), stdout); + if (eb_have_menu(&book)) + fputs(_("menu "), stdout); + if (eb_have_image_menu(&book)) + fputs(_("image-menu "), stdout); + if (eb_have_copyright(&book)) + fputs(_("copyright "), stdout); + fputc('\n', stdout); + + /* + * Output a font list. + */ + fputs(_(" font sizes: "), stdout); + error_code = eb_font_list(&book, font_list, &font_count); + if (error_code != EB_SUCCESS) { + fputc('\n', stdout); + output_error_message(error_code); + return_code = error_code; + } else { + for (j = 0; j < font_count; j++) { + error_code = eb_font_height2(font_list[j], &font_height); + if (error_code == EB_SUCCESS) + printf("%d ", font_height); + else { + output_error_message(error_code); + return_code = error_code; + } + } + fputc('\n', stdout); + } + + /* + * Output character range of the narrow font. + */ + fputs(_(" narrow font characters: "), stdout); + if (eb_have_narrow_font(&book)) { + do { + error_code = eb_set_font(&book, font_list[0]); + if (error_code != EB_SUCCESS) + break; + error_code = eb_narrow_font_start(&book, &font_start); + if (error_code != EB_SUCCESS) + break; + error_code = eb_narrow_font_end(&book, &font_end); + if (error_code != EB_SUCCESS) + break; + } while (0); + + if (error_code == EB_SUCCESS) + printf("0x%04x -- 0x%04x\n", font_start, font_end); + else { + fputc('\n', stdout); + output_error_message(error_code); + return_code = error_code; + } + } else { + fputc('\n', stdout); + } + + /* + * Output character range of the wide font. + */ + printf(_(" wide font characters: ")); + if (eb_have_wide_font(&book)) { + do { + error_code = eb_set_font(&book, font_list[0]); + if (error_code != EB_SUCCESS) + break; + error_code = eb_wide_font_start(&book, &font_start); + if (error_code != EB_SUCCESS) + break; + error_code = eb_wide_font_end(&book, &font_end); + if (error_code != EB_SUCCESS) + break; + } while (0); + + if (error_code == EB_SUCCESS) + printf("0x%04x -- 0x%04x\n", font_start, font_end); + else { + fputc('\n', stdout); + output_error_message(error_code); + return_code = error_code; + } + } else { + fputc('\n', stdout); + } + + if (multi_flag) { + error_code = output_multi_information(&book); + if (error_code != EB_SUCCESS) + return_code = error_code; + } + fputc('\n', stdout); + } + fflush(stdout); + + /* + * End to use the book. + */ + eb_finalize_book(&book); + eb_finalize_library(); + + return return_code; + + /* + * An error occurs... + */ + failed: + fflush(stdout); + fflush(stderr); + eb_finalize_book(&book); + eb_finalize_library(); + + return return_code; +} + +/* + * Output information about multi searches. + */ +static EB_Error_Code +output_multi_information(EB_Book *book) +{ + EB_Error_Code return_code = EB_SUCCESS; + EB_Error_Code error_code; + EB_Multi_Search_Code multi_list[EB_MAX_MULTI_SEARCHES]; + int multi_count; + int entry_count; + char search_title[EB_MAX_MULTI_TITLE_LENGTH + 1]; + char entry_label[EB_MAX_MULTI_LABEL_LENGTH + 1]; + int i, j; + + /* + * Get a list of mutli search codes. + */ + error_code = eb_multi_search_list(book, multi_list, &multi_count); + if (error_code != EB_SUCCESS) { + output_error_message(error_code); + return_code = error_code; + multi_count = 0; + } + + /* + * Output information. + */ + for (i = 0; i < multi_count; i++) { + printf(_(" multi search %d:\n"), i + 1); + error_code = eb_multi_entry_count(book, multi_list[i], &entry_count); + if (error_code != EB_SUCCESS) { + output_error_message(error_code); + return_code = error_code; + continue; + } + + error_code = eb_multi_title(book, multi_list[i], search_title); + if (error_code != EB_SUCCESS) { + output_error_message(error_code); + return_code = error_code; + continue; + } + printf(_(" title: "), search_title); + fputs_eucjp_to_locale(search_title, stdout); + fputc('\n', stdout); + + for (j = 0; j < entry_count; j++) { + error_code = eb_multi_entry_label(book, multi_list[i], j, + entry_label); + if (error_code != EB_SUCCESS) { + output_error_message(error_code); + return_code = error_code; + continue; + } + + printf(_(" label %d: "), j + 1); + fputs_eucjp_to_locale(entry_label, stdout); + fputc('\n', stdout); + + fputs(_(" candidates: "), stdout); + if (eb_multi_entry_have_candidates(book, multi_list[i], j)) + fputs(_("exist\n"), stdout); + else + fputs(_("not-exist\n"), stdout); + } + } + + fflush(stdout); + + return return_code; +} + + +/* + * Output help message to stdandard out. + */ +static void +output_help(void) +{ + printf(_("Usage: %s [option...] [book-directory]\n"), + program_name); + printf(_("Options:\n")); + printf(_(" -h --help display this help, then exit\n")); + printf(_(" -l --book-list output a list of books on an EBENT server\n")); + printf(_(" -m --multi-search also output multi-search information\n")); + printf(_(" -v --version display version number, then exit\n")); + printf(_("\nArgument:\n")); + printf(_(" book-directory top directory of a CD-ROM book\n")); + printf(_(" (default: %s)\n"), + DEFAULT_BOOK_DIRECTORY); + printf(_("\nReport bugs to %s.\n"), MAILING_ADDRESS); + fflush(stdout); +} + + diff --git a/ebrefile/Makefile.am b/ebrefile/Makefile.am new file mode 100644 index 0000000..8dd0d97 --- /dev/null +++ b/ebrefile/Makefile.am @@ -0,0 +1,14 @@ +localedir = $(datadir)/locale + +LIBEB = $(top_builddir)/eb/libeb.la +LIBEBUTILS = $(top_builddir)/libebutils/libebutils.a + +bin_PROGRAMS = ebrefile + +ebrefile_SOURCES = ebrefile.c +ebrefile_LDADD = $(LIBEBUTILS) $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) $(ICONVLIBS) +ebrefile_DEPENDENCIES = $(LIBEBUTILS) $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) \ + $(ICONVDEPS) + +INCLUDES = -I../libebutils -I$(top_srcdir)/libebutils \ + -I../eb -I$(top_srcdir)/eb $(INTLINCS) diff --git a/ebrefile/Makefile.in b/ebrefile/Makefile.in new file mode 100644 index 0000000..d1a138e --- /dev/null +++ b/ebrefile/Makefile.in @@ -0,0 +1,502 @@ +# Makefile.in generated by automake 1.10.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = ebrefile$(EXEEXT) +subdir = ebrefile +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/in6addr.m4 $(top_srcdir)/m4/largefile.m4 \ + $(top_srcdir)/m4/lcmessage.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/sockaddrin6.m4 \ + $(top_srcdir)/m4/sockinttypes.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_ebrefile_OBJECTS = ebrefile.$(OBJEXT) +ebrefile_OBJECTS = $(am_ebrefile_OBJECTS) +am__DEPENDENCIES_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(ebrefile_SOURCES) +DIST_SOURCES = $(ebrefile_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +EBCONF_EBINCS = @EBCONF_EBINCS@ +EBCONF_EBLIBS = @EBCONF_EBLIBS@ +EBCONF_INTLINCS = @EBCONF_INTLINCS@ +EBCONF_INTLLIBS = @EBCONF_INTLLIBS@ +EBCONF_ZLIBINCS = @EBCONF_ZLIBINCS@ +EBCONF_ZLIBLIBS = @EBCONF_ZLIBLIBS@ +EB_VERSION_MAJOR = @EB_VERSION_MAJOR@ +EB_VERSION_MINOR = @EB_VERSION_MINOR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_EBNET = @ENABLE_EBNET@ +ENABLE_NLS = @ENABLE_NLS@ +ENABLE_PTHREAD = @ENABLE_PTHREAD@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +ICONVINCS = @ICONVINCS@ +ICONVLIBS = @ICONVLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLINCS = @INTLINCS@ +INTLLIBS = @INTLLIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBEB_VERSION_INFO = @LIBEB_VERSION_INFO@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAILING_ADDRESS = @MAILING_ADDRESS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_CPPFLAGS = @PTHREAD_CPPFLAGS@ +PTHREAD_LDFLAGS = @PTHREAD_LDFLAGS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +ZLIBDEPS = @ZLIBDEPS@ +ZLIBINCS = @ZLIBINCS@ +ZLIBLIBS = @ZLIBLIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = $(datadir)/locale +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgdocdir = @pkgdocdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +LIBEB = $(top_builddir)/eb/libeb.la +LIBEBUTILS = $(top_builddir)/libebutils/libebutils.a +ebrefile_SOURCES = ebrefile.c +ebrefile_LDADD = $(LIBEBUTILS) $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) $(ICONVLIBS) +ebrefile_DEPENDENCIES = $(LIBEBUTILS) $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) \ + $(ICONVDEPS) + +INCLUDES = -I../libebutils -I$(top_srcdir)/libebutils \ + -I../eb -I$(top_srcdir)/eb $(INTLINCS) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ebrefile/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu ebrefile/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +ebrefile$(EXEEXT): $(ebrefile_OBJECTS) $(ebrefile_DEPENDENCIES) + @rm -f ebrefile$(EXEEXT) + $(LINK) $(ebrefile_OBJECTS) $(ebrefile_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ebrefile.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-binPROGRAMS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/ebrefile/ebrefile.c b/ebrefile/ebrefile.c new file mode 100644 index 0000000..078c9c1 --- /dev/null +++ b/ebrefile/ebrefile.c @@ -0,0 +1,810 @@ +/* -*- C -*- + * Copyright (c) 2001-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef ENABLE_NLS +#ifdef HAVE_LOCALE_H +#include +#endif +#include +#endif + +#ifndef HAVE_STRCASECMP +int strcasecmp(const char *, const char *); +int strncasecmp(const char *, const char *, size_t); +#endif + +#ifndef O_BINARY +#define O_BINARY 0 +#endif + +/* + * stat macros. + */ +#ifndef S_ISREG +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#endif +#ifndef S_ISDIR +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif + +/* + * The maximum length of path name. + */ +#ifndef PATH_MAX +#ifdef MAXPATHLEN +#define PATH_MAX MAXPATHLEN +#else /* not MAXPATHLEN */ +#define PATH_MAX 1024 +#endif /* not MAXPATHLEN */ +#endif /* not PATH_MAX */ + +/* + * rename() on Windows complains if the new file already exists. + * We fake rename() here for Windows. + */ +#ifdef WIN32 +#include +#define rename(old, new) \ + (MoveFileEx((old), (new), MOVEFILE_REPLACE_EXISTING) ? 0 : -1) +#endif + +#include "eb.h" +#include "error.h" +#include "build-post.h" + +#include "ebutils.h" + +#include "getopt.h" +#include "getumask.h" +#include "makedir.h" +#include "samefile.h" +#include "yesno.h" + +/* + * Tricks for gettext. + */ +#ifdef ENABLE_NLS +#define _(string) gettext(string) +#ifdef gettext_noop +#define N_(string) gettext_noop(string) +#else +#define N_(string) (string) +#endif +#else +#define _(string) (string) +#define N_(string) (string) +#endif + +#define DEFAULT_BOOK_DIRECTORY "." +#define DEFAULT_OUTPUT_DIRECTORY "." + +/* + * Unexported functions. + */ +static void output_help(void); +static int refile_book(const char *out_path, const char *in_path, + char subbook_name_list[][EB_MAX_DIRECTORY_NAME_LENGTH + 1], + int subbook_name_count); +static int refile_catalog(const char *out_catalog_name, + const char *in_catalog_name, EB_Disc_Code disc_code, + char subbook_name_list[][EB_MAX_DIRECTORY_NAME_LENGTH + 1], + int subbook_name_count); +static int copy_file(const char *out_file_name, const char *in_file_name); +static void trap(int signal_number); +static int find_subbook_name(char + subbook_name_list[][EB_MAX_DIRECTORY_NAME_LENGTH + 1], + int subbook_name_count, const char *pattern); + +/* + * Command line options. + */ +static const char *short_options = "ho:S:v"; +static struct option long_options[] = { + {"help", no_argument, NULL, 'h'}, + {"output-directory", required_argument, NULL, 'o'}, + {"subbook", required_argument, NULL, 'S'}, + {"version", no_argument, NULL, 'v'}, + {NULL, 0, NULL, 0} +}; + +/* + * Program name and version. + */ +const char *program_name = "ebrefile"; +const char *program_version = VERSION; +const char *invoked_name; + +/* + * File names to be deleted when signal is received. + */ +static const char *trap_file_name = NULL; +static int trap_file = -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 + * "/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); +} + + +/* + * Output help message to stdandard out. + */ +static void +output_help(void) +{ + printf(_("Usage: %s [option...] [book-directory]\n"), program_name); + printf(_("Options:\n")); + printf(_(" -h --help display this help, then exit\n")); + printf(_(" -o DIRECTORY --output-directory DIRECTORY\n")); + printf(_(" ouput files under DIRECTORY\n")); + printf(_(" (default: %s)\n"), + DEFAULT_OUTPUT_DIRECTORY); + printf(_(" -S SUBBOOK[,SUBBOOK...] --subbook SUBBOOK[,SUBBOOK...]\n")); + printf(_(" target subbook\n")); + printf(_(" (default: all subbooks)\n")); + printf(_(" -v --version display version number, then exit\n")); + printf(_("\nArgument:\n")); + printf(_(" book-directory top directory of a CD-ROM book\n")); + printf(_(" (default: %s)\n"), + DEFAULT_BOOK_DIRECTORY); + + printf(_("\nReport bugs to %s.\n"), MAILING_ADDRESS); + fflush(stdout); +} + + +/* + * Read a catalog file in `in_path' and create refiled catalog file + * in `out_path'. + */ +static int +refile_book(const char *out_path, const char *in_path, + char subbook_name_list[][EB_MAX_DIRECTORY_NAME_LENGTH + 1], + int subbook_name_count) +{ + char in_file_name[PATH_MAX + 1]; + char out_file_name[PATH_MAX + 1]; + char tmp_file_name[PATH_MAX + 1]; + char old_file_name[PATH_MAX + 1]; + char in_base_name[EB_MAX_FILE_NAME_LENGTH + 1]; + EB_Disc_Code disc_code; + struct stat out_status; + struct stat old_status; + + /* + * Find a catalog file. + */ + if (eb_find_file_name(in_path, "catalog", in_base_name) + == EB_SUCCESS) { + disc_code = EB_DISC_EB; + } else if (eb_find_file_name(in_path, "catalogs", in_base_name) + == EB_SUCCESS) { + disc_code = EB_DISC_EPWING; + } else { + fprintf(stderr, _("%s: no catalog file: %s\n"), invoked_name, in_path); + return -1; + } + + /* + * Set file names. + */ + eb_compose_path_name(in_path, in_base_name, in_file_name); + eb_compose_path_name(out_path, in_base_name, out_file_name); + + strcpy(old_file_name, out_file_name); + eb_fix_path_name_suffix(old_file_name, ".old"); + strcpy(tmp_file_name, out_file_name); + eb_fix_path_name_suffix(tmp_file_name, ".tmp"); + + /* + * Copy the original catalog file. + */ + if (stat(old_file_name, &old_status) < 0 + && errno == ENOENT + && stat(out_file_name, &out_status) == 0 + && S_ISREG(out_status.st_mode)) { + trap_file_name = old_file_name; + if (copy_file(old_file_name, out_file_name) < 0) + return -1; + trap_file_name = NULL; + } + + /* + * Refile the catalog file. + */ + trap_file_name = tmp_file_name; + if (refile_catalog(tmp_file_name, in_file_name, disc_code, + subbook_name_list, subbook_name_count) < 0) { + unlink(tmp_file_name); + rename(old_file_name, out_file_name); + return -1; + } + if (rename(tmp_file_name, out_file_name) < 0) { + fprintf(stderr, _("%s: failed to move the file, %s: %s -> %s\n"), + invoked_name, strerror(errno), tmp_file_name, out_file_name); + unlink(tmp_file_name); + return -1; + } + + trap_file_name = NULL; + + return 0; +} + + +/* + * Read a catalog file `in_catalog_name' and create refiled catalog file + * as `out_catalog_name'. + */ +static int +refile_catalog(const char *out_catalog_name, const char *in_catalog_name, + EB_Disc_Code disc_code, + char subbook_name_list[][EB_MAX_DIRECTORY_NAME_LENGTH + 1], + int subbook_name_count) +{ + char buffer[EB_SIZE_PAGE]; + char directory_name[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; + int in_subbook_count; + int in_file = -1; + int out_file = -1; + int subbbook_map_table[EB_MAX_SUBBOOKS]; + off_t out_file_offset; + size_t catalog_size; + int i, j; + + for (i = 0; i < EB_MAX_SUBBOOKS; i++) + subbbook_map_table[i] = EB_SUBBOOK_INVALID; + + if (disc_code == EB_DISC_EB) + catalog_size = EB_SIZE_EB_CATALOG; + else + catalog_size = EB_SIZE_EPWING_CATALOG; + + /* + * Open input file. + */ + in_file = open(in_catalog_name, O_RDONLY | O_BINARY); + if (in_file < 0) { + fprintf(stderr, _("%s: failed to open the file, %s: %s\n"), + invoked_name, strerror(errno), in_catalog_name); + goto failed; + } + + /* + * Open output file. + */ +#ifdef O_CREAT + out_file = open(out_catalog_name, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, + 0666 ^ get_umask()); +#else + out_file = creat(out_catalog_name, 0666 ^ get_umask()); +#endif + trap_file = out_file; + if (out_file < 0) { + fprintf(stderr, _("%s: failed to open the file, %s: %s\n"), + invoked_name, strerror(errno), out_catalog_name); + goto failed; + } + + /* + * Copy header. + */ + if (read(in_file, buffer, 16) != 16) { + fprintf(stderr, _("%s: failed to read the file, %s: %s\n"), + invoked_name, strerror(errno), in_catalog_name); + goto failed; + } + in_subbook_count = eb_uint2(buffer); + + if (write(out_file, buffer, 16) != 16) { + fprintf(stderr, _("%s: failed to write the file, %s: %s\n"), + invoked_name, strerror(errno), out_catalog_name); + goto failed; + } + out_file_offset = 16; + + /* + * Copy basic information of subbooks. + */ + for (i = 0; i < in_subbook_count; i++) { + /* + * Read subbook entry. + */ + if (read(in_file, buffer, catalog_size) != catalog_size) { + fprintf(stderr, _("%s: failed to read the file, %s: %s\n"), + invoked_name, strerror(errno), in_catalog_name); + goto failed; + } + + /* + * Check whether `subbook_name_list' has a directory name of + * this subbook. If not, we ignore this subbook. + */ + if (disc_code == EB_DISC_EB) { + strncpy(directory_name, buffer + 2 + EB_MAX_EB_TITLE_LENGTH, + EB_MAX_DIRECTORY_NAME_LENGTH); + } else { + strncpy(directory_name, buffer + 2 + EB_MAX_EPWING_TITLE_LENGTH, + EB_MAX_DIRECTORY_NAME_LENGTH); + } + directory_name[EB_MAX_DIRECTORY_NAME_LENGTH] = '\0'; + + if (subbook_name_count == 0) + subbbook_map_table[i] = i; + else { + int subbook_index; + + subbook_index = find_subbook_name(subbook_name_list, + subbook_name_count, directory_name); + if (subbook_index < 0) + continue; + subbbook_map_table[i] = subbook_index; + } + + /* + * Write the subbook entry. + */ + if (write(out_file, buffer, catalog_size) != catalog_size) { + fprintf(stderr, _("%s: failed to write the file, %s: %s\n"), + invoked_name, strerror(errno), out_catalog_name); + goto failed; + } + + out_file_offset += catalog_size; + } + + /* + * Copy extended information of subbooks. + */ + if (disc_code == EB_DISC_EPWING) { + for (i = 0; i < in_subbook_count; i++) { + if (read(in_file, buffer, catalog_size) != catalog_size) { + fprintf(stderr, _("%s: failed to read the file, %s: %s\n"), + invoked_name, strerror(errno), in_catalog_name); + goto failed; + } + if (subbbook_map_table[i] == EB_SUBBOOK_INVALID) + continue; + if (write(out_file, buffer, catalog_size) != catalog_size) { + fprintf(stderr, _("%s: failed to write the file, %s: %s\n"), + invoked_name, strerror(errno), out_catalog_name); + goto failed; + } + + out_file_offset += catalog_size; + } + } + + /* + * Check whether all subbooks in `subbook_name_list' are found. + */ + for (i = 0; i < subbook_name_count; i++) { + for (j = 0; j < in_subbook_count; j++) { + if (subbbook_map_table[j] == i) + break; + } + if (in_subbook_count <= j) { + fprintf(stderr, _("%s: warning: no such subbook: %s\n"), + invoked_name, subbook_name_list[i]); + } + } + + /* + * Copy rest of the catalog file. + */ + for (;;) { + ssize_t read_length; + + read_length = read(in_file, buffer, EB_SIZE_PAGE); + if (read_length == 0) { + break; + } else if (read_length < 0) { + fprintf(stderr, _("%s: failed to read the file, %s: %s\n"), + invoked_name, strerror(errno), in_catalog_name); + goto failed; + } + if (write(out_file, buffer, read_length) != read_length) { + fprintf(stderr, _("%s: failed to write the file, %s: %s\n"), + invoked_name, strerror(errno), out_catalog_name); + goto failed; + } + out_file_offset += read_length; + } + + /* + * Fill the current page with 0. + */ + if (0 < out_file_offset % EB_SIZE_PAGE) { + size_t pad_length; + + pad_length = EB_SIZE_PAGE - (out_file_offset % EB_SIZE_PAGE); + memset(buffer, 0, EB_SIZE_PAGE); + if (write(out_file, buffer, pad_length) != pad_length) { + fprintf(stderr, _("%s: failed to write the file, %s: %s\n"), + invoked_name, strerror(errno), out_catalog_name); + goto failed; + } + } + + /* + * Fix the number of subbook. + */ + if (subbook_name_count == 0) { + buffer[0] = (in_subbook_count >> 8) & 0xff; + buffer[1] = in_subbook_count & 0xff; + } else { + buffer[0] = (subbook_name_count >> 8) & 0xff; + buffer[1] = subbook_name_count & 0xff; + } + if (lseek(out_file, 0, SEEK_SET) < 0) { + fprintf(stderr, _("%s: failed to seek the file, %s: %s\n"), + invoked_name, strerror(errno), out_catalog_name); + goto failed; + } + if (write(out_file, buffer, 2) != 2) { + fprintf(stderr, _("%s: failed to write the file, %s: %s\n"), + invoked_name, strerror(errno), out_catalog_name); + goto failed; + } + + /* + * Close files. + */ + close(in_file); + close(out_file); + trap_file = -1; + + return 0; + + /* + * An error occurs... + */ + failed: + if (0 <= in_file) + close(in_file); + if (0 <= out_file) + close(out_file); + return -1; +} + + +/* + * Copy a file from `in_file_name' to `out_file_name'. + * If it succeeds, 0 is returned. Otherwise -1 is returned. + */ +static int +copy_file(const char *out_file_name, const char *in_file_name) +{ + unsigned char buffer[EB_SIZE_PAGE]; + size_t copied_length; + struct stat in_status; + int in_file = -1, out_file = -1; + ssize_t read_result; + struct utimbuf utim; + + /* + * Check for the input file. + */ + if (stat(in_file_name, &in_status) != 0 || !S_ISREG(in_status.st_mode)) { + fprintf(stderr, _("%s: no such file: %s\n"), invoked_name, + in_file_name); + goto failed; + } + + /* + * Open files. + */ + in_file = open(in_file_name, O_RDONLY | O_BINARY); + if (in_file < 0) { + fprintf(stderr, _("%s: failed to open the file, %s: %s\n"), + invoked_name, strerror(errno), in_file_name); + goto failed; + } + +#ifdef O_CREAT + out_file = open(out_file_name, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, + 0666 ^ get_umask()); +#else + out_file = creat(out_file_name, 0666 ^ get_umask()); +#endif + trap_file = out_file; + if (out_file < 0) { + fprintf(stderr, _("%s: failed to open the file, %s: %s\n"), + invoked_name, strerror(errno), out_file_name); + goto failed; + } + + /* + * Read data from the input file, compress the data, and then + * write them to the output file. + */ + copied_length = 0; + for (;;) { + /* + * Read data from `in_file', and write them to `out_file'. + */ + read_result = read(in_file, buffer, EB_SIZE_PAGE); + if (read_result == 0) { + break; + } else if (read_result < 0) { + fprintf(stderr, _("%s: failed to read from the file, %s: %s\n"), + invoked_name, strerror(errno), in_file_name); + goto failed; + } + + /* + * Write decoded data to `out_file'. + */ + if (write(out_file, buffer, read_result) != read_result) { + fprintf(stderr, _("%s: failed to write to the file, %s: %s\n"), + invoked_name, strerror(errno), out_file_name); + goto failed; + } + copied_length += read_result; + } + + /* + * Close files. + */ + close(in_file); + close(out_file); + trap_file = -1; + + /* + * Set owner, group, permission, atime and mtime of `out_file'. + * We ignore return values of `chown', `chmod' and `utime'. + */ + utim.actime = in_status.st_atime; + utim.modtime = in_status.st_mtime; + utime(out_file_name, &utim); + + return 0; + + /* + * An error occurs... + */ + failed: + if (0 <= in_file) + close(in_file); + if (0 <= out_file) + close(out_file); + + return -1; +} + + +/* + * Signal handler. + */ +static void +trap(int signal_number) +{ + if (0 <= trap_file) + close(trap_file); + if (trap_file_name != NULL) + unlink(trap_file_name); + + exit(1); +} + + +/* + * Search `subbook_name_list[]' for `pattern'. + * `subbook_name_count' is length of `subbook_name_list[]'. + * + * If found, the function returns index of the element. Otherwise it + * returns -1. + */ +static int +find_subbook_name(char subbook_name_list[][EB_MAX_DIRECTORY_NAME_LENGTH + 1], + int subbook_name_count, const char *pattern) +{ + char canonicalized_pattern[EB_MAX_FILE_NAME_LENGTH + 1]; + char *space; + int i; + + strcpy(canonicalized_pattern, pattern); + space = strchr(canonicalized_pattern, ' '); + if (space != NULL) + *space = '\0'; + + for (i = 0; i < subbook_name_count; i++) { + if (strcasecmp(subbook_name_list[i], canonicalized_pattern) == 0) + return i; + } + + return -1; +} diff --git a/ebstopcode/Makefile.am b/ebstopcode/Makefile.am new file mode 100644 index 0000000..5773665 --- /dev/null +++ b/ebstopcode/Makefile.am @@ -0,0 +1,14 @@ +localedir = $(datadir)/locale + +LIBEB = $(top_builddir)/eb/libeb.la +LIBEBUTILS = $(top_builddir)/libebutils/libebutils.a + +bin_PROGRAMS = ebstopcode + +ebstopcode_SOURCES = ebstopcode.c +ebstopcode_LDADD = $(LIBEBUTILS) $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) $(ICONVLIBS) +ebstopcode_DEPENDENCIES = $(LIBEBUTILS) $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) \ + $(ICONVDEPS) + +INCLUDES = -I../libebutils -I$(top_srcdir)/libebutils -I$(top_srcdir) \ + $(INTLINCS) diff --git a/ebstopcode/Makefile.in b/ebstopcode/Makefile.in new file mode 100644 index 0000000..7b88793 --- /dev/null +++ b/ebstopcode/Makefile.in @@ -0,0 +1,502 @@ +# Makefile.in generated by automake 1.10.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = ebstopcode$(EXEEXT) +subdir = ebstopcode +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/in6addr.m4 $(top_srcdir)/m4/largefile.m4 \ + $(top_srcdir)/m4/lcmessage.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/sockaddrin6.m4 \ + $(top_srcdir)/m4/sockinttypes.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_ebstopcode_OBJECTS = ebstopcode.$(OBJEXT) +ebstopcode_OBJECTS = $(am_ebstopcode_OBJECTS) +am__DEPENDENCIES_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(ebstopcode_SOURCES) +DIST_SOURCES = $(ebstopcode_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +EBCONF_EBINCS = @EBCONF_EBINCS@ +EBCONF_EBLIBS = @EBCONF_EBLIBS@ +EBCONF_INTLINCS = @EBCONF_INTLINCS@ +EBCONF_INTLLIBS = @EBCONF_INTLLIBS@ +EBCONF_ZLIBINCS = @EBCONF_ZLIBINCS@ +EBCONF_ZLIBLIBS = @EBCONF_ZLIBLIBS@ +EB_VERSION_MAJOR = @EB_VERSION_MAJOR@ +EB_VERSION_MINOR = @EB_VERSION_MINOR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_EBNET = @ENABLE_EBNET@ +ENABLE_NLS = @ENABLE_NLS@ +ENABLE_PTHREAD = @ENABLE_PTHREAD@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +ICONVINCS = @ICONVINCS@ +ICONVLIBS = @ICONVLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLINCS = @INTLINCS@ +INTLLIBS = @INTLLIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBEB_VERSION_INFO = @LIBEB_VERSION_INFO@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAILING_ADDRESS = @MAILING_ADDRESS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_CPPFLAGS = @PTHREAD_CPPFLAGS@ +PTHREAD_LDFLAGS = @PTHREAD_LDFLAGS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +ZLIBDEPS = @ZLIBDEPS@ +ZLIBINCS = @ZLIBINCS@ +ZLIBLIBS = @ZLIBLIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = $(datadir)/locale +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgdocdir = @pkgdocdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +LIBEB = $(top_builddir)/eb/libeb.la +LIBEBUTILS = $(top_builddir)/libebutils/libebutils.a +ebstopcode_SOURCES = ebstopcode.c +ebstopcode_LDADD = $(LIBEBUTILS) $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) $(ICONVLIBS) +ebstopcode_DEPENDENCIES = $(LIBEBUTILS) $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) \ + $(ICONVDEPS) + +INCLUDES = -I../libebutils -I$(top_srcdir)/libebutils -I$(top_srcdir) \ + $(INTLINCS) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ebstopcode/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu ebstopcode/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +ebstopcode$(EXEEXT): $(ebstopcode_OBJECTS) $(ebstopcode_DEPENDENCIES) + @rm -f ebstopcode$(EXEEXT) + $(LINK) $(ebstopcode_OBJECTS) $(ebstopcode_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ebstopcode.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-binPROGRAMS + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/ebstopcode/ebstopcode.c b/ebstopcode/ebstopcode.c new file mode 100644 index 0000000..7494a9d --- /dev/null +++ b/ebstopcode/ebstopcode.c @@ -0,0 +1,630 @@ +/* -*- C -*- + * Copyright (c) 2003-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#ifdef ENABLE_NLS +#ifdef HAVE_LOCALE_H +#include +#endif +#include +#endif + +/* + * The maximum length of path name. + */ +#ifndef PATH_MAX +#ifdef MAXPATHLEN +#define PATH_MAX MAXPATHLEN +#else /* not MAXPATHLEN */ +#define PATH_MAX 1024 +#endif /* not MAXPATHLEN */ +#endif /* not PATH_MAX */ + +#include "eb/eb.h" +#include "eb/error.h" +#include "eb/text.h" +#include "eb/appendix.h" + +#include "getopt.h" +#include "ebutils.h" + +/* + * Tricks for gettext. + */ +#ifdef ENABLE_NLS +#define _(string) gettext(string) +#ifdef gettext_noop +#define N_(string) gettext_noop(string) +#else +#define N_(string) (string) +#endif +#else +#define _(string) (string) +#define N_(string) (string) +#endif + +/* + * Character type tests and conversions. + */ +#define ASCII_ISDIGIT(c) ('0' <= (c) && (c) <= '9') +#define ASCII_ISUPPER(c) ('A' <= (c) && (c) <= 'Z') +#define ASCII_ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define ASCII_ISALPHA(c) \ + (ASCII_ISUPPER(c) || ASCII_ISLOWER(c)) +#define ASCII_ISALNUM(c) \ + (ASCII_ISUPPER(c) || ASCII_ISLOWER(c) || ASCII_ISDIGIT(c)) +#define ASCII_ISXDIGIT(c) \ + (ASCII_ISDIGIT(c) || ('A' <= (c) && (c) <= 'F') || ('a' <= (c) && (c) <= 'f')) +#define ASCII_TOUPPER(c) (('a' <= (c) && (c) <= 'z') ? (c) - 0x20 : (c)) +#define ASCII_TOLOWER(c) (('A' <= (c) && (c) <= 'Z') ? (c) + 0x20 : (c)) + +/* + * Default maximum length of text. + */ +#define DEFAULT_MAX_TEXT_LENGTH EB_SIZE_PAGE + +/* + * Default book directory. + */ +#define DEFAULT_BOOK_DIRECTORY "." + +/* + * Dummy stop code. + * + * Application cannot order EB Library not to use stop code. + * EB Library guesses stop code automatically when appendix is not + * given by application. + * + * Instead, we use dummy stop code. The code is never used in text + * of CD-ROM book. + */ +#define DUMMY_STOP_CODE0 0x1f00 +#define DUMMY_STOP_CODE1 0x0000 + +/* + * Command line options. + */ +static const char *short_options = "c:hl:np:v"; +static struct option long_options[] = { + {"code", required_argument, NULL, 'c'}, + {"help", no_argument, NULL, 'h'}, + {"text-length", required_argument, NULL, 'l'}, + {"no-candidates", no_argument, NULL, 'n'}, + {"text-position", required_argument, NULL, 'p'}, + {"version", no_argument, NULL, 'v'}, + {NULL, 0, NULL, 0} +}; + +/* + * Program name and version. + */ +static const char *program_name = "ebstopcode"; +static const char *program_version = VERSION; +static const char *invoked_name; + +/* + * Unexported functions. + */ +static int parse_stop_code_argument(const char *argument, + unsigned int *stop_code0, unsigned int *stop_code1); +static int parse_text_length_argument(const char *argument, + ssize_t *text_length); +static int parse_text_position_argument(const char *argument, + EB_Position *text_position); +static void output_help(void); +static int scan_subbook_text(const char *book_directory, + const char *subbook_name, EB_Position *text_position, + ssize_t max_text_length, int show_stop_code_flag, unsigned int stop_code0, + unsigned int stop_code1); +static EB_Error_Code hook_stop_code(EB_Book *book, EB_Appendix *appendix, + void *container, EB_Hook_Code code, int argc, const unsigned int *argv); + + +int +main(int argc, char *argv[]) +{ + const char *book_directory; + ssize_t max_text_length; + const char *subbook_name; + int show_stop_code_flag; + EB_Position text_position; + unsigned int stop_code0, stop_code1; + int ch; + + invoked_name = argv[0]; + max_text_length = DEFAULT_MAX_TEXT_LENGTH; + show_stop_code_flag = 1; + stop_code0 = DUMMY_STOP_CODE0; + stop_code1 = DUMMY_STOP_CODE1; + text_position.page = 0; + text_position.offset = 0; + + /* + * Initialize locale data. + */ +#ifdef ENABLE_NLS +#ifdef HAVE_SETLOCALE + setlocale(LC_ALL, ""); +#endif + bindtextdomain(TEXT_DOMAIN_NAME, LOCALEDIR); + textdomain(TEXT_DOMAIN_NAME); +#endif + + /* + * Parse command line options. + */ + for (;;) { + ch = getopt_long(argc, argv, short_options, long_options, NULL); + if (ch == -1) + break; + + switch (ch) { + case 'c': + /* + * Option `-c'. Specify stop code manually. + */ + if (parse_stop_code_argument(optarg, &stop_code0, &stop_code1) < 0) + goto die; + max_text_length = 0; + break; + + case 'h': + /* + * Option `-h'. Display help message, then exit. + */ + output_help(); + exit(0); + + case 'l': + /* + * Option `-l'. Specify maximum length of text. + */ + if (parse_text_length_argument(optarg, &max_text_length) < 0) + goto die; + stop_code0 = DUMMY_STOP_CODE0; + stop_code1 = DUMMY_STOP_CODE1; + break; + + case 'n': + /* + * Option `-n'. Do not output stop code candidates. + */ + show_stop_code_flag = 0; + break; + + case 'p': + /* + * Option `-p'. Specify text position. + */ + if (parse_text_position_argument(optarg, &text_position) < 0) + goto die; + 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 (argc - optind < 2) { + fprintf(stderr, _("%s: too few argument\n"), invoked_name); + output_try_help(invoked_name); + goto die; + } + if (2 < argc - optind) { + fprintf(stderr, _("%s: too many arguments\n"), invoked_name); + output_try_help(invoked_name); + goto die; + } + if (argc - optind == 2) { + book_directory = argv[optind]; + subbook_name = argv[optind + 1]; + } else { + book_directory = DEFAULT_BOOK_DIRECTORY; + subbook_name = argv[optind]; + } + + /* + * Scan stop code in text. + */ + if (scan_subbook_text(book_directory, subbook_name, &text_position, + max_text_length, show_stop_code_flag, stop_code0, stop_code1) < 0) + goto die; + + return 0; + + die: + fflush(stdout); + exit(1); +} + + +/* + * Parse stop code given as argument of the `-c' option. + */ +static int +parse_stop_code_argument(const char *argument, unsigned int *stop_code0, + unsigned int *stop_code1) +{ + const char *p = argument; + const char *foundp; + + /* + * Parse stop_code0. + */ + while (*p == ' ' || *p == '\t') + p++; + if (*p == '0' && (*(p + 1) == 'x' || *(p + 1) == 'X')) + p += 2; + + foundp = p; + while (ASCII_ISXDIGIT(*p)) + p++; + + if (p == foundp || (*p != ' ' && *p != '\t')) + goto failed; + *stop_code0 = strtol(foundp, NULL, 16); + if (*stop_code0 != 0x1f09 && *stop_code0 != 0x1f41) + goto failed; + + /* + * Parse stop_code1. + */ + while (*p == ' ' || *p == '\t') + p++; + if (*p == '0' && (*(p + 1) == 'x' || *(p + 1) == 'X')) + p += 2; + + foundp = p; + while (ASCII_ISXDIGIT(*p)) + p++; + + if (p == foundp || (*p != ' ' && *p != '\t' && *p != '\0')) + goto failed; + *stop_code1 = strtol(foundp, NULL, 16); + if (0xffff < *stop_code1) + goto failed; + + while (*p == ' ' || *p == '\t') + p++; + if (*p != '\0') + goto failed; + + return 0; + + /* + * An error occurs... + */ + failed: + fprintf(stderr, _("%s: invalid stop code `%s'\n"), invoked_name, + argument); + return -1; +} + + +/* + * Parse stop code given as argument of the `-t' option. + */ +static int +parse_text_length_argument(const char *argument, ssize_t *text_length) +{ + const char *p = argument; + const char *foundp; + + while (*p == ' ' || *p == '\t') + p++; + + foundp = p; + while (ASCII_ISDIGIT(*p)) + p++; + if (p == foundp) + goto failed; + while (*p == ' ' || *p == '\t') + p++; + if (*p != '\0') + goto failed; + + *text_length = strtol(foundp, NULL, 10); + return 0; + + /* + * An error occurs... + */ + failed: + fprintf(stderr, _("%s: invalid text length `%s'\n"), invoked_name, + argument); + return -1; +} + + +/* + * Parse text position given as argument of the `-p' option. + */ +static int +parse_text_position_argument(const char *argument, EB_Position *text_position) +{ + const char *p = argument; + const char *end_p; + int page; + int offset; + + /* + * Parse page. + */ + while (*p == ' ' || *p == '\t') + p++; + + if (*p == '0' && (*(p + 1) == 'x' || *(p + 1) == 'X')) + p += 2; + page = strtol(p, (char **)&end_p, 16); + if (end_p == p || *end_p != ':') + goto failed; + if (page <= 0) + goto failed; + + /* + * Parse offset. + */ + p = end_p + 1; + + if (*p == '0' && (*(p + 1) == 'x' || *(p + 1) == 'X')) + p += 2; + offset = strtol(p, (char **)&end_p, 16); + if (end_p == p) + goto failed; + while (*end_p == ' ' || *end_p == '\t') + end_p++; + if (*end_p != '\0') + goto failed; + if (offset < 0 || EB_SIZE_PAGE <= offset) + goto failed; + + text_position->page = page; + text_position->offset = offset; + + return 0; + + /* + * An error occurs... + */ + failed: + fprintf(stderr, _("%s: invalid text position `%s'\n"), invoked_name, + argument); + return -1; +} + + +/* + * Output help message to standard out, then exit. + */ +static void +output_help(void) +{ + printf(_("Usage: %s [option...] [book-directory] subbook\n"), + program_name); + printf(_("Options:\n")); + printf(_(" -c CODE, --code CODE\n")); + printf(_(" set stop code manually\n")); + printf(_(" -h --help display this help, then exit\n")); + printf(_(" -l LENGTH, --text-length LENGTH\n")); + printf(_(" maximum length of output text\n")); + printf(_(" (default: %d)\n"), + DEFAULT_MAX_TEXT_LENGTH); + printf(_(" -n --no-candidates suppress stop code candidates\n")); + printf(_(" -p PAGE:OFFSET, --text-position PAGE:OFFSET\n")); + printf(_(" start position of text\n")); + printf(_(" -v --version display version number, then exit\n")); + printf(_("\nArgument:\n")); + printf(_(" book-directory top directory of a CD-ROM book\n")); + printf(_(" (default: %s)\n"), + DEFAULT_BOOK_DIRECTORY); + printf(_("\nReport bugs to %s.\n"), MAILING_ADDRESS); + fflush(stdout); +} + + +/* + * Scan stop code in text. + */ +static int +scan_subbook_text(const char *book_directory, const char *subbook_name, + EB_Position *text_position, ssize_t max_text_length, + int show_stop_code_flag, unsigned int stop_code0, unsigned int stop_code1) +{ + EB_Error_Code error_code; + EB_Book book; + EB_Hookset hookset; + EB_Hook hook; + EB_Appendix appendix; + EB_Appendix_Subbook appendix_subbook; + EB_Subbook_Code subbook_code; + char text[EB_SIZE_PAGE]; + ssize_t text_length; + + /* + * Initialize EB Library, `book', `appendix' and `hookset'. + */ + eb_initialize_library(); + eb_initialize_book(&book); + eb_initialize_appendix(&appendix); + eb_initialize_hookset(&hookset); + + /* + * Bind `book'. + */ + error_code = eb_bind(&book, book_directory); + if (error_code != EB_SUCCESS) { + fprintf(stderr, _("%s: failed to bind the book, %s: %s\n"), + program_name, eb_error_message(error_code), book_directory); + goto die; + } + + /* + * Get a subbook code from the subbook name. + */ + error_code = find_subbook(&book, subbook_name, &subbook_code); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s: %s\n", + program_name, eb_error_message(error_code), subbook_name); + goto die; + } + + /* + * Set current subbook. + */ + if (eb_set_subbook(&book, subbook_code) < 0) { + fprintf(stderr, _("%s: failed to set the current subbook, %s\n"), + program_name, eb_error_message(error_code)); + goto die; + } + + /* + * Set stop-code manually. + * (we hack `appendix' directly.) + */ + appendix.code = subbook_code; + appendix.subbook_current = &appendix_subbook; + appendix_subbook.code = subbook_code; + appendix_subbook.stop_code0 = stop_code0; + appendix_subbook.stop_code1 = stop_code1; + + /* + * Set text hooks (for 0x1f41 and 0x1f09). + */ + if (show_stop_code_flag) { + hook.code = EB_HOOK_BEGIN_KEYWORD; + hook.function = hook_stop_code; + eb_set_hook(&hookset, &hook); + + hook.code = EB_HOOK_SET_INDENT; + hook.function = hook_stop_code; + eb_set_hook(&hookset, &hook); + } + + /* + * Get a position where the text data starts, if text_position + * is {page=0, offset=0}. + */ + if (text_position->page == 0 && text_position->offset == 0) { + error_code = eb_text(&book, text_position); + if (error_code != EB_SUCCESS) { + fprintf(stderr, _("%s: failed to get text information, %s\n"), + program_name, eb_error_message(error_code)); + goto die; + } + } + + /* + * Read text. + */ + error_code = eb_seek_text(&book, text_position); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s\n", + program_name, eb_error_message(error_code)); + goto die; + } + + text_length = 0; + while (max_text_length == 0 || text_length < max_text_length) { + ssize_t result_length; + size_t read_length; + + if (max_text_length == 0 + || sizeof(text) - 1 <= max_text_length - text_length) { + read_length = sizeof(text) - 1; + } else { + read_length = max_text_length - text_length; + } + error_code = eb_read_text(&book, &appendix, &hookset, NULL, + read_length, text, &result_length); + if (error_code != EB_SUCCESS) { + fprintf(stderr, _("%s: failed to read text, %s\n"), + program_name, eb_error_message(error_code)); + goto die; + } + if (result_length <= 0) + break; + fputs_eucjp_to_locale(text, stdout); + text_length += result_length; + } + + /* + * Finalize `hookset', `appendix', `book' and EB Library. + */ + eb_finalize_hookset(&hookset); + eb_finalize_appendix(&appendix); + eb_finalize_book(&book); + eb_finalize_library(); + return 0; + + /* + * An error occurs... + */ + die: + eb_finalize_hookset(&hookset); + eb_finalize_appendix(&appendix); + eb_finalize_book(&book); + eb_finalize_library(); + return -1; +} + + +/* + * Hook function for EB_HOOK_BEGIN_KEYWORD and EB_HOK_SET_INDENT. + */ +static EB_Error_Code +hook_stop_code(EB_Book *book, EB_Appendix *appendix, void *container, + EB_Hook_Code code, int argc, const unsigned int *argv) +{ + char string[EB_SIZE_PAGE]; + + if (0 < book->text_context.printable_count) { + sprintf(string, "\n=== stop-code?: 0x%04x 0x%04x ===\n", + argv[0], argv[1]); + eb_write_text_string(book, string); + } + + return EB_SUCCESS; +} diff --git a/ebzip/Makefile.am b/ebzip/Makefile.am new file mode 100644 index 0000000..d564c36 --- /dev/null +++ b/ebzip/Makefile.am @@ -0,0 +1,40 @@ +localedir = $(datadir)/locale + +LIBEB = $(top_builddir)/eb/libeb.la +LIBEBUTILS = $(top_builddir)/libebutils/libebutils.a + +bin_PROGRAMS = ebzip +noinst_HEADERS = ebzip.h + +ebzip_SOURCES = ebzip.c ebzip1.c copyfile.c unzipbook.c unzipfile.c \ + zipbook.c zipfile.c zipinfobook.c zipinfofile.c sebxa.c speedup.c \ + unlinkfile.c +ebzip_LDADD = $(LIBEBUTILS) $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) $(ICONVLIBS) +ebzip_DEPENDENCIES = $(LIBEB) $(LIBEBUTILS) $(ZLIBDEPS) $(INTLDEPS) \ + $(ICONVDEPS) + +INCLUDES = -I../libebutils -I$(top_srcdir)/libebutils \ + -I../eb -I$(top_srcdir)/eb $(INTLINCS) $(ZLIBINCS) + +# Shorten command name `ebzipinfo' for DOS & Win32. +if EXEEXT_EXE +ebzipinfo = ebzipinf +else +ebzipinfo = ebzipinfo +endif + +install-exec-hook: + rm -f $(DESTDIR)$(bindir)/ebunzip$(EXEEXT) + ln $(DESTDIR)$(bindir)/`echo ebzip|sed '$(transform)'`$(EXEEXT) \ + $(DESTDIR)$(bindir)/`echo ebunzip|sed '$(transform)'`$(EXEEXT) \ + || cp $(DESTDIR)$(bindir)/`echo ebzip|sed '$(transform)'`$(EXEEXT) \ + $(DESTDIR)$(bindir)/`echo ebunzip|sed '$(transform)'`$(EXEEXT) + rm -f $(DESTDIR)$(bindir)/ebzipinfo$(EXEEXT) + ln $(DESTDIR)$(bindir)/`echo ebzip|sed '$(transform)'`$(EXEEXT) \ + $(DESTDIR)$(bindir)/`echo $(ebzipinfo)|sed '$(transform)'`$(EXEEXT) \ + || cp $(DESTDIR)$(bindir)/`echo ebzip|sed '$(transform)'`$(EXEEXT) \ + $(DESTDIR)$(bindir)/`echo $(ebzipinfo)|sed '$(transform)'`$(EXEEXT) + +uninstall-hook: + rm -f $(DESTDIR)$(bindir)/`echo ebunzip|sed '$(transform)'`$(EXEEXT) + rm -f $(DESTDIR)$(bindir)/`echo $(ebzipinfo)|sed '$(transform)'`$(EXEEXT) diff --git a/ebzip/Makefile.in b/ebzip/Makefile.in new file mode 100644 index 0000000..d02740a --- /dev/null +++ b/ebzip/Makefile.in @@ -0,0 +1,547 @@ +# Makefile.in generated by automake 1.10.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = ebzip$(EXEEXT) +subdir = ebzip +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/in6addr.m4 $(top_srcdir)/m4/largefile.m4 \ + $(top_srcdir)/m4/lcmessage.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/sockaddrin6.m4 \ + $(top_srcdir)/m4/sockinttypes.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_ebzip_OBJECTS = ebzip.$(OBJEXT) ebzip1.$(OBJEXT) copyfile.$(OBJEXT) \ + unzipbook.$(OBJEXT) unzipfile.$(OBJEXT) zipbook.$(OBJEXT) \ + zipfile.$(OBJEXT) zipinfobook.$(OBJEXT) zipinfofile.$(OBJEXT) \ + sebxa.$(OBJEXT) speedup.$(OBJEXT) unlinkfile.$(OBJEXT) +ebzip_OBJECTS = $(am_ebzip_OBJECTS) +am__DEPENDENCIES_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(ebzip_SOURCES) +DIST_SOURCES = $(ebzip_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +EBCONF_EBINCS = @EBCONF_EBINCS@ +EBCONF_EBLIBS = @EBCONF_EBLIBS@ +EBCONF_INTLINCS = @EBCONF_INTLINCS@ +EBCONF_INTLLIBS = @EBCONF_INTLLIBS@ +EBCONF_ZLIBINCS = @EBCONF_ZLIBINCS@ +EBCONF_ZLIBLIBS = @EBCONF_ZLIBLIBS@ +EB_VERSION_MAJOR = @EB_VERSION_MAJOR@ +EB_VERSION_MINOR = @EB_VERSION_MINOR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_EBNET = @ENABLE_EBNET@ +ENABLE_NLS = @ENABLE_NLS@ +ENABLE_PTHREAD = @ENABLE_PTHREAD@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +ICONVINCS = @ICONVINCS@ +ICONVLIBS = @ICONVLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLINCS = @INTLINCS@ +INTLLIBS = @INTLLIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBEB_VERSION_INFO = @LIBEB_VERSION_INFO@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAILING_ADDRESS = @MAILING_ADDRESS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_CPPFLAGS = @PTHREAD_CPPFLAGS@ +PTHREAD_LDFLAGS = @PTHREAD_LDFLAGS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +ZLIBDEPS = @ZLIBDEPS@ +ZLIBINCS = @ZLIBINCS@ +ZLIBLIBS = @ZLIBLIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = $(datadir)/locale +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgdocdir = @pkgdocdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +LIBEB = $(top_builddir)/eb/libeb.la +LIBEBUTILS = $(top_builddir)/libebutils/libebutils.a +noinst_HEADERS = ebzip.h +ebzip_SOURCES = ebzip.c ebzip1.c copyfile.c unzipbook.c unzipfile.c \ + zipbook.c zipfile.c zipinfobook.c zipinfofile.c sebxa.c speedup.c \ + unlinkfile.c + +ebzip_LDADD = $(LIBEBUTILS) $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) $(ICONVLIBS) +ebzip_DEPENDENCIES = $(LIBEB) $(LIBEBUTILS) $(ZLIBDEPS) $(INTLDEPS) \ + $(ICONVDEPS) + +INCLUDES = -I../libebutils -I$(top_srcdir)/libebutils \ + -I../eb -I$(top_srcdir)/eb $(INTLINCS) $(ZLIBINCS) + +@EXEEXT_EXE_FALSE@ebzipinfo = ebzipinfo + +# Shorten command name `ebzipinfo' for DOS & Win32. +@EXEEXT_EXE_TRUE@ebzipinfo = ebzipinf +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ebzip/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu ebzip/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +ebzip$(EXEEXT): $(ebzip_OBJECTS) $(ebzip_DEPENDENCIES) + @rm -f ebzip$(EXEEXT) + $(LINK) $(ebzip_OBJECTS) $(ebzip_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copyfile.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ebzip.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ebzip1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sebxa.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/speedup.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unlinkfile.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzipbook.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzipfile.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zipbook.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zipfile.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zipinfobook.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zipinfofile.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-exec-hook + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) uninstall-hook + +.MAKE: install-am install-exec-am install-strip uninstall-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-exec-hook \ + install-html install-html-am install-info install-info-am \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS uninstall-hook + + +install-exec-hook: + rm -f $(DESTDIR)$(bindir)/ebunzip$(EXEEXT) + ln $(DESTDIR)$(bindir)/`echo ebzip|sed '$(transform)'`$(EXEEXT) \ + $(DESTDIR)$(bindir)/`echo ebunzip|sed '$(transform)'`$(EXEEXT) \ + || cp $(DESTDIR)$(bindir)/`echo ebzip|sed '$(transform)'`$(EXEEXT) \ + $(DESTDIR)$(bindir)/`echo ebunzip|sed '$(transform)'`$(EXEEXT) + rm -f $(DESTDIR)$(bindir)/ebzipinfo$(EXEEXT) + ln $(DESTDIR)$(bindir)/`echo ebzip|sed '$(transform)'`$(EXEEXT) \ + $(DESTDIR)$(bindir)/`echo $(ebzipinfo)|sed '$(transform)'`$(EXEEXT) \ + || cp $(DESTDIR)$(bindir)/`echo ebzip|sed '$(transform)'`$(EXEEXT) \ + $(DESTDIR)$(bindir)/`echo $(ebzipinfo)|sed '$(transform)'`$(EXEEXT) + +uninstall-hook: + rm -f $(DESTDIR)$(bindir)/`echo ebunzip|sed '$(transform)'`$(EXEEXT) + rm -f $(DESTDIR)$(bindir)/`echo $(ebzipinfo)|sed '$(transform)'`$(EXEEXT) +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/ebzip/copyfile.c b/ebzip/copyfile.c new file mode 100644 index 0000000..10a4f15 --- /dev/null +++ b/ebzip/copyfile.c @@ -0,0 +1,399 @@ +/* -*- C -*- + * Copyright (c) 1998-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "ebzip.h" +#include "ebutils.h" + +/* + * File name to be deleted and file to be closed when signal is received. + */ +static const char *trap_file_name = NULL; +static int trap_file = -1; + +/* + * Unexported function. + */ +static void trap(int signal_number); + + +/* + * Copy a file. + * If it succeeds, 0 is returned. Otherwise -1 is returned. + */ +int +ebzip_copy_file(const char *out_file_name, const char *in_file_name) +{ + unsigned char buffer[EB_SIZE_PAGE]; + off_t total_length; + struct stat in_status, out_status; + int in_file = -1, out_file = -1; + ssize_t in_length; + int progress_interval; + int total_slices; + struct utimbuf utim; + int i; + + /* + * Output file name information. + */ + if (!ebzip_quiet_flag) { + fprintf(stderr, _("==> copy %s <==\n"), in_file_name); + fprintf(stderr, _("output to %s\n"), out_file_name); + fflush(stderr); + } + + /* + * Check for the input file. + */ + if (stat(in_file_name, &in_status) != 0 || !S_ISREG(in_status.st_mode)) { + fprintf(stderr, _("%s: no such file: %s\n"), invoked_name, + in_file_name); + goto failed; + } + + /* + * Do nothing if the `in_file_name' and `out_file_name' are the same. + */ + if (is_same_file(out_file_name, in_file_name)) { + if (!ebzip_quiet_flag) { + fprintf(stderr, + _("the input and output files are the same, skipped.\n\n")); + fflush(stderr); + } + return 0; + } + + /* + * When test mode, return immediately. + */ + if (ebzip_test_flag) { +#if defined(PRINTF_LL_MODIFIER) + fprintf(stderr, _("completed (%llu / %llu bytes)\n"), + (unsigned long long) in_status.st_size, + (unsigned long long) in_status.st_size); +#elif defined(PRINTF_I64_MODIFIER) + fprintf(stderr, _("completed (%I64u / %I64u bytes)\n"), + (unsigned __int64) in_status.st_size, + (unsigned __int64) in_status.st_size); +#else + fprintf(stderr, _("completed (%lu / %lu bytes)\n"), + (unsigned long) in_status.st_size, + (unsigned long) in_status.st_size); +#endif + fputc('\n', stderr); + fflush(stderr); + return 0; + } + + /* + * If the file to be output already exists, confirm and unlink it. + */ + if (stat(out_file_name, &out_status) == 0 + && S_ISREG(out_status.st_mode)) { + if (ebzip_overwrite_mode == EBZIP_OVERWRITE_NO) { + if (!ebzip_quiet_flag) { + fputs(_("already exists, skip the file\n\n"), stderr); + fflush(stderr); + } + return 0; + } + if (ebzip_overwrite_mode == EBZIP_OVERWRITE_CONFIRM) { + int y_or_n; + + fprintf(stderr, _("\nthe file already exists: %s\n"), + out_file_name); + y_or_n = query_y_or_n(_("do you wish to overwrite (y or n)? ")); + fputc('\n', stderr); + fflush(stderr); + if (!y_or_n) + return 0; + } + if (unlink(out_file_name) < 0) { + fprintf(stderr, _("%s: failed to unlink the file: %s\n"), + invoked_name, out_file_name); + goto failed; + } + } + + /* + * Open files. + */ + in_file = open(in_file_name, O_RDONLY | O_BINARY); + if (in_file < 0) { + fprintf(stderr, _("%s: failed to open the file, %s: %s\n"), + invoked_name, strerror(errno), in_file_name); + goto failed; + } + + trap_file_name = out_file_name; +#ifdef SIGHUP + signal(SIGHUP, trap); +#endif + signal(SIGINT, trap); +#ifdef SIGQUIT + signal(SIGQUIT, trap); +#endif +#ifdef SIGTERM + signal(SIGTERM, trap); +#endif + +#ifdef O_CREAT + out_file = open(out_file_name, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, + 0666 ^ get_umask()); +#else + out_file = creat(out_file_name, 0666 ^ get_umask()); +#endif + if (out_file < 0) { + fprintf(stderr, _("%s: failed to open the file, %s: %s\n"), + invoked_name, strerror(errno), out_file_name); + goto failed; + } + trap_file = out_file; + + /* + * Read data from the input file, compress the data, and then + * write them to the output file. + */ + total_length = 0; + total_slices = (in_status.st_size + EB_SIZE_PAGE - 1) / EB_SIZE_PAGE; + progress_interval = EBZIP_PROGRESS_INTERVAL_FACTOR; + for (i = 0; i < total_slices; i++) { + /* + * Read data from `in_file', and write them to `out_file'. + */ + in_length = read(in_file, buffer, EB_SIZE_PAGE); + if (in_length < 0) { + fprintf(stderr, _("%s: failed to read from the file, %s: %s\n"), + invoked_name, strerror(errno), in_file_name); + goto failed; + } else if (in_length == 0) { + fprintf(stderr, _("%s: unexpected EOF: %s\n"), + invoked_name, in_file_name); + goto failed; + } else if (in_length != EB_SIZE_PAGE + && total_length + in_length != in_status.st_size) { + fprintf(stderr, _("%s: unexpected EOF: %s\n"), + invoked_name, in_file_name); + goto failed; + } + + /* + * Write decoded data to `out_file'. + */ + if (write(out_file, buffer, in_length) != in_length) { + fprintf(stderr, _("%s: failed to write to the file, %s: %s\n"), + invoked_name, strerror(errno), out_file_name); + goto failed; + } + total_length += in_length; + + /* + * Output status information unless `quiet' mode. + */ + if (!ebzip_quiet_flag && (i + 1) % progress_interval == 0) { +#if defined(PRINTF_LL_MODIFIER) + fprintf(stderr, _("%4.1f%% done (%llu / %llu bytes)\n"), + (double) (i + 1) * 100.0 / (double) total_slices, + (unsigned long long) total_length, + (unsigned long long) in_status.st_size); +#elif defined(PRINTF_I64_MODIFIER) + fprintf(stderr, _("%4.1f%% done (%I64u / %I64u bytes)\n"), + (double) (i + 1) * 100.0 / (double) total_slices, + (unsigned __int64) total_length, + (unsigned __int64) in_status.st_size); +#else + fprintf(stderr, _("%4.1f%% done (%lu / %lu bytes)\n"), + (double) (i + 1) * 100.0 / (double) total_slices, + (unsigned long) total_length, + (unsigned long) in_status.st_size); +#endif + fflush(stderr); + } + } + + /* + * Output the result unless quiet mode. + */ + if (!ebzip_quiet_flag) { +#if defined(PRINTF_LL_MODIFIER) + fprintf(stderr, _("completed (%llu / %llu bytes)\n"), + (unsigned long long) total_length, + (unsigned long long) in_status.st_size); +#elif defined(PRINTF_I64_MODIFIER) + fprintf(stderr, _("completed (%I64u / %I64u bytes)\n"), + (unsigned __int64) total_length, + (unsigned __int64) in_status.st_size); +#else + fprintf(stderr, _("completed (%lu / %lu bytes)\n"), + (unsigned long) total_length, + (unsigned long) in_status.st_size); +#endif + fputc('\n', stderr); + fflush(stderr); + } + + /* + * Close files. + */ + close(in_file); + in_file = -1; + + close(out_file); + out_file = -1; + trap_file = -1; + trap_file_name = NULL; +#ifdef SIGHUP + signal(SIGHUP, SIG_DFL); +#endif + signal(SIGINT, SIG_DFL); +#ifdef SIGQUIT + signal(SIGQUIT, SIG_DFL); +#endif +#ifdef SIGTERM + signal(SIGTERM, SIG_DFL); +#endif + + /* + * Delete an original file unless the keep flag is set. + */ + if (!ebzip_test_flag && !ebzip_keep_flag) + unlink_files_add(in_file_name); + + /* + * Set owner, group, permission, atime and mtime of `out_file'. + * We ignore return values of `chown', `chmod' and `utime'. + */ + utim.actime = in_status.st_atime; + utim.modtime = in_status.st_mtime; + utime(out_file_name, &utim); + + return 0; + + /* + * An error occurs... + */ + failed: + if (0 <= in_file) + close(in_file); + if (0 <= out_file) + close(out_file); + + fputc('\n', stderr); + fflush(stderr); + + return -1; +} + + +/* + * Copy all files in a directory. + * If it succeeds, 0 is returned. Otherwise -1 is returned. + */ +int +ebzip_copy_files_in_directory(const char *out_directory_name, + const char *in_directory_name) +{ + struct dirent *entry; + DIR *dir = NULL; + struct stat in_status; + char in_path_name[PATH_MAX + 1]; + char out_path_name[PATH_MAX + 1]; + + /* + * Check for the input directory. + */ + if (stat(in_directory_name, &in_status) != 0 + || !S_ISDIR(in_status.st_mode)) + return 0; + + + /* + * Make the output directory if missing. + */ + if (!ebzip_test_flag + && make_missing_directory(out_directory_name, 0777 ^ get_umask()) + < 0) { + fprintf(stderr, _("%s: failed to create a directory, %s: %s\n"), + invoked_name, strerror(errno), out_directory_name); + goto failed; + } + + /* + * Open the directory `path'. + */ + dir = opendir(in_directory_name); + if (dir == NULL) { + fprintf(stderr, _("%s: failed to open the directory, %s: %s\n"), + invoked_name, strerror(errno), in_directory_name); + goto failed; + } + + for (;;) { + /* + * Read the directory entry. + */ + entry = readdir(dir); + if (entry == NULL) + break; + + eb_compose_path_name(in_directory_name, entry->d_name, in_path_name); + eb_compose_path_name(out_directory_name, entry->d_name, out_path_name); + + if (stat(in_path_name, &in_status) != 0 + || !S_ISREG(in_status.st_mode)) + continue; + + ebzip_copy_file(out_path_name, in_path_name); + } + + closedir(dir); + return 0; + + /* + * An error occurs... + */ + failed: + if (dir != NULL) + closedir(dir); + return -1; +} + + +/* + * Signal handler. + */ +static void +trap(int signal_number) +{ + if (0 <= trap_file) + close(trap_file); + if (trap_file_name != NULL) + unlink(trap_file_name); + + exit(1); +} diff --git a/ebzip/ebzip.c b/ebzip/ebzip.c new file mode 100644 index 0000000..9c87a0d --- /dev/null +++ b/ebzip/ebzip.c @@ -0,0 +1,570 @@ +/* -*- C -*- + * Copyright (c) 1998-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "ebzip.h" +#include "ebutils.h" + +#if defined(DOS_FILE_PATH) && defined(HAVE_MBSTRING_H) +/* a path may contain double-byte chars in SJIS. */ +#include +#define strchr _mbschr +#define strrchr _mbsrchr +#endif + +/* + * Program name and version. + */ +const char *program_name = "ebzip"; +const char *program_version = VERSION; +const char *invoked_name; + +/* + * Command line options. + */ +static const char *short_options = "fhikl:no:qs:S:tT:uvw:z"; +static struct option long_options[] = { + {"force-overwrite", no_argument, NULL, 'f'}, + {"help", no_argument, NULL, 'h'}, + {"information", no_argument, NULL, 'i'}, + {"keep", no_argument, NULL, 'k'}, + {"level", required_argument, NULL, 'l'}, + {"no-overwrite", no_argument, NULL, 'n'}, + {"output-directory", required_argument, NULL, 'o'}, + {"quiet", no_argument, NULL, 'q'}, + {"silent", no_argument, NULL, 'q'}, + {"skip-content", required_argument, NULL, 's'}, + {"subbook", required_argument, NULL, 'S'}, + {"test", no_argument, NULL, 't'}, + {"uncompress", no_argument, NULL, 'u'}, + {"version", no_argument, NULL, 'v'}, + {"overwrite", required_argument, NULL, 'w'}, + {"compress", no_argument, NULL, 'z'}, + {NULL, 0, NULL, 0} +}; + +/* + * Zip level. + */ +int ebzip_level = EBZIP_DEFAULT_LEVEL; + +/* + * Keep mode flag. + */ +int ebzip_keep_flag = EBZIP_DEFAULT_KEEP; + +/* + * Quiet mode flag. + */ +int ebzip_quiet_flag = EBZIP_DEFAULT_QUIET; + +/* + * Test mode flag. + */ +int ebzip_test_flag = EBZIP_DEFAULT_TEST; + +/* + * Overwrite mode. + */ +int ebzip_overwrite_mode = EBZIP_DEFAULT_OVERWRITE; + +/* + * Target contents. + */ +int ebzip_skip_flag_font = EBZIP_DEFAULT_SKIP_FONT; +int ebzip_skip_flag_graphic = EBZIP_DEFAULT_SKIP_GRAPHIC; +int ebzip_skip_flag_movie = EBZIP_DEFAULT_SKIP_MOVIE; +int ebzip_skip_flag_sound = EBZIP_DEFAULT_SKIP_SOUND; + +/* + * List of files to be unlinked. + */ +String_List unlinking_files; + +/* + * Operation modes. + */ +#define EBZIP_ACTION_ZIP 0 +#define EBZIP_ACTION_UNZIP 1 +#define EBZIP_ACTION_INFO 2 + +static int action_mode = EBZIP_ACTION_ZIP; + +/* + * A list of subbook names to be compressed/uncompressed. + */ +static char +subbook_name_list[EB_MAX_SUBBOOKS][EB_MAX_DIRECTORY_NAME_LENGTH + 1]; +static int subbook_name_count = 0; + +/* + * Unexported functions. + */ +static int parse_zip_level(const char *argument, int *zip_level); +static int parse_skip_content_argument(const char *argument); +static void output_help(void); + + +int +main(int argc, char *argv[]) +{ + EB_Error_Code error_code; + char out_top_path[PATH_MAX + 1]; + char book_path[PATH_MAX + 1]; + int ch; + char *last_slash, *last_backslash; + char *invoked_base_name; + + invoked_name = argv[0]; + strcpy(out_top_path, EBZIP_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 + + /* + * Determine the default action. + */ + last_slash = strrchr(argv[0], '/'); +#ifndef DOS_FILE_PATH + last_backslash = NULL; +#else + last_backslash = strrchr(argv[0], '\\'); +#endif + + if (last_slash == NULL && last_backslash == NULL) + invoked_base_name = argv[0]; + else if (last_slash == NULL) + invoked_base_name = last_backslash + 1; + else if (last_backslash == NULL) + invoked_base_name = last_slash + 1; + else if (last_slash < last_backslash) + invoked_base_name = last_backslash + 1; + else + invoked_base_name = last_slash + 1; + +#ifndef EXEEXT_EXE + if (strcmp(invoked_base_name, "ebunzip") == 0) + action_mode = EBZIP_ACTION_UNZIP; + else if (strcmp(invoked_base_name, "ebzipinfo") == 0) + action_mode = EBZIP_ACTION_INFO; +#else /* EXEEXT_EXE */ + if (strcasecmp(invoked_base_name, "ebunzip") == 0 + || strcasecmp(invoked_base_name, "ebunzip.exe") == 0) { + action_mode = EBZIP_ACTION_UNZIP; + } else if (strcasecmp(invoked_base_name, "ebzipinfo") == 0 + || strcasecmp(invoked_base_name, "ebzipinfo.exe") == 0 + || strcasecmp(invoked_base_name, "ebzipinf") == 0 + || strcasecmp(invoked_base_name, "ebzipinf.exe") == 0) { + action_mode = EBZIP_ACTION_INFO; + } +#endif /* EXEEXT_EXE */ + + /* + * Set overwrite mode. + */ + if (!isatty(0)) + ebzip_overwrite_mode = EBZIP_OVERWRITE_NO; + + /* + * Initialize list of files to be unlinked. + */ + + string_list_initialize(&unlinking_files); + + /* + * Initialize EB Library. + */ + 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 'f': + /* + * Obsolete option `-f'. Set `force' to the overwrite flag. + */ + ebzip_overwrite_mode = EBZIP_OVERWRITE_FORCE; + break; + + case 'h': + /* + * Option `-h'. Display help message, then exit. + */ + output_help(); + exit(0); + + case 'i': + /* + * Option `-i'. Information mode. + */ + action_mode = EBZIP_ACTION_INFO; + break; + + case 'k': + /* + * Option `-k'. Keep (don't delete) input files. + */ + ebzip_keep_flag = 1; + break; + + case 'l': + /* + * Option `-l'. Specify compression level. + */ + if (parse_zip_level(optarg, &ebzip_level) < 0) + exit(1); + break; + + case 'n': + /* + * Obsolete option `-n'. Set `no' to the overwrite flag. + */ + ebzip_overwrite_mode = EBZIP_OVERWRITE_NO; + break; + + case 'o': + /* + * Option `-o'. Output files under DIRECOTRY. + * The length of the file name + * "/subdir/subsubdir/file.ebz;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_top_path, optarg); + canonicalize_path(out_top_path); + if (PATH_MAX < strlen(out_top_path) + 1 + + EB_MAX_DIRECTORY_NAME_LENGTH + 1 + + EB_MAX_DIRECTORY_NAME_LENGTH + 1 + + EB_MAX_FILE_NAME_LENGTH) { + fprintf(stderr, _("%s: too long output directory path\n"), + invoked_name); + goto die; + } + break; + + case 'q': + /* + * Option `-q'. Set quiet flag. + */ + ebzip_quiet_flag = 1; + break; + + case 's': + /* + * Option `-s'. Specify content type to be skipped. + */ + if (parse_skip_content_argument(optarg) < 0) + exit(1); + 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 't': + /* + * Option `-t'. Set test mode. + */ + ebzip_test_flag = 1; + break; + + case 'u': + /* + * Option `-u'. Decompression mode. + */ + action_mode = EBZIP_ACTION_UNZIP; + break; + + case 'v': + /* + * Option `-v'. Display version number, then exit. + */ + output_version(program_name, program_version); + exit(0); + + case 'w': + /* + * Option `-w'. Set overwrite mode. + */ + if (strcasecmp(optarg, "confirm") == 0) + ebzip_overwrite_mode = EBZIP_OVERWRITE_CONFIRM; + else if (strcasecmp(optarg, "force") == 0) + ebzip_overwrite_mode = EBZIP_OVERWRITE_FORCE; + else if (strcasecmp(optarg, "no") == 0) + ebzip_overwrite_mode = EBZIP_OVERWRITE_NO; + else { + fprintf(stderr, _("%s: invalid overwrite mode: %s\n"), + invoked_name, optarg); + output_try_help(invoked_name); + goto die; + } + break; + + case 'z': + /* + * Option `-z'. Compression mode. + */ + action_mode = EBZIP_ACTION_ZIP; + break; + + 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, EBZIP_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); + + /* + * Compress the book. + */ + switch (action_mode) { + case EBZIP_ACTION_ZIP: + if (ebzip_zip_book(out_top_path, book_path, subbook_name_list, + subbook_name_count) < 0) { + goto die; + } + break; + case EBZIP_ACTION_UNZIP: + if (ebzip_unzip_book(out_top_path, book_path, subbook_name_list, + subbook_name_count) < 0) { + goto die; + } + break; + case EBZIP_ACTION_INFO: + if (ebzip_zipinfo_book(book_path, subbook_name_list, + subbook_name_count) < 0) { + goto die; + } + break; + } + + eb_finalize_library(); + unlink_files(); + string_list_finalize(&unlinking_files); + + return 0; + + /* + * A critical error occurs... + */ + die: + eb_finalize_library(); + exit(1); +} + + +/* + * Parse an argument to option `--level (-l)'. + * If the argument is valid form, 0 is returned. + * Otherwise -1 is returned. + */ +static int +parse_zip_level(const char *argument, int *zip_level) +{ + char *end_p; + int level; + + level = (int)strtol(argument, &end_p, 10); + if (!ASCII_ISDIGIT(*argument) || *end_p != '\0' + || level < 0 || ZIO_MAX_EBZIP_LEVEL < level) { + fprintf(stderr, _("%s: invalid compression level `%s'\n"), + invoked_name, argument); + fflush(stderr); + return -1; + } + + *zip_level = level; + + return 0; +} + + +/* + * Parse an argument to option `--skip-content (-S)'. + * If the argument is valid form, 0 is returned. + * Otherwise -1 is returned. + */ +static int +parse_skip_content_argument(const char *argument) +{ + const char *argument_p = argument; + char name[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; + char *name_p; + int i; + + while (*argument_p != '\0') { + /* + * Take a next element in the argument. + */ + i = 0; + name_p = name; + while (*argument_p != ',' && *argument_p != '\0' + && i < EB_MAX_DIRECTORY_NAME_LENGTH) { + *name_p = ASCII_TOLOWER(*argument_p); + i++; + name_p++; + argument_p++; + } + *name_p = '\0'; + if (*argument_p == ',') + argument_p++; + else if (*argument_p != '\0') { + fprintf(stderr, _("%s: invalid content name `%s'\n"), + invoked_name, name); + fflush(stderr); + return -1; + } + + /* + * If the font name is not found in `font_list', it is added to + * the list. + */ + if (strcasecmp(name, "font") == 0) { + ebzip_skip_flag_font = 1; + } else if (strcasecmp(name, "sound") == 0) { + ebzip_skip_flag_sound = 1; + } else if (strcasecmp(name, "graphic") == 0) { + ebzip_skip_flag_graphic = 1; + } else if (strcasecmp(name, "movie") == 0) { + ebzip_skip_flag_movie = 1; + } else { + fprintf(stderr, _("%s: invalid content name `%s'\n"), + invoked_name, name); + fflush(stderr); + return -1; + } + } + + return 0; +} + + +/* + * Output help message to stdandard out. + */ +static void +output_help(void) +{ + printf(_("Usage: %s [option...] [book-directory]\n"), program_name); + printf(_("Options:\n")); + printf(_(" -f --force-overwrite set overwrite mode to `force'\n")); + printf(_(" (same as `--overwrite force')\n")); + printf(_(" -h --help display this help, then exit\n")); + printf(_(" -i --information list information of compressed files\n")); + printf(_(" -k --keep don't delete original files\n")); + printf(_(" -l INTEGER --level INTEGER\n")); + printf(_(" compression level; 0..%d\n"), + ZIO_MAX_EBZIP_LEVEL); + printf(_(" (default: %d)\n"), + EBZIP_DEFAULT_LEVEL); + printf(_(" -n --no-overwrite set overwrite mode to `no'\n")); + printf(_(" (same as `--overwrite no')\n")); + printf(_(" -o DIRECTORY --output-directory DIRECTORY\n")); + printf(_(" ouput files under DIRECTORY\n")); + printf(_(" (default: %s)\n"), + EBZIP_DEFAULT_OUTPUT_DIRECTORY); + printf(_(" -q --quiet --silence suppress all warnings\n")); + printf(_(" -s TYPE[,TYPE] --skip-content TYPE[,TYPE...]\n")); + printf(_(" skip content; font, graphic, sound or movie\n")); + printf(_(" (default: none is skipped)\n")); + printf(_(" -S SUBBOOK[,SUBBOOK...] --subbook SUBBOOK[,SUBBOOK...]\n")); + printf(_(" target subbook\n")); + printf(_(" (default: all subbooks)\n")); + printf(_(" -t --test only check for input files\n")); + printf(_(" -u --uncompress uncompress files\n")); + printf(_(" -v --version display version number, then exit\n")); + printf(_(" -w MODE --overwrite MODE set overwrite mode of output files;\n")); + printf(_(" confirm, force or no\n")); + printf(_(" (default: confirm)\n")); + printf(_(" -z --compress compress files\n")); + printf(_("\nArgument:\n")); + printf(_(" book-directory top directory of a CD-ROM book\n")); + printf(_(" (default: %s)\n"), + EBZIP_DEFAULT_BOOK_DIRECTORY); + + printf(_("\nDefault action:\n")); +#ifndef EXEEXT + printf(_(" When invoked as `ebunzip', uncompression is the default action.\n")); + printf(_(" When invoked as `ebzipinfo', listing information is the default action.\n")); +#else + printf(_(" When invoked as `ebunzip.exe', uncompression is the default action.\n")); + printf(_(" When invoked as `ebzipinf.exe', listing information is the default action.\n")); +#endif + printf(_(" Otherwise, compression is the default action.\n")); + printf(_("\nReport bugs to %s.\n"), MAILING_ADDRESS); + fflush(stdout); +} diff --git a/ebzip/ebzip.h b/ebzip/ebzip.h new file mode 100644 index 0000000..ee29994 --- /dev/null +++ b/ebzip/ebzip.h @@ -0,0 +1,269 @@ +/* -*- C -*- + * Copyright (c) 2001-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef EBZIP_H +#define EBZIP_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef ENABLE_NLS +#ifdef HAVE_LOCALE_H +#include +#endif +#include +#endif + +#include + +#ifndef HAVE_STRCASECMP +int strcasecmp(const char *, const char *); +int strncasecmp(const char *, const char *, size_t); +#endif + +/* + * O_BINARY flag for open(). + */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + +/* + * stat macros. + */ +#ifndef S_ISREG +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#endif +#ifndef S_ISDIR +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif + +/* + * The maximum length of path name. + */ +#ifndef PATH_MAX +#ifdef MAXPATHLEN +#define PATH_MAX MAXPATHLEN +#else /* not MAXPATHLEN */ +#define PATH_MAX 1024 +#endif /* not MAXPATHLEN */ +#endif /* not PATH_MAX */ + +#include "eb.h" +#include "error.h" +#include "font.h" +#include "build-post.h" + +#include "getopt.h" +#include "getumask.h" +#include "makedir.h" +#include "samefile.h" +#include "strlist.h" +#include "yesno.h" + +/* + * Tricks for gettext. + */ +#ifdef ENABLE_NLS +#define _(string) gettext(string) +#ifdef gettext_noop +#define N_(string) gettext_noop(string) +#else +#define N_(string) (string) +#endif +#else +#define _(string) (string) +#define N_(string) (string) +#endif + +/* + * Character type tests and conversions. + */ +#define ASCII_ISDIGIT(c) ('0' <= (c) && (c) <= '9') +#define ASCII_ISUPPER(c) ('A' <= (c) && (c) <= 'Z') +#define ASCII_ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define ASCII_ISALPHA(c) \ + (ASCII_ISUPPER(c) || ASCII_ISLOWER(c)) +#define ASCII_ISALNUM(c) \ + (ASCII_ISUPPER(c) || ASCII_ISLOWER(c) || ASCII_ISDIGIT(c)) +#define ASCII_ISXDIGIT(c) \ + (ASCII_ISDIGIT(c) || ('A' <= (c) && (c) <= 'F') || ('a' <= (c) && (c) <= 'f')) +#define ASCII_TOUPPER(c) (('a' <= (c) && (c) <= 'z') ? (c) - 0x20 : (c)) +#define ASCII_TOLOWER(c) (('A' <= (c) && (c) <= 'Z') ? (c) + 0x20 : (c)) + +/* + * File name suffixes. + */ +#define EBZIP_SUFFIX_NONE "" +#define EBZIP_SUFFIX_EBZ ".ebz" +#define EBZIP_SUFFIX_ORG ".org" + +/* + * Defaults input and output directories. + */ +#define EBZIP_DEFAULT_BOOK_DIRECTORY "." +#define EBZIP_DEFAULT_OUTPUT_DIRECTORY "." + +/* + * Information output interval. + */ +#define EBZIP_PROGRESS_INTERVAL_FACTOR 1024 + +/* + * Overwrite modes. + */ +#define EBZIP_OVERWRITE_CONFIRM 0 +#define EBZIP_OVERWRITE_FORCE 1 +#define EBZIP_OVERWRITE_NO 2 + +/* + * Defaults. + */ +#define EBZIP_DEFAULT_LEVEL 0 +#define EBZIP_DEFAULT_KEEP 0 +#define EBZIP_DEFAULT_QUIET 0 +#define EBZIP_DEFAULT_TEST 0 +#define EBZIP_DEFAULT_OVERWRITE EBZIP_OVERWRITE_CONFIRM + +#define EBZIP_DEFAULT_SKIP_FONT 0 +#define EBZIP_DEFAULT_SKIP_GRAPHIC 0 +#define EBZIP_DEFAULT_SKIP_MOVIE 0 +#define EBZIP_DEFAULT_SKIP_SOUND 0 + +/* + * Region in HONMON or START file which ebzip doesn't compress. + */ +#define EBZIP_MAX_SPEEDUP_REGION_COUNT 3 + +typedef struct { + int start_page; + int end_page; +} Zip_Speedup_Region; + +typedef struct { + int region_count; + Zip_Speedup_Region regions[EBZIP_MAX_SPEEDUP_REGION_COUNT]; +} Zip_Speedup; + + +/* + * Global variables. + */ +extern const char *program_name; +extern const char *program_version; +extern const char *invoked_name; + +extern int ebzip_level; +extern int ebzip_keep_flag; +extern int ebzip_quiet_flag; +extern int ebzip_test_flag; +extern int ebzip_overwrite_mode; + +extern int ebzip_skip_flag_font; +extern int ebzip_skip_flag_graphic; +extern int ebzip_skip_flag_movie; +extern int ebzip_skip_flag_sound; + +extern String_List unlinking_files; + +/* + * Function declarations. + */ +/* copyfile.c */ +int ebzip_copy_file(const char *out_file_name, const char *in_file_name); +int ebzip_copy_files_in_directory(const char *out_directory_name, + const char *in_directory_name); + +/* ebzip1.c */ +int ebzip1_slice(char *out_buffer, size_t *out_byte_length, char *in_buffer, + size_t in_byte_length); + +/* sebxa.c */ +int rewrite_sebxa_start(const char *file_name, int index_page); +int get_sebxa_indexes(const char *file_name, int index_page, + off_t *index_location, off_t *index_base, off_t *zio_start_location, + off_t *zio_end_location); + +/* unzipbook.c */ +int ebzip_unzip_book(const char *out_top_path, const char *book_path, + char subbook_name_list[][EB_MAX_DIRECTORY_NAME_LENGTH + 1], + int subbook_name_count); + +/* unzipfile.c */ +int ebzip_unzip_file(const char *out_file_name, const char *in_file_name, + Zio_Code in_zio_code); +int ebzip_unzip_start_file(const char *out_file_name, + const char *in_file_name, Zio_Code in_zio_code, int index_page); + +/* zipbook.c */ +int ebzip_zip_book(const char *out_top_path, const char *book_path, + char subbook_name_list[][EB_MAX_DIRECTORY_NAME_LENGTH + 1], + int subbook_name_count); + +/* zipfile.c */ +int ebzip_zip_file(const char *out_file_name, const char *in_file_name, + Zio_Code in_zio_code, Zip_Speedup *speedup); +int ebzip_zip_start_file(const char *out_file_name, const char *in_file_name, + Zio_Code in_zio_code, int index_page, Zip_Speedup *speedup); + +/* zipinfobook.c */ +int ebzip_zipinfo_book(const char *book_path, + char subbook_name_list[][EB_MAX_DIRECTORY_NAME_LENGTH + 1], + int subbook_name_count); + +/* zipinfofile.c */ +int ebzip_zipinfo_file(const char *in_file_name, Zio_Code in_zio_code); +int ebzip_zipinfo_start_file(const char *in_file_name, Zio_Code in_zio_code, + int index_page); + +/* sppedup.c */ +void ebzip_initialize_zip_speedup(Zip_Speedup *speedup); +void ebzip_finalize_zip_speedup(Zip_Speedup *speedup); +int ebzip_set_zip_speedup(Zip_Speedup *speedup, const char *file_name, + Zio_Code zio_code, int index_page); +int ebzip_is_speedup_slice(Zip_Speedup *speedup, int slice, int zip_level); + +/* unlinkfile.c */ +int unlink_files_add(const char *file_name); +void unlink_files(); + +#endif /* EBZIP_H */ diff --git a/ebzip/ebzip1.c b/ebzip/ebzip1.c new file mode 100644 index 0000000..d2bb8bf --- /dev/null +++ b/ebzip/ebzip1.c @@ -0,0 +1,76 @@ +/* -*- C -*- + * Copyright (c) 1998-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include + +#include "eb/eb.h" + +/* + * Compress a slice with the ebzip compression format. + * + * If it succeeds, 0 is returned. Otherwise, -1 is returned. + */ +int +ebzip1_slice(char *out_buffer, size_t *out_byte_length, char *in_buffer, + size_t in_byte_length) +{ + z_stream stream; + + stream.zalloc = Z_NULL; + stream.zfree = Z_NULL; + stream.opaque = Z_NULL; + + if (deflateInit(&stream, Z_DEFAULT_COMPRESSION) != Z_OK) + return -1; + + stream.next_in = (Bytef *) in_buffer; + stream.avail_in = in_byte_length; + stream.next_out = (Bytef *) out_buffer; + stream.avail_out = in_byte_length; + + if (deflate(&stream, Z_FINISH) != Z_STREAM_END) { + *out_byte_length = in_byte_length; + deflateEnd(&stream); + return 0; + } + + if (deflateEnd(&stream) != Z_OK) + return -1; + + *out_byte_length = stream.total_out; + return 0; +} + + diff --git a/ebzip/sebxa.c b/ebzip/sebxa.c new file mode 100644 index 0000000..e72855b --- /dev/null +++ b/ebzip/sebxa.c @@ -0,0 +1,279 @@ +/* -*- C -*- + * Copyright (c) 2001-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "ebzip.h" + +#define zio_uint4(p) ((*(const unsigned char *)(p) << 24) \ + + (*(const unsigned char *)((p) + 1) << 16) \ + + (*(const unsigned char *)((p) + 2) << 8) \ + + (*(const unsigned char *)((p) + 3))) + +/* + * Delete compression information in START file of S-EBXA. + * Return 0 if succeeds, -1 otherwise. + */ +int +rewrite_sebxa_start(const char *file_name, int index_page) +{ + char buffer[EB_SIZE_PAGE]; + int file = -1; + int index_count; + int removed_index_count; + char *index_in_p; + char *index_out_p; + ssize_t done_length; + ssize_t n; + int i; + + if (index_page == 0) + index_page = 1; + + /* + * Output information. + */ + if (!ebzip_quiet_flag) { + fprintf(stderr, _("==> rewrite %s <==\n"), file_name); + fflush(stderr); + } + + /* + * Open the file. + */ + file = open(file_name, O_RDWR | O_BINARY); + if (file < 0) { + fprintf(stderr, _("%s: failed to open the file, %s: %s\n"), + invoked_name, strerror(errno), file_name); + goto failed; + } + + /* + * Read index page. + */ + if (lseek(file, ((off_t) index_page - 1) * EB_SIZE_PAGE, SEEK_SET) < 0) { + fprintf(stderr, _("%s: failed to seek the file, %s: %s\n"), + invoked_name, strerror(errno), file_name); + goto failed; + } + + done_length = 0; + while (done_length < EB_SIZE_PAGE) { + errno = 0; + n = read(file, buffer + done_length, EB_SIZE_PAGE - done_length); + if (n < 0) { + if (errno == EINTR) + continue; + fprintf(stderr, _("%s: failed to read the file, %s: %s\n"), + invoked_name, strerror(errno), file_name); + goto failed; + } else if (n == 0) { + fprintf(stderr, _("%s: unexpected EOF: %s\n"), + invoked_name, file_name); + goto failed; + } else { + done_length += n; + } + } + + /* + * Remove index 0x21 and 0x22. + * They has comression information. + */ + index_count = *(unsigned char *)(buffer + 1); + removed_index_count = 0; + + index_in_p = buffer + 16; + index_out_p = buffer + 16; + for (i = 0; i < index_count; i++, index_in_p += 16) { + if (*index_in_p == 0x21 || *index_in_p == 0x22) { + removed_index_count++; + } else { + if (index_in_p != index_out_p) + memcpy(index_out_p, index_in_p, 16); + index_out_p += 16; + } + } + for (i = 0; i < removed_index_count; i++, index_out_p += 16) { + memset(index_out_p, 0, 16); + } + + *(unsigned char *)(buffer + 1) = index_count - removed_index_count; + + /* + * Write back the index page. + */ + if (lseek(file, ((off_t) index_page - 1) * EB_SIZE_PAGE, SEEK_SET) < 0) { + fprintf(stderr, _("%s: failed to seek the file, %s: %s\n"), + invoked_name, strerror(errno), file_name); + goto failed; + } + + done_length = 0; + while (done_length < EB_SIZE_PAGE) { + errno = 0; + n = write(file, buffer + done_length, EB_SIZE_PAGE - done_length); + if (n < 0) { + if (errno == EINTR) + continue; + fprintf(stderr, _("%s: failed to write the file, %s: %s\n"), + invoked_name, strerror(errno), file_name); + goto failed; + } else { + done_length += n; + } + } + + if (!ebzip_quiet_flag) { +#if defined(PRINTF_LL_MODIFIER) + fprintf(stderr, _("completed (%llu / %llu bytes)\n"), + (unsigned long long) done_length, + (unsigned long long) done_length); +#elif defined(PRINTF_I64_MODIFIER) + fprintf(stderr, _("completed (%I64u / %I64u bytes)\n"), + (unsigned __int64) done_length, + (unsigned __int64) done_length); +#else + fprintf(stderr, _("completed (%lu / %lu bytes)\n"), + (unsigned long) done_length, + (unsigned long) done_length); +#endif + fputc('\n', stderr); + fflush(stderr); + } + + close(file); + return 0; + + failed: + if (0 <= file) + close(file); + fputc('\n', stderr); + return -1; +} + + +/* + * Get compression information (`index_page', `index_location', `index_base', + * `zio_start_location' and `zio_end_location') in START file. + * Return 0 if succeeds, -1 otherwise. + */ +int +get_sebxa_indexes(const char *file_name, int index_page, off_t *index_location, + off_t *index_base, off_t *zio_start_location, off_t *zio_end_location) +{ + char buffer[EB_SIZE_PAGE]; + int file = -1; + int index_count; + char *index_p; + ssize_t done_length; + ssize_t n; + int page; + int page_count; + int i; + + *index_location = 0; + *index_base = 0; + *zio_start_location = 0; + *zio_end_location = 0; + + if (index_page == 0) + index_page = 1; + + /* + * Open the file. + */ + file = open(file_name, O_RDONLY | O_BINARY); + if (file < 0) { + fprintf(stderr, _("%s: failed to open the file, %s: %s\n"), + invoked_name, strerror(errno), file_name); + goto failed; + } + + /* + * Read index page. + */ + if (lseek(file, ((off_t) index_page - 1) * EB_SIZE_PAGE, SEEK_SET) < 0) { + fprintf(stderr, _("%s: failed to seek the file, %s: %s\n"), + invoked_name, strerror(errno), file_name); + goto failed; + } + + done_length = 0; + while (done_length < EB_SIZE_PAGE) { + errno = 0; + n = read(file, buffer + done_length, EB_SIZE_PAGE - done_length); + if (n < 0) { + if (errno == EINTR) + continue; + fprintf(stderr, _("%s: failed to read the file, %s: %s\n"), + invoked_name, strerror(errno), file_name); + goto failed; + } else if (n == 0) { + fprintf(stderr, _("%s: unexpected EOF: %s\n"), + invoked_name, file_name); + goto failed; + } else { + done_length += n; + } + } + + /* + * Get information in index 0x21 and 0x22. + * They has comression information. + */ + index_count = *(unsigned char *)(buffer + 1); + + index_p = buffer + 16; + for (i = 0; i < index_count; i++, index_p += 16) { + page = zio_uint4(index_p + 2); + page_count = zio_uint4(index_p + 6); + + switch (*index_p) { + case 0x00: + *zio_start_location + = ((off_t) page - 1) * EB_SIZE_PAGE; + *zio_end_location + = ((off_t) page + page_count - 1) * EB_SIZE_PAGE - 1; + break; + case 0x21: + *index_base = ((off_t) page - 1) * EB_SIZE_PAGE; + break; + case 0x22: + *index_location = ((off_t) page - 1) * EB_SIZE_PAGE; + break; + } + } + + close(file); + return 0; + + failed: + if (0 <= file) + close(file); + fputc('\n', stderr); + return -1; +} diff --git a/ebzip/speedup.c b/ebzip/speedup.c new file mode 100644 index 0000000..8632328 --- /dev/null +++ b/ebzip/speedup.c @@ -0,0 +1,195 @@ +/* -*- C -*- + * Copyright (c) 2004-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "ebzip.h" + +#define zio_uint1(p) (*(const unsigned char *)(p)) + +#define zio_uint4(p) ((*(const unsigned char *)(p) << 24) \ + + (*(const unsigned char *)((p) + 1) << 16) \ + + (*(const unsigned char *)((p) + 2) << 8) \ + + (*(const unsigned char *)((p) + 3))) + +/* + * Initialize `speeedup'. + */ +void +ebzip_initialize_zip_speedup(Zip_Speedup *speedup) +{ + speedup->region_count = 0; +} + + +/* + * Finalize `speeedup'. + */ +void +ebzip_finalize_zip_speedup(Zip_Speedup *speedup) +{ + speedup->region_count = 0; +} + + +/* + * Read HONMON/START file to set `speedup'. + */ +int +ebzip_set_zip_speedup(Zip_Speedup *speedup, const char *file_name, + Zio_Code zio_code, int index_page) +{ + char buffer[EB_SIZE_PAGE]; + char *buffer_p; + int start_page; + Zio zio; + int index_count; + int index_code; + int i; + + zio_initialize(&zio); + + /* + * Open the file and read it's index page. + */ + if (zio_open(&zio, file_name, zio_code) < 0) { + fprintf(stderr, _("%s: failed to open the file: %s\n"), + invoked_name, file_name); + goto failed; + } + if (zio_lseek(&zio, ((off_t) index_page - 1) * EB_SIZE_PAGE, SEEK_SET) + < 0) { + fprintf(stderr, _("%s: failed to read the file: %s\n"), + invoked_name, file_name); + goto failed; + } + if (zio_read(&zio, buffer, EB_SIZE_PAGE) != EB_SIZE_PAGE) { + fprintf(stderr, _("%s: failed to read the file: %s\n"), + invoked_name, file_name); + goto failed; + } + + /* + * Read the index page to get `start_page' location. + */ + index_count = zio_uint1(buffer + 1); + buffer_p = buffer + 16; + for (i = 0; i < index_count; i++) { + index_code = zio_uint1(buffer_p); + if (0x90 <= index_code && index_code <= 0x92) { + if (EBZIP_MAX_SPEEDUP_REGION_COUNT <= speedup->region_count) + break; + speedup->regions[speedup->region_count].start_page + = zio_uint4(buffer_p + 2); + speedup->region_count++; + } + buffer_p += 16; + } + + /* + * Read `start_page' to get `end_page' location. + */ + for (i = 0; i < speedup->region_count; i++) { + start_page = speedup->regions[i].start_page; + if (zio_lseek(&zio, ((off_t) start_page - 1) * EB_SIZE_PAGE, SEEK_SET) + < 0) { + fprintf(stderr, _("%s: failed to read the file: %s\n"), + invoked_name, file_name); + goto failed; + } + if (zio_read(&zio, buffer, EB_SIZE_PAGE) != EB_SIZE_PAGE) { + fprintf(stderr, _("%s: failed to read the file: %s\n"), + invoked_name, file_name); + goto failed; + } + + speedup->regions[i].end_page = start_page + zio_uint1(buffer + 3) - 1; + } + + zio_close(&zio); + zio_finalize(&zio); + return 0; + + /* + * An error occurs... + */ + failed: + zio_close(&zio); + zio_finalize(&zio); + speedup->region_count = 0; + + return -1; +} + + +/* + * Check if `slice' is lain in/over/across a speedup region. + */ +int +ebzip_is_speedup_slice(Zip_Speedup *speedup, int slice, int ebzip_level) +{ + Zip_Speedup_Region *p; + int start_page; + int end_page; + int i; + + start_page = slice * (1 << ebzip_level) + 1; + end_page = (slice + 1) * (1 << ebzip_level); + + for (i = 0, p = speedup->regions; i < speedup->region_count; i++, p++) { + /* + * speedup region + * +================+ + * o------o + * or o-----------------------o + * + */ + if (start_page <= speedup->regions[i].start_page + && speedup->regions[i].start_page <= end_page) + return 1; + + /* + * speedup region + * +================+ + * o------o + * or o--------------------o + */ + if (start_page <= speedup->regions[i].end_page + && speedup->regions[i].end_page <= end_page) + return 1; + + /* + * speedup region + * +================+ + * o--------o + */ + if (speedup->regions[i].start_page <= start_page + && end_page <= speedup->regions[i].end_page) + return 1; + } + + return 0; +} diff --git a/ebzip/unlinkfile.c b/ebzip/unlinkfile.c new file mode 100644 index 0000000..4c983b0 --- /dev/null +++ b/ebzip/unlinkfile.c @@ -0,0 +1,61 @@ +/* -*- C -*- + * Copyright (c) 2008-2009 Kazuhiro Ito + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "ebzip.h" + +/* + * Add a file to the list of unlinking files. + * If it succeeds, 0 is returned. Otherwise -1 is returned. + */ +int unlink_files_add(const char *file_name) +{ + if (string_list_add(&unlinking_files, file_name)) { + if (!ebzip_quiet_flag) { + fprintf(stderr, _("%s: warning: memory exhausted, file %s is not to be unlinked\n"), invoked_name, file_name); + } + return -1; + } + + return 0; +} + +/* + * Unlink files. + */ +void unlink_files() +{ + String_List_Node *p = unlinking_files.head; + + while (p != NULL) { + if (unlink(p->string) < 0 && !ebzip_quiet_flag) { + fprintf(stderr, _("%s: warning: failed to unlink the file: %s\n"), + invoked_name, p->string); + } + p = p->next; + } +} diff --git a/ebzip/unzipbook.c b/ebzip/unzipbook.c new file mode 100644 index 0000000..0f33bf6 --- /dev/null +++ b/ebzip/unzipbook.c @@ -0,0 +1,470 @@ +/* -*- C -*- + * Copyright (c) 1998-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "ebzip.h" +#include "ebutils.h" + +#include "getumask.h" +#include "makedir.h" +#include "strlist.h" + +/* + * Unexported function. + */ +static int ebzip_unzip_book_eb(EB_Book *book, const char *out_top_path, + const char *book_path, EB_Subbook_Code *subbook_list, int subbook_count); +static int ebzip_unzip_book_epwing(EB_Book *book, const char *out_top_path, + const char *book_path, EB_Subbook_Code *subbook_list, int subbook_count); + + +/* + * Uncompress files in `book' and output them under `out_top_path'. + * If it succeeds, 0 is returned. Otherwise -1 is returned. + */ +int +ebzip_unzip_book(const char *out_top_path, const char *book_path, + char subbook_name_list[][EB_MAX_DIRECTORY_NAME_LENGTH + 1], + int subbook_name_count) +{ + EB_Book book; + EB_Error_Code error_code; + EB_Subbook_Code subbook_list[EB_MAX_SUBBOOKS]; + EB_Subbook_Code subbook_code; + int subbook_count = 0; + int result; + int i; + + eb_initialize_book(&book); + + /* + * Bind a book. + */ + error_code = eb_bind(&book, book_path); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s\n", invoked_name, + eb_error_message(error_code)); + fflush(stderr); + return -1; + } + + /* + * For each targe subbook, convert a subbook-names to a subbook-codes. + * If no subbook is specified by `--subbook'(`-S'), set all subbooks + * as the target. + */ + if (subbook_name_count == 0) { + error_code = eb_subbook_list(&book, subbook_list, &subbook_count); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s\n", invoked_name, + eb_error_message(error_code)); + fflush(stderr); + return -1; + } + } else { + for (i = 0; i < subbook_name_count; i++) { + error_code = find_subbook(&book, subbook_name_list[i], + &subbook_code); + if (error_code != EB_SUCCESS) { + fprintf(stderr, _("%s: unknown subbook name `%s'\n"), + invoked_name, subbook_name_list[i]); + return -1; + } + subbook_list[subbook_count++] = subbook_code; + } + } + + /* + * Uncompress the book. + */ + if (book.disc_code == EB_DISC_EB) { + result = ebzip_unzip_book_eb(&book, out_top_path, book_path, + subbook_list, subbook_count); + } else { + result = ebzip_unzip_book_epwing(&book, out_top_path, book_path, + subbook_list, subbook_count); + } + + eb_finalize_book(&book); + + return result; +} + + +/* + * Internal function for `unzip_book'. + * This is used to compress an EB book. + */ +static int +ebzip_unzip_book_eb(EB_Book *book, const char *out_top_path, + const char *book_path, EB_Subbook_Code *subbook_list, int subbook_count) +{ + EB_Subbook *subbook; + EB_Error_Code error_code; + String_List string_list; + char in_path_name[PATH_MAX + 1]; + char out_sub_path[PATH_MAX + 1]; + char out_path_name[PATH_MAX + 1]; + char catalog_file_name[EB_MAX_FILE_NAME_LENGTH]; + char language_file_name[EB_MAX_FILE_NAME_LENGTH]; + mode_t out_directory_mode; + Zio_Code in_zio_code; + int i; + + /* + * If `out_top_path' and/or `book_path' represents "/", replace it + * to an empty string. + */ + if (strcmp(out_top_path, "/") == 0) + out_top_path++; + if (strcmp(book_path, "/") == 0) + book_path++; + + /* + * Initialize variables. + */ + out_directory_mode = 0777 ^ get_umask(); + string_list_initialize(&string_list); + + error_code = eb_load_all_subbooks(book); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s\n", invoked_name, + eb_error_message(error_code)); + } + + /* + * Uncompress a book. + */ + for (i = 0; i < subbook_count; i++) { + subbook = book->subbooks + subbook_list[i]; + + /* + * Make an output directory for the current subbook. + */ + eb_compose_path_name(out_top_path, subbook->directory_name, + out_sub_path); + if (!ebzip_test_flag + && make_missing_directory(out_sub_path, out_directory_mode) < 0) { + fprintf(stderr, _("%s: failed to create a directory, %s: %s\n"), + invoked_name, strerror(errno), out_sub_path); + goto failed; + } + + /* + * Uncompress START file. + */ + in_zio_code = zio_mode(&subbook->text_zio); + eb_compose_path_name2(book->path, subbook->directory_name, + subbook->text_file_name, in_path_name); + eb_compose_path_name2(out_top_path, subbook->directory_name, + subbook->text_file_name, out_path_name); + eb_fix_path_name_suffix(out_path_name, EBZIP_SUFFIX_NONE); + + if (in_zio_code != ZIO_INVALID + && !string_list_find(&string_list, in_path_name)) { + if (ebzip_unzip_start_file(out_path_name, in_path_name, + in_zio_code, subbook->index_page) < 0) + goto failed; + } + + if (!ebzip_test_flag + && rewrite_sebxa_start(out_path_name, subbook->index_page) < 0) + goto failed; + string_list_add(&string_list, in_path_name); + } + + /* + * Uncompress a language file. + */ + if (eb_find_file_name(book->path, "language", language_file_name) + == EB_SUCCESS) { + eb_compose_path_name(book->path, language_file_name, in_path_name); + eb_compose_path_name(out_top_path, language_file_name, out_path_name); + eb_path_name_zio_code(in_path_name, ZIO_PLAIN, &in_zio_code); + eb_fix_path_name_suffix(out_path_name, EBZIP_SUFFIX_NONE); + if (ebzip_unzip_file(out_path_name, in_path_name, in_zio_code) < 0) + goto failed; + } + + /* + * Copy CATALOG file. + */ + if (eb_find_file_name(book->path, "catalog", catalog_file_name) + == EB_SUCCESS) { + eb_compose_path_name(book->path, catalog_file_name, in_path_name); + eb_compose_path_name(out_top_path, catalog_file_name, out_path_name); + if (ebzip_copy_file(out_path_name, in_path_name) < 0) + goto failed; + } + + string_list_finalize(&string_list); + return 0; + + /* + * An error occurs... + */ + failed: + string_list_finalize(&string_list); + return -1; +} + + +/* + * Internal function for `unzip_book'. + * This is used to compress an EPWING book. + */ +static int +ebzip_unzip_book_epwing(EB_Book *book, const char *out_top_path, + const char *book_path, EB_Subbook_Code *subbook_list, int subbook_count) +{ + EB_Subbook *subbook; + EB_Error_Code error_code; + EB_Font *font; + String_List string_list; + char in_path_name[PATH_MAX + 1]; + char out_sub_path[PATH_MAX + 1]; + char out_path_name[PATH_MAX + 1]; + char catalogs_file_name[EB_MAX_FILE_NAME_LENGTH]; + mode_t out_directory_mode; + Zio_Code in_zio_code; + int i, j; + + /* + * If `out_top_path' and/or `book_path' represents "/", replace it + * to an empty string. + */ + if (strcmp(out_top_path, "/") == 0) + out_top_path++; + if (strcmp(book_path, "/") == 0) + book_path++; + + /* + * Initialize variables. + */ + out_directory_mode = 0777 ^ get_umask(); + string_list_initialize(&string_list); + + error_code = eb_load_all_subbooks(book); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s\n", invoked_name, + eb_error_message(error_code)); + } + + /* + * Uncompress a book. + */ + for (i = 0; i < subbook_count; i++) { + subbook = book->subbooks + subbook_list[i]; + + /* + * Make an output directory for the current subbook. + */ + eb_compose_path_name(out_top_path, subbook->directory_name, + out_sub_path); + if (!ebzip_test_flag + && make_missing_directory(out_sub_path, out_directory_mode) < 0) { + fprintf(stderr, _("%s: failed to create a directory, %s: %s\n"), + invoked_name, strerror(errno), out_sub_path); + goto failed; + } + + /* + * Make `data' sub directory for the current subbook. + */ + eb_compose_path_name2(out_top_path, subbook->directory_name, + subbook->data_directory_name, out_sub_path); + if (!ebzip_test_flag + && make_missing_directory(out_sub_path, out_directory_mode) < 0) { + fprintf(stderr, _("%s: failed to create a directory, %s: %s\n"), + invoked_name, strerror(errno), out_sub_path); + goto failed; + } + + /* + * Uncompress HONMON/HONMON2 file. + */ + in_zio_code = zio_mode(&subbook->text_zio); + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->data_directory_name, subbook->text_file_name, + in_path_name); + eb_compose_path_name3(out_top_path, subbook->directory_name, + subbook->data_directory_name, subbook->text_file_name, + out_path_name); + + if (in_zio_code != ZIO_INVALID + && !string_list_find(&string_list, in_path_name)) { + if (strncasecmp(subbook->text_file_name, "honmon2", 7) == 0) + eb_fix_path_name_suffix(out_path_name, EBZIP_SUFFIX_ORG); + else + eb_fix_path_name_suffix(out_path_name, EBZIP_SUFFIX_NONE); + if (ebzip_unzip_file(out_path_name, in_path_name, in_zio_code) < 0) + goto failed; + string_list_add(&string_list, in_path_name); + } + + /* + * Uncompress HONMONS file. + */ + in_zio_code = zio_mode(&subbook->sound_zio); + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->data_directory_name, subbook->sound_file_name, + in_path_name); + eb_compose_path_name3(out_top_path, subbook->directory_name, + subbook->data_directory_name, subbook->sound_file_name, + out_path_name); + eb_fix_path_name_suffix(out_path_name, EBZIP_SUFFIX_NONE); + + if (!ebzip_skip_flag_sound + && in_zio_code != ZIO_INVALID + && !string_list_find(&string_list, in_path_name)) { + if (ebzip_unzip_file(out_path_name, in_path_name, in_zio_code) < 0) + goto failed; + string_list_add(&string_list, in_path_name); + } + + /* + * Uncompress HONMONG file. + */ + in_zio_code = zio_mode(&subbook->graphic_zio); + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->data_directory_name, subbook->graphic_file_name, + in_path_name); + eb_compose_path_name3(out_top_path, subbook->directory_name, + subbook->data_directory_name, subbook->graphic_file_name, + out_path_name); + eb_fix_path_name_suffix(out_path_name, EBZIP_SUFFIX_NONE); + + if (!ebzip_skip_flag_graphic + && in_zio_code != ZIO_INVALID + && !string_list_find(&string_list, in_path_name)) { + if (ebzip_unzip_file(out_path_name, in_path_name, in_zio_code) < 0) + goto failed; + string_list_add(&string_list, in_path_name); + } + + /* + * Make `gaiji' sub directory for the current subbook. + */ + if (!ebzip_skip_flag_font) { + eb_compose_path_name2(out_top_path, subbook->directory_name, + subbook->gaiji_directory_name, out_sub_path); + if (!ebzip_test_flag + && make_missing_directory(out_sub_path, out_directory_mode) + < 0) { + fprintf(stderr, + _("%s: failed to create a directory, %s: %s\n"), + invoked_name, strerror(errno), out_sub_path); + goto failed; + } + + /* + * Uncompress narrow font files. + */ + for (j = 0; j < EB_MAX_FONTS; j++) { + font = subbook->narrow_fonts + j; + if (font->font_code == EB_FONT_INVALID) + continue; + + in_zio_code = zio_mode(&font->zio); + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->gaiji_directory_name, font->file_name, + in_path_name); + eb_compose_path_name3(out_top_path, subbook->directory_name, + subbook->gaiji_directory_name, font->file_name, + out_path_name); + eb_fix_path_name_suffix(out_path_name, EBZIP_SUFFIX_NONE); + + if (in_zio_code != ZIO_INVALID + && !string_list_find(&string_list, in_path_name)) { + if (ebzip_unzip_file(out_path_name, in_path_name, + in_zio_code) < 0) + goto failed; + string_list_add(&string_list, in_path_name); + } + } + + /* + * Uncompress wide font files. + */ + for (j = 0; j < EB_MAX_FONTS; j++) { + font = subbook->wide_fonts + j; + if (font->font_code == EB_FONT_INVALID) + continue; + + in_zio_code = zio_mode(&font->zio); + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->gaiji_directory_name, + font->file_name, in_path_name); + eb_compose_path_name3(out_top_path, subbook->directory_name, + subbook->gaiji_directory_name, font->file_name, + out_path_name); + eb_fix_path_name_suffix(out_path_name, EBZIP_SUFFIX_NONE); + + if (in_zio_code != ZIO_INVALID + && !string_list_find(&string_list, in_path_name)) { + if (ebzip_unzip_file(out_path_name, in_path_name, + in_zio_code) < 0) + goto failed; + string_list_add(&string_list, in_path_name); + } + } + } + + /* + * Copy movie files. + */ + if (!ebzip_skip_flag_movie) { + eb_compose_path_name2(book->path, subbook->directory_name, + subbook->movie_directory_name, in_path_name); + eb_compose_path_name2(out_top_path, subbook->directory_name, + subbook->movie_directory_name, out_path_name); + if (ebzip_copy_files_in_directory(out_path_name, in_path_name) < 0) + goto failed; + } + } + + /* + * Copy CATALOGS file. + */ + if (eb_find_file_name(book->path, "catalogs", catalogs_file_name) + == EB_SUCCESS) { + eb_compose_path_name(book->path, catalogs_file_name, in_path_name); + eb_compose_path_name(out_top_path, catalogs_file_name, out_path_name); + if (ebzip_copy_file(out_path_name, in_path_name) < 0) + goto failed; + } + + string_list_finalize(&string_list); + return 0; + + /* + * An error occurs... + */ + failed: + string_list_finalize(&string_list); + return -1; +} diff --git a/ebzip/unzipfile.c b/ebzip/unzipfile.c new file mode 100644 index 0000000..f575aa7 --- /dev/null +++ b/ebzip/unzipfile.c @@ -0,0 +1,434 @@ +/* -*- C -*- + * Copyright (c) 1998-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "ebzip.h" + +#include "getumask.h" +#include "makedir.h" +#include "samefile.h" +#include "yesno.h" + +/* + * Tricks for gettext. + */ +#ifdef ENABLE_NLS +#define _(string) gettext(string) +#ifdef gettext_noop +#define N_(string) gettext_noop(string) +#else +#define N_(string) (string) +#endif +#else +#define _(string) (string) +#define N_(string) (string) +#endif + +/* + * File name to be deleted and file to be closed when signal is received. + */ +static const char *trap_file_name = NULL; +static int trap_file = -1; + +/* + * Unexported function. + */ +static int ebzip_unzip_file_internal(const char *out_file_name, + const char *in_file_name, Zio_Code in_zio_code, int index_page); +static void trap(int signal_number); + + +/* + * Uncompress a file `in_file_name'. + * For START file, use ebzip_unzip_start_file() instead. + * If it succeeds, 0 is returned. Otherwise -1 is returned. + */ +int +ebzip_unzip_file(const char *out_file_name, const char *in_file_name, + Zio_Code in_zio_code) +{ + return ebzip_unzip_file_internal(out_file_name, in_file_name, + in_zio_code, 0); +} + +/* + * Uncompress START file `in_file_name'. + * If it succeeds, 0 is returned. Otherwise -1 is returned. + */ +int +ebzip_unzip_start_file(const char *out_file_name, const char *in_file_name, + Zio_Code in_zio_code, int index_page) +{ + return ebzip_unzip_file_internal(out_file_name, in_file_name, + in_zio_code, index_page); +} + +/* + * Internal function for ebzip_unzip_file() and ebzip_unzip_sebxa_start(). + * If it succeeds, 0 is returned. Otherwise -1 is returned. + */ +static int +ebzip_unzip_file_internal(const char *out_file_name, const char *in_file_name, + Zio_Code in_zio_code, int index_page) +{ + Zio in_zio; + unsigned char *buffer = NULL; + off_t total_length; + int out_file = -1; + ssize_t length; + struct stat in_status, out_status; + unsigned int crc = 1; + int progress_interval; + int total_slices; + int i; + + zio_initialize(&in_zio); + + /* + * Simply copy a file, when an input file is not compressed. + */ + if (in_zio_code == ZIO_PLAIN) + return ebzip_copy_file(out_file_name, in_file_name); + + /* + * Output file name information. + */ + if (!ebzip_quiet_flag) { + fprintf(stderr, _("==> uncompress %s <==\n"), in_file_name); + fprintf(stderr, _("output to %s\n"), out_file_name); + fflush(stderr); + } + + /* + * Get status of the input file. + */ + if (stat(in_file_name, &in_status) < 0 || !S_ISREG(in_status.st_mode)) { + fprintf(stderr, _("%s: no such file: %s\n"), invoked_name, + in_file_name); + goto failed; + } + + /* + * Do nothing if the `in_file_name' and `out_file_name' are the same. + */ + if (is_same_file(out_file_name, in_file_name)) { + if (!ebzip_quiet_flag) { + fprintf(stderr, + _("the input and output files are the same, skipped.\n\n")); + fflush(stderr); + } + return 0; + } + + /* + * Allocate memories for in/out buffers. + */ + buffer = (unsigned char *)malloc(EB_SIZE_PAGE << ZIO_MAX_EBZIP_LEVEL); + if (buffer == NULL) { + fprintf(stderr, _("%s: memory exhausted\n"), invoked_name); + goto failed; + } + + /* + * If the file `out_file_name' already exists, confirm and unlink it. + */ + if (!ebzip_test_flag + && stat(out_file_name, &out_status) == 0 + && S_ISREG(out_status.st_mode)) { + if (ebzip_overwrite_mode == EBZIP_OVERWRITE_NO) { + if (!ebzip_quiet_flag) { + fputs(_("already exists, skip the file\n\n"), stderr); + fflush(stderr); + } + return 0; + } else if (ebzip_overwrite_mode == EBZIP_OVERWRITE_CONFIRM) { + int y_or_n; + + fprintf(stderr, _("\nthe file already exists: %s\n"), + out_file_name); + y_or_n = query_y_or_n(_("do you wish to overwrite (y or n)? ")); + fputc('\n', stderr); + fflush(stderr); + if (!y_or_n) + return 0; + } + if (unlink(out_file_name) < 0) { + fprintf(stderr, _("%s: failed to unlink the file: %s\n"), + invoked_name, out_file_name); + goto failed; + } + } + + /* + * Open files. + */ + if (zio_open(&in_zio, in_file_name, in_zio_code) < 0) { + fprintf(stderr, _("%s: failed to open the file: %s\n"), + invoked_name, in_file_name); + goto failed; + } + if (in_zio_code == ZIO_SEBXA) { + off_t index_location; + off_t index_base; + off_t zio_start_location; + off_t zio_end_location; + + if (get_sebxa_indexes(in_file_name, index_page, &index_location, + &index_base, &zio_start_location, &zio_end_location) < 0) { + goto failed; + } + zio_set_sebxa_mode(&in_zio, index_location, index_base, + zio_start_location, zio_end_location); + } + + if (!ebzip_test_flag) { + trap_file_name = out_file_name; +#ifdef SIGHUP + signal(SIGHUP, trap); +#endif + signal(SIGINT, trap); +#ifdef SIGQUIT + signal(SIGQUIT, trap); +#endif +#ifdef SIGTERM + signal(SIGTERM, trap); +#endif + +#ifdef O_CREAT + out_file = open(out_file_name, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, + 0666 ^ get_umask()); +#else + out_file = creat(out_file_name, 0666 ^ get_umask()); +#endif + if (out_file < 0) { + fprintf(stderr, _("%s: failed to open the file: %s\n"), + invoked_name, out_file_name); + goto failed; + } + trap_file = out_file; + } + + /* + * Read a slice from the input file, uncompress it if required, + * and then write it to the output file. + */ + total_length = 0; + total_slices = (in_zio.file_size + in_zio.slice_size - 1) + / in_zio.slice_size; + progress_interval = EBZIP_PROGRESS_INTERVAL_FACTOR; + if (((total_slices + 999) / 1000) > progress_interval) + progress_interval = ((total_slices + 999) / 1000); + + for (i = 0; i < total_slices; i++) { + /* + * Read a slice. + */ + if (zio_lseek(&in_zio, total_length, SEEK_SET) < 0) { + fprintf(stderr, _("%s: failed to seek the file: %s\n"), + invoked_name, in_file_name); + goto failed; + } + length = zio_read(&in_zio, (char *)buffer, in_zio.slice_size); + if (length < 0) { + fprintf(stderr, _("%s: failed to read from the file: %s\n"), + invoked_name, in_file_name); + goto failed; + } else if (length == 0) { + fprintf(stderr, _("%s: unexpected EOF: %s\n"), + invoked_name, in_file_name); + goto failed; + } else if (length != in_zio.slice_size + && total_length + length != in_zio.file_size) { + fprintf(stderr, _("%s: unexpected EOF: %s\n"), + invoked_name, in_file_name); + goto failed; + } + + /* + * Update CRC. (Calculate adler32 again.) + */ + if (in_zio.code == ZIO_EBZIP1) + crc = adler32((uLong)crc, (Bytef *)buffer, (uInt)length); + + /* + * Write the slice to `out_file'. + */ + if (!ebzip_test_flag) { + if (write(out_file, buffer, length) != length) { + fprintf(stderr, _("%s: failed to write to the file, %s: %s\n"), + invoked_name, strerror(errno), out_file_name); + goto failed; + } + } + total_length += length; + + /* + * Output status information unless `quiet' mode. + */ + if (!ebzip_quiet_flag && (i + 1) % progress_interval == 0) { +#if defined(PRINTF_LL_MODIFIER) + fprintf(stderr, _("%4.1f%% done (%llu / %llu bytes)\n"), + (double) (i + 1) * 100.0 / (double) total_slices, + (unsigned long long) total_length, + (unsigned long long) in_zio.file_size); +#elif defined(PRINTF_I64_MODIFIER) + fprintf(stderr, _("%4.1f%% done (%I64u / %I64u bytes)\n"), + (double) (i + 1) * 100.0 / (double) total_slices, + (unsigned __int64) total_length, + (unsigned __int64) in_zio.file_size); +#else + fprintf(stderr, _("%4.1f%% done (%lu / %lu bytes)\n"), + (double) (i + 1) * 100.0 / (double) total_slices, + (unsigned long) total_length, + (unsigned long) in_zio.file_size); +#endif + fflush(stderr); + } + } + + /* + * Output the result unless quiet mode. + */ + if (!ebzip_quiet_flag) { +#if defined(PRINTF_LL_MODIFIER) + fprintf(stderr, _("completed (%llu / %llu bytes)\n"), + (unsigned long long) in_zio.file_size, + (unsigned long long) in_zio.file_size); +#elif defined(PRINTF_I64_MODIFIER) + fprintf(stderr, _("completed (%I64u / %I64u bytes)\n"), + (unsigned __int64) in_zio.file_size, + (unsigned __int64) in_zio.file_size); +#else + fprintf(stderr, _("%lu -> %lu bytes\n\n"), + (unsigned long) in_status.st_size, + (unsigned long) total_length); +#endif + fflush(stderr); + } + + /* + * Close files. + */ + zio_close(&in_zio); + zio_finalize(&in_zio); + + if (!ebzip_test_flag) { + close(out_file); + out_file = -1; + trap_file = -1; + trap_file_name = NULL; +#ifdef SIGHUP + signal(SIGHUP, SIG_DFL); +#endif + signal(SIGINT, SIG_DFL); +#ifdef SIGQUIT + signal(SIGQUIT, SIG_DFL); +#endif +#ifdef SIGTERM + signal(SIGTERM, SIG_DFL); +#endif + } + + /* + * Check for CRC. + */ + if (in_zio.code == ZIO_EBZIP1 && in_zio.crc != crc) { + fprintf(stderr, _("%s: CRC error: %s\n"), invoked_name, out_file_name); + goto failed; + } + + /* + * Delete an original file unless the keep flag is set. + */ + if (!ebzip_test_flag && !ebzip_keep_flag) + unlink_files_add(in_file_name); + + /* + * Set owner, group, permission, atime and mtime of `out_file'. + * We ignore return values of `chown', `chmod' and `utime'. + */ + if (!ebzip_test_flag) { + struct utimbuf utim; + + utim.actime = in_status.st_atime; + utim.modtime = in_status.st_mtime; + utime(out_file_name, &utim); + } + + /* + * Dispose memories. + */ + free(buffer); + + return 0; + + /* + * An error occurs... + */ + failed: + if (buffer != NULL) + free(buffer); + + zio_close(&in_zio); + zio_finalize(&in_zio); + + if (0 <= out_file) { + close(out_file); + trap_file = -1; + trap_file_name = NULL; +#ifdef SIGHUP + signal(SIGHUP, SIG_DFL); +#endif + signal(SIGINT, SIG_DFL); +#ifdef SIGQUIT + signal(SIGQUIT, SIG_DFL); +#endif +#ifdef SIGTERM + signal(SIGTERM, SIG_DFL); +#endif + } + + fputc('\n', stderr); + fflush(stderr); + + return -1; +} + + +/* + * Signal handler. + */ +static void +trap(int signal_number) +{ + if (0 <= trap_file) + close(trap_file); + if (trap_file_name != NULL) + unlink(trap_file_name); + + exit(1); +} diff --git a/ebzip/zipbook.c b/ebzip/zipbook.c new file mode 100644 index 0000000..90cd6c9 --- /dev/null +++ b/ebzip/zipbook.c @@ -0,0 +1,478 @@ +/* -*- C -*- + * Copyright (c) 1998-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "ebzip.h" +#include "ebutils.h" + +#include "getumask.h" +#include "makedir.h" +#include "strlist.h" + +/* + * Unexported function. + */ +static int ebzip_zip_book_eb(EB_Book *book, const char *out_top_path, + const char *book_path, EB_Subbook_Code *subbook_list, int subbook_count); +static int ebzip_zip_book_epwing(EB_Book *book, const char *out_top_path, + const char *book_path, EB_Subbook_Code *subbook_list, int subbook_count); + + +/* + * Compress files in `book' and output them under `out_top_path'. + * If it succeeds, 0 is returned. Otherwise -1 is returned. + */ +int +ebzip_zip_book(const char *out_top_path, const char *book_path, + char subbook_name_list[][EB_MAX_DIRECTORY_NAME_LENGTH + 1], + int subbook_name_count) +{ + EB_Book book; + EB_Error_Code error_code; + EB_Subbook_Code subbook_list[EB_MAX_SUBBOOKS]; + EB_Subbook_Code subbook_code; + int subbook_count; + int result; + int i; + + eb_initialize_book(&book); + + /* + * Bind a book. + */ + error_code = eb_bind(&book, book_path); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s\n", invoked_name, + eb_error_message(error_code)); + fflush(stderr); + return -1; + } + + /* + * For each targe subbook, convert a subbook-names to a subbook-codes. + * If no subbook is specified by `--subbook'(`-S'), set all subbooks + * as the target. + */ + if (subbook_name_count == 0) { + error_code = eb_subbook_list(&book, subbook_list, &subbook_count); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s\n", invoked_name, + eb_error_message(error_code)); + fflush(stderr); + return -1; + } + } else { + subbook_count = 0; + for (i = 0; i < subbook_name_count; i++) { + error_code = find_subbook(&book, subbook_name_list[i], + &subbook_code); + if (error_code != EB_SUCCESS) { + fprintf(stderr, _("%s: unknown subbook name `%s'\n"), + invoked_name, subbook_name_list[i]); + return -1; + } + subbook_list[subbook_count++] = subbook_code; + } + } + + /* + * Compress the book. + */ + if (book.disc_code == EB_DISC_EB) { + result = ebzip_zip_book_eb(&book, out_top_path, book_path, + subbook_list, subbook_count); + } else { + result = ebzip_zip_book_epwing(&book, out_top_path, book_path, + subbook_list, subbook_count); + } + + eb_finalize_book(&book); + + return result; +} + + +/* + * Internal function for `zip_book'. + * This is used to compress an EB book. + */ +static int +ebzip_zip_book_eb(EB_Book *book, const char *out_top_path, + const char *book_path, EB_Subbook_Code *subbook_list, int subbook_count) +{ + EB_Subbook *subbook; + EB_Error_Code error_code; + String_List string_list; + char in_path_name[PATH_MAX + 1]; + char out_sub_path[PATH_MAX + 1]; + char out_path_name[PATH_MAX + 1]; + char catalog_file_name[EB_MAX_FILE_NAME_LENGTH]; + char language_file_name[EB_MAX_FILE_NAME_LENGTH]; + mode_t out_directory_mode; + Zip_Speedup speedup; + Zio_Code in_zio_code; + int i; + + /* + * If `out_top_path' and/or `book_path' represents "/", replace it + * to an empty string. + */ + if (strcmp(out_top_path, "/") == 0) + out_top_path++; + if (strcmp(book_path, "/") == 0) + book_path++; + + /* + * Initialize variables. + */ + out_directory_mode = 0777 ^ get_umask(); + string_list_initialize(&string_list); + + error_code = eb_load_all_subbooks(book); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s\n", invoked_name, + eb_error_message(error_code)); + } + + /* + * Compress a book. + */ + for (i = 0; i < subbook_count; i++) { + subbook = book->subbooks + subbook_list[i]; + + /* + * Make an output directory for the current subbook. + */ + eb_compose_path_name(out_top_path, subbook->directory_name, + out_sub_path); + if (!ebzip_test_flag + && make_missing_directory(out_sub_path, out_directory_mode) < 0) { + fprintf(stderr, _("%s: failed to create a directory, %s: %s\n"), + invoked_name, strerror(errno), out_sub_path); + goto failed; + } + + /* + * Compress START file. + */ + in_zio_code = zio_mode(&subbook->text_zio); + + eb_compose_path_name2(book->path, subbook->directory_name, + subbook->text_file_name, in_path_name); + eb_compose_path_name2(out_top_path, subbook->directory_name, + subbook->text_file_name, out_path_name); + eb_fix_path_name_suffix(out_path_name, EBZIP_SUFFIX_EBZ); + + if (in_zio_code != ZIO_INVALID + && !string_list_find(&string_list, in_path_name)) { + ebzip_initialize_zip_speedup(&speedup); + if (ebzip_set_zip_speedup(&speedup, in_path_name, in_zio_code, + subbook->index_page) < 0) + goto failed; + if (ebzip_zip_start_file(out_path_name, in_path_name, in_zio_code, + subbook->index_page, &speedup) < 0) + goto failed; + ebzip_finalize_zip_speedup(&speedup); + string_list_add(&string_list, in_path_name); + } + } + + /* + * Compress a language file. + */ + if (eb_find_file_name(book->path, "language", language_file_name) + == EB_SUCCESS) { + eb_compose_path_name(book->path, language_file_name, in_path_name); + eb_compose_path_name(out_top_path, language_file_name, out_path_name); + eb_path_name_zio_code(in_path_name, ZIO_PLAIN, &in_zio_code); + eb_fix_path_name_suffix(out_path_name, EBZIP_SUFFIX_EBZ); + if (ebzip_zip_file(out_path_name, in_path_name, in_zio_code, NULL) < 0) + goto failed; + } + + /* + * Copy CATALOG file. + */ + if (eb_find_file_name(book->path, "catalog", catalog_file_name) + == EB_SUCCESS) { + eb_compose_path_name(book->path, catalog_file_name, in_path_name); + eb_compose_path_name(out_top_path, catalog_file_name, out_path_name); + eb_path_name_zio_code(in_path_name, ZIO_PLAIN, &in_zio_code); + if (ebzip_copy_file(out_path_name, in_path_name) < 0) + goto failed; + } + + string_list_finalize(&string_list); + return 0; + + /* + * An error occurs... + */ + failed: + string_list_finalize(&string_list); + return -1; +} + + +/* + * Internal function for `zip_book'. + * This is used to compress an EPWING book. + */ +static int +ebzip_zip_book_epwing(EB_Book *book, const char *out_top_path, + const char *book_path, EB_Subbook_Code *subbook_list, int subbook_count) +{ + EB_Subbook *subbook; + EB_Error_Code error_code; + EB_Font *font; + String_List string_list; + char in_path_name[PATH_MAX + 1]; + char out_sub_path[PATH_MAX + 1]; + char out_path_name[PATH_MAX + 1]; + char catalogs_file_name[EB_MAX_FILE_NAME_LENGTH]; + mode_t out_directory_mode; + Zip_Speedup speedup; + Zio_Code in_zio_code; + int i, j; + + /* + * If `out_top_path' and/or `book_path' represents "/", replace it + * to an empty string. + */ + if (strcmp(out_top_path, "/") == 0) + out_top_path++; + if (strcmp(book_path, "/") == 0) + book_path++; + + /* + * Initialize variables. + */ + out_directory_mode = 0777 ^ get_umask(); + string_list_initialize(&string_list); + + error_code = eb_load_all_subbooks(book); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s\n", invoked_name, + eb_error_message(error_code)); + } + + /* + * Compress a book. + */ + for (i = 0; i < subbook_count; i++) { + subbook = book->subbooks + subbook_list[i]; + + /* + * Make an output directory for the current subbook. + */ + eb_compose_path_name(out_top_path, subbook->directory_name, + out_sub_path); + if (!ebzip_test_flag + && make_missing_directory(out_sub_path, out_directory_mode) < 0) { + fprintf(stderr, _("%s: failed to create a directory, %s: %s\n"), + invoked_name, strerror(errno), out_sub_path); + goto failed; + } + + /* + * Make `data' sub directory for the current subbook. + */ + eb_compose_path_name2(out_top_path, subbook->directory_name, + subbook->data_directory_name, out_sub_path); + if (!ebzip_test_flag + && make_missing_directory(out_sub_path, out_directory_mode) < 0) { + fprintf(stderr, _("%s: failed to create a directory, %s: %s\n"), + invoked_name, strerror(errno), out_sub_path); + goto failed; + } + /* + * Compress HONMON/HONMON2 file. + */ + in_zio_code = zio_mode(&subbook->text_zio); + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->data_directory_name, subbook->text_file_name, + in_path_name); + eb_compose_path_name3(out_top_path, subbook->directory_name, + subbook->data_directory_name, subbook->text_file_name, + out_path_name); + eb_fix_path_name_suffix(out_path_name, EBZIP_SUFFIX_EBZ); + + if (in_zio_code != ZIO_INVALID + && !string_list_find(&string_list, in_path_name)) { + ebzip_initialize_zip_speedup(&speedup); + if (ebzip_set_zip_speedup(&speedup, in_path_name, in_zio_code, + subbook->index_page) < 0) + goto failed; + if (ebzip_zip_file(out_path_name, in_path_name, in_zio_code, + &speedup) < 0) + goto failed; + ebzip_finalize_zip_speedup(&speedup); + string_list_add(&string_list, in_path_name); + } + + /* + * Compress HONMONS file. + */ + in_zio_code = zio_mode(&subbook->sound_zio); + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->data_directory_name, subbook->sound_file_name, + in_path_name); + eb_compose_path_name3(out_top_path, subbook->directory_name, + subbook->data_directory_name, subbook->sound_file_name, + out_path_name); + eb_fix_path_name_suffix(out_path_name, EBZIP_SUFFIX_EBZ); + + if (!ebzip_skip_flag_sound + && in_zio_code != ZIO_INVALID + && !string_list_find(&string_list, in_path_name)) { + if (ebzip_zip_file(out_path_name, in_path_name, in_zio_code, + NULL) < 0) + goto failed; + string_list_add(&string_list, in_path_name); + } + + /* + * Copy HONMONG file. + */ + in_zio_code = zio_mode(&subbook->graphic_zio); + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->data_directory_name, subbook->graphic_file_name, + in_path_name); + eb_compose_path_name3(out_top_path, subbook->directory_name, + subbook->data_directory_name, subbook->graphic_file_name, + out_path_name); + + if (!ebzip_skip_flag_graphic + && in_zio_code != ZIO_INVALID + && !string_list_find(&string_list, in_path_name)) { + if (ebzip_copy_file(out_path_name, in_path_name) < 0) + goto failed; + string_list_add(&string_list, in_path_name); + } + + if (!ebzip_skip_flag_font) { + /* + * Make `gaiji' sub directory for the current subbook. + */ + eb_compose_path_name2(out_top_path, subbook->directory_name, + subbook->gaiji_directory_name, out_sub_path); + if (!ebzip_test_flag + && make_missing_directory(out_sub_path, out_directory_mode) + < 0) { + fprintf(stderr, + _("%s: failed to create a directory, %s: %s\n"), + invoked_name, strerror(errno), out_sub_path); + goto failed; + } + + /* + * Compress narrow font files. + */ + for (j = 0; j < EB_MAX_FONTS; j++) { + font = subbook->narrow_fonts + j; + if (font->font_code == EB_FONT_INVALID) + continue; + + in_zio_code = zio_mode(&font->zio); + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->gaiji_directory_name, font->file_name, + in_path_name); + eb_compose_path_name3(out_top_path, subbook->directory_name, + subbook->gaiji_directory_name, font->file_name, + out_path_name); + eb_fix_path_name_suffix(out_path_name, EBZIP_SUFFIX_EBZ); + + if (in_zio_code != ZIO_INVALID + && !string_list_find(&string_list, in_path_name)) { + if (ebzip_zip_file(out_path_name, in_path_name, + in_zio_code, NULL) < 0) + goto failed; + string_list_add(&string_list, in_path_name); + } + } + + /* + * Compress wide font files. + */ + for (j = 0; j < EB_MAX_FONTS; j++) { + font = subbook->wide_fonts + j; + if (font->font_code == EB_FONT_INVALID) + continue; + + in_zio_code = zio_mode(&font->zio); + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->gaiji_directory_name, font->file_name, + in_path_name); + eb_compose_path_name3(out_top_path, subbook->directory_name, + subbook->gaiji_directory_name, font->file_name, + out_path_name); + eb_fix_path_name_suffix(out_path_name, EBZIP_SUFFIX_EBZ); + + if (in_zio_code != ZIO_INVALID + && !string_list_find(&string_list, in_path_name)) { + if (ebzip_zip_file(out_path_name, in_path_name, + in_zio_code, NULL) < 0) + goto failed; + string_list_add(&string_list, in_path_name); + } + } + } + + /* + * Copy movie files. + */ + if (!ebzip_skip_flag_movie) { + eb_compose_path_name2(book->path, subbook->directory_name, + subbook->movie_directory_name, in_path_name); + eb_compose_path_name2(out_top_path, subbook->directory_name, + subbook->movie_directory_name, out_path_name); + if (ebzip_copy_files_in_directory(out_path_name, in_path_name) < 0) + goto failed; + } + } + + /* + * Copy CATALOGS file. + */ + if (eb_find_file_name(book->path, "catalogs", catalogs_file_name) + == EB_SUCCESS) { + eb_compose_path_name(book->path, catalogs_file_name, in_path_name); + eb_compose_path_name(out_top_path, catalogs_file_name, out_path_name); + if (ebzip_copy_file(out_path_name, in_path_name) < 0) + goto failed; + } + + string_list_finalize(&string_list); + return 0; + + /* + * An error occurs... + */ + failed: + string_list_finalize(&string_list); + return -1; +} diff --git a/ebzip/zipfile.c b/ebzip/zipfile.c new file mode 100644 index 0000000..6208112 --- /dev/null +++ b/ebzip/zipfile.c @@ -0,0 +1,660 @@ +/* -*- C -*- + * Copyright (c) 1998-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "ebzip.h" + +#include "getumask.h" +#include "makedir.h" +#include "samefile.h" +#include "yesno.h" + +/* + * File name to be deleted and file to be closed when signal is received. + */ +static const char *trap_file_name = NULL; +static int trap_file = -1; + +/* + * Unexported function. + */ +static int ebzip_zip_file_internal(const char *out_file_name, + const char *in_file_name, Zio_Code in_zio_code, int index_page, + Zip_Speedup *speedup); +static void trap(int signal_number); + + +/* + * Ccompress a file `in_file_name'. + * For START file, use ebzip_zip_start_file() instead. + * If it succeeds, 0 is returned. Otherwise -1 is returned. + */ +int +ebzip_zip_file(const char *out_file_name, const char *in_file_name, + Zio_Code in_zio_code, Zip_Speedup *speedup) +{ + return ebzip_zip_file_internal(out_file_name, in_file_name, + in_zio_code, 0, speedup); +} + +/* + * Compress TART file `in_file_name'. + * If it succeeds, 0 is returned. Otherwise -1 is returned. + */ +int +ebzip_zip_start_file(const char *out_file_name, const char *in_file_name, + Zio_Code in_zio_code, int index_page, Zip_Speedup *speedup) +{ + return ebzip_zip_file_internal(out_file_name, in_file_name, + in_zio_code, index_page, speedup); +} + +/* + * Internal function for zip_unzip_file() and ebzip_zip_sebxa_start(). + * If it succeeds, 0 is returned. Otherwise -1 is returned. + */ +static int +ebzip_zip_file_internal(const char *out_file_name, const char *in_file_name, + Zio_Code in_zio_code, int index_page, Zip_Speedup *speedup) +{ + Zio in_zio, out_zio; + unsigned char *in_buffer = NULL, *out_buffer = NULL; + off_t in_total_length, out_total_length; + ssize_t in_length; + size_t out_length; + struct stat in_status, out_status; + off_t slice_location = 0; + off_t next_location; + size_t index_length; + int progress_interval; + int total_slices; + int i; + + zio_initialize(&in_zio); + zio_initialize(&out_zio); + + /* + * Output information. + */ + if (!ebzip_quiet_flag) { + fprintf(stderr, _("==> compress %s <==\n"), in_file_name); + fprintf(stderr, _("output to %s\n"), out_file_name); + fflush(stderr); + } + + /* + * Get status of the input file. + */ + if (stat(in_file_name, &in_status) < 0 || !S_ISREG(in_status.st_mode)) { + fprintf(stderr, _("%s: no such file: %s\n"), invoked_name, + in_file_name); + goto failed; + } + + /* + * Do nothing if the `in_file_name' and `out_file_name' are the same. + */ + if (is_same_file(out_file_name, in_file_name)) { + if (!ebzip_quiet_flag) { + fprintf(stderr, + _("the input and output files are the same, skipped.\n\n")); + fflush(stderr); + } + return 0; + } + + /* + * Allocate memories for in/out buffers. + */ + in_buffer = (unsigned char *)malloc(EB_SIZE_PAGE << ZIO_MAX_EBZIP_LEVEL); + if (in_buffer == NULL) { + fprintf(stderr, _("%s: memory exhausted\n"), invoked_name); + goto failed; + } + + out_buffer = (unsigned char *) malloc((EB_SIZE_PAGE << ZIO_MAX_EBZIP_LEVEL) + + ZIO_SIZE_EBZIP_MARGIN); + if (out_buffer == NULL) { + fprintf(stderr, _("%s: memory exhausted\n"), invoked_name); + goto failed; + } + + /* + * If the file `out_file_name' already exists, confirm and unlink it. + */ + if (!ebzip_test_flag + && stat(out_file_name, &out_status) == 0 + && S_ISREG(out_status.st_mode)) { + if (ebzip_overwrite_mode == EBZIP_OVERWRITE_NO) { + if (!ebzip_quiet_flag) { + fputs(_("already exists, skip the file\n\n"), stderr); + fflush(stderr); + } + return 0; + } else if (ebzip_overwrite_mode == EBZIP_OVERWRITE_CONFIRM) { + int y_or_n; + + fprintf(stderr, _("\nthe file already exists: %s\n"), + out_file_name); + y_or_n = query_y_or_n(_("do you wish to overwrite (y or n)? ")); + fputc('\n', stderr); + fflush(stderr); + if (!y_or_n) + return 0; + } + if (unlink(out_file_name) < 0) { + fprintf(stderr, _("%s: failed to unlink the file: %s\n"), + invoked_name, out_file_name); + goto failed; + } + } + + /* + * Open files. + */ + if (zio_open(&in_zio, in_file_name, in_zio_code) < 0) { + fprintf(stderr, _("%s: failed to open the file: %s\n"), + invoked_name, in_file_name); + goto failed; + } + if (in_zio_code == ZIO_SEBXA) { + off_t index_location; + off_t index_base; + off_t zio_start_location; + off_t zio_end_location; + + if (get_sebxa_indexes(in_file_name, index_page, &index_location, + &index_base, &zio_start_location, &zio_end_location) < 0) { + goto failed; + } + zio_set_sebxa_mode(&in_zio, index_location, index_base, + zio_start_location, zio_end_location); + } + + if (!ebzip_test_flag) { + trap_file_name = out_file_name; +#ifdef SIGHUP + signal(SIGHUP, trap); +#endif + signal(SIGINT, trap); +#ifdef SIGQUIT + signal(SIGQUIT, trap); +#endif +#ifdef SIGTERM + signal(SIGTERM, trap); +#endif + +#ifdef O_CREAT + out_zio.file = open(out_file_name, + O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0666 ^ get_umask()); +#else + out_zio.file = creat(out_file_name, 0666 ^ get_umask()); +#endif + if (out_zio.file < 0) { + fprintf(stderr, _("%s: failed to open the file, %s: %s\n"), + invoked_name, strerror(errno), out_file_name); + goto failed; + } + trap_file = out_zio.file; + } + + /* + * Initialize `zip'. + */ + out_zio.code = ZIO_EBZIP1; + out_zio.slice_size = EB_SIZE_PAGE << ebzip_level; + out_zio.file_size = in_zio.file_size; + out_zio.crc = 1; + out_zio.mtime = in_status.st_mtime; + + if (out_zio.file_size < (off_t) 1 << 16) + out_zio.index_width = 2; + else if (out_zio.file_size < (off_t) 1 << 24) + out_zio.index_width = 3; + else if (out_zio.file_size < (off_t) 1 << 32 || !off_t_is_large) + out_zio.index_width = 4; + else + out_zio.index_width = 5; + + /* + * Fill header and index part with `\0'. + * + * Original File: + * +-----------------+-----------------+-....-+-------+ + * | slice 1 | slice 2 | |slice N| [EOF] + * | | | | | + * +-----------------+-----------------+-....-+-------+ + * slice_size slice_size odds + * <-------------------- file size -------------------> + * + * Compressed file: + * +------+---------+...+---------+---------+----------+...+- + * |Header|index for| |index for|index for|compressed| | + * | | slice 1 | | slice N | EOF | slice 1 | | + * +------+---------+...+---------+---------+----------+...+- + * index index index + * width width width + * <--------- index_length ---------> + * + * total_slices = N = (file_size + slice_size - 1) / slice_size + * index_length = (N + 1) * index_width + */ + total_slices = (out_zio.file_size + out_zio.slice_size - 1) + / out_zio.slice_size; + index_length = (total_slices + 1) * out_zio.index_width; + memset(out_buffer, '\0', out_zio.slice_size); + + if (!ebzip_test_flag) { + for (i = index_length + ZIO_SIZE_EBZIP_HEADER; + out_zio.slice_size <= i; i -= out_zio.slice_size) { + if (write(out_zio.file, out_buffer, out_zio.slice_size) + != out_zio.slice_size) { + fprintf(stderr, _("%s: failed to write to the file: %s\n"), + invoked_name, out_file_name); + goto failed; + } + } + if (0 < i) { + if (write(out_zio.file, out_buffer, i) != i) { + fprintf(stderr, _("%s: failed to write to the file: %s\n"), + invoked_name, out_file_name); + goto failed; + } + } + } + + /* + * Read a slice from the input file, compress it, and then + * write it to the output file. + */ + in_total_length = 0; + out_total_length = 0; + progress_interval = EBZIP_PROGRESS_INTERVAL_FACTOR >> ebzip_level; + if (((total_slices + 999) / 1000) > progress_interval) + progress_interval = ((total_slices + 999) / 1000); + + for (i = 0; i < total_slices; i++) { + /* + * Read a slice from the original file. + */ + if (zio_lseek(&in_zio, in_total_length, SEEK_SET) < 0) { + fprintf(stderr, _("%s: failed to seek the file: %s\n"), + invoked_name, in_file_name); + goto failed; + } + in_length = zio_read(&in_zio, (char *)in_buffer, out_zio.slice_size); + if (in_length < 0) { + fprintf(stderr, _("%s: failed to read from the file: %s\n"), + invoked_name, in_file_name); + goto failed; + } else if (in_length == 0) { + fprintf(stderr, _("%s: unexpected EOF: %s\n"), + invoked_name, in_file_name); + goto failed; + } else if (in_length != out_zio.slice_size + && in_total_length + in_length != out_zio.file_size) { + fprintf(stderr, _("%s: unexpected EOF: %s\n"), + invoked_name, in_file_name); + goto failed; + } + + /* + * Update CRC. (Calculate adler32 again.) + */ + out_zio.crc = adler32((uLong)out_zio.crc, (Bytef *)in_buffer, + (uInt)in_length); + + /* + * If this is last slice and its length is shorter than + * `slice_size', fill `\0'. + */ + if (in_length < out_zio.slice_size) { + memset(in_buffer + in_length, '\0', + out_zio.slice_size - in_length); + in_length = out_zio.slice_size; + } + + /* + * Compress the slice. + */ + if (speedup != NULL + && ebzip_is_speedup_slice(speedup, i, ebzip_level)) { + out_length = out_zio.slice_size; + } else if (ebzip1_slice((char *)out_buffer, &out_length, + (char *)in_buffer, out_zio.slice_size) < 0) { + fprintf(stderr, _("%s: memory exhausted\n"), invoked_name); + goto failed; + } + if (out_zio.slice_size <= out_length) { + memcpy(out_buffer, in_buffer, out_zio.slice_size); + out_length = out_zio.slice_size; + } + + /* + * Write the slice to the zip file. + * If the length of the zipped slice is not shorter than + * original, write orignal slice. + */ + if (!ebzip_test_flag) { + slice_location = lseek(out_zio.file, 0, SEEK_END); + if (slice_location < 0) { + fprintf(stderr, _("%s: failed to seek the file, %s: %s\n"), + invoked_name, strerror(errno), out_file_name); + goto failed; + } + if (write(out_zio.file, out_buffer, out_length) != out_length) { + fprintf(stderr, _("%s: failed to write to the file: %s\n"), + invoked_name, out_file_name); + goto failed; + } + } + + /* + * Write an index for the slice. + */ + next_location = slice_location + out_length; + switch (out_zio.index_width) { + case 2: + out_buffer[0] = (slice_location >> 8) & 0xff; + out_buffer[1] = slice_location & 0xff; + out_buffer[2] = (next_location >> 8) & 0xff; + out_buffer[3] = next_location & 0xff; + break; + case 3: + out_buffer[0] = (slice_location >> 16) & 0xff; + out_buffer[1] = (slice_location >> 8) & 0xff; + out_buffer[2] = slice_location & 0xff; + out_buffer[3] = (next_location >> 16) & 0xff; + out_buffer[4] = (next_location >> 8) & 0xff; + out_buffer[5] = next_location & 0xff; + break; + case 4: + out_buffer[0] = (slice_location >> 24) & 0xff; + out_buffer[1] = (slice_location >> 16) & 0xff; + out_buffer[2] = (slice_location >> 8) & 0xff; + out_buffer[3] = slice_location & 0xff; + out_buffer[4] = (next_location >> 24) & 0xff; + out_buffer[5] = (next_location >> 16) & 0xff; + out_buffer[6] = (next_location >> 8) & 0xff; + out_buffer[7] = next_location & 0xff; + break; + case 5: + out_buffer[0] = (slice_location >> 32) & 0xff; + out_buffer[1] = (slice_location >> 24) & 0xff; + out_buffer[2] = (slice_location >> 16) & 0xff; + out_buffer[3] = (slice_location >> 8) & 0xff; + out_buffer[4] = slice_location & 0xff; + out_buffer[5] = (next_location >> 32) & 0xff; + out_buffer[6] = (next_location >> 24) & 0xff; + out_buffer[7] = (next_location >> 16) & 0xff; + out_buffer[8] = (next_location >> 8) & 0xff; + out_buffer[9] = next_location & 0xff; + break; + } + + if (!ebzip_test_flag) { + if (lseek(out_zio.file, + ZIO_SIZE_EBZIP_HEADER + (off_t) i * out_zio.index_width, + SEEK_SET) < 0) { + fprintf(stderr, _("%s: failed to seek the file, %s: %s\n"), + invoked_name, strerror(errno), out_file_name); + goto failed; + } + if (write(out_zio.file, out_buffer, out_zio.index_width * 2) + != out_zio.index_width * 2) { + fprintf(stderr, _("%s: failed to write to the file, %s: %s\n"), + invoked_name, strerror(errno), out_file_name); + goto failed; + } + } + + in_total_length += in_length; + out_total_length += out_length + out_zio.index_width; + + /* + * Output status information unless `quiet' mode. + */ + if (!ebzip_quiet_flag && (i + 1) % progress_interval == 0) { +#if defined(PRINTF_LL_MODIFIER) + fprintf(stderr, _("%4.1f%% done (%llu / %llu bytes)\n"), + (double) (i + 1) * 100.0 / (double) total_slices, + (unsigned long long) in_total_length, + (unsigned long long) in_zio.file_size); +#elif defined(PRINTF_I64_MODIFIER) + fprintf(stderr, _("%4.1f%% done (%I64u / %I64u bytes)\n"), + (double) (i + 1) * 100.0 / (double) total_slices, + (unsigned __int64) in_total_length, + (unsigned __int64) in_zio.file_size); +#else + fprintf(stderr, _("%4.1f%% done (%lu / %lu bytes)\n"), + (double) (i + 1) * 100.0 / (double) total_slices, + (unsigned long) in_total_length, + (unsigned long) in_zio.file_size); +#endif + fflush(stderr); + } + } + + /* + * Write a header part (22 bytes): + * magic-id 5 bytes ( 0 ... 4) + * zip-mode 4/8 bytes ( 5) + * slice_size 4/8 bytes ( 5) + * (reserved) 4 bytes ( 6 ... 9) + * file_size 4 bytes (10 ... 13) + * crc 4 bytes (14 ... 17) + * mtime 4 bytes (18 ... 21) + */ + memcpy(out_buffer, "EBZip", 5); + + if (out_zio.file_size < (off_t) 1 << 32 || !off_t_is_large) + out_buffer[5] = (1 << 4) + (ebzip_level & 0x0f); + else + out_buffer[5] = (2 << 4) + (ebzip_level & 0x0f); + out_buffer[ 6] = 0; + out_buffer[ 7] = 0; + out_buffer[ 8] = 0; + out_buffer[ 9] = (out_zio.file_size >> 32) & 0xff; + out_buffer[10] = (out_zio.file_size >> 24) & 0xff; + out_buffer[11] = (out_zio.file_size >> 16) & 0xff; + out_buffer[12] = (out_zio.file_size >> 8) & 0xff; + out_buffer[13] = out_zio.file_size & 0xff; + out_buffer[14] = (out_zio.crc >> 24) & 0xff; + out_buffer[15] = (out_zio.crc >> 16) & 0xff; + out_buffer[16] = (out_zio.crc >> 8) & 0xff; + out_buffer[17] = out_zio.crc & 0xff; + out_buffer[18] = (out_zio.mtime >> 24) & 0xff; + out_buffer[19] = (out_zio.mtime >> 16) & 0xff; + out_buffer[20] = (out_zio.mtime >> 8) & 0xff; + out_buffer[21] = out_zio.mtime & 0xff; + + if (!ebzip_test_flag) { + if (lseek(out_zio.file, 0, SEEK_SET) < 0) { + fprintf(stderr, _("%s: failed to seek the file, %s: %s\n"), + invoked_name, strerror(errno), out_file_name); + goto failed; + } + if (write(out_zio.file, out_buffer, ZIO_SIZE_EBZIP_HEADER) + != ZIO_SIZE_EBZIP_HEADER) { + fprintf(stderr, _("%s: failed to write to the file, %s: %s\n"), + invoked_name, strerror(errno), out_file_name); + goto failed; + } + } + + /* + * Output the result information unless quiet mode. + */ + out_total_length += ZIO_SIZE_EBZIP_HEADER + out_zio.index_width; + + if (!ebzip_quiet_flag) { +#if defined(PRINTF_LL_MODIFIER) + fprintf(stderr, _("completed (%llu / %llu bytes)\n"), + (unsigned long long) in_zio.file_size, + (unsigned long long) in_zio.file_size); + if (in_total_length != 0) { + fprintf(stderr, _("%llu -> %llu bytes (%4.1f%%)\n\n"), + (unsigned long long) in_zio.file_size, + (unsigned long long) out_total_length, + (double) out_total_length * 100.0 / (double) in_zio.file_size); + } else { + fprintf(stderr, _("%llu -> %llu bytes\n\n"), + (unsigned long long) in_zio.file_size, + (unsigned long long) out_total_length); + } +#elif defined(PRINTF_I64_MODIFIER) + fprintf(stderr, _("completed (%I64u / %I64u bytes)\n"), + (unsigned __int64) in_zio.file_size, + (unsigned __int64) in_zio.file_size); + if (in_total_length != 0) { + fprintf(stderr, _("%I64u -> %I64u bytes (%4.1f%%)\n\n"), + (unsigned __int64) in_zio.file_size, + (unsigned __int64) out_total_length, + (double) out_total_length * 100.0 / (double) in_zio.file_size); + } else { + fprintf(stderr, _("%I64u -> %I64u bytes\n\n"), + (unsigned __int64) in_zio.file_size, + (unsigned __int64) out_total_length); + } +#else + fprintf(stderr, _("completed (%lu / %lu bytes)\n"), + (unsigned long) in_zio.file_size, + (unsigned long) in_zio.file_size); + if (in_total_length != 0) { + fprintf(stderr, _("%lu -> %lu bytes (%4.1f%%)\n\n"), + (unsigned long) in_zio.file_size, + (unsigned long) out_total_length, + (double) out_total_length * 100.0 / (double) in_zio.file_size); + } else { + fprintf(stderr, _("%lu -> %lu bytes\n\n"), + (unsigned long) in_zio.file_size, + (unsigned long) out_total_length); + } +#endif + fflush(stderr); + } + + /* + * Close files. + */ + zio_close(&in_zio); + zio_finalize(&in_zio); + + if (!ebzip_test_flag) { + close(out_zio.file); + out_zio.file = -1; + zio_finalize(&out_zio); + trap_file = -1; + trap_file_name = NULL; +#ifdef SIGHUP + signal(SIGHUP, SIG_DFL); +#endif + signal(SIGINT, SIG_DFL); +#ifdef SIGQUIT + signal(SIGQUIT, SIG_DFL); +#endif +#ifdef SIGTERM + signal(SIGTERM, SIG_DFL); +#endif + } + + /* + * Delete an original file unless the keep flag is set. + */ + if (!ebzip_test_flag && !ebzip_keep_flag) + unlink_files_add(in_file_name); + + /* + * Set owner, group, permission, atime and utime of `out_zio.file'. + * We ignore return values of `chown', `chmod' and `utime'. + */ + if (!ebzip_test_flag) { + struct utimbuf utim; + + utim.actime = in_status.st_atime; + utim.modtime = in_status.st_mtime; + utime(out_file_name, &utim); + } + + /* + * Dispose memories. + */ + free(in_buffer); + free(out_buffer); + + return 0; + + /* + * An error occurs... + */ + failed: + if (in_buffer != NULL) + free(in_buffer); + if (out_buffer != NULL) + free(out_buffer); + + zio_close(&in_zio); + zio_finalize(&in_zio); + + if (0 <= out_zio.file) { + close(out_zio.file); + out_zio.file = -1; + zio_finalize(&out_zio); + trap_file = -1; + trap_file_name = NULL; +#ifdef SIGHUP + signal(SIGHUP, SIG_DFL); +#endif + signal(SIGINT, SIG_DFL); +#ifdef SIGQUIT + signal(SIGQUIT, SIG_DFL); +#endif +#ifdef SIGTERM + signal(SIGTERM, SIG_DFL); +#endif + } + + fputc('\n', stderr); + fflush(stderr); + + return -1; +} + + +/* + * Signal handler. + */ +static void +trap(int signal_number) +{ + if (0 <= trap_file) + close(trap_file); + if (trap_file_name != NULL) + unlink(trap_file_name); + + exit(1); +} diff --git a/ebzip/zipinfobook.c b/ebzip/zipinfobook.c new file mode 100644 index 0000000..64c3971 --- /dev/null +++ b/ebzip/zipinfobook.c @@ -0,0 +1,340 @@ +/* -*- C -*- + * Copyright (c) 1998-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "ebzip.h" +#include "ebutils.h" + +/* + * Unexported functions. + */ +static int ebzip_zipinfo_book_eb(EB_Book *book, const char *book_path, + EB_Subbook_Code *subbook_list, int subbook_count); +static int ebzip_zipinfo_book_epwing(EB_Book *book, const char *book_path, + EB_Subbook_Code *subbook_list, int subbook_count); + + +/* + * Hints of language file names in a book. + */ +#define EB_HINT_INDEX_LANGUAGE 0 +#define EB_HINT_INDEX_LANGUAGE_EBZ 1 + +/* + * List compressed book information. + * If is succeeds, 0 is returned. Otherwise -1 is returned. + */ +int +ebzip_zipinfo_book(const char *book_path, + char subbook_name_list[][EB_MAX_DIRECTORY_NAME_LENGTH + 1], + int subbook_name_count) +{ + EB_Book book; + EB_Error_Code error_code; + EB_Subbook_Code subbook_list[EB_MAX_SUBBOOKS]; + EB_Subbook_Code subbook_code; + int subbook_count = 0; + int result; + int i; + + eb_initialize_book(&book); + + /* + * Bind a book. + */ + error_code = eb_bind(&book, book_path); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s\n", invoked_name, + eb_error_message(error_code)); + fflush(stderr); + return -1; + } + + /* + * For each targe subbook, convert a subbook-names to a subbook-codes. + * If no subbook is specified by `--subbook'(`-S'), set all subbooks + * as the target. + */ + if (subbook_name_count == 0) { + error_code = eb_subbook_list(&book, subbook_list, &subbook_count); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s\n", invoked_name, + eb_error_message(error_code)); + fflush(stderr); + return -1; + } + } else { + for (i = 0; i < subbook_name_count; i++) { + error_code = find_subbook(&book, *(subbook_name_list + i), + &subbook_code); + if (error_code != EB_SUCCESS) { + fprintf(stderr, _("%s: unknown subbook name `%s'\n"), + invoked_name, subbook_name_list[i]); + return -1; + } + subbook_list[subbook_count++] = subbook_code; + } + } + + /* + * List compressed book information. + */ + if (book.disc_code == EB_DISC_EB) { + result = ebzip_zipinfo_book_eb(&book, book_path, subbook_list, + subbook_count); + } else { + result = ebzip_zipinfo_book_epwing(&book, book_path, subbook_list, + subbook_count); + } + + eb_finalize_book(&book); + + return result; +} + + +/* + * Internal function for `zipinfo_book'. + * This is used to list files in an EB book. + */ +static int +ebzip_zipinfo_book_eb(EB_Book *book, const char *book_path, + EB_Subbook_Code *subbook_list, int subbook_count) +{ + EB_Subbook *subbook; + EB_Error_Code error_code; + char in_path_name[PATH_MAX + 1]; + char catalog_file_name[EB_MAX_FILE_NAME_LENGTH]; + char language_file_name[EB_MAX_FILE_NAME_LENGTH]; + Zio_Code in_zio_code; + int i; + + /* + * If `book_path' represents "/", replace it to an empty string. + */ + if (strcmp(book_path, "/") == 0) + book_path++; + + /* + * Initialize variables. + */ + error_code = eb_load_all_subbooks(book); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s\n", invoked_name, + eb_error_message(error_code)); + } + + /* + * Inspect a book. + */ + for (i = 0; i < subbook_count; i++) { + subbook = book->subbooks + subbook_list[i]; + + in_zio_code = zio_mode(&subbook->text_zio); + eb_compose_path_name2(book->path, subbook->directory_name, + subbook->text_file_name, in_path_name); + + if (in_zio_code != ZIO_INVALID) { + ebzip_zipinfo_start_file(in_path_name, in_zio_code, + subbook->index_page); + } + } + + /* + * Inspect a language file. + */ + if (eb_find_file_name(book->path, "language", language_file_name) + == EB_SUCCESS) { + eb_compose_path_name(book->path, language_file_name, in_path_name); + eb_path_name_zio_code(in_path_name, ZIO_PLAIN, &in_zio_code); + ebzip_zipinfo_file(in_path_name, in_zio_code); + } + + /* + * Inspect CATALOG file. + */ + if (eb_find_file_name(book->path, "catalog", catalog_file_name) + == EB_SUCCESS) { + eb_compose_path_name(book->path, catalog_file_name, in_path_name); + ebzip_zipinfo_file(in_path_name, ZIO_PLAIN); + } + + return 0; +} + + +/* + * Internal function for `zipinfo_book'. + * This is used to list files in an EPWING book. + */ +static int +ebzip_zipinfo_book_epwing(EB_Book *book, const char *book_path, + EB_Subbook_Code *subbook_list, int subbook_count) +{ + EB_Subbook *subbook; + EB_Error_Code error_code; + EB_Font *font; + char in_path_name[PATH_MAX + 1]; + char in_movie_path_name[PATH_MAX + 1]; + char catalogs_file_name[EB_MAX_FILE_NAME_LENGTH]; + Zio_Code in_zio_code; + DIR *dir; + int i, j; + + /* + * If `book_path' represents "/", replace it to an empty string. + */ + if (strcmp(book_path, "/") == 0) + book_path++; + + /* + * Initialize variables. + */ + error_code = eb_load_all_subbooks(book); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: %s\n", invoked_name, + eb_error_message(error_code)); + } + + /* + * Inspect a book. + */ + for (i = 0; i < subbook_count; i++) { + subbook = book->subbooks + subbook_list[i]; + + /* + * Inspect HONMON/HONMON2 file. + */ + in_zio_code = zio_mode(&subbook->text_zio); + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->data_directory_name, subbook->text_file_name, + in_path_name); + if (in_zio_code != ZIO_INVALID) + ebzip_zipinfo_file(in_path_name, in_zio_code); + + /* + * Inspect HONMONS file. + */ + in_zio_code = zio_mode(&subbook->sound_zio); + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->data_directory_name, subbook->sound_file_name, + in_path_name); + if (!ebzip_skip_flag_sound + && in_zio_code != ZIO_INVALID + && strncasecmp(subbook->sound_file_name, "honmons", 7) == 0) + ebzip_zipinfo_file(in_path_name, in_zio_code); + + /* + * Inspect HONMONG file. + */ + in_zio_code = zio_mode(&subbook->graphic_zio); + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->data_directory_name, subbook->graphic_file_name, + in_path_name); + if (!ebzip_skip_flag_graphic + && in_zio_code != ZIO_INVALID + && strncasecmp(subbook->graphic_file_name, "honmong", 7) == 0) + ebzip_zipinfo_file(in_path_name, in_zio_code); + + if (!ebzip_skip_flag_font) { + /* + * Inspect narrow font files. + */ + for (j = 0; j < EB_MAX_FONTS; j++) { + font = subbook->narrow_fonts + j; + if (font->font_code == EB_FONT_INVALID) + continue; + + in_zio_code = zio_mode(&font->zio); + + if (in_zio_code != ZIO_INVALID) { + eb_compose_path_name3(book->path, + subbook->directory_name, subbook->gaiji_directory_name, + font->file_name, in_path_name); + ebzip_zipinfo_file(in_path_name, in_zio_code); + } + } + + /* + * Inspect wide font files. + */ + for (j = 0; j < EB_MAX_FONTS; j++) { + font = subbook->wide_fonts + j; + if (font->font_code == EB_FONT_INVALID) + continue; + + in_zio_code = zio_mode(&font->zio); + + if (in_zio_code != ZIO_INVALID) { + eb_compose_path_name3(book->path, + subbook->directory_name, subbook->gaiji_directory_name, + font->file_name, in_path_name); + ebzip_zipinfo_file(in_path_name, in_zio_code); + } + } + } + + /* + * Inspect movie files. + */ + if (!ebzip_skip_flag_movie) { + eb_compose_path_name2(book->path, subbook->directory_name, + subbook->movie_directory_name, in_movie_path_name); + dir = opendir(in_movie_path_name); + if (dir == NULL) + continue; + for (;;) { + struct dirent *entry; + struct stat st; + + entry = readdir(dir); + if (entry == NULL) + break; + eb_compose_path_name3(book->path, subbook->directory_name, + subbook->movie_directory_name, entry->d_name, + in_path_name); + if (stat(in_path_name, &st) < 0 || !S_ISREG(st.st_mode)) + continue; + eb_path_name_zio_code(in_path_name, ZIO_PLAIN, &in_zio_code); + ebzip_zipinfo_file(in_path_name, in_zio_code); + } + closedir(dir); + } + } + + /* + * Inspect CATALOGS file. + */ + if (eb_find_file_name(book->path, "catalogs", catalogs_file_name) + == EB_SUCCESS) { + eb_compose_path_name(book->path, catalogs_file_name, in_path_name); + eb_path_name_zio_code(in_path_name, ZIO_PLAIN, &in_zio_code); + ebzip_zipinfo_file(in_path_name, in_zio_code); + } + + return 0; +} diff --git a/ebzip/zipinfofile.c b/ebzip/zipinfofile.c new file mode 100644 index 0000000..741dede --- /dev/null +++ b/ebzip/zipinfofile.c @@ -0,0 +1,185 @@ +/* -*- C -*- + * Copyright (c) 1998-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "ebzip.h" + +#include "samefile.h" +#include "yesno.h" + +/* + * Tricks for gettext. + */ +#ifdef ENABLE_NLS +#define _(string) gettext(string) +#ifdef gettext_noop +#define N_(string) gettext_noop(string) +#else +#define N_(string) (string) +#endif +#else +#define _(string) (string) +#define N_(string) (string) +#endif + +/* + * Unexported functions. + */ +static int ebzip_zipinfo_file_internal(const char *in_file_name, + Zio_Code in_zio_code, int index_page); + + +/* + * Output status of a file `in_file_name'. + * For START file, use ebzip_zipinfo_start_file() instead. + * If it succeeds, 0 is returned. Otherwise -1 is returned. + */ +int +ebzip_zipinfo_file(const char *in_file_name, Zio_Code in_zio_code) +{ + return ebzip_zipinfo_file_internal(in_file_name, in_zio_code, 0); +} + +/* + * Output status of START file `in_file_name'. + * If it succeeds, 0 is returned. Otherwise -1 is returned. + */ +int +ebzip_zipinfo_start_file(const char *in_file_name, Zio_Code in_zio_code, + int index_page) +{ + return ebzip_zipinfo_file_internal(in_file_name, in_zio_code, index_page); +} + +/* + * Output status of a file `file_name'. + * If it succeeds, 0 is returned. Otherwise -1 is returned. + */ +static int +ebzip_zipinfo_file_internal(const char *in_file_name, Zio_Code in_zio_code, + int index_page) +{ + Zio in_zio; + int in_file = -1; + struct stat in_status; + + /* + * Output file name information. + */ + printf("==> %s <==\n", in_file_name); + fflush(stdout); + + /* + * Open the file. + */ + zio_initialize(&in_zio); + if (stat(in_file_name, &in_status) == 0 && S_ISREG(in_status.st_mode)) + in_file = zio_open(&in_zio, in_file_name, in_zio_code); + + if (in_file < 0) { + fprintf(stderr, _("%s: failed to open the file: %s\n"), + invoked_name, in_file_name); + goto failed; + } + if (in_zio_code == ZIO_SEBXA) { + off_t index_location; + off_t index_base; + off_t zio_start_location; + off_t zio_end_location; + + if (get_sebxa_indexes(in_file_name, index_page, &index_location, + &index_base, &zio_start_location, &zio_end_location) < 0) { + goto failed; + } + zio_set_sebxa_mode(&in_zio, index_location, index_base, + zio_start_location, zio_end_location); + } + + /* + * Close the file. + */ + zio_close(&in_zio); + + /* + * Output information. + */ + if (in_zio.code == ZIO_PLAIN) { +#if defined(PRINTF_LL_MODIFIER) + printf(_("%llu bytes (not compressed)\n"), + (unsigned long long) in_status.st_size); +#elif defined(PRINTF_I64_MODIFIER) + printf(_("%I64u bytes (not compressed)\n"), + (unsigned __int64) in_status.st_size); +#else + printf(_("%lu bytes (not compressed)\n"), + (unsigned long) in_status.st_size); +#endif + } else { +#if defined(PRINTF_LL_MODIFIER) + printf(_("%llu -> %llu bytes "), + (unsigned long long) in_zio.file_size, + (unsigned long long) in_status.st_size); +#elif defined(PRINTF_I64_MODIFIER) + printf(_("%I64u -> %I64u bytes "), + (unsigned __int64) in_zio.file_size, + (unsigned __int64) in_status.st_size); +#else + printf(_("%lu -> %lu bytes "), + (unsigned long) in_zio.file_size, + (unsigned long) in_status.st_size); +#endif + if (in_zio.file_size == 0) + fputs(_("(empty original file, "), stdout); + else { + printf("(%4.1f%%, ", (double)in_status.st_size * 100.0 + / (double)in_zio.file_size); + } + if (in_zio.code == ZIO_EBZIP1) + printf(_("ebzip level %d compression)\n"), in_zio.zip_level); + else if (in_zio.code == ZIO_SEBXA) + printf(_("S-EBXA compression)\n")); + else + printf(_("EPWING compression)\n")); + } + + fputc('\n', stdout); + fflush(stdout); + + return 0; + + /* + * An error occurs... + */ + failed: + if (0 <= in_file) + close(in_file); + + fputc('\n', stderr); + fflush(stderr); + + return -1; +} diff --git a/install-sh b/install-sh new file mode 100755 index 0000000..a5897de --- /dev/null +++ b/install-sh @@ -0,0 +1,519 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2006-12-25.00 + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +nl=' +' +IFS=" "" $nl" + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit=${DOITPROG-} +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_glob='?' +initialize_posix_glob=' + test "$posix_glob" != "?" || { + if (set -f) 2>/dev/null; then + posix_glob= + else + posix_glob=: + fi + } +' + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +no_target_directory= + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + + -t) dst_arg=$2 + shift;; + + -T) no_target_directory=true;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + trap '(exit $?); exit' 1 2 13 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dst_arg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + -*) prefix='./';; + *) prefix='';; + esac + + eval "$initialize_posix_glob" + + oIFS=$IFS + IFS=/ + $posix_glob set -f + set fnord $dstdir + shift + $posix_glob set +f + IFS=$oIFS + + prefixes= + + for d + do + test -z "$d" && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + + eval "$initialize_posix_glob" && + $posix_glob set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + $posix_glob set +f && + + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/libebutils/Makefile.am b/libebutils/Makefile.am new file mode 100644 index 0000000..9d0791f --- /dev/null +++ b/libebutils/Makefile.am @@ -0,0 +1,24 @@ +noinst_LIBRARIES = libebutils.a +libebutils_a_SOURCES = ebutils.c getopt.c getumask.c makedir.c puts_eucjp.c \ + samefile.c strlist.c yesno.c +libebutils_a_LIBADD = @LIBOBJS@ + +dist_noinst_HEADERS = getopt.h getumask.h makedir.h samefile.h strlist.h \ + yesno.h +nodist_noinst_HEADERS = ebutils.h + +EXTRA_DIST = getopt_long.pl ebutils.h.in +CLEANFILES = stamp-ebutils-h ebutils.h +BUILT_SOURCES = ebutils.h + +INCLUDES = -I$(top_srcdir) @INTLINCS@ @ICONVINCS@ + +ebutils.h: stamp-ebutils-h +stamp-ebutils-h: ebutils.h.in Makefile + rm -f ebutils.h.tmp + echo '/* automatically generated from ebutils.h.in. */' \ + > ebutils.h.tmp + sed -e 's;\@localedir\@;$(localedir);' \ + $(srcdir)/ebutils.h.in >> ebutils.h.tmp + $(top_srcdir)/move-if-change ebutils.h.tmp ebutils.h + @echo timestamp > stamp-ebutils-h diff --git a/libebutils/Makefile.in b/libebutils/Makefile.in new file mode 100644 index 0000000..de316c5 --- /dev/null +++ b/libebutils/Makefile.in @@ -0,0 +1,505 @@ +# Makefile.in generated by automake 1.10.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = libebutils +DIST_COMMON = $(dist_noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in strcasecmp.c +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/in6addr.m4 $(top_srcdir)/m4/largefile.m4 \ + $(top_srcdir)/m4/lcmessage.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/sockaddrin6.m4 \ + $(top_srcdir)/m4/sockinttypes.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +libebutils_a_AR = $(AR) $(ARFLAGS) +libebutils_a_DEPENDENCIES = @LIBOBJS@ +am_libebutils_a_OBJECTS = ebutils.$(OBJEXT) getopt.$(OBJEXT) \ + getumask.$(OBJEXT) makedir.$(OBJEXT) puts_eucjp.$(OBJEXT) \ + samefile.$(OBJEXT) strlist.$(OBJEXT) yesno.$(OBJEXT) +libebutils_a_OBJECTS = $(am_libebutils_a_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libebutils_a_SOURCES) +DIST_SOURCES = $(libebutils_a_SOURCES) +HEADERS = $(dist_noinst_HEADERS) $(nodist_noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +EBCONF_EBINCS = @EBCONF_EBINCS@ +EBCONF_EBLIBS = @EBCONF_EBLIBS@ +EBCONF_INTLINCS = @EBCONF_INTLINCS@ +EBCONF_INTLLIBS = @EBCONF_INTLLIBS@ +EBCONF_ZLIBINCS = @EBCONF_ZLIBINCS@ +EBCONF_ZLIBLIBS = @EBCONF_ZLIBLIBS@ +EB_VERSION_MAJOR = @EB_VERSION_MAJOR@ +EB_VERSION_MINOR = @EB_VERSION_MINOR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_EBNET = @ENABLE_EBNET@ +ENABLE_NLS = @ENABLE_NLS@ +ENABLE_PTHREAD = @ENABLE_PTHREAD@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +ICONVINCS = @ICONVINCS@ +ICONVLIBS = @ICONVLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLINCS = @INTLINCS@ +INTLLIBS = @INTLLIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBEB_VERSION_INFO = @LIBEB_VERSION_INFO@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAILING_ADDRESS = @MAILING_ADDRESS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_CPPFLAGS = @PTHREAD_CPPFLAGS@ +PTHREAD_LDFLAGS = @PTHREAD_LDFLAGS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +ZLIBDEPS = @ZLIBDEPS@ +ZLIBINCS = @ZLIBINCS@ +ZLIBLIBS = @ZLIBLIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgdocdir = @pkgdocdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +noinst_LIBRARIES = libebutils.a +libebutils_a_SOURCES = ebutils.c getopt.c getumask.c makedir.c puts_eucjp.c \ + samefile.c strlist.c yesno.c + +libebutils_a_LIBADD = @LIBOBJS@ +dist_noinst_HEADERS = getopt.h getumask.h makedir.h samefile.h strlist.h \ + yesno.h + +nodist_noinst_HEADERS = ebutils.h +EXTRA_DIST = getopt_long.pl ebutils.h.in +CLEANFILES = stamp-ebutils-h ebutils.h +BUILT_SOURCES = ebutils.h +INCLUDES = -I$(top_srcdir) @INTLINCS@ @ICONVINCS@ +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libebutils/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu libebutils/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libebutils.a: $(libebutils_a_OBJECTS) $(libebutils_a_DEPENDENCIES) + -rm -f libebutils.a + $(libebutils_a_AR) libebutils.a $(libebutils_a_OBJECTS) $(libebutils_a_LIBADD) + $(RANLIB) libebutils.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strcasecmp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ebutils.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getumask.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/makedir.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/puts_eucjp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/samefile.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlist.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yesno.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(LIBRARIES) $(HEADERS) +installdirs: +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf $(DEPDIR) ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf $(DEPDIR) ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + + +ebutils.h: stamp-ebutils-h +stamp-ebutils-h: ebutils.h.in Makefile + rm -f ebutils.h.tmp + echo '/* automatically generated from ebutils.h.in. */' \ + > ebutils.h.tmp + sed -e 's;\@localedir\@;$(localedir);' \ + $(srcdir)/ebutils.h.in >> ebutils.h.tmp + $(top_srcdir)/move-if-change ebutils.h.tmp ebutils.h + @echo timestamp > stamp-ebutils-h +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libebutils/ebutils.c b/libebutils/ebutils.c new file mode 100644 index 0000000..26e6c3f --- /dev/null +++ b/libebutils/ebutils.c @@ -0,0 +1,289 @@ +/* -*- C -*- + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#ifdef ENABLE_NLS +#ifdef HAVE_LOCALE_H +#include +#endif +#include +#endif + +#ifndef HAVE_STRCASECMP +int strcasecmp(const char *, const char *); +int strncasecmp(const char *, const char *, size_t); +#endif + +/* + * The maximum length of path name. + */ +#ifndef PATH_MAX +#ifdef MAXPATHLEN +#define PATH_MAX MAXPATHLEN +#else /* not MAXPATHLEN */ +#define PATH_MAX 1024 +#endif /* not MAXPATHLEN */ +#endif /* not PATH_MAX */ + +#include "eb/eb.h" +#include "eb/error.h" +#include "ebutils.h" + +/* + * Tricks for gettext. + */ +#ifdef ENABLE_NLS +#define _(string) gettext(string) +#ifdef gettext_noop +#define N_(string) gettext_noop(string) +#else +#define N_(string) (string) +#endif +#else +#define _(string) (string) +#define N_(string) (string) +#endif + +/* + * Character type tests and conversions. + */ +#define ASCII_ISDIGIT(c) ('0' <= (c) && (c) <= '9') +#define ASCII_ISUPPER(c) ('A' <= (c) && (c) <= 'Z') +#define ASCII_ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define ASCII_ISALPHA(c) \ + (ASCII_ISUPPER(c) || ASCII_ISLOWER(c)) +#define ASCII_ISALNUM(c) \ + (ASCII_ISUPPER(c) || ASCII_ISLOWER(c) || ASCII_ISDIGIT(c)) +#define ASCII_ISXDIGIT(c) \ + (ASCII_ISDIGIT(c) || ('A' <= (c) && (c) <= 'F') || ('a' <= (c) && (c) <= 'f')) +#define ASCII_TOUPPER(c) (('a' <= (c) && (c) <= 'z') ? (c) - 0x20 : (c)) +#define ASCII_TOLOWER(c) (('A' <= (c) && (c) <= 'Z') ? (c) + 0x20 : (c)) + +#if defined(DOS_FILE_PATH) && defined(HAVE_MBSTRING_H) +/* path may contain double-byte chars in SJIS. */ +#include +#define strchr _mbschr +#define strrchr _mbsrchr +#endif + +/* + * Output ``try ...'' message to standard error. + */ +void +output_try_help(const char *invoked_name) +{ + fprintf(stderr, _("try `%s --help' for more information\n"), invoked_name); + fflush(stderr); +} + + +/* + * Output version number to stdandard out. + */ +void +output_version(const char *program_name, const char *program_version) +{ + printf("%s (EB Library) version %s\n", program_name, program_version); + printf("Copyright (c) 1997-2006 Motoyuki Kasahara\n"); + fflush(stdout); +} + + +/* + * Parse an argument to option `--subbook (-S)'. + * If the argument is valid form, 0 is returned. + * Otherwise -1 is returned. + */ +int +parse_subbook_name_argument(const char *invoked_name, const char *argument, + char name_list[][EB_MAX_DIRECTORY_NAME_LENGTH + 1], int *name_count) +{ + const char *argument_p = argument; + char name[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; + char *name_p; + int i; + + while (*argument_p != '\0') { + /* + * Check current `name_count'. + */ + if (EB_MAX_SUBBOOKS <= *name_count) { + fprintf(stderr, _("%s: too many subbooks\n"), invoked_name); + fflush(stderr); + return -1; + } + + /* + * Take a next element in the argument. + */ + i = 0; + name_p = name; + while (*argument_p != ',' && *argument_p != '\0' + && i < EB_MAX_DIRECTORY_NAME_LENGTH) { + *name_p = ASCII_TOLOWER(*argument_p); + i++; + name_p++; + argument_p++; + } + *name_p = '\0'; + if (*argument_p == ',') + argument_p++; + else if (*argument_p != '\0') { + fprintf(stderr, _("%s: invalid subbook name `%s...'\n"), + invoked_name, name); + fflush(stderr); + return -1; + } + + /* + * If the subbook name is not found in the subbook name list, + * it is added to the list. + */ + for (i = 0; i < *name_count; i++) { + if (strcmp(name, name_list[i]) == 0) + break; + } + if (*name_count <= i) { + strcpy(name_list[i], name); + (*name_count)++; + } + } + + return 0; +} + + +/* + * Find a subbook-code of the subbook whose directory name is `directory'. + * When no sub-book is matched', EB_ERR_NO_SUCH_SUB is returned. + */ +EB_Subbook_Code +find_subbook(EB_Book *book, const char *directory, + EB_Subbook_Code *subbook_code) +{ + EB_Error_Code error_code; + EB_Subbook_Code subbook_list[EB_MAX_SUBBOOKS]; + char directory2[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; + int subbook_count; + int i; + + /* + * Find the subbook in the current book. + */ + error_code = eb_subbook_list(book, subbook_list, &subbook_count); + if (error_code != EB_SUCCESS) { + *subbook_code = EB_SUBBOOK_INVALID; + return EB_ERR_NO_SUCH_SUB; + } + for (i = 0; i < subbook_count; i++) { + error_code = eb_subbook_directory2(book, subbook_list[i], directory2); + if (error_code != EB_SUCCESS) + continue; + if (strcasecmp(directory, directory2) == 0) { + *subbook_code = subbook_list[i]; + return EB_SUCCESS; + } + } + + *subbook_code = EB_SUBBOOK_INVALID; + return EB_ERR_NO_SUCH_SUB; +} + + +#ifndef DOS_FILE_PATH + +/* + * Canonicalize `path' (UNIX version). + * It eliminaes `/' at the tail of `path' unless `path' is not "/". + */ +void +canonicalize_path(char *path) +{ + char *last_slash; + + last_slash = strrchr(path, '/'); + if (last_slash == NULL || *(last_slash + 1) != '\0') + return; + + if (last_slash != path) + *last_slash = '\0'; +} + +#else /* DOS_FILE_PATH */ + +/* + * Canonicalize `path' (DOS version). + * It eliminaes `\' at the tail of `path' unless `path' is not "X:\". + */ +void +canonicalize_path(char *path) +{ + char *slash; + char *last_backslash; + + /* + * Replace `/' with `\\'. + */ + slash = path; + for (;;) { + slash = strchr(slash, '/'); + if (slash == NULL) + break; + *slash++ = '\\'; + } + + last_backslash = strrchr(path, '\\'); + if (last_backslash == NULL || *(last_backslash + 1) != '\0') + return; + + /* + * Eliminate `\' in the tail of the path. + */ + if (ASCII_ISALPHA(*path) && *(path + 1) == ':') { + if (last_backslash != path + 2) + *last_backslash = '\0'; + } else if (*path == '\\' && *(path + 1) == '\\') { + if (last_backslash != path + 1) + *last_backslash = '\0'; + } else if (*path == '\\') { + if (last_backslash != path) + *last_backslash = '\0'; + } else { + *last_backslash = '\0'; + } +} + +#endif /* DOS_FILE_PATH */ + diff --git a/libebutils/ebutils.h.in b/libebutils/ebutils.h.in new file mode 100644 index 0000000..9727eef --- /dev/null +++ b/libebutils/ebutils.h.in @@ -0,0 +1,68 @@ +/* -*- C -*- + * Copyright (c) 2000-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef EBUTILS_H +#define EBUTILS_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "eb/eb.h" + +/* + * Text domain name for message catalog. + */ +#define TEXT_DOMAIN_NAME "ebutils" + +/* + * Path to the locale directory. + */ +#ifndef WIN32 +#define LOCALEDIR "@localedir@" +#else +#define LOCALEDIR localedir() +#endif + +/* + * Function declarations. + */ +/* ebutils.c */ +void output_try_help(const char *invoked_name); +void output_version(const char *program_name, const char *program_version); +int parse_subbook_name_argument(const char *invoked_name, const char *argument, + char name_list[][EB_MAX_DIRECTORY_NAME_LENGTH + 1], int *name_count); +EB_Subbook_Code find_subbook(EB_Book *book, const char *directory, + EB_Subbook_Code *subbook_code); +void canonicalize_path(char *path); + +/* puts_eucjp.c */ +int fputs_eucjp_to_locale(const char *string, FILE *stream); +int puts_eucjp_to_locale(const char *string); + +#endif /* not EBUTILS_H */ diff --git a/libebutils/getopt.c b/libebutils/getopt.c new file mode 100644 index 0000000..785574a --- /dev/null +++ b/libebutils/getopt.c @@ -0,0 +1,480 @@ +/* $NetBSD: getopt_long.c,v 1.11.2.1 2001/10/08 20:21:09 nathanw Exp $ */ + +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Dieter Baron and Thomas Klausner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#ifdef ENABLE_NLS +#include +#endif + +#ifdef ENABLE_NLS +#define _(string) gettext(string) +#ifdef gettext_noop +#define N_(string) gettext_noop(string) +#else +#define N_(string) (string) +#endif +#else +#define gettext(string) (string) +#define _(string) (string) +#define N_(string) (string) +#endif + +#include + +#ifdef REPLACE_GETOPT +int opterr = 1; /* if error message should be printed */ +int optind = 1; /* index into parent argv vector */ +int optopt = '?'; /* character checked for validity */ +char *optarg; /* argument associated with option */ +#endif + +#define IGNORE_FIRST (*options == '-' || *options == '+') +#define PRINT_ERROR ((opterr) && ((*options != ':') \ + || (IGNORE_FIRST && options[1] != ':'))) +#define IS_POSIXLY_CORRECT (getenv("POSIXLY_CORRECT") != NULL) +#define PERMUTE (!IS_POSIXLY_CORRECT && !IGNORE_FIRST) +/* XXX: GNU ignores PC if *options == '-' */ +#define IN_ORDER (!IS_POSIXLY_CORRECT && *options == '-') + +/* return values */ +#define BADCH (int)'?' +#define BADARG ((IGNORE_FIRST && options[1] == ':') \ + || (*options == ':') ? (int)':' : (int)'?') +#define INORDER (int)1 + +#define EMSG "" + +extern char *getenv(); + +static int getopt_internal(int nargc, char * const *nargv, + const char *options); +static int gcd(int a, int b); +static void permute_args(int nonopt_start, int nonopt_end, int opt_end, + char * const *nargv); + +static char *place = EMSG; /* option letter processing */ + +static int nonopt_start = -1; /* first non option argument (for permute) */ +static int nonopt_end = -1; /* first option after non options (for permute) */ + +/* Error messages */ +static const char *recargchar + = N_("%s: option requires an argument -- %c\n"); +static const char *recargstring + = N_("%s: option `%.*s' requires an argument\n"); +static const char *ambig + = N_("%s: option `--%.*s' is ambiguous\n"); +static const char *noarg + = N_("%s: option `--%.*s' doesn't allow an argument\n"); +static const char *illopt + = N_("%s: illegal option -- %c\n"); +static const char *invopt + = N_("%s: invalid option -- %c\n"); +static const char *unrec + = N_("%s: unrecognized option `--%.*s'\n"); + + +/* + * Compute the greatest common divisor of a and b. + */ +static int +gcd(int a, int b) +{ + int c; + + c = a % b; + while (c != 0) { + a = b; + b = c; + c = a % b; + } + + return b; +} + +/* + * Exchange the block from nonopt_start to nonopt_end with the block + * from nonopt_end to opt_end (keeping the same order of arguments + * in each block). + */ +static void +permute_args(int nonopt_start, int nonopt_end, int opt_end, + char * const *nargv) +{ + int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; + char *swap; + + /* + * compute lengths of blocks and number and size of cycles + */ + nnonopts = nonopt_end - nonopt_start; + nopts = opt_end - nonopt_end; + ncycle = gcd(nnonopts, nopts); + cyclelen = (opt_end - nonopt_start) / ncycle; + + for (i = 0; i < ncycle; i++) { + cstart = nonopt_end+i; + pos = cstart; + for (j = 0; j < cyclelen; j++) { + if (pos >= nonopt_end) + pos -= nnonopts; + else + pos += nopts; + swap = nargv[pos]; + /* LINTED const cast */ + ((char **) nargv)[pos] = nargv[cstart]; + /* LINTED const cast */ + ((char **)nargv)[cstart] = swap; + } + } +} + +/* + * getopt_internal -- + * Parse argc/argv argument vector. Called by user level routines. + * Returns -2 if -- is found (can be long option or end of options marker). + */ +static int +getopt_internal(int nargc, char * const *nargv, const char *options) +{ + char *oli; /* option letter list index */ + int optchar; + + optarg = NULL; + + /* + * XXX Some programs (like rsyncd) expect to be able to + * XXX re-initialize optind to 0 and have getopt_long(3) + * XXX properly function again. Work around this braindamage. + */ + if (optind == 0) + optind = 1; + +start: + if (!*place) { /* update scanning pointer */ + if (optind >= nargc) { /* end of argument vector */ + place = EMSG; + if (nonopt_end != -1) { + /* do permutation, if we have to */ + permute_args(nonopt_start, nonopt_end, + optind, nargv); + optind -= nonopt_end - nonopt_start; + } + else if (nonopt_start != -1) { + /* + * If we skipped non-options, set optind + * to the first of them. + */ + optind = nonopt_start; + } + nonopt_start = nonopt_end = -1; + return -1; + } + if ((*(place = nargv[optind]) != '-') + || (place[1] == '\0')) { /* found non-option */ + place = EMSG; + if (IN_ORDER) { + /* + * GNU extension: + * return non-option as argument to option 1 + */ + optarg = nargv[optind++]; + return INORDER; + } + if (!PERMUTE) { + /* + * if no permutation wanted, stop parsing + * at first non-option + */ + return -1; + } + /* do permutation */ + if (nonopt_start == -1) + nonopt_start = optind; + else if (nonopt_end != -1) { + permute_args(nonopt_start, nonopt_end, + optind, nargv); + nonopt_start = optind - + (nonopt_end - nonopt_start); + nonopt_end = -1; + } + optind++; + /* process next argument */ + goto start; + } + if (nonopt_start != -1 && nonopt_end == -1) + nonopt_end = optind; + if (place[1] && *++place == '-') { /* found "--" */ + place++; + return -2; + } + } + if ((optchar = (int)*place++) == (int)':' || + (oli = strchr(options + (IGNORE_FIRST ? 1 : 0), optchar)) == NULL) { + /* option letter unknown or ':' */ + if (!*place) + ++optind; + if (PRINT_ERROR) { + if (IS_POSIXLY_CORRECT) + fprintf(stderr, gettext(illopt), nargv[0], + optchar); + else + fprintf(stderr, gettext(invopt), nargv[0], + optchar); + } + optopt = optchar; + return BADCH; + } + if (optchar == 'W' && oli[1] == ';') { /* -W long-option */ + /* XXX: what if no long options provided (called by getopt)? */ + if (*place) + return -2; + + if (++optind >= nargc) { /* no arg */ + place = EMSG; + if (PRINT_ERROR) + fprintf(stderr, gettext(recargchar), nargv[0], + optchar); + optopt = optchar; + return BADARG; + } else /* white space */ + place = nargv[optind]; + /* + * Handle -W arg the same as --arg (which causes getopt to + * stop parsing). + */ + return -2; + } + if (*++oli != ':') { /* doesn't take argument */ + if (!*place) + ++optind; + } else { /* takes (optional) argument */ + optarg = NULL; + if (*place) /* no white space */ + optarg = place; + /* XXX: disable test for :: if PC? (GNU doesn't) */ + else if (oli[1] != ':') { /* arg not optional */ + if (++optind >= nargc) { /* no arg */ + place = EMSG; + if (PRINT_ERROR) + fprintf(stderr, gettext(recargchar), + nargv[0], optchar); + optopt = optchar; + return BADARG; + } else + optarg = nargv[optind]; + } + place = EMSG; + ++optind; + } + /* dump back option letter */ + return optchar; +} + +#ifdef REPLACE_GETOPT +/* + * getopt -- + * Parse argc/argv argument vector. + * + * [eventually this will replace the real getopt] + */ +int +getopt(int nargc, char * const *nargv, const char *options) +{ + int retval; + + if ((retval = getopt_internal(nargc, nargv, options)) == -2) { + ++optind; + /* + * We found an option (--), so if we skipped non-options, + * we have to permute. + */ + if (nonopt_end != -1) { + permute_args(nonopt_start, nonopt_end, optind, + nargv); + optind -= nonopt_end - nonopt_start; + } + nonopt_start = nonopt_end = -1; + retval = -1; + } + return retval; +} +#endif + +/* + * getopt_long -- + * Parse argc/argv argument vector. + */ +int +getopt_long(int nargc, char * const *nargv, const char *options, + const struct option *long_options, int *idx) +{ + int retval; + + if ((retval = getopt_internal(nargc, nargv, options)) == -2) { + char *current_argv, *has_equal; + size_t current_argv_len; + int i, match; + + current_argv = place; + match = -1; + + optind++; + place = EMSG; + + if (*current_argv == '\0') { /* found "--" */ + /* + * We found an option (--), so if we skipped + * non-options, we have to permute. + */ + if (nonopt_end != -1) { + permute_args(nonopt_start, nonopt_end, + optind, nargv); + optind -= nonopt_end - nonopt_start; + } + nonopt_start = nonopt_end = -1; + return -1; + } + if ((has_equal = strchr(current_argv, '=')) != NULL) { + /* argument found (--option=arg) */ + current_argv_len = has_equal - current_argv; + has_equal++; + } else + current_argv_len = strlen(current_argv); + + for (i = 0; long_options[i].name; i++) { + /* find matching long option */ + if (strncmp(current_argv, long_options[i].name, + current_argv_len)) + continue; + + if (strlen(long_options[i].name) == + (unsigned)current_argv_len) { + /* exact match */ + match = i; + break; + } + if (match == -1) /* partial match */ + match = i; + else { + /* ambiguous abbreviation */ + if (PRINT_ERROR) + fprintf(stderr, gettext(ambig), + nargv[0], (int)current_argv_len, + current_argv); + optopt = 0; + return BADCH; + } + } + if (match != -1) { /* option found */ + if (long_options[match].has_arg == no_argument + && has_equal) { + if (PRINT_ERROR) + fprintf(stderr, + gettext(noarg), nargv[0], + strlen(long_options[match].name), + long_options[match].name); + /* + * XXX: GNU sets optopt to val regardless of + * flag + */ + if (long_options[match].flag == NULL) + optopt = long_options[match].val; + else + optopt = 0; + return BADARG; + } + if (long_options[match].has_arg == required_argument || + long_options[match].has_arg == optional_argument) { + if (has_equal) + optarg = has_equal; + else if (long_options[match].has_arg == + required_argument) { + /* + * optional argument doesn't use + * next nargv + */ + optarg = nargv[optind++]; + } + } + if ((long_options[match].has_arg == required_argument) + && (optarg == NULL)) { + /* + * Missing argument; leading ':' + * indicates no error should be generated + */ + if (PRINT_ERROR) + fprintf(stderr, gettext(recargstring), + nargv[0], (int)current_argv_len, + current_argv); + /* + * XXX: GNU sets optopt to val regardless + * of flag + */ + if (long_options[match].flag == NULL) + optopt = long_options[match].val; + else + optopt = 0; + --optind; + return BADARG; + } + } else { /* unknown option */ + if (PRINT_ERROR) + fprintf(stderr, gettext(unrec), nargv[0], + (int)current_argv_len,current_argv); + optopt = 0; + return BADCH; + } + if (long_options[match].flag) { + *long_options[match].flag = long_options[match].val; + retval = 0; + } else + retval = long_options[match].val; + if (idx) + *idx = match; + } + return retval; +} diff --git a/libebutils/getopt.h b/libebutils/getopt.h new file mode 100644 index 0000000..688fb93 --- /dev/null +++ b/libebutils/getopt.h @@ -0,0 +1,85 @@ +/* $NetBSD: getopt.h,v 1.3 2000/04/02 22:03:29 christos Exp $ */ + +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Dieter Baron and Thomas Klausner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef GETOPT_H +#define GETOPT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +/* + * Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions + */ +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +extern int opterr; +extern int optind; +extern int optopt; +extern char *optarg; + +struct option { + /* name of long option */ + const char *name; + /* + * one of no_argument, required_argument, and optional_argument: + * whether option takes an argument + */ + int has_arg; + /* if not NULL, set *flag to val when option found */ + int *flag; + /* if flag not NULL, value to set *flag to; else return value */ + int val; +}; + +int getopt_long (int, char * const *, const char *, + const struct option *, int *); + +#ifdef __cplusplus +} +#endif + +#endif /* !_GETOPT_H_ */ diff --git a/libebutils/getopt_long.pl b/libebutils/getopt_long.pl new file mode 100644 index 0000000..270012b --- /dev/null +++ b/libebutils/getopt_long.pl @@ -0,0 +1,362 @@ +# -*- Perl -*- +# Copyright (c) 1997-2006 Motoyuki Kasahara +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +# +# This program is a Perl package running on Perl 4.036 or later. +# The package provides routines to process command line options like +# as GNU getopt_long(). +# +# Version: +# 2.0 +# +# Interface: +# +# &getopt_initialize(LIST) +# Set a list of command line options and initialize internal data +# for &getopt_long. +# You must call the routine before calling &getopt_long. +# Format of each element in the LIST is: +# +# `CANONICAL-OPTION-NAME [ALIAS-OPTION-NAME...] ARGUMENT-FLAG' +# +# CANONICAL-OPTION-NAME, ALIAS-OPTION-NAME and ARGUMENT-FLAG fields +# are separated by spaces or tabs. +# +# CANONICAL-OPTION-NAME and ALIAS-OPTION-NAME must be either a single +# character option including preceding `-' (e.g. `-v'), or a long +# name option including preceding `--' (e.g. `--version'). Whether +# CANONICAL-OPTION-NAME is single character option or long name +# option is not significant. +# +# ARGUMENT-FLAG must be `no-argument', `required-argument' or +# `optional-argument'. If it is set to `required-argument', the +# option always takes an argument. If set to `optional-argument', +# an argument to the option is optional. +# +# You can put a special element `+' or `-' at the first element in +# LIST. See `Details about Option Processing:' for details. +# If succeeded to initialize, 1 is returned. Otherwise 0 is +# returned. +# +# &getopt_long +# Get a option name, and if exists, its argument of the leftmost +# option in @ARGV. +# +# An option name and its argument are returned as a list with two +# elements; the first element is CANONICAL-OPTION-NAME of the option, +# and second is its argument. +# Upon return, the option and its argument are removed from @ARGV. +# When you have already got all options in @ARGV, an empty list is +# returned. In this case, only non-option elements are left in +# @ARGV. +# +# When an error occurs, an error message is output to standard +# error, and the option name in a returned list is set to `?'. +# +# Example: +# +# &getopt_intialize('--help -h no-argument', '--version -v no-argument') +# || die; +# +# while (($name, $arg) = &getopt_long) { +# die "For help, type \`$0 --help\'\n" if ($name eq '?'); +# $opts{$name} = $arg; +# } +# +# Details about Option Processing: +# +# * There are three processing modes: +# 1. PERMUTE +# It permutes the contents of ARGV as it scans, so that all the +# non-option ARGV-elements are at the end. This mode is default. +# 2. REQUIRE_ORDER +# It stops option processing when the first non-option is seen. +# This mode is chosen if the environment variable POSIXLY_CORRECT +# is defined, or the first element in the option list is `+'. +# 3. RETURN_IN_ORDER +# It describes each non-option ARGV-element as if it were the +# argument of an option with an empty name. +# This mode is chosen if the first element in the option list is +# `-'. +# +# * An argument starting with `-' and not exactly `-', is a single +# character option. +# If the option takes an argument, it must be specified at just +# behind the option name (e.g. `-f/tmp/file'), or at the next +# ARGV-element of the option name (e.g. `-f /tmp/file'). +# If the option doesn't have an argument, other single character +# options can be followed within an ARGV-element. For example, +# `-l -g -d' is identical to `-lgd'. +# +# * An argument starting with `--' and not exactly `--', is a long +# name option. +# If the option has an argument, it can be specified at behind the +# option name preceded by `=' (e.g. `--option=argument'), or at the +# next ARGV-element of the option name (e.g. `--option argument'). +# Long name options can be abbreviated as long as the abbreviation +# is unique. +# +# * The special argument `--' forces an end of option processing. +# + +{ + package getopt_long; + + $initflag = 0; + $REQUIRE_ORDER = 0; + $PERMUTE = 1; + $RETURN_IN_ORDER = 2; +} + + +# +# Initialize the internal data. +# +sub getopt_initialize { + local(@fields); + local($name, $flag, $canon); + local($_); + + # + # Determine odering. + # + if ($_[$[] eq '+') { + $getopt_long'ordering = $getopt_long'REQUIRE_ORDER; + shift(@_); + } elsif ($_[$[] eq '-') { + $getopt_long'ordering = $getopt_long'RETURN_IN_ORDER; + shift(@_); + } elsif (defined($ENV{'POSIXLY_CORRECT'})) { + $getopt_long'ordering = $getopt_long'REQUIRE_ORDER; + } else { + $getopt_long'ordering = $getopt_long'PERMUTE; + } + + # + # Parse an option list. + # + %getopt_long'optnames = (); + %getopt_long'argflags = (); + + foreach (@_) { + @fields = split(/[ \t]+/, $_); + if (@fields < 2) { + warn "$0: (getopt_initialize) too few fields \`$arg\'\n"; + return 0; + } + $flag = pop(@fields); + if ($flag ne 'no-argument' && $flag ne 'required-argument' + && $flag ne 'optional-argument') { + warn "$0: (getopt_initialize) invalid argument flag \`$flag\'\n"; + return 0; + } + + $canon = ''; + foreach $name (@fields) { + if ($name !~ /^-([^-]|-.+)$/) { + warn "$0: (getopt_initialize) invalid option name \`$name\'\n"; + return 0; + } elsif (defined($getopt_long'optnames{$name})) { + warn "$0: (getopt_initialize) redefined option \`$name\'\n"; + return 0; + } + $canon = $name if ($canon eq ''); + $getopt_long'optnames{$name} = $canon; + $getopt_long'argflags{$name} = $flag; + } + } + + $getopt_long'endflag = 0; + $getopt_long'shortrest = ''; + @getopt_long'nonopts = (); + + $getopt_long'initflag = 1; +} + + +# +# When it comes to the end of options, restore PERMUTEd non-option +# arguments to @ARGV. +# +sub getopt_end { + $getopt_long'endflag = 1; + unshift(@ARGV, @getopt_long'nonopts); +} + + +# +# Scan elements of @ARGV for getting an option. +# +sub getopt_long { + local($name, $arg) = ('', 1); + local($patt, $key, $ambig, $ch); + local($_); + + &getopt_initialize(@_) if (!$getopt_long'initflag); + return () if ($getopt_long'endflag); + + # + # Take the next argument from @ARGV. + # + if ($getopt_long'shortrest ne '') { + $_ = '-'.$getopt_long'shortrest; + } elsif (@ARGV == 0) { + &getopt_end; + return (); + } elsif ($getopt_long'ordering == $getopt_long'REQUIRE_ORDER) { + $_ = shift(@ARGV); + if (!/^-./) { + push(@getopt_long'nonopts, $_); + &getopt_end; + return (); + } + } elsif ($getopt_long'ordering == $getopt_long'PERMUTE) { + for (;;) { + if (@ARGV == 0) { + &getopt_end; + return (); + } + $_ = shift(@ARGV); + last if (/^-./); + push(@getopt_long'nonopts, $_); + } + } else { # RETURN_IN_ORDER + $_ = shift(@ARGV); + } + + # + # Check for the special option `--'. + # + if ($_ eq '--' && $getopt_long'shortrest eq '') { + # + # `--' indicates the end of the option list. + # + &getopt_end; + return (); + } + + # + # Check for long and short options. + # + if (/^(--[^=]+)/ && $getopt_long'shortrest eq '') { + # + # Long style option, which start with `--'. + # Abbreviations for option names are allowed as long as + # they are unique. + # + $patt = $1; + if (defined($getopt_long'optnames{$patt})) { + $name = $patt; + } else { + $ambig = 0; + foreach $key (keys(%getopt_long'optnames)) { + if (index($key, $patt) == 0) { + if ($name eq '') { + $name = $key; + } else { + $ambig = 1; + } + } + } + if ($ambig) { + warn "$0: option \`$_\' is ambiguous\n"; + return ('?', ''); + } + if ($name eq '') { + warn "$0: unrecognized option \`$_\'\n"; + return ('?', ''); + } + } + + if ($getopt_long'argflags{$name} eq 'required-argument') { + if (/=(.*)$/) { + $arg = $1; + } elsif (0 < @ARGV) { + $arg = shift(@ARGV); + } else { + warn "$0: option \`$_\' requires an argument\n"; + return ('?', ''); + } + } elsif ($getopt_long'argflags{$name} eq 'optional-argument') { + if (/=(.*)$/) { + $arg = $1; + } elsif (0 < @ARGV && $ARGV[$[] !~ /^-./) { + $arg = shift(@ARGV); + } else { + $arg = ''; + } + } elsif (/=(.*)$/) { + warn "$0: option \`$name\' doesn't allow an argument\n"; + return ('?', ''); + } + } elsif (/^(-(.))(.*)/) { + # + # Short style option, which start with `-' (not `--'). + # + ($name, $ch, $getopt_long'shortrest) = ($1, $2, $3); + + if (defined($getopt_long'optnames{$name})) { + if ($getopt_long'argflags{$name} eq 'required-argument') { + if ($getopt_long'shortrest ne '') { + $arg = $getopt_long'shortrest; + $getopt_long'shortrest = ''; + } elsif (0 < @ARGV) { + $arg = shift(@ARGV); + } else { + # 1003.2 specifies the format of this message. + warn "$0: option requires an argument -- $ch\n"; + return ('?', ''); + } + } elsif ($getopt_long'argflags{$name} eq 'optional-argument') { + if ($getopt_long'shortrest ne '') { + $arg = $getopt_long'shortrest; + $getopt_long'shortrest = ''; + } elsif (0 < @ARGV && $ARGV[$[] !~ /^-./) { + $arg = shift(@ARGV); + } else { + $arg = ''; + } + } + } elsif (defined($ENV{'POSIXLY_CORRECT'})) { + # 1003.2 specifies the format of this message. + warn "$0: illegal option -- $ch\n"; + return ('?', ''); + } else { + warn "$0: invalid option -- $ch\n"; + return ('?', ''); + } + } else { + # + # Only RETURN_IN_ORDER falled into here. + # + $arg = $_; + } + + return ($getopt_long'optnames{$name}, $arg); +} + +1; diff --git a/libebutils/getumask.c b/libebutils/getumask.c new file mode 100644 index 0000000..45e95a7 --- /dev/null +++ b/libebutils/getumask.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 1998-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * This program requires the following Autoconf macros: + * AC_TYPE_MODE_T + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +/* + * Get the current umask. + */ +mode_t +get_umask(void) +{ + mode_t current_umask; + + current_umask = umask((mode_t)022); + umask(current_umask); + + return current_umask; +} diff --git a/libebutils/getumask.h b/libebutils/getumask.h new file mode 100644 index 0000000..1f3d013 --- /dev/null +++ b/libebutils/getumask.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 1998-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef GETUMASK_H +#define GETUMASK_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +/* + * Function declarations. + */ +mode_t get_umask(void); + +#endif /* not GETUMASK_H */ diff --git a/libebutils/makedir.c b/libebutils/makedir.c new file mode 100644 index 0000000..e9e7963 --- /dev/null +++ b/libebutils/makedir.c @@ -0,0 +1,76 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * This program requires the following Autoconf macros: + * AC_TYPE_MODE_T + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#ifdef HAVE_DIRECT_H +#include +#endif + +#ifndef S_ISREG +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#endif +#ifndef S_ISDIR +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif + +/* + * Make a directory if the directory doesn't exist. + * + * If making the directory is succeeded or the directory has already + * created, 0 is returned. Otherwise -1 is returned. + */ +int +make_missing_directory(const char *path, mode_t mode) +{ + struct stat status; + + if (stat(path, &status) == 0 && S_ISDIR(status.st_mode)) + return 0; + +#ifndef WIN32 + if (mkdir(path, mode) < 0) + return -1; +#else + if (mkdir(path) < 0) + return -1; +#endif + + return 0; +} diff --git a/libebutils/makedir.h b/libebutils/makedir.h new file mode 100644 index 0000000..f4188c2 --- /dev/null +++ b/libebutils/makedir.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef MAKEDIR_H +#define MAKEDIR_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + + +/* + * Function declarations. + */ +int make_missing_directory(const char *, int); + +#endif /* not MAKEDIR_H */ diff --git a/libebutils/puts_eucjp.c b/libebutils/puts_eucjp.c new file mode 100644 index 0000000..678b296 --- /dev/null +++ b/libebutils/puts_eucjp.c @@ -0,0 +1,155 @@ +/* -*- C -*- + * Copyright (c) 2003-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include + +#ifdef HAVE_ICONV_H +#include +#endif + +#if defined(HAVE_LIBCHARSET_H) +#include +#elif defined(HAVE_LANGINFO_H) +#include +#endif + +/* + * Convert `string' from EUC-JP to the current locale encoding, and + * then write it to `stream'. + */ +int +fputs_eucjp_to_locale(const char *string, FILE *stream) +{ +#if defined(HAVE_ICONV_OPEN) + size_t string_length; + const char *locale_encoding; + char *buffer = NULL; + size_t buffer_size; + iconv_t cd = (iconv_t)-1; + const char *in_p; + char *out_p; + size_t in_left; + size_t out_left; + int fputs_result; + + string_length = strlen(string); + +#if defined(HAVE_LOCALE_CHARSET) + locale_encoding = locale_charset(); +#elif defined(HAVE_NL_LANGINFO) && defined(CODESET) + locale_encoding = nl_langinfo(CODESET); +#else + locale_encoding = NULL; +#endif + if (locale_encoding == NULL) + goto failed; + cd = iconv_open(locale_encoding, "eucJP"); + if (cd == (iconv_t)-1) + cd = iconv_open(locale_encoding, "EUC-JP"); + if (cd == (iconv_t)-1) + goto failed; + + buffer_size = (string_length + 1) * 2; + + for (;;) { + buffer = malloc(buffer_size); + if (buffer == NULL) + goto failed; + + in_p = string; + in_left = string_length + 1; + out_p = buffer; + out_left = buffer_size; + + if (iconv(cd, &in_p, &in_left, &out_p, &out_left) != -1) + break; + if (errno == E2BIG) { + /* + * Reset initial state. + * To avoid a bug of iconv() on Solaris 2.6, we set `in_left', + * `out_p' and `out_left' to non-NULL values. + */ + in_left = 0; + out_p = buffer; + out_left = 0; + iconv(cd, NULL, &in_left, &out_p, &out_left); + + free(buffer); + buffer = NULL; + buffer_size += string_length + 1; + + continue; + } else { + goto failed; + } + } + + iconv_close(cd); + fputs_result = fputs(buffer, stream); + free(buffer); + + return fputs_result; + + /* + * An error occurs... + */ + failed: + if (cd != (iconv_t)-1) + iconv_close(cd); + if (buffer != NULL) + free(buffer); + return fputs(string, stream); + +#else /* not HAVE_ICONV_OPEN */ + return fputs(string, stream); +#endif /* not HAVE_ICONV_OPEN */ +} + + +/* + * Convert `string' from EUC-JP to the current locale encoding, and + * then write it and a newline to `stdout'. + */ +int +puts_eucjp_to_locale(const char *string) +{ + if (fputs_eucjp_to_locale(string, stdout) == EOF) + return EOF; + if (fputs_eucjp_to_locale("\n", stdout) == EOF) + return EOF; + + return 0; +} diff --git a/libebutils/samefile.c b/libebutils/samefile.c new file mode 100644 index 0000000..c61d449 --- /dev/null +++ b/libebutils/samefile.c @@ -0,0 +1,67 @@ +/* -*- C -*- + * Copyright (c) 1998-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +/* + * If the files `file_name1' and `file_name2' are identical (i.e. the are + * written on a same device and a same i-node is assigned to them), 1 is + * returned. Otherwise, 0 is returned. + */ +int +is_same_file(const char *file_name1, const char *file_name2) +{ + struct stat st1, st2; + + if (stat(file_name1, &st1) != 0 || stat(file_name2, &st2) != 0) + return 0; + +#ifndef DOS_FILE_PATH + if (st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino) + return 0; + +#else /* DOS_FILE_PATH */ + /* Can't rely on st_ino and st_dev, use other fields: */ + if (st1.st_mode != st2.st_mode + || st1.st_uid != st2.st_uid + || st1.st_gid != st2.st_gid + || st1.st_size != st2.st_size + || st1.st_atime != st2.st_atime + || st1.st_mtime != st2.st_mtime + || st1.st_ctime != st2.st_ctime) + return 0; +#endif /* DOS_FILE_PATH */ + + return 1; +} diff --git a/libebutils/samefile.h b/libebutils/samefile.h new file mode 100644 index 0000000..5cc6963 --- /dev/null +++ b/libebutils/samefile.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 1998-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef SAMEFILE_H +#define SAMEFILE_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +/* + * Function declarations. + */ +int is_same_file(const char *, const char *); + +#endif /* not SAMEFILE_H */ diff --git a/libebutils/strcasecmp.c b/libebutils/strcasecmp.c new file mode 100644 index 0000000..fc80f62 --- /dev/null +++ b/libebutils/strcasecmp.c @@ -0,0 +1,105 @@ +/* + * Copyright (c) 1997-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +/* + * Compare strings. + * Cases in the strings are insensitive. + */ +int +strcasecmp(const char *string1, const char *string2) +{ + const unsigned char *string1_p = (const unsigned char *)string1; + const unsigned char *string2_p = (const unsigned char *)string2; + int c1, c2; + + while (*string1_p != '\0') { + if ('a' <= *string1_p && *string1_p <= 'z') + c1 = *string1_p - ('a' - 'A'); + else + c1 = *string1_p; + + if ('a' <= *string2_p && *string2_p <= 'z') + c2 = *string2_p - ('a' - 'A'); + else + c2 = *string2_p; + + if (c1 != c2) + return c1 - c2; + + string1_p++; + string2_p++; + } + + return -(*string2_p); +} + + +/* + * Compare strings within `n' characters. + * Cases in the strings are insensitive. + */ +int +strncasecmp(const char *string1, const char *string2, size_t n) +{ + const unsigned char *string1_p = (const unsigned char *)string1; + const unsigned char *string2_p = (const unsigned char *)string2; + size_t i = n; + int c1, c2; + + if (i <= 0) + return 0; + + while (*string1_p != '\0') { + if ('a' <= *string1_p && *string1_p <= 'z') + c1 = *string1_p - ('a' - 'A'); + else + c1 = *string1_p; + + if ('a' <= *string2_p && *string2_p <= 'z') + c2 = *string2_p - ('a' - 'A'); + else + c2 = *string2_p; + + if (c1 != c2) + return c1 - c2; + + string1_p++; + string2_p++; + i--; + if (i <= 0) + return 0; + } + + return -(*string2_p); +} diff --git a/libebutils/strlist.c b/libebutils/strlist.c new file mode 100644 index 0000000..cc19b0e --- /dev/null +++ b/libebutils/strlist.c @@ -0,0 +1,194 @@ +/* -*- C -*- + * Copyright (c) 2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include "strlist.h" + +/* + * Unexported functions. + */ +static String_List_Node * +string_list_find_node(String_List *list, const char *string); + + +/* + * Initialize `list'. + */ +void +string_list_initialize(String_List *list) +{ + list->node_count = 0; + list->head = NULL; + list->tail = NULL; +} + + +/* + * Finalize `list'. + */ +void +string_list_finalize(String_List *list) +{ + string_list_delete_all(list); +} + + +/* + * Add `string' to `list'. + * If `list' has already had `string', it doesn't do anything. + */ +int +string_list_add(String_List *list, const char *string) +{ + String_List_Node *new_node; + + if (string_list_find_node(list, string) != NULL) + return 0; + + new_node = (String_List_Node *)malloc(sizeof(String_List_Node)); + if (new_node == NULL) + return -1; + + new_node->string = (char *)malloc(strlen(string) + 1); + if (new_node->string == NULL) { + free(new_node); + return -1; + } + strcpy(new_node->string, string); + + if (list->node_count == 0) { + new_node->back = NULL; + list->head = new_node; + } else { + new_node->back = list->tail; + list->tail->next = new_node; + } + + new_node->next = NULL; + list->tail = new_node; + list->node_count++; + + return 0; +} + + +/* + * Delete `string' from `list'. + * The function doesn't complain if `list' doesn't have `string'. + */ +void +string_list_delete(String_List *list, const char *string) +{ + String_List_Node *p; + + p = string_list_find_node(list, string); + if (p == NULL) + return; + + if (p->next != NULL) + p->next->back = p->back; + if (p->back != NULL) + p->back->next = p->next; + free(p->string); + free(p); + + list->node_count--; + if (list->node_count == 0) { + list->head = NULL; + list->tail = NULL; + } +} + + +/* + * Delete all strings in `list'. + */ +void +string_list_delete_all(String_List *list) +{ + String_List_Node *p = list->head; + String_List_Node *next_p; + + while (p != NULL) { + next_p = p->next; + free(p->string); + free(p); + p = next_p; + } + + list->node_count = 0; + list->head = NULL; + list->tail = NULL; +} + + +/* + * Return true if `list' has `string'. + */ +int +string_list_find(String_List *list, const char *string) +{ + return (string_list_find_node(list, string) != NULL); +} + + +/* + * Count the number of strings in `list'. + */ +int +string_list_count_node(String_List *list) +{ + return list->node_count; +} + + +/* + * Return a pointer to the node with `string' in `list'. + * Return NULL if `list' doesn't have `string'. + */ +static String_List_Node * +string_list_find_node(String_List *list, const char *string) +{ + String_List_Node *p; + + for (p = list->head; p != NULL; p = p->next) { + if (strcmp(string, p->string) == 0) + return p; + } + + return NULL; +} + + diff --git a/libebutils/strlist.h b/libebutils/strlist.h new file mode 100644 index 0000000..48fac94 --- /dev/null +++ b/libebutils/strlist.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef STRLIST_H +#define STRLIST_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +/* + * Type definitions. + */ +typedef struct String_List_Struct String_List; +typedef struct String_List_Node_Struct String_List_Node; + +struct String_List_Struct { + int node_count; + String_List_Node *head; + String_List_Node *tail; +}; + + +struct String_List_Node_Struct { + char *string; + String_List_Node *next; + String_List_Node *back; +}; + + +/* + * Function declarations. + */ +void +string_list_initialize(String_List *list); + +void +string_list_finalize(String_List *list); + +int +string_list_add(String_List *list, const char *string); + +void +string_list_delete(String_List *list, const char *string); + +void +string_list_delete_all(String_List *list); + +int +string_list_find(String_List *list, const char *string); + +int +string_list_count_node(String_List *list); + +#endif /* not STRLIST_H */ diff --git a/libebutils/yesno.c b/libebutils/yesno.c new file mode 100644 index 0000000..cf41184 --- /dev/null +++ b/libebutils/yesno.c @@ -0,0 +1,86 @@ +/* -*- C -*- + * Copyright (c) 1998-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#define YESNO_RESPONSE_SIZE 80 + +/* + * Get y/n response to `message'. + * If `y' is selected, 1 is returned. Otherwise 0 is returned. + */ +int +query_y_or_n(const char *message) +{ + char response[YESNO_RESPONSE_SIZE]; + char *head, *tail; + + for (;;) { + /* + * Output `message' to standard error. + */ + fputs(message, stderr); + fflush(stderr); + + /* + * Get a line from standard in. + */ + if (fgets(response, YESNO_RESPONSE_SIZE, stdin) == NULL) + return 0; + if (strchr(response, '\n') == NULL) + continue; + + /* + * Delete spaces and tabs in the beginning and end of the + * line. + */ + for (head = response; *head == ' ' || *head == '\t'; head++) + ; + for (tail = head + strlen(head) - 1; + head <= tail && (*tail == ' ' || *tail == '\t' || *tail == '\n'); + tail--) + *tail = '\0'; + + /* + * Return if the line is `y' or `n'. + */ + if ((*head == 'Y' || *head == 'y') && *(head + 1) == '\0') + return 1; + if ((*head == 'N' || *head == 'n') && *(head + 1) == '\0') + return 0; + } + + /* not reached */ + return 0; +} diff --git a/libebutils/yesno.h b/libebutils/yesno.h new file mode 100644 index 0000000..14d12b3 --- /dev/null +++ b/libebutils/yesno.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 1998-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef YESNO_H +#define YESNO_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +/* + * Function declarations. + */ +int query_y_or_n(const char *); + +#endif /* not YESNO_H */ diff --git a/ltmain.sh b/ltmain.sh new file mode 100644 index 0000000..b36c4ad --- /dev/null +++ b/ltmain.sh @@ -0,0 +1,8406 @@ +# Generated from ltmain.m4sh. + +# ltmain.sh (GNU libtool) 2.2.6 +# Written by Gordon Matzigkeit , 1996 + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Libtool; see the file COPYING. If not, a copy +# can be downloaded from http://www.gnu.org/licenses/gpl.html, +# or obtained by writing to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# Usage: $progname [OPTION]... [MODE-ARG]... +# +# Provide generalized library-building support services. +# +# --config show all configuration variables +# --debug enable verbose shell tracing +# -n, --dry-run display commands without modifying any files +# --features display basic configuration information and exit +# --mode=MODE use operation mode MODE +# --preserve-dup-deps don't remove duplicate dependency libraries +# --quiet, --silent don't print informational messages +# --tag=TAG use configuration variables from tag TAG +# -v, --verbose print informational messages (default) +# --version print version information +# -h, --help print short or long help message +# +# MODE must be one of the following: +# +# clean remove files from the build directory +# compile compile a source file into a libtool object +# execute automatically set library path, then run a program +# finish complete the installation of libtool libraries +# install install libraries or executables +# link create a library or an executable +# uninstall remove libraries from an installed directory +# +# MODE-ARGS vary depending on the MODE. +# Try `$progname --help --mode=MODE' for a more detailed description of MODE. +# +# When reporting a bug, please describe a test case to reproduce it and +# include the following information: +# +# host-triplet: $host +# shell: $SHELL +# compiler: $LTCC +# compiler flags: $LTCFLAGS +# linker: $LD (gnu? $with_gnu_ld) +# $progname: (GNU libtool) 2.2.6 +# automake: $automake_version +# autoconf: $autoconf_version +# +# Report bugs to . + +PROGRAM=ltmain.sh +PACKAGE=libtool +VERSION=2.2.6 +TIMESTAMP="" +package_revision=1.3012 + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# NLS nuisances: We save the old values to restore during execute mode. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +lt_user_locale= +lt_safe_locale= +for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES +do + eval "if test \"\${$lt_var+set}\" = set; then + save_$lt_var=\$$lt_var + $lt_var=C + export $lt_var + lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" + lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" + fi" +done + +$lt_unset CDPATH + + + + + +: ${CP="cp -f"} +: ${ECHO="echo"} +: ${EGREP="/usr/bin/grep -E"} +: ${FGREP="/usr/bin/grep -F"} +: ${GREP="/usr/bin/grep"} +: ${LN_S="ln -s"} +: ${MAKE="make"} +: ${MKDIR="mkdir"} +: ${MV="mv -f"} +: ${RM="rm -f"} +: ${SED="/opt/local/bin/gsed"} +: ${SHELL="${CONFIG_SHELL-/bin/sh}"} +: ${Xsed="$SED -e 1s/^X//"} + +# Global variables: +EXIT_SUCCESS=0 +EXIT_FAILURE=1 +EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. +EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. + +exit_status=$EXIT_SUCCESS + +# Make sure IFS has a sensible default +lt_nl=' +' +IFS=" $lt_nl" + +dirname="s,/[^/]*$,," +basename="s,^.*/,," + +# func_dirname_and_basename file append nondir_replacement +# perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# Implementation must be kept synchronized with func_dirname +# and func_basename. For efficiency, we do not delegate to +# those functions but instead duplicate the functionality here. +func_dirname_and_basename () +{ + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi + func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` +} + +# Generated shell functions inserted here. + +# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh +# is ksh but when the shell is invoked as "sh" and the current value of +# the _XPG environment variable is not equal to 1 (one), the special +# positional parameter $0, within a function call, is the name of the +# function. +progpath="$0" + +# The name of this program: +# In the unlikely event $progname began with a '-', it would play havoc with +# func_echo (imagine progname=-n), so we prepend ./ in that case: +func_dirname_and_basename "$progpath" +progname=$func_basename_result +case $progname in + -*) progname=./$progname ;; +esac + +# Make sure we have an absolute path for reexecution: +case $progpath in + [\\/]*|[A-Za-z]:\\*) ;; + *[\\/]*) + progdir=$func_dirname_result + progdir=`cd "$progdir" && pwd` + progpath="$progdir/$progname" + ;; + *) + save_IFS="$IFS" + IFS=: + for progdir in $PATH; do + IFS="$save_IFS" + test -x "$progdir/$progname" && break + done + IFS="$save_IFS" + test -n "$progdir" || progdir=`pwd` + progpath="$progdir/$progname" + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed="${SED}"' -e 1s/^X//' +sed_quote_subst='s/\([`"$\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Re-`\' parameter expansions in output of double_quote_subst that were +# `\'-ed in input to the same. If an odd number of `\' preceded a '$' +# in input to double_quote_subst, that '$' was protected from expansion. +# Since each input `\' is now two `\'s, look for any number of runs of +# four `\'s followed by two `\'s and then a '$'. `\' that '$'. +bs='\\' +bs2='\\\\' +bs4='\\\\\\\\' +dollar='\$' +sed_double_backslash="\ + s/$bs4/&\\ +/g + s/^$bs2$dollar/$bs&/ + s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g + s/\n//g" + +# Standard options: +opt_dry_run=false +opt_help=false +opt_quiet=false +opt_verbose=false +opt_warning=: + +# func_echo arg... +# Echo program name prefixed message, along with the current mode +# name if it has been set yet. +func_echo () +{ + $ECHO "$progname${mode+: }$mode: $*" +} + +# func_verbose arg... +# Echo program name prefixed message in verbose mode only. +func_verbose () +{ + $opt_verbose && func_echo ${1+"$@"} + + # A bug in bash halts the script if the last line of a function + # fails when set -e is in force, so we need another command to + # work around that: + : +} + +# func_error arg... +# Echo program name prefixed message to standard error. +func_error () +{ + $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2 +} + +# func_warning arg... +# Echo program name prefixed warning message to standard error. +func_warning () +{ + $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2 + + # bash bug again: + : +} + +# func_fatal_error arg... +# Echo program name prefixed message to standard error, and exit. +func_fatal_error () +{ + func_error ${1+"$@"} + exit $EXIT_FAILURE +} + +# func_fatal_help arg... +# Echo program name prefixed message to standard error, followed by +# a help hint, and exit. +func_fatal_help () +{ + func_error ${1+"$@"} + func_fatal_error "$help" +} +help="Try \`$progname --help' for more information." ## default + + +# func_grep expression filename +# Check whether EXPRESSION matches any line of FILENAME, without output. +func_grep () +{ + $GREP "$1" "$2" >/dev/null 2>&1 +} + + +# func_mkdir_p directory-path +# Make sure the entire path to DIRECTORY-PATH is available. +func_mkdir_p () +{ + my_directory_path="$1" + my_dir_list= + + if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then + + # Protect directory names starting with `-' + case $my_directory_path in + -*) my_directory_path="./$my_directory_path" ;; + esac + + # While some portion of DIR does not yet exist... + while test ! -d "$my_directory_path"; do + # ...make a list in topmost first order. Use a colon delimited + # list incase some portion of path contains whitespace. + my_dir_list="$my_directory_path:$my_dir_list" + + # If the last portion added has no slash in it, the list is done + case $my_directory_path in */*) ;; *) break ;; esac + + # ...otherwise throw away the child directory and loop + my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"` + done + my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'` + + save_mkdir_p_IFS="$IFS"; IFS=':' + for my_dir in $my_dir_list; do + IFS="$save_mkdir_p_IFS" + # mkdir can fail with a `File exist' error if two processes + # try to create one of the directories concurrently. Don't + # stop in that case! + $MKDIR "$my_dir" 2>/dev/null || : + done + IFS="$save_mkdir_p_IFS" + + # Bail out if we (or some other process) failed to create a directory. + test -d "$my_directory_path" || \ + func_fatal_error "Failed to create \`$1'" + fi +} + + +# func_mktempdir [string] +# Make a temporary directory that won't clash with other running +# libtool processes, and avoids race conditions if possible. If +# given, STRING is the basename for that directory. +func_mktempdir () +{ + my_template="${TMPDIR-/tmp}/${1-$progname}" + + if test "$opt_dry_run" = ":"; then + # Return a directory name, but don't create it in dry-run mode + my_tmpdir="${my_template}-$$" + else + + # If mktemp works, use that first and foremost + my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` + + if test ! -d "$my_tmpdir"; then + # Failing that, at least try and use $RANDOM to avoid a race + my_tmpdir="${my_template}-${RANDOM-0}$$" + + save_mktempdir_umask=`umask` + umask 0077 + $MKDIR "$my_tmpdir" + umask $save_mktempdir_umask + fi + + # If we're not in dry-run mode, bomb out on failure + test -d "$my_tmpdir" || \ + func_fatal_error "cannot create temporary directory \`$my_tmpdir'" + fi + + $ECHO "X$my_tmpdir" | $Xsed +} + + +# func_quote_for_eval arg +# Aesthetically quote ARG to be evaled later. +# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT +# is double-quoted, suitable for a subsequent eval, whereas +# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters +# which are still active within double quotes backslashified. +func_quote_for_eval () +{ + case $1 in + *[\\\`\"\$]*) + func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;; + *) + func_quote_for_eval_unquoted_result="$1" ;; + esac + + case $func_quote_for_eval_unquoted_result in + # Double-quote args containing shell metacharacters to delay + # word splitting, command substitution and and variable + # expansion for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" + ;; + *) + func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" + esac +} + + +# func_quote_for_expand arg +# Aesthetically quote ARG to be evaled later; same as above, +# but do not quote variable references. +func_quote_for_expand () +{ + case $1 in + *[\\\`\"]*) + my_arg=`$ECHO "X$1" | $Xsed \ + -e "$double_quote_subst" -e "$sed_double_backslash"` ;; + *) + my_arg="$1" ;; + esac + + case $my_arg in + # Double-quote args containing shell metacharacters to delay + # word splitting and command substitution for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + my_arg="\"$my_arg\"" + ;; + esac + + func_quote_for_expand_result="$my_arg" +} + + +# func_show_eval cmd [fail_exp] +# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is +# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP +# is given, then evaluate it. +func_show_eval () +{ + my_cmd="$1" + my_fail_exp="${2-:}" + + ${opt_silent-false} || { + func_quote_for_expand "$my_cmd" + eval "func_echo $func_quote_for_expand_result" + } + + if ${opt_dry_run-false}; then :; else + eval "$my_cmd" + my_status=$? + if test "$my_status" -eq 0; then :; else + eval "(exit $my_status); $my_fail_exp" + fi + fi +} + + +# func_show_eval_locale cmd [fail_exp] +# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is +# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP +# is given, then evaluate it. Use the saved locale for evaluation. +func_show_eval_locale () +{ + my_cmd="$1" + my_fail_exp="${2-:}" + + ${opt_silent-false} || { + func_quote_for_expand "$my_cmd" + eval "func_echo $func_quote_for_expand_result" + } + + if ${opt_dry_run-false}; then :; else + eval "$lt_user_locale + $my_cmd" + my_status=$? + eval "$lt_safe_locale" + if test "$my_status" -eq 0; then :; else + eval "(exit $my_status); $my_fail_exp" + fi + fi +} + + + + + +# func_version +# Echo version message to standard output and exit. +func_version () +{ + $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / { + s/^# // + s/^# *$// + s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ + p + }' < "$progpath" + exit $? +} + +# func_usage +# Echo short help message to standard output and exit. +func_usage () +{ + $SED -n '/^# Usage:/,/# -h/ { + s/^# // + s/^# *$// + s/\$progname/'$progname'/ + p + }' < "$progpath" + $ECHO + $ECHO "run \`$progname --help | more' for full usage" + exit $? +} + +# func_help +# Echo long help message to standard output and exit. +func_help () +{ + $SED -n '/^# Usage:/,/# Report bugs to/ { + s/^# // + s/^# *$// + s*\$progname*'$progname'* + s*\$host*'"$host"'* + s*\$SHELL*'"$SHELL"'* + s*\$LTCC*'"$LTCC"'* + s*\$LTCFLAGS*'"$LTCFLAGS"'* + s*\$LD*'"$LD"'* + s/\$with_gnu_ld/'"$with_gnu_ld"'/ + s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ + s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ + p + }' < "$progpath" + exit $? +} + +# func_missing_arg argname +# Echo program name prefixed message to standard error and set global +# exit_cmd. +func_missing_arg () +{ + func_error "missing argument for $1" + exit_cmd=exit +} + +exit_cmd=: + + + + + +# Check that we have a working $ECHO. +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then + # Yippee, $ECHO works! + : +else + # Restart under the correct shell, and then maybe $ECHO will work. + exec $SHELL "$progpath" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null 2>&1; then + taglist="$taglist $tagname" + + # Evaluate the configuration. Be careful to quote the path + # and the sed script, to avoid splitting on whitespace, but + # also don't use non-portable quotes within backquotes within + # quotes we have to do it in 2 steps: + extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` + eval "$extractedcf" + else + func_error "ignoring unknown tag $tagname" + fi + ;; + esac +} + +# Parse options once, thoroughly. This comes as soon as possible in +# the script to make things like `libtool --version' happen quickly. +{ + + # Shorthand for --mode=foo, only valid as the first argument + case $1 in + clean|clea|cle|cl) + shift; set dummy --mode clean ${1+"$@"}; shift + ;; + compile|compil|compi|comp|com|co|c) + shift; set dummy --mode compile ${1+"$@"}; shift + ;; + execute|execut|execu|exec|exe|ex|e) + shift; set dummy --mode execute ${1+"$@"}; shift + ;; + finish|finis|fini|fin|fi|f) + shift; set dummy --mode finish ${1+"$@"}; shift + ;; + install|instal|insta|inst|ins|in|i) + shift; set dummy --mode install ${1+"$@"}; shift + ;; + link|lin|li|l) + shift; set dummy --mode link ${1+"$@"}; shift + ;; + uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) + shift; set dummy --mode uninstall ${1+"$@"}; shift + ;; + esac + + # Parse non-mode specific arguments: + while test "$#" -gt 0; do + opt="$1" + shift + + case $opt in + --config) func_config ;; + + --debug) preserve_args="$preserve_args $opt" + func_echo "enabling shell trace mode" + opt_debug='set -x' + $opt_debug + ;; + + -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break + execute_dlfiles="$execute_dlfiles $1" + shift + ;; + + --dry-run | -n) opt_dry_run=: ;; + --features) func_features ;; + --finish) mode="finish" ;; + + --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break + case $1 in + # Valid mode arguments: + clean) ;; + compile) ;; + execute) ;; + finish) ;; + install) ;; + link) ;; + relink) ;; + uninstall) ;; + + # Catch anything else as an error + *) func_error "invalid argument for $opt" + exit_cmd=exit + break + ;; + esac + + mode="$1" + shift + ;; + + --preserve-dup-deps) + opt_duplicate_deps=: ;; + + --quiet|--silent) preserve_args="$preserve_args $opt" + opt_silent=: + ;; + + --verbose| -v) preserve_args="$preserve_args $opt" + opt_silent=false + ;; + + --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break + preserve_args="$preserve_args $opt $1" + func_enable_tag "$1" # tagname is set here + shift + ;; + + # Separate optargs to long options: + -dlopen=*|--mode=*|--tag=*) + func_opt_split "$opt" + set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"} + shift + ;; + + -\?|-h) func_usage ;; + --help) opt_help=: ;; + --version) func_version ;; + + -*) func_fatal_help "unrecognized option \`$opt'" ;; + + *) nonopt="$opt" + break + ;; + esac + done + + + case $host in + *cygwin* | *mingw* | *pw32* | *cegcc*) + # don't eliminate duplications in $postdeps and $predeps + opt_duplicate_compiler_generated_deps=: + ;; + *) + opt_duplicate_compiler_generated_deps=$opt_duplicate_deps + ;; + esac + + # Having warned about all mis-specified options, bail out if + # anything was wrong. + $exit_cmd $EXIT_FAILURE +} + +# func_check_version_match +# Ensure that we are using m4 macros, and libtool script from the same +# release of libtool. +func_check_version_match () +{ + if test "$package_revision" != "$macro_revision"; then + if test "$VERSION" != "$macro_version"; then + if test -z "$macro_version"; then + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from an older release. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + fi + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, +$progname: but the definition of this LT_INIT comes from revision $macro_revision. +$progname: You should recreate aclocal.m4 with macros from revision $package_revision +$progname: of $PACKAGE $VERSION and run autoconf again. +_LT_EOF + fi + + exit $EXIT_MISMATCH + fi +} + + +## ----------- ## +## Main. ## +## ----------- ## + +$opt_help || { + # Sanity checks first: + func_check_version_match + + if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then + func_fatal_configuration "not configured to build any kind of library" + fi + + test -z "$mode" && func_fatal_error "error: you must specify a MODE." + + + # Darwin sucks + eval std_shrext=\"$shrext_cmds\" + + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$execute_dlfiles" && test "$mode" != execute; then + func_error "unrecognized option \`-dlopen'" + $ECHO "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$progname --help --mode=$mode' for more information." +} + + +# func_lalib_p file +# True iff FILE is a libtool `.la' library or `.lo' object file. +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_lalib_p () +{ + test -f "$1" && + $SED -e 4q "$1" 2>/dev/null \ + | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 +} + +# func_lalib_unsafe_p file +# True iff FILE is a libtool `.la' library or `.lo' object file. +# This function implements the same check as func_lalib_p without +# resorting to external programs. To this end, it redirects stdin and +# closes it afterwards, without saving the original file descriptor. +# As a safety measure, use it only where a negative result would be +# fatal anyway. Works if `file' does not exist. +func_lalib_unsafe_p () +{ + lalib_p=no + if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then + for lalib_p_l in 1 2 3 4 + do + read lalib_p_line + case "$lalib_p_line" in + \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; + esac + done + exec 0<&5 5<&- + fi + test "$lalib_p" = yes +} + +# func_ltwrapper_script_p file +# True iff FILE is a libtool wrapper script +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_script_p () +{ + func_lalib_p "$1" +} + +# func_ltwrapper_executable_p file +# True iff FILE is a libtool wrapper executable +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_executable_p () +{ + func_ltwrapper_exec_suffix= + case $1 in + *.exe) ;; + *) func_ltwrapper_exec_suffix=.exe ;; + esac + $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 +} + +# func_ltwrapper_scriptname file +# Assumes file is an ltwrapper_executable +# uses $file to determine the appropriate filename for a +# temporary ltwrapper_script. +func_ltwrapper_scriptname () +{ + func_ltwrapper_scriptname_result="" + if func_ltwrapper_executable_p "$1"; then + func_dirname_and_basename "$1" "" "." + func_stripname '' '.exe' "$func_basename_result" + func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" + fi +} + +# func_ltwrapper_p file +# True iff FILE is a libtool wrapper script or wrapper executable +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_p () +{ + func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" +} + + +# func_execute_cmds commands fail_cmd +# Execute tilde-delimited COMMANDS. +# If FAIL_CMD is given, eval that upon failure. +# FAIL_CMD may read-access the current command in variable CMD! +func_execute_cmds () +{ + $opt_debug + save_ifs=$IFS; IFS='~' + for cmd in $1; do + IFS=$save_ifs + eval cmd=\"$cmd\" + func_show_eval "$cmd" "${2-:}" + done + IFS=$save_ifs +} + + +# func_source file +# Source FILE, adding directory component if necessary. +# Note that it is not necessary on cygwin/mingw to append a dot to +# FILE even if both FILE and FILE.exe exist: automatic-append-.exe +# behavior happens only for exec(3), not for open(2)! Also, sourcing +# `FILE.' does not work on cygwin managed mounts. +func_source () +{ + $opt_debug + case $1 in + */* | *\\*) . "$1" ;; + *) . "./$1" ;; + esac +} + + +# func_infer_tag arg +# Infer tagged configuration to use if any are available and +# if one wasn't chosen via the "--tag" command line option. +# Only attempt this if the compiler in the base compile +# command doesn't match the default compiler. +# arg is usually of the form 'gcc ...' +func_infer_tag () +{ + $opt_debug + if test -n "$available_tags" && test -z "$tagname"; then + CC_quoted= + for arg in $CC; do + func_quote_for_eval "$arg" + CC_quoted="$CC_quoted $func_quote_for_eval_result" + done + case $@ in + # Blanks in the command may have been stripped by the calling shell, + # but not from the CC environment variable when configure was run. + " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;; + # Blanks at the start of $base_compile will cause this to fail + # if we don't check for them as well. + *) + for z in $available_tags; do + if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" + CC_quoted= + for arg in $CC; do + # Double-quote args containing other shell metacharacters. + func_quote_for_eval "$arg" + CC_quoted="$CC_quoted $func_quote_for_eval_result" + done + case "$@ " in + " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) + # The compiler in the base compile command matches + # the one in the tagged configuration. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + fi + done + # If $tagname still isn't set, then no tagged configuration + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then + func_echo "unable to infer tagged configuration" + func_fatal_error "specify a tag with \`--tag'" +# else +# func_verbose "using $tagname tagged configuration" + fi + ;; + esac + fi +} + + + +# func_write_libtool_object output_name pic_name nonpic_name +# Create a libtool object file (analogous to a ".la" file), +# but don't create it if we're doing a dry run. +func_write_libtool_object () +{ + write_libobj=${1} + if test "$build_libtool_libs" = yes; then + write_lobj=\'${2}\' + else + write_lobj=none + fi + + if test "$build_old_libs" = yes; then + write_oldobj=\'${3}\' + else + write_oldobj=none + fi + + $opt_dry_run || { + cat >${write_libobj}T <?"'"'"' &()|`$[]' \ + && func_warning "libobj name \`$libobj' may not contain shell special characters." + func_dirname_and_basename "$obj" "/" "" + objname="$func_basename_result" + xdir="$func_dirname_result" + lobj=${xdir}$objdir/$objname + + test -z "$base_compile" && \ + func_fatal_help "you must specify a compilation command" + + # Delete any leftover library objects. + if test "$build_old_libs" = yes; then + removelist="$obj $lobj $libobj ${libobj}T" + else + removelist="$lobj $libobj ${libobj}T" + fi + + # On Cygwin there's no "real" PIC flag so we must build both object types + case $host_os in + cygwin* | mingw* | pw32* | os2* | cegcc*) + pic_mode=default + ;; + esac + if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then + # non-PIC code in shared libraries is not supported + pic_mode=default + fi + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test "$compiler_c_o" = no; then + output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} + lockfile="$output_obj.lock" + else + output_obj= + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test "$need_locks" = yes; then + until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do + func_echo "Waiting for $lockfile to be removed" + sleep 2 + done + elif test "$need_locks" = warn; then + if test -f "$lockfile"; then + $ECHO "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + removelist="$removelist $output_obj" + $ECHO "$srcfile" > "$lockfile" + fi + + $opt_dry_run || $RM $removelist + removelist="$removelist $lockfile" + trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 + + if test -n "$fix_srcfile_path"; then + eval srcfile=\"$fix_srcfile_path\" + fi + func_quote_for_eval "$srcfile" + qsrcfile=$func_quote_for_eval_result + + # Only build a PIC object if we are building libtool libraries. + if test "$build_libtool_libs" = yes; then + # Without this assignment, base_compile gets emptied. + fbsd_hideous_sh_bug=$base_compile + + if test "$pic_mode" != no; then + command="$base_compile $qsrcfile $pic_flag" + else + # Don't build PIC code + command="$base_compile $qsrcfile" + fi + + func_mkdir_p "$xdir$objdir" + + if test -z "$output_obj"; then + # Place PIC objects in $objdir + command="$command -o $lobj" + fi + + func_show_eval_locale "$command" \ + 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' + + if test "$need_locks" = warn && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $ECHO "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed, then go on to compile the next one + if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then + func_show_eval '$MV "$output_obj" "$lobj"' \ + 'error=$?; $opt_dry_run || $RM $removelist; exit $error' + fi + + # Allow error messages only from the first compilation. + if test "$suppress_opt" = yes; then + suppress_output=' >/dev/null 2>&1' + fi + fi + + # Only build a position-dependent object if we build old libraries. + if test "$build_old_libs" = yes; then + if test "$pic_mode" != yes; then + # Don't build PIC code + command="$base_compile $qsrcfile$pie_flag" + else + command="$base_compile $qsrcfile $pic_flag" + fi + if test "$compiler_c_o" = yes; then + command="$command -o $obj" + fi + + # Suppress compiler output if we already did a PIC compilation. + command="$command$suppress_output" + func_show_eval_locale "$command" \ + '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' + + if test "$need_locks" = warn && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $ECHO "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed + if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then + func_show_eval '$MV "$output_obj" "$obj"' \ + 'error=$?; $opt_dry_run || $RM $removelist; exit $error' + fi + fi + + $opt_dry_run || { + func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" + + # Unlock the critical section if it was locked + if test "$need_locks" != no; then + removelist=$lockfile + $RM "$lockfile" + fi + } + + exit $EXIT_SUCCESS +} + +$opt_help || { +test "$mode" = compile && func_mode_compile ${1+"$@"} +} + +func_mode_help () +{ + # We need to display help for each of the modes. + case $mode in + "") + # Generic help is extracted from the usage comments + # at the start of this file. + func_help + ;; + + clean) + $ECHO \ +"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... + +Remove files from the build directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, object or program, all the files associated +with it are deleted. Otherwise, only FILE itself is deleted using RM." + ;; + + compile) + $ECHO \ +"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -no-suppress do not suppress compiler output for multiple passes + -prefer-pic try to building PIC objects only + -prefer-non-pic try to building non-PIC objects only + -shared do not build a \`.o' file suitable for static linking + -static only build a \`.o' file suitable for static linking + +COMPILE-COMMAND is a command to be used in creating a \`standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix \`.c' with the +library object suffix, \`.lo'." + ;; + + execute) + $ECHO \ +"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to \`-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + + finish) + $ECHO \ +"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the \`--dry-run' option if you just want to see what would be executed." + ;; + + install) + $ECHO \ +"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the \`install' or \`cp' program. + +The following components of INSTALL-COMMAND are treated specially: + + -inst-prefix PREFIX-DIR Use PREFIX-DIR as a staging area for installation + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + + link) + $ECHO \ +"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-fast-install disable the fast-install mode + -no-install link a not-installable executable + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -objectlist FILE Use a list of object files found in FILE to specify objects + -precious-files-regex REGEX + don't remove output files matching REGEX + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -shared only do dynamic linking of libtool libraries + -shrext SUFFIX override the standard shared library file extension + -static do not do any dynamic linking of uninstalled libtool libraries + -static-libtool-libs + do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + -weak LIBNAME declare that the target provides the LIBNAME interface + +All other options (arguments beginning with \`-') are ignored. + +Every other argument is treated as a filename. Files ending in \`.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in \`.la', then a libtool library is created, +only library objects (\`.lo' files) may be specified, and \`-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created +using \`ar' and \`ranlib', or on Windows using \`lib'. + +If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file +is created, otherwise an executable program is created." + ;; + + uninstall) + $ECHO \ +"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + + *) + func_fatal_help "invalid operation mode \`$mode'" + ;; + esac + + $ECHO + $ECHO "Try \`$progname --help' for more information about other modes." + + exit $? +} + + # Now that we've collected a possible --mode arg, show help if necessary + $opt_help && func_mode_help + + +# func_mode_execute arg... +func_mode_execute () +{ + $opt_debug + # The first argument is the command name. + cmd="$nonopt" + test -z "$cmd" && \ + func_fatal_help "you must specify a COMMAND" + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + test -f "$file" \ + || func_fatal_help "\`$file' is not a file" + + dir= + case $file in + *.la) + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$file" \ + || func_fatal_help "\`$lib' is not a valid libtool archive" + + # Read the libtool library. + dlname= + library_names= + func_source "$file" + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && \ + func_warning "\`$file' was not linked with \`-export-dynamic'" + continue + fi + + func_dirname "$file" "" "." + dir="$func_dirname_result" + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + if test ! -f "$dir/$dlname"; then + func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" + fi + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + func_dirname "$file" "" "." + dir="$func_dirname_result" + ;; + + *) + func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case $file in + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if func_ltwrapper_script_p "$file"; then + func_source "$file" + # Transform arg to wrapped name. + file="$progdir/$program" + elif func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + func_source "$func_ltwrapper_scriptname_result" + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + func_quote_for_eval "$file" + args="$args $func_quote_for_eval_result" + done + + if test "X$opt_dry_run" = Xfalse; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved environment variables + for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES + do + eval "if test \"\${save_$lt_var+set}\" = set; then + $lt_var=\$save_$lt_var; export $lt_var + else + $lt_unset $lt_var + fi" + done + + # Now prepare to actually exec the command. + exec_cmd="\$cmd$args" + else + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" + $ECHO "export $shlibpath_var" + fi + $ECHO "$cmd$args" + exit $EXIT_SUCCESS + fi +} + +test "$mode" = execute && func_mode_execute ${1+"$@"} + + +# func_mode_finish arg... +func_mode_finish () +{ + $opt_debug + libdirs="$nonopt" + admincmds= + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + func_execute_cmds "$finish_cmds" 'admincmds="$admincmds +'"$cmd"'"' + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $opt_dry_run || eval "$cmds" || admincmds="$admincmds + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + $opt_silent && exit $EXIT_SUCCESS + + $ECHO "X----------------------------------------------------------------------" | $Xsed + $ECHO "Libraries have been installed in:" + for libdir in $libdirs; do + $ECHO " $libdir" + done + $ECHO + $ECHO "If you ever happen to want to link against installed libraries" + $ECHO "in a given directory, LIBDIR, you must either use libtool, and" + $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'" + $ECHO "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + $ECHO " - add LIBDIR to the \`$shlibpath_var' environment variable" + $ECHO " during execution" + fi + if test -n "$runpath_var"; then + $ECHO " - add LIBDIR to the \`$runpath_var' environment variable" + $ECHO " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + $ECHO " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + $ECHO " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + $ECHO " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + $ECHO + + $ECHO "See any operating system documentation about shared libraries for" + case $host in + solaris2.[6789]|solaris2.1[0-9]) + $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual" + $ECHO "pages." + ;; + *) + $ECHO "more information, such as the ld(1) and ld.so(8) manual pages." + ;; + esac + $ECHO "X----------------------------------------------------------------------" | $Xsed + exit $EXIT_SUCCESS +} + +test "$mode" = finish && func_mode_finish ${1+"$@"} + + +# func_mode_install arg... +func_mode_install () +{ + $opt_debug + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || + # Allow the use of GNU shtool's install command. + $ECHO "X$nonopt" | $GREP shtool >/dev/null; then + # Aesthetically quote it. + func_quote_for_eval "$nonopt" + install_prog="$func_quote_for_eval_result " + arg=$1 + shift + else + install_prog= + arg=$nonopt + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + func_quote_for_eval "$arg" + install_prog="$install_prog$func_quote_for_eval_result" + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=no + stripme= + for arg + do + if test -n "$dest"; then + files="$files $dest" + dest=$arg + continue + fi + + case $arg in + -d) isdir=yes ;; + -f) + case " $install_prog " in + *[\\\ /]cp\ *) ;; + *) prev=$arg ;; + esac + ;; + -g | -m | -o) + prev=$arg + ;; + -s) + stripme=" -s" + continue + ;; + -*) + ;; + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + prev= + else + dest=$arg + continue + fi + ;; + esac + + # Aesthetically quote the argument. + func_quote_for_eval "$arg" + install_prog="$install_prog $func_quote_for_eval_result" + done + + test -z "$install_prog" && \ + func_fatal_help "you must specify an install program" + + test -n "$prev" && \ + func_fatal_help "the \`$prev' option requires an argument" + + if test -z "$files"; then + if test -z "$dest"; then + func_fatal_help "no file or destination specified" + else + func_fatal_help "you must specify a destination" + fi + fi + + # Strip any trailing slash from the destination. + func_stripname '' '/' "$dest" + dest=$func_stripname_result + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test "$isdir" = yes; then + destdir="$dest" + destname= + else + func_dirname_and_basename "$dest" "" "." + destdir="$func_dirname_result" + destname="$func_basename_result" + + # Not a directory, so check to see that there is only one file specified. + set dummy $files; shift + test "$#" -gt 1 && \ + func_fatal_help "\`$dest' is not a directory" + fi + case $destdir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case $file in + *.lo) ;; + *) + func_fatal_help "\`$destdir' must be an absolute directory name" + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case $file in + *.$libext) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$file" \ + || func_fatal_help "\`$file' is not a valid libtool archive" + + library_names= + old_library= + relink_command= + func_source "$file" + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + func_dirname "$file" "/" "" + dir="$func_dirname_result" + dir="$dir$objdir" + + if test -n "$relink_command"; then + # Determine the prefix the user has applied to our future dir. + inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"` + + # Don't allow the user to place us outside of our expected + # location b/c this prevents finding dependent libraries that + # are installed to the same prefix. + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. + test "$inst_prefix_dir" = "$destdir" && \ + func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. + relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` + else + relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"` + fi + + func_warning "relinking \`$file'" + func_show_eval "$relink_command" \ + 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' + fi + + # See the names of the shared library. + set dummy $library_names; shift + if test -n "$1"; then + realname="$1" + shift + + srcname="$realname" + test -n "$relink_command" && srcname="$realname"T + + # Install the shared library and build the symlinks. + func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \ + 'exit $?' + tstripme="$stripme" + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + case $realname in + *.dll.a) + tstripme="" + ;; + esac + ;; + esac + if test -n "$tstripme" && test -n "$striplib"; then + func_show_eval "$striplib $destdir/$realname" 'exit $?' + fi + + if test "$#" -gt 0; then + # Delete the old symlinks, and create new ones. + # Try `ln -sf' first, because the `ln' binary might depend on + # the symlink we replace! Solaris /bin/ln does not understand -f, + # so we also need to try rm && ln -s. + for linkname + do + test "$linkname" != "$realname" \ + && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" + done + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + func_execute_cmds "$postinstall_cmds" 'exit $?' + fi + + # Install the pseudo-library for information purposes. + func_basename "$file" + name="$func_basename_result" + instname="$dir/$name"i + func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + func_basename "$file" + destfile="$func_basename_result" + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case $destfile in + *.lo) + func_lo2o "$destfile" + staticdest=$func_lo2o_result + ;; + *.$objext) + staticdest="$destfile" + destfile= + ;; + *) + func_fatal_help "cannot copy a libtool object to \`$destfile'" + ;; + esac + + # Install the libtool object if requested. + test -n "$destfile" && \ + func_show_eval "$install_prog $file $destfile" 'exit $?' + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + func_lo2o "$file" + staticobj=$func_lo2o_result + func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' + fi + exit $EXIT_SUCCESS + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + func_basename "$file" + destfile="$func_basename_result" + destfile="$destdir/$destfile" + fi + + # If the file is missing, and there is a .exe on the end, strip it + # because it is most likely a libtool script we actually want to + # install + stripped_ext="" + case $file in + *.exe) + if test ! -f "$file"; then + func_stripname '' '.exe' "$file" + file=$func_stripname_result + stripped_ext=".exe" + fi + ;; + esac + + # Do a test to see if this is really a libtool program. + case $host in + *cygwin* | *mingw*) + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + wrapper=$func_ltwrapper_scriptname_result + else + func_stripname '' '.exe' "$file" + wrapper=$func_stripname_result + fi + ;; + *) + wrapper=$file + ;; + esac + if func_ltwrapper_script_p "$wrapper"; then + notinst_deplibs= + relink_command= + + func_source "$wrapper" + + # Check the variables that should have been set. + test -z "$generated_by_libtool_version" && \ + func_fatal_error "invalid libtool wrapper script \`$wrapper'" + + finalize=yes + for lib in $notinst_deplibs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + func_source "$lib" + fi + libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test + if test -n "$libdir" && test ! -f "$libfile"; then + func_warning "\`$lib' has not been installed in \`$libdir'" + finalize=no + fi + done + + relink_command= + func_source "$wrapper" + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + $opt_dry_run || { + if test "$finalize" = yes; then + tmpdir=`func_mktempdir` + func_basename "$file$stripped_ext" + file="$func_basename_result" + outputname="$tmpdir/$file" + # Replace the output file specification. + relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` + + $opt_silent || { + func_quote_for_expand "$relink_command" + eval "func_echo $func_quote_for_expand_result" + } + if eval "$relink_command"; then : + else + func_error "error: relink \`$file' with the above command before installing it" + $opt_dry_run || ${RM}r "$tmpdir" + continue + fi + file="$outputname" + else + func_warning "cannot relink \`$file'" + fi + } + else + # Install the binary that we compiled earlier. + file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + # remove .exe since cygwin /usr/bin/install will append another + # one anyway + case $install_prog,$host in + */usr/bin/install*,*cygwin*) + case $file:$destfile in + *.exe:*.exe) + # this is ok + ;; + *.exe:*) + destfile=$destfile.exe + ;; + *:*.exe) + func_stripname '' '.exe' "$destfile" + destfile=$func_stripname_result + ;; + esac + ;; + esac + func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' + $opt_dry_run || if test -n "$outputname"; then + ${RM}r "$tmpdir" + fi + ;; + esac + done + + for file in $staticlibs; do + func_basename "$file" + name="$func_basename_result" + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + func_show_eval "$install_prog \$file \$oldlib" 'exit $?' + + if test -n "$stripme" && test -n "$old_striplib"; then + func_show_eval "$old_striplib $oldlib" 'exit $?' + fi + + # Do each command in the postinstall commands. + func_execute_cmds "$old_postinstall_cmds" 'exit $?' + done + + test -n "$future_libdirs" && \ + func_warning "remember to run \`$progname --finish$future_libdirs'" + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + $opt_dry_run && current_libdirs=" -n$current_libdirs" + exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' + else + exit $EXIT_SUCCESS + fi +} + +test "$mode" = install && func_mode_install ${1+"$@"} + + +# func_generate_dlsyms outputname originator pic_p +# Extract symbols from dlprefiles and create ${outputname}S.o with +# a dlpreopen symbol table. +func_generate_dlsyms () +{ + $opt_debug + my_outputname="$1" + my_originator="$2" + my_pic_p="${3-no}" + my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` + my_dlsyms= + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + my_dlsyms="${my_outputname}S.c" + else + func_error "not configured to extract global symbols from dlpreopened files" + fi + fi + + if test -n "$my_dlsyms"; then + case $my_dlsyms in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist="$output_objdir/${my_outputname}.nm" + + func_show_eval "$RM $nlist ${nlist}S ${nlist}T" + + # Parse the name list into a source file. + func_verbose "creating $output_objdir/$my_dlsyms" + + $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ +/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ +/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +/* External symbol declarations for the compiler. */\ +" + + if test "$dlself" = yes; then + func_verbose "generating symbol list for \`$output'" + + $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + for progfile in $progfiles; do + func_verbose "extracting global C symbols from \`$progfile'" + $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $opt_dry_run || { + eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + } + fi + + if test -n "$export_symbols_regex"; then + $opt_dry_run || { + eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + } + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols="$output_objdir/$outputname.exp" + $opt_dry_run || { + $RM $export_symbols + eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + case $host in + *cygwin* | *mingw* | *cegcc* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' + ;; + esac + } + else + $opt_dry_run || { + eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' + eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + case $host in + *cygwin | *mingw* | *cegcc* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' + ;; + esac + } + fi + fi + + for dlprefile in $dlprefiles; do + func_verbose "extracting global C symbols from \`$dlprefile'" + func_basename "$dlprefile" + name="$func_basename_result" + $opt_dry_run || { + eval '$ECHO ": $name " >> "$nlist"' + eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'" + } + done + + $opt_dry_run || { + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $MV "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if $GREP -v "^: " < "$nlist" | + if sort -k 3 /dev/null 2>&1; then + sort -k 3 + else + sort +2 + fi | + uniq > "$nlist"S; then + : + else + $GREP -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' + else + $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms" + fi + + $ECHO >> "$output_objdir/$my_dlsyms" "\ + +/* The mapping between symbol names and symbols. */ +typedef struct { + const char *name; + void *address; +} lt_dlsymlist; +" + case $host in + *cygwin* | *mingw* | *cegcc* ) + $ECHO >> "$output_objdir/$my_dlsyms" "\ +/* DATA imports from DLLs on WIN32 con't be const, because + runtime relocations are performed -- see ld's documentation + on pseudo-relocs. */" + lt_dlsym_const= ;; + *osf5*) + echo >> "$output_objdir/$my_dlsyms" "\ +/* This system does not cope well with relocations in const data */" + lt_dlsym_const= ;; + *) + lt_dlsym_const=const ;; + esac + + $ECHO >> "$output_objdir/$my_dlsyms" "\ +extern $lt_dlsym_const lt_dlsymlist +lt_${my_prefix}_LTX_preloaded_symbols[]; +$lt_dlsym_const lt_dlsymlist +lt_${my_prefix}_LTX_preloaded_symbols[] = +{\ + { \"$my_originator\", (void *) 0 }," + + case $need_lib_prefix in + no) + eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" + ;; + *) + eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" + ;; + esac + $ECHO >> "$output_objdir/$my_dlsyms" "\ + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_${my_prefix}_LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + } # !$opt_dry_run + + pic_flag_for_symtable= + case "$compile_command " in + *" -static "*) ;; + *) + case $host in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; + *-*-hpux*) + pic_flag_for_symtable=" $pic_flag" ;; + *) + if test "X$my_pic_p" != Xno; then + pic_flag_for_symtable=" $pic_flag" + fi + ;; + esac + ;; + esac + symtab_cflags= + for arg in $LTCFLAGS; do + case $arg in + -pie | -fpie | -fPIE) ;; + *) symtab_cflags="$symtab_cflags $arg" ;; + esac + done + + # Now compile the dynamic symbol file. + func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' + + # Clean up the generated files. + func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' + + # Transform the symbol file into the correct name. + symfileobj="$output_objdir/${my_outputname}S.$objext" + case $host in + *cygwin* | *mingw* | *cegcc* ) + if test -f "$output_objdir/$my_outputname.def"; then + compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + else + compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + fi + ;; + *) + compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + ;; + esac + ;; + *) + func_fatal_error "unknown suffix for \`$my_dlsyms'" + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` + fi +} + +# func_win32_libid arg +# return the library type of file 'arg' +# +# Need a lot of goo to handle *both* DLLs and import libs +# Has to be a shell function in order to 'eat' the argument +# that is supplied when $file_magic_command is called. +func_win32_libid () +{ + $opt_debug + win32_libid_type="unknown" + win32_fileres=`file -L $1 2>/dev/null` + case $win32_fileres in + *ar\ archive\ import\ library*) # definitely import + win32_libid_type="x86 archive import" + ;; + *ar\ archive*) # could be an import, or static + if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | + $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then + win32_nmres=`eval $NM -f posix -A $1 | + $SED -n -e ' + 1,100{ + / I /{ + s,.*,import, + p + q + } + }'` + case $win32_nmres in + import*) win32_libid_type="x86 archive import";; + *) win32_libid_type="x86 archive static";; + esac + fi + ;; + *DLL*) + win32_libid_type="x86 DLL" + ;; + *executable*) # but shell scripts are "executable" too... + case $win32_fileres in + *MS\ Windows\ PE\ Intel*) + win32_libid_type="x86 DLL" + ;; + esac + ;; + esac + $ECHO "$win32_libid_type" +} + + + +# func_extract_an_archive dir oldlib +func_extract_an_archive () +{ + $opt_debug + f_ex_an_ar_dir="$1"; shift + f_ex_an_ar_oldlib="$1" + func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?' + if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then + : + else + func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" + fi +} + + +# func_extract_archives gentop oldlib ... +func_extract_archives () +{ + $opt_debug + my_gentop="$1"; shift + my_oldlibs=${1+"$@"} + my_oldobjs="" + my_xlib="" + my_xabs="" + my_xdir="" + + for my_xlib in $my_oldlibs; do + # Extract the objects. + case $my_xlib in + [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; + *) my_xabs=`pwd`"/$my_xlib" ;; + esac + func_basename "$my_xlib" + my_xlib="$func_basename_result" + my_xlib_u=$my_xlib + while :; do + case " $extracted_archives " in + *" $my_xlib_u "*) + func_arith $extracted_serial + 1 + extracted_serial=$func_arith_result + my_xlib_u=lt$extracted_serial-$my_xlib ;; + *) break ;; + esac + done + extracted_archives="$extracted_archives $my_xlib_u" + my_xdir="$my_gentop/$my_xlib_u" + + func_mkdir_p "$my_xdir" + + case $host in + *-darwin*) + func_verbose "Extracting $my_xabs" + # Do not bother doing anything if just a dry run + $opt_dry_run || { + darwin_orig_dir=`pwd` + cd $my_xdir || exit $? + darwin_archive=$my_xabs + darwin_curdir=`pwd` + darwin_base_archive=`basename "$darwin_archive"` + darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` + if test -n "$darwin_arches"; then + darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` + darwin_arch= + func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" + for darwin_arch in $darwin_arches ; do + func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" + $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" + cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" + func_extract_an_archive "`pwd`" "${darwin_base_archive}" + cd "$darwin_curdir" + $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" + done # $darwin_arches + ## Okay now we've a bunch of thin objects, gotta fatten them up :) + darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` + darwin_file= + darwin_files= + for darwin_file in $darwin_filelist; do + darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` + $LIPO -create -output "$darwin_file" $darwin_files + done # $darwin_filelist + $RM -rf unfat-$$ + cd "$darwin_orig_dir" + else + cd $darwin_orig_dir + func_extract_an_archive "$my_xdir" "$my_xabs" + fi # $darwin_arches + } # !$opt_dry_run + ;; + *) + func_extract_an_archive "$my_xdir" "$my_xabs" + ;; + esac + my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` + done + + func_extract_archives_result="$my_oldobjs" +} + + + +# func_emit_wrapper_part1 [arg=no] +# +# Emit the first part of a libtool wrapper script on stdout. +# For more information, see the description associated with +# func_emit_wrapper(), below. +func_emit_wrapper_part1 () +{ + func_emit_wrapper_part1_arg1=no + if test -n "$1" ; then + func_emit_wrapper_part1_arg1=$1 + fi + + $ECHO "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='${SED} -e 1s/^X//' +sed_quote_subst='$sed_quote_subst' + +# Be Bourne compatible +if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variables: + generated_by_libtool_version='$macro_version' + notinst_deplibs='$notinst_deplibs' +else + # When we are sourced in execute mode, \$file and \$ECHO are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + ECHO=\"$qecho\" + file=\"\$0\" + # Make sure echo works. + if test \"X\$1\" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then + # Yippee, \$ECHO works! + : + else + # Restart under the correct shell, and then maybe \$ECHO will work. + exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} + fi + fi\ +" + $ECHO "\ + + # Find the directory that this script lives in. + thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` + done +" +} +# end: func_emit_wrapper_part1 + +# func_emit_wrapper_part2 [arg=no] +# +# Emit the second part of a libtool wrapper script on stdout. +# For more information, see the description associated with +# func_emit_wrapper(), below. +func_emit_wrapper_part2 () +{ + func_emit_wrapper_part2_arg1=no + if test -n "$1" ; then + func_emit_wrapper_part2_arg1=$1 + fi + + $ECHO "\ + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1 + if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then + # special case for '.' + if test \"\$thisdir\" = \".\"; then + thisdir=\`pwd\` + fi + # remove .libs from thisdir + case \"\$thisdir\" in + *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;; + $objdir ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + $ECHO "\ + program=lt-'$outputname'$exeext + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $MKDIR \"\$progdir\" + else + $RM \"\$progdir/\$file\" + fi" + + $ECHO "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if relink_command_output=\`eval \$relink_command 2>&1\`; then : + else + $ECHO \"\$relink_command_output\" >&2 + $RM \"\$progdir/\$file\" + exit 1 + fi + fi + + $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $RM \"\$progdir/\$program\"; + $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $RM \"\$progdir/\$file\" + fi" + else + $ECHO "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + $ECHO "\ + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $ECHO "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $ECHO "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $ECHO "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. +" + case $host in + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2* | *-cegcc*) + $ECHO "\ + exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} +" + ;; + + *) + $ECHO "\ + exec \"\$progdir/\$program\" \${1+\"\$@\"} +" + ;; + esac + $ECHO "\ + \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 + exit 1 + fi + else + # The program doesn't exist. + \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 + \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 + $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" +} +# end: func_emit_wrapper_part2 + + +# func_emit_wrapper [arg=no] +# +# Emit a libtool wrapper script on stdout. +# Don't directly open a file because we may want to +# incorporate the script contents within a cygwin/mingw +# wrapper executable. Must ONLY be called from within +# func_mode_link because it depends on a number of variables +# set therein. +# +# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR +# variable will take. If 'yes', then the emitted script +# will assume that the directory in which it is stored is +# the $objdir directory. This is a cygwin/mingw-specific +# behavior. +func_emit_wrapper () +{ + func_emit_wrapper_arg1=no + if test -n "$1" ; then + func_emit_wrapper_arg1=$1 + fi + + # split this up so that func_emit_cwrapperexe_src + # can call each part independently. + func_emit_wrapper_part1 "${func_emit_wrapper_arg1}" + func_emit_wrapper_part2 "${func_emit_wrapper_arg1}" +} + + +# func_to_host_path arg +# +# Convert paths to host format when used with build tools. +# Intended for use with "native" mingw (where libtool itself +# is running under the msys shell), or in the following cross- +# build environments: +# $build $host +# mingw (msys) mingw [e.g. native] +# cygwin mingw +# *nix + wine mingw +# where wine is equipped with the `winepath' executable. +# In the native mingw case, the (msys) shell automatically +# converts paths for any non-msys applications it launches, +# but that facility isn't available from inside the cwrapper. +# Similar accommodations are necessary for $host mingw and +# $build cygwin. Calling this function does no harm for other +# $host/$build combinations not listed above. +# +# ARG is the path (on $build) that should be converted to +# the proper representation for $host. The result is stored +# in $func_to_host_path_result. +func_to_host_path () +{ + func_to_host_path_result="$1" + if test -n "$1" ; then + case $host in + *mingw* ) + lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' + case $build in + *mingw* ) # actually, msys + # awkward: cmd appends spaces to result + lt_sed_strip_trailing_spaces="s/[ ]*\$//" + func_to_host_path_tmp1=`( cmd //c echo "$1" |\ + $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""` + func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ + $SED -e "$lt_sed_naive_backslashify"` + ;; + *cygwin* ) + func_to_host_path_tmp1=`cygpath -w "$1"` + func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ + $SED -e "$lt_sed_naive_backslashify"` + ;; + * ) + # Unfortunately, winepath does not exit with a non-zero + # error code, so we are forced to check the contents of + # stdout. On the other hand, if the command is not + # found, the shell will set an exit code of 127 and print + # *an error message* to stdout. So we must check for both + # error code of zero AND non-empty stdout, which explains + # the odd construction: + func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null` + if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then + func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ + $SED -e "$lt_sed_naive_backslashify"` + else + # Allow warning below. + func_to_host_path_result="" + fi + ;; + esac + if test -z "$func_to_host_path_result" ; then + func_error "Could not determine host path corresponding to" + func_error " '$1'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback: + func_to_host_path_result="$1" + fi + ;; + esac + fi +} +# end: func_to_host_path + +# func_to_host_pathlist arg +# +# Convert pathlists to host format when used with build tools. +# See func_to_host_path(), above. This function supports the +# following $build/$host combinations (but does no harm for +# combinations not listed here): +# $build $host +# mingw (msys) mingw [e.g. native] +# cygwin mingw +# *nix + wine mingw +# +# Path separators are also converted from $build format to +# $host format. If ARG begins or ends with a path separator +# character, it is preserved (but converted to $host format) +# on output. +# +# ARG is a pathlist (on $build) that should be converted to +# the proper representation on $host. The result is stored +# in $func_to_host_pathlist_result. +func_to_host_pathlist () +{ + func_to_host_pathlist_result="$1" + if test -n "$1" ; then + case $host in + *mingw* ) + lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' + # Remove leading and trailing path separator characters from + # ARG. msys behavior is inconsistent here, cygpath turns them + # into '.;' and ';.', and winepath ignores them completely. + func_to_host_pathlist_tmp2="$1" + # Once set for this call, this variable should not be + # reassigned. It is used in tha fallback case. + func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\ + $SED -e 's|^:*||' -e 's|:*$||'` + case $build in + *mingw* ) # Actually, msys. + # Awkward: cmd appends spaces to result. + lt_sed_strip_trailing_spaces="s/[ ]*\$//" + func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\ + $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""` + func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\ + $SED -e "$lt_sed_naive_backslashify"` + ;; + *cygwin* ) + func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"` + func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\ + $SED -e "$lt_sed_naive_backslashify"` + ;; + * ) + # unfortunately, winepath doesn't convert pathlists + func_to_host_pathlist_result="" + func_to_host_pathlist_oldIFS=$IFS + IFS=: + for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do + IFS=$func_to_host_pathlist_oldIFS + if test -n "$func_to_host_pathlist_f" ; then + func_to_host_path "$func_to_host_pathlist_f" + if test -n "$func_to_host_path_result" ; then + if test -z "$func_to_host_pathlist_result" ; then + func_to_host_pathlist_result="$func_to_host_path_result" + else + func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result" + fi + fi + fi + IFS=: + done + IFS=$func_to_host_pathlist_oldIFS + ;; + esac + if test -z "$func_to_host_pathlist_result" ; then + func_error "Could not determine the host path(s) corresponding to" + func_error " '$1'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback. This may break if $1 contains DOS-style drive + # specifications. The fix is not to complicate the expression + # below, but for the user to provide a working wine installation + # with winepath so that path translation in the cross-to-mingw + # case works properly. + lt_replace_pathsep_nix_to_dos="s|:|;|g" + func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\ + $SED -e "$lt_replace_pathsep_nix_to_dos"` + fi + # Now, add the leading and trailing path separators back + case "$1" in + :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result" + ;; + esac + case "$1" in + *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;" + ;; + esac + ;; + esac + fi +} +# end: func_to_host_pathlist + +# func_emit_cwrapperexe_src +# emit the source code for a wrapper executable on stdout +# Must ONLY be called from within func_mode_link because +# it depends on a number of variable set therein. +func_emit_cwrapperexe_src () +{ + cat < +#include +#ifdef _MSC_VER +# include +# include +# include +# define setmode _setmode +#else +# include +# include +# ifdef __CYGWIN__ +# include +# define HAVE_SETENV +# ifdef __STRICT_ANSI__ +char *realpath (const char *, char *); +int putenv (char *); +int setenv (const char *, const char *, int); +# endif +# endif +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(PATH_MAX) +# define LT_PATHMAX PATH_MAX +#elif defined(MAXPATHLEN) +# define LT_PATHMAX MAXPATHLEN +#else +# define LT_PATHMAX 1024 +#endif + +#ifndef S_IXOTH +# define S_IXOTH 0 +#endif +#ifndef S_IXGRP +# define S_IXGRP 0 +#endif + +#ifdef _MSC_VER +# define S_IXUSR _S_IEXEC +# define stat _stat +# ifndef _INTPTR_T_DEFINED +# define intptr_t int +# endif +#endif + +#ifndef DIR_SEPARATOR +# define DIR_SEPARATOR '/' +# define PATH_SEPARATOR ':' +#endif + +#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ + defined (__OS2__) +# define HAVE_DOS_BASED_FILE_SYSTEM +# define FOPEN_WB "wb" +# ifndef DIR_SEPARATOR_2 +# define DIR_SEPARATOR_2 '\\' +# endif +# ifndef PATH_SEPARATOR_2 +# define PATH_SEPARATOR_2 ';' +# endif +#endif + +#ifndef DIR_SEPARATOR_2 +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) +#else /* DIR_SEPARATOR_2 */ +# define IS_DIR_SEPARATOR(ch) \ + (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) +#endif /* DIR_SEPARATOR_2 */ + +#ifndef PATH_SEPARATOR_2 +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) +#else /* PATH_SEPARATOR_2 */ +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) +#endif /* PATH_SEPARATOR_2 */ + +#ifdef __CYGWIN__ +# define FOPEN_WB "wb" +#endif + +#ifndef FOPEN_WB +# define FOPEN_WB "w" +#endif +#ifndef _O_BINARY +# define _O_BINARY 0 +#endif + +#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) +#define XFREE(stale) do { \ + if (stale) { free ((void *) stale); stale = 0; } \ +} while (0) + +#undef LTWRAPPER_DEBUGPRINTF +#if defined DEBUGWRAPPER +# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args +static void +ltwrapper_debugprintf (const char *fmt, ...) +{ + va_list args; + va_start (args, fmt); + (void) vfprintf (stderr, fmt, args); + va_end (args); +} +#else +# define LTWRAPPER_DEBUGPRINTF(args) +#endif + +const char *program_name = NULL; + +void *xmalloc (size_t num); +char *xstrdup (const char *string); +const char *base_name (const char *name); +char *find_executable (const char *wrapper); +char *chase_symlinks (const char *pathspec); +int make_executable (const char *path); +int check_executable (const char *path); +char *strendzap (char *str, const char *pat); +void lt_fatal (const char *message, ...); +void lt_setenv (const char *name, const char *value); +char *lt_extend_str (const char *orig_value, const char *add, int to_end); +void lt_opt_process_env_set (const char *arg); +void lt_opt_process_env_prepend (const char *arg); +void lt_opt_process_env_append (const char *arg); +int lt_split_name_value (const char *arg, char** name, char** value); +void lt_update_exe_path (const char *name, const char *value); +void lt_update_lib_path (const char *name, const char *value); + +static const char *script_text_part1 = +EOF + + func_emit_wrapper_part1 yes | + $SED -e 's/\([\\"]\)/\\\1/g' \ + -e 's/^/ "/' -e 's/$/\\n"/' + echo ";" + cat <"))); + for (i = 0; i < newargc; i++) + { + LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, (newargz[i] ? newargz[i] : ""))); + } + +EOF + + case $host_os in + mingw*) + cat <<"EOF" + /* execv doesn't actually work on mingw as expected on unix */ + rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); + if (rval == -1) + { + /* failed to start process */ + LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno)); + return 127; + } + return rval; +EOF + ;; + *) + cat <<"EOF" + execv (lt_argv_zero, newargz); + return rval; /* =127, but avoids unused variable warning */ +EOF + ;; + esac + + cat <<"EOF" +} + +void * +xmalloc (size_t num) +{ + void *p = (void *) malloc (num); + if (!p) + lt_fatal ("Memory exhausted"); + + return p; +} + +char * +xstrdup (const char *string) +{ + return string ? strcpy ((char *) xmalloc (strlen (string) + 1), + string) : NULL; +} + +const char * +base_name (const char *name) +{ + const char *base; + +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + /* Skip over the disk name in MSDOS pathnames. */ + if (isalpha ((unsigned char) name[0]) && name[1] == ':') + name += 2; +#endif + + for (base = name; *name; name++) + if (IS_DIR_SEPARATOR (*name)) + base = name + 1; + return base; +} + +int +check_executable (const char *path) +{ + struct stat st; + + LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n", + path ? (*path ? path : "EMPTY!") : "NULL!")); + if ((!path) || (!*path)) + return 0; + + if ((stat (path, &st) >= 0) + && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) + return 1; + else + return 0; +} + +int +make_executable (const char *path) +{ + int rval = 0; + struct stat st; + + LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n", + path ? (*path ? path : "EMPTY!") : "NULL!")); + if ((!path) || (!*path)) + return 0; + + if (stat (path, &st) >= 0) + { + rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); + } + return rval; +} + +/* Searches for the full path of the wrapper. Returns + newly allocated full path name if found, NULL otherwise + Does not chase symlinks, even on platforms that support them. +*/ +char * +find_executable (const char *wrapper) +{ + int has_slash = 0; + const char *p; + const char *p_next; + /* static buffer for getcwd */ + char tmp[LT_PATHMAX + 1]; + int tmp_len; + char *concat_name; + + LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n", + wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!")); + + if ((wrapper == NULL) || (*wrapper == '\0')) + return NULL; + + /* Absolute path? */ +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') + { + concat_name = xstrdup (wrapper); + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } + else + { +#endif + if (IS_DIR_SEPARATOR (wrapper[0])) + { + concat_name = xstrdup (wrapper); + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + } +#endif + + for (p = wrapper; *p; p++) + if (*p == '/') + { + has_slash = 1; + break; + } + if (!has_slash) + { + /* no slashes; search PATH */ + const char *path = getenv ("PATH"); + if (path != NULL) + { + for (p = path; *p; p = p_next) + { + const char *q; + size_t p_len; + for (q = p; *q; q++) + if (IS_PATH_SEPARATOR (*q)) + break; + p_len = q - p; + p_next = (*q == '\0' ? q : q + 1); + if (p_len == 0) + { + /* empty path: current directory */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + tmp_len = strlen (tmp); + concat_name = + XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + } + else + { + concat_name = + XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, p, p_len); + concat_name[p_len] = '/'; + strcpy (concat_name + p_len + 1, wrapper); + } + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } + } + /* not found in PATH; assume curdir */ + } + /* Relative path | not found in path: prepend cwd */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + tmp_len = strlen (tmp); + concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + return NULL; +} + +char * +chase_symlinks (const char *pathspec) +{ +#ifndef S_ISLNK + return xstrdup (pathspec); +#else + char buf[LT_PATHMAX]; + struct stat s; + char *tmp_pathspec = xstrdup (pathspec); + char *p; + int has_symlinks = 0; + while (strlen (tmp_pathspec) && !has_symlinks) + { + LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n", + tmp_pathspec)); + if (lstat (tmp_pathspec, &s) == 0) + { + if (S_ISLNK (s.st_mode) != 0) + { + has_symlinks = 1; + break; + } + + /* search backwards for last DIR_SEPARATOR */ + p = tmp_pathspec + strlen (tmp_pathspec) - 1; + while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + p--; + if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + { + /* no more DIR_SEPARATORS left */ + break; + } + *p = '\0'; + } + else + { + char *errstr = strerror (errno); + lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr); + } + } + XFREE (tmp_pathspec); + + if (!has_symlinks) + { + return xstrdup (pathspec); + } + + tmp_pathspec = realpath (pathspec, buf); + if (tmp_pathspec == 0) + { + lt_fatal ("Could not follow symlinks for %s", pathspec); + } + return xstrdup (tmp_pathspec); +#endif +} + +char * +strendzap (char *str, const char *pat) +{ + size_t len, patlen; + + assert (str != NULL); + assert (pat != NULL); + + len = strlen (str); + patlen = strlen (pat); + + if (patlen <= len) + { + str += len - patlen; + if (strcmp (str, pat) == 0) + *str = '\0'; + } + return str; +} + +static void +lt_error_core (int exit_status, const char *mode, + const char *message, va_list ap) +{ + fprintf (stderr, "%s: %s: ", program_name, mode); + vfprintf (stderr, message, ap); + fprintf (stderr, ".\n"); + + if (exit_status >= 0) + exit (exit_status); +} + +void +lt_fatal (const char *message, ...) +{ + va_list ap; + va_start (ap, message); + lt_error_core (EXIT_FAILURE, "FATAL", message, ap); + va_end (ap); +} + +void +lt_setenv (const char *name, const char *value) +{ + LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n", + (name ? name : ""), + (value ? value : ""))); + { +#ifdef HAVE_SETENV + /* always make a copy, for consistency with !HAVE_SETENV */ + char *str = xstrdup (value); + setenv (name, str, 1); +#else + int len = strlen (name) + 1 + strlen (value) + 1; + char *str = XMALLOC (char, len); + sprintf (str, "%s=%s", name, value); + if (putenv (str) != EXIT_SUCCESS) + { + XFREE (str); + } +#endif + } +} + +char * +lt_extend_str (const char *orig_value, const char *add, int to_end) +{ + char *new_value; + if (orig_value && *orig_value) + { + int orig_value_len = strlen (orig_value); + int add_len = strlen (add); + new_value = XMALLOC (char, add_len + orig_value_len + 1); + if (to_end) + { + strcpy (new_value, orig_value); + strcpy (new_value + orig_value_len, add); + } + else + { + strcpy (new_value, add); + strcpy (new_value + add_len, orig_value); + } + } + else + { + new_value = xstrdup (add); + } + return new_value; +} + +int +lt_split_name_value (const char *arg, char** name, char** value) +{ + const char *p; + int len; + if (!arg || !*arg) + return 1; + + p = strchr (arg, (int)'='); + + if (!p) + return 1; + + *value = xstrdup (++p); + + len = strlen (arg) - strlen (*value); + *name = XMALLOC (char, len); + strncpy (*name, arg, len-1); + (*name)[len - 1] = '\0'; + + return 0; +} + +void +lt_opt_process_env_set (const char *arg) +{ + char *name = NULL; + char *value = NULL; + + if (lt_split_name_value (arg, &name, &value) != 0) + { + XFREE (name); + XFREE (value); + lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg); + } + + lt_setenv (name, value); + XFREE (name); + XFREE (value); +} + +void +lt_opt_process_env_prepend (const char *arg) +{ + char *name = NULL; + char *value = NULL; + char *new_value = NULL; + + if (lt_split_name_value (arg, &name, &value) != 0) + { + XFREE (name); + XFREE (value); + lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg); + } + + new_value = lt_extend_str (getenv (name), value, 0); + lt_setenv (name, new_value); + XFREE (new_value); + XFREE (name); + XFREE (value); +} + +void +lt_opt_process_env_append (const char *arg) +{ + char *name = NULL; + char *value = NULL; + char *new_value = NULL; + + if (lt_split_name_value (arg, &name, &value) != 0) + { + XFREE (name); + XFREE (value); + lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg); + } + + new_value = lt_extend_str (getenv (name), value, 1); + lt_setenv (name, new_value); + XFREE (new_value); + XFREE (name); + XFREE (value); +} + +void +lt_update_exe_path (const char *name, const char *value) +{ + LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n", + (name ? name : ""), + (value ? value : ""))); + + if (name && *name && value && *value) + { + char *new_value = lt_extend_str (getenv (name), value, 0); + /* some systems can't cope with a ':'-terminated path #' */ + int len = strlen (new_value); + while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) + { + new_value[len-1] = '\0'; + } + lt_setenv (name, new_value); + XFREE (new_value); + } +} + +void +lt_update_lib_path (const char *name, const char *value) +{ + LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n", + (name ? name : ""), + (value ? value : ""))); + + if (name && *name && value && *value) + { + char *new_value = lt_extend_str (getenv (name), value, 0); + lt_setenv (name, new_value); + XFREE (new_value); + } +} + + +EOF +} +# end: func_emit_cwrapperexe_src + +# func_mode_link arg... +func_mode_link () +{ + $opt_debug + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + # It is impossible to link a dll without this setting, and + # we shouldn't force the makefile maintainer to figure out + # which system we are compiling for in order to pass an extra + # flag for every libtool invocation. + # allow_undefined=no + + # FIXME: Unfortunately, there are problems with the above when trying + # to make a dll which has undefined symbols, in which case not + # even a static library is built. For now, we need to specify + # -no-undefined on the libtool link line when we can be certain + # that all symbols are satisfied, otherwise we get a static library. + allow_undefined=yes + ;; + *) + allow_undefined=yes + ;; + esac + libtool_args=$nonopt + base_compile="$nonopt $@" + compile_command=$nonopt + finalize_command=$nonopt + + compile_rpath= + finalize_rpath= + compile_shlibpath= + finalize_shlibpath= + convenience= + old_convenience= + deplibs= + old_deplibs= + compiler_flags= + linker_flags= + dllsearchpath= + lib_search_path=`pwd` + inst_prefix_dir= + new_inherited_linker_flags= + + avoid_version=no + dlfiles= + dlprefiles= + dlself=no + export_dynamic=no + export_symbols= + export_symbols_regex= + generated= + libobjs= + ltlibs= + module=no + no_install=no + objs= + non_pic_objects= + precious_files_regex= + prefer_static_libs=no + preload=no + prev= + prevarg= + release= + rpath= + xrpath= + perm_rpath= + temp_rpath= + thread_safe=no + vinfo= + vinfo_number=no + weak_libs= + single_module="${wl}-single_module" + func_infer_tag $base_compile + + # We need to know -static, to get the right output filenames. + for arg + do + case $arg in + -shared) + test "$build_libtool_libs" != yes && \ + func_fatal_configuration "can not build a shared library" + build_old_libs=no + break + ;; + -all-static | -static | -static-libtool-libs) + case $arg in + -all-static) + if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then + func_warning "complete static linking is impossible in this configuration" + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + -static) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=built + ;; + -static-libtool-libs) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + esac + build_libtool_libs=no + build_old_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test "$#" -gt 0; do + arg="$1" + shift + func_quote_for_eval "$arg" + qarg=$func_quote_for_eval_unquoted_result + func_append libtool_args " $func_quote_for_eval_result" + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + output) + func_append compile_command " @OUTPUT@" + func_append finalize_command " @OUTPUT@" + ;; + esac + + case $prev in + dlfiles|dlprefiles) + if test "$preload" = no; then + # Add the symbol object into the linking commands. + func_append compile_command " @SYMFILE@" + func_append finalize_command " @SYMFILE@" + preload=yes + fi + case $arg in + *.la | *.lo) ;; # We handle these cases below. + force) + if test "$dlself" = no; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test "$prev" = dlprefiles; then + dlself=yes + elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + else + dlprefiles="$dlprefiles $arg" + fi + prev= + continue + ;; + esac + ;; + expsyms) + export_symbols="$arg" + test -f "$arg" \ + || func_fatal_error "symbol file \`$arg' does not exist" + prev= + continue + ;; + expsyms_regex) + export_symbols_regex="$arg" + prev= + continue + ;; + framework) + case $host in + *-*-darwin*) + case "$deplibs " in + *" $qarg.ltframework "*) ;; + *) deplibs="$deplibs $qarg.ltframework" # this is fixed later + ;; + esac + ;; + esac + prev= + continue + ;; + inst_prefix) + inst_prefix_dir="$arg" + prev= + continue + ;; + objectlist) + if test -f "$arg"; then + save_arg=$arg + moreargs= + for fil in `cat "$save_arg"` + do +# moreargs="$moreargs $fil" + arg=$fil + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if func_lalib_unsafe_p "$arg"; then + pic_object= + non_pic_object= + + # Read the .lo file + func_source "$arg" + + if test -z "$pic_object" || + test -z "$non_pic_object" || + test "$pic_object" = none && + test "$non_pic_object" = none; then + func_fatal_error "cannot find name of object for \`$arg'" + fi + + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir="$func_dirname_result" + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + func_append libobjs " $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + func_append non_pic_objects " $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object="$pic_object" + func_append non_pic_objects " $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if $opt_dry_run; then + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir="$func_dirname_result" + + func_lo2o "$arg" + pic_object=$xdir$objdir/$func_lo2o_result + non_pic_object=$xdir$func_lo2o_result + func_append libobjs " $pic_object" + func_append non_pic_objects " $non_pic_object" + else + func_fatal_error "\`$arg' is not a valid libtool object" + fi + fi + done + else + func_fatal_error "link input file \`$arg' does not exist" + fi + arg=$save_arg + prev= + continue + ;; + precious_regex) + precious_files_regex="$arg" + prev= + continue + ;; + release) + release="-$arg" + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case $arg in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + func_fatal_error "only absolute run-paths are allowed" + ;; + esac + if test "$prev" = rpath; then + case "$rpath " in + *" $arg "*) ;; + *) rpath="$rpath $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) xrpath="$xrpath $arg" ;; + esac + fi + prev= + continue + ;; + shrext) + shrext_cmds="$arg" + prev= + continue + ;; + weak) + weak_libs="$weak_libs $arg" + prev= + continue + ;; + xcclinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $qarg" + prev= + func_append compile_command " $qarg" + func_append finalize_command " $qarg" + continue + ;; + xcompiler) + compiler_flags="$compiler_flags $qarg" + prev= + func_append compile_command " $qarg" + func_append finalize_command " $qarg" + continue + ;; + xlinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $wl$qarg" + prev= + func_append compile_command " $wl$qarg" + func_append finalize_command " $wl$qarg" + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi # test -n "$prev" + + prevarg="$arg" + + case $arg in + -all-static) + if test -n "$link_static_flag"; then + # See comment for -static flag below, for more details. + func_append compile_command " $link_static_flag" + func_append finalize_command " $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + func_fatal_error "\`-allow-undefined' must not be used because it is the default" + ;; + + -avoid-version) + avoid_version=yes + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + func_fatal_error "more than one -exported-symbols argument is not allowed" + fi + if test "X$arg" = "X-export-symbols"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -framework) + prev=framework + continue + ;; + + -inst-prefix-dir) + prev=inst_prefix + continue + ;; + + # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* + # so, if we see these flags be careful not to treat them like -L + -L[A-Z][A-Z]*:*) + case $with_gcc/$host in + no/*-*-irix* | /*-*-irix*) + func_append compile_command " $arg" + func_append finalize_command " $arg" + ;; + esac + continue + ;; + + -L*) + func_stripname '-L' '' "$arg" + dir=$func_stripname_result + if test -z "$dir"; then + if test "$#" -gt 0; then + func_fatal_error "require no space between \`-L' and \`$1'" + else + func_fatal_error "need path for \`-L' option" + fi + fi + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + test -z "$absdir" && \ + func_fatal_error "cannot determine absolute directory name of \`$dir'" + dir="$absdir" + ;; + esac + case "$deplibs " in + *" -L$dir "*) ;; + *) + deplibs="$deplibs -L$dir" + lib_search_path="$lib_search_path $dir" + ;; + esac + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$dir:"*) ;; + ::) dllsearchpath=$dir;; + *) dllsearchpath="$dllsearchpath:$dir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + ::) dllsearchpath=$testbindir;; + *) dllsearchpath="$dllsearchpath:$testbindir";; + esac + ;; + esac + continue + ;; + + -l*) + if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*) + # These systems don't actually have a C or math library (as such) + continue + ;; + *-*-os2*) + # These systems don't actually have a C library (as such) + test "X$arg" = "X-lc" && continue + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc due to us having libc/libc_r. + test "X$arg" = "X-lc" && continue + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C and math libraries are in the System framework + deplibs="$deplibs System.ltframework" + continue + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + test "X$arg" = "X-lc" && continue + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + test "X$arg" = "X-lc" && continue + ;; + esac + elif test "X$arg" = "X-lc_r"; then + case $host in + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; + esac + fi + deplibs="$deplibs $arg" + continue + ;; + + -module) + module=yes + continue + ;; + + # Tru64 UNIX uses -model [arg] to determine the layout of C++ + # classes, name mangling, and exception handling. + # Darwin uses the -arch flag to determine output architecture. + -model|-arch|-isysroot) + compiler_flags="$compiler_flags $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + prev=xcompiler + continue + ;; + + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) + compiler_flags="$compiler_flags $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + case "$new_inherited_linker_flags " in + *" $arg "*) ;; + * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;; + esac + continue + ;; + + -multi_module) + single_module="${wl}-multi_module" + continue + ;; + + -no-fast-install) + fast_install=no + continue + ;; + + -no-install) + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) + # The PATH hackery in wrapper scripts is required on Windows + # and Darwin in order for the loader to find any dlls it needs. + func_warning "\`-no-install' is ignored for $host" + func_warning "assuming \`-no-fast-install' instead" + fast_install=no + ;; + *) no_install=yes ;; + esac + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -objectlist) + prev=objectlist + continue + ;; + + -o) prev=output ;; + + -precious-files-regex) + prev=precious_regex + continue + ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + func_stripname '-R' '' "$arg" + dir=$func_stripname_result + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + func_fatal_error "only absolute run-paths are allowed" + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + continue + ;; + + -shared) + # The effects of -shared are defined in a previous loop. + continue + ;; + + -shrext) + prev=shrext + continue + ;; + + -static | -static-libtool-libs) + # The effects of -static are defined in a previous loop. + # We used to do the same as -all-static on platforms that + # didn't have a PIC flag, but the assumption that the effects + # would be equivalent was wrong. It would break on at least + # Digital Unix and AIX. + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + + -version-number) + prev=vinfo + vinfo_number=yes + continue + ;; + + -weak) + prev=weak + continue + ;; + + -Wc,*) + func_stripname '-Wc,' '' "$arg" + args=$func_stripname_result + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + func_quote_for_eval "$flag" + arg="$arg $wl$func_quote_for_eval_result" + compiler_flags="$compiler_flags $func_quote_for_eval_result" + done + IFS="$save_ifs" + func_stripname ' ' '' "$arg" + arg=$func_stripname_result + ;; + + -Wl,*) + func_stripname '-Wl,' '' "$arg" + args=$func_stripname_result + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + func_quote_for_eval "$flag" + arg="$arg $wl$func_quote_for_eval_result" + compiler_flags="$compiler_flags $wl$func_quote_for_eval_result" + linker_flags="$linker_flags $func_quote_for_eval_result" + done + IFS="$save_ifs" + func_stripname ' ' '' "$arg" + arg=$func_stripname_result + ;; + + -Xcompiler) + prev=xcompiler + continue + ;; + + -Xlinker) + prev=xlinker + continue + ;; + + -XCClinker) + prev=xcclinker + continue + ;; + + # -msg_* for osf cc + -msg_*) + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + ;; + + # -64, -mips[0-9] enable 64-bit mode on the SGI compiler + # -r[0-9][0-9]* specifies the processor on the SGI compiler + # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler + # +DA*, +DD* enable 64-bit mode on the HP compiler + # -q* pass through compiler args for the IBM compiler + # -m*, -t[45]*, -txscale* pass through architecture-specific + # compiler args for GCC + # -F/path gives path to uninstalled frameworks, gcc on darwin + # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC + # @file GCC response files + -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ + -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*) + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + func_append compile_command " $arg" + func_append finalize_command " $arg" + compiler_flags="$compiler_flags $arg" + continue + ;; + + # Some other compiler flag. + -* | +*) + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + ;; + + *.$objext) + # A standard object. + objs="$objs $arg" + ;; + + *.lo) + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if func_lalib_unsafe_p "$arg"; then + pic_object= + non_pic_object= + + # Read the .lo file + func_source "$arg" + + if test -z "$pic_object" || + test -z "$non_pic_object" || + test "$pic_object" = none && + test "$non_pic_object" = none; then + func_fatal_error "cannot find name of object for \`$arg'" + fi + + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir="$func_dirname_result" + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + func_append libobjs " $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + func_append non_pic_objects " $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object="$pic_object" + func_append non_pic_objects " $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if $opt_dry_run; then + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir="$func_dirname_result" + + func_lo2o "$arg" + pic_object=$xdir$objdir/$func_lo2o_result + non_pic_object=$xdir$func_lo2o_result + func_append libobjs " $pic_object" + func_append non_pic_objects " $non_pic_object" + else + func_fatal_error "\`$arg' is not a valid libtool object" + fi + fi + ;; + + *.$libext) + # An archive. + deplibs="$deplibs $arg" + old_deplibs="$old_deplibs $arg" + continue + ;; + + *.la) + # A libtool-controlled library. + + if test "$prev" = dlfiles; then + # This library was specified with -dlopen. + dlfiles="$dlfiles $arg" + prev= + elif test "$prev" = dlprefiles; then + # The library was specified with -dlpreopen. + dlprefiles="$dlprefiles $arg" + prev= + else + deplibs="$deplibs $arg" + fi + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + ;; + esac # arg + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + func_append compile_command " $arg" + func_append finalize_command " $arg" + fi + done # argument parsing loop + + test -n "$prev" && \ + func_fatal_help "the \`$prevarg' option requires an argument" + + if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + func_append compile_command " $arg" + func_append finalize_command " $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + func_basename "$output" + outputname="$func_basename_result" + libobjs_save="$libobjs" + + if test -n "$shlibpath_var"; then + # get the directories listed in $shlibpath_var + eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` + else + shlib_search_path= + fi + eval sys_lib_search_path=\"$sys_lib_search_path_spec\" + eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" + + func_dirname "$output" "/" "" + output_objdir="$func_dirname_result$objdir" + # Create the object directory. + func_mkdir_p "$output_objdir" + + # Determine the type of output + case $output in + "") + func_fatal_help "you must specify an output file" + ;; + *.$libext) linkmode=oldlib ;; + *.lo | *.$objext) linkmode=obj ;; + *.la) linkmode=lib ;; + *) linkmode=prog ;; # Anything else should be a program. + esac + + specialdeplibs= + + libs= + # Find all interdependent deplibs by searching for libraries + # that are linked more than once (e.g. -la -lb -la) + for deplib in $deplibs; do + if $opt_duplicate_deps ; then + case "$libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + libs="$libs $deplib" + done + + if test "$linkmode" = lib; then + libs="$predeps $libs $compiler_lib_search_path $postdeps" + + # Compute libraries that are listed more than once in $predeps + # $postdeps and mark them as special (i.e., whose duplicates are + # not to be eliminated). + pre_post_deps= + if $opt_duplicate_compiler_generated_deps; then + for pre_post_dep in $predeps $postdeps; do + case "$pre_post_deps " in + *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; + esac + pre_post_deps="$pre_post_deps $pre_post_dep" + done + fi + pre_post_deps= + fi + + deplibs= + newdependency_libs= + newlib_search_path= + need_relink=no # whether we're linking any uninstalled libtool libraries + notinst_deplibs= # not-installed libtool libraries + notinst_path= # paths that contain not-installed libtool libraries + + case $linkmode in + lib) + passes="conv dlpreopen link" + for file in $dlfiles $dlprefiles; do + case $file in + *.la) ;; + *) + func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" + ;; + esac + done + ;; + prog) + compile_deplibs= + finalize_deplibs= + alldeplibs=no + newdlfiles= + newdlprefiles= + passes="conv scan dlopen dlpreopen link" + ;; + *) passes="conv" + ;; + esac + + for pass in $passes; do + # The preopen pass in lib mode reverses $deplibs; put it back here + # so that -L comes before libs that need it for instance... + if test "$linkmode,$pass" = "lib,link"; then + ## FIXME: Find the place where the list is rebuilt in the wrong + ## order, and fix it there properly + tmp_deplibs= + for deplib in $deplibs; do + tmp_deplibs="$deplib $tmp_deplibs" + done + deplibs="$tmp_deplibs" + fi + + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan"; then + libs="$deplibs" + deplibs= + fi + if test "$linkmode" = prog; then + case $pass in + dlopen) libs="$dlfiles" ;; + dlpreopen) libs="$dlprefiles" ;; + link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; + esac + fi + if test "$linkmode,$pass" = "lib,dlpreopen"; then + # Collect and forward deplibs of preopened libtool libs + for lib in $dlprefiles; do + # Ignore non-libtool-libs + dependency_libs= + case $lib in + *.la) func_source "$lib" ;; + esac + + # Collect preopened libtool deplibs, except any this library + # has declared as weak libs + for deplib in $dependency_libs; do + deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"` + case " $weak_libs " in + *" $deplib_base "*) ;; + *) deplibs="$deplibs $deplib" ;; + esac + done + done + libs="$dlprefiles" + fi + if test "$pass" = dlopen; then + # Collect dlpreopened libraries + save_deplibs="$deplibs" + deplibs= + fi + + for deplib in $libs; do + lib= + found=no + case $deplib in + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + compiler_flags="$compiler_flags $deplib" + if test "$linkmode" = lib ; then + case "$new_inherited_linker_flags " in + *" $deplib "*) ;; + * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; + esac + fi + fi + continue + ;; + -l*) + if test "$linkmode" != lib && test "$linkmode" != prog; then + func_warning "\`-l' is ignored for archives/objects" + continue + fi + func_stripname '-l' '' "$deplib" + name=$func_stripname_result + if test "$linkmode" = lib; then + searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" + else + searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" + fi + for searchdir in $searchdirs; do + for search_ext in .la $std_shrext .so .a; do + # Search the libtool library + lib="$searchdir/lib${name}${search_ext}" + if test -f "$lib"; then + if test "$search_ext" = ".la"; then + found=yes + else + found=no + fi + break 2 + fi + done + done + if test "$found" != yes; then + # deplib doesn't seem to be a libtool library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + else # deplib is a libtool library + # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, + # We need to do some special things here, and not later. + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $deplib "*) + if func_lalib_p "$lib"; then + library_names= + old_library= + func_source "$lib" + for l in $old_library $library_names; do + ll="$l" + done + if test "X$ll" = "X$old_library" ; then # only static version available + found=no + func_dirname "$lib" "" "." + ladir="$func_dirname_result" + lib=$ladir/$old_library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + fi + ;; + *) ;; + esac + fi + fi + ;; # -l + *.ltframework) + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + if test "$linkmode" = lib ; then + case "$new_inherited_linker_flags " in + *" $deplib "*) ;; + * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; + esac + fi + fi + continue + ;; + -L*) + case $linkmode in + lib) + deplibs="$deplib $deplibs" + test "$pass" = conv && continue + newdependency_libs="$deplib $newdependency_libs" + func_stripname '-L' '' "$deplib" + newlib_search_path="$newlib_search_path $func_stripname_result" + ;; + prog) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + if test "$pass" = scan; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + func_stripname '-L' '' "$deplib" + newlib_search_path="$newlib_search_path $func_stripname_result" + ;; + *) + func_warning "\`-L' is ignored for archives/objects" + ;; + esac # linkmode + continue + ;; # -L + -R*) + if test "$pass" = link; then + func_stripname '-R' '' "$deplib" + dir=$func_stripname_result + # Make sure the xrpath contains only unique directories. + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + fi + deplibs="$deplib $deplibs" + continue + ;; + *.la) lib="$deplib" ;; + *.$libext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + case $linkmode in + lib) + # Linking convenience modules into shared libraries is allowed, + # but linking other static libraries is non-portable. + case " $dlpreconveniencelibs " in + *" $deplib "*) ;; + *) + valid_a_lib=no + case $deplibs_check_method in + match_pattern*) + set dummy $deplibs_check_method; shift + match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` + if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + valid_a_lib=yes + fi + ;; + pass_all) + valid_a_lib=yes + ;; + esac + if test "$valid_a_lib" != yes; then + $ECHO + $ECHO "*** Warning: Trying to link with static lib archive $deplib." + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which you do not appear to have" + $ECHO "*** because the file extensions .$libext of this argument makes me believe" + $ECHO "*** that it is just a static archive that I should not use here." + else + $ECHO + $ECHO "*** Warning: Linking the shared library $output against the" + $ECHO "*** static library $deplib is not portable!" + deplibs="$deplib $deplibs" + fi + ;; + esac + continue + ;; + prog) + if test "$pass" != link; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + continue + ;; + esac # linkmode + ;; # *.$libext + *.lo | *.$objext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + elif test "$linkmode" = prog; then + if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then + # If there is no dlopen support or we're linking statically, + # we need to preload. + newdlprefiles="$newdlprefiles $deplib" + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + newdlfiles="$newdlfiles $deplib" + fi + fi + continue + ;; + %DEPLIBS%) + alldeplibs=yes + continue + ;; + esac # case $deplib + + if test "$found" = yes || test -f "$lib"; then : + else + func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" + fi + + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$lib" \ + || func_fatal_error "\`$lib' is not a valid libtool archive" + + func_dirname "$lib" "" "." + ladir="$func_dirname_result" + + dlname= + dlopen= + dlpreopen= + libdir= + library_names= + old_library= + inherited_linker_flags= + # If the library was installed with an old release of libtool, + # it will not redefine variables installed, or shouldnotlink + installed=yes + shouldnotlink=no + avoidtemprpath= + + + # Read the .la file + func_source "$lib" + + # Convert "-framework foo" to "foo.ltframework" + if test -n "$inherited_linker_flags"; then + tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'` + for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do + case " $new_inherited_linker_flags " in + *" $tmp_inherited_linker_flag "*) ;; + *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";; + esac + done + fi + dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan" || + { test "$linkmode" != prog && test "$linkmode" != lib; }; then + test -n "$dlopen" && dlfiles="$dlfiles $dlopen" + test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" + fi + + if test "$pass" = conv; then + # Only check for convenience libraries + deplibs="$lib $deplibs" + if test -z "$libdir"; then + if test -z "$old_library"; then + func_fatal_error "cannot find name of link library for \`$lib'" + fi + # It is a libtool convenience library, so add in its objects. + convenience="$convenience $ladir/$objdir/$old_library" + old_convenience="$old_convenience $ladir/$objdir/$old_library" + elif test "$linkmode" != prog && test "$linkmode" != lib; then + func_fatal_error "\`$lib' is not a convenience library" + fi + tmp_libs= + for deplib in $dependency_libs; do + deplibs="$deplib $deplibs" + if $opt_duplicate_deps ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + continue + fi # $pass = conv + + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + if test -z "$linklib"; then + func_fatal_error "cannot find name of link library for \`$lib'" + fi + + # This library was specified with -dlopen. + if test "$pass" = dlopen; then + if test -z "$libdir"; then + func_fatal_error "cannot -dlopen a convenience library: \`$lib'" + fi + if test -z "$dlname" || + test "$dlopen_support" != yes || + test "$build_libtool_libs" = no; then + # If there is no dlname, no dlopen support or we're linking + # statically, we need to preload. We also need to preload any + # dependent libraries so libltdl's deplib preloader doesn't + # bomb out in the load deplibs phase. + dlprefiles="$dlprefiles $lib $dependency_libs" + else + newdlfiles="$newdlfiles $lib" + fi + continue + fi # $pass = dlopen + + # We need an absolute path. + case $ladir in + [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; + *) + abs_ladir=`cd "$ladir" && pwd` + if test -z "$abs_ladir"; then + func_warning "cannot determine absolute directory name of \`$ladir'" + func_warning "passing it literally to the linker, although it might fail" + abs_ladir="$ladir" + fi + ;; + esac + func_basename "$lib" + laname="$func_basename_result" + + # Find the relevant object directory and library name. + if test "X$installed" = Xyes; then + if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then + func_warning "library \`$lib' was moved." + dir="$ladir" + absdir="$abs_ladir" + libdir="$abs_ladir" + else + dir="$libdir" + absdir="$libdir" + fi + test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes + else + if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then + dir="$ladir" + absdir="$abs_ladir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + else + dir="$ladir/$objdir" + absdir="$abs_ladir/$objdir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + fi + fi # $installed = yes + func_stripname 'lib' '.la' "$laname" + name=$func_stripname_result + + # This library was specified with -dlpreopen. + if test "$pass" = dlpreopen; then + if test -z "$libdir" && test "$linkmode" = prog; then + func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" + fi + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + newdlprefiles="$newdlprefiles $dir/$old_library" + # Keep a list of preopened convenience libraries to check + # that they are being used correctly in the link pass. + test -z "$libdir" && \ + dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library" + # Otherwise, use the dlname, so that lt_dlopen finds it. + elif test -n "$dlname"; then + newdlprefiles="$newdlprefiles $dir/$dlname" + else + newdlprefiles="$newdlprefiles $dir/$linklib" + fi + fi # $pass = dlpreopen + + if test -z "$libdir"; then + # Link the convenience library + if test "$linkmode" = lib; then + deplibs="$dir/$old_library $deplibs" + elif test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$dir/$old_library $compile_deplibs" + finalize_deplibs="$dir/$old_library $finalize_deplibs" + else + deplibs="$lib $deplibs" # used for prog,scan pass + fi + continue + fi + + + if test "$linkmode" = prog && test "$pass" != link; then + newlib_search_path="$newlib_search_path $ladir" + deplibs="$lib $deplibs" + + linkalldeplibs=no + if test "$link_all_deplibs" != no || test -z "$library_names" || + test "$build_libtool_libs" = no; then + linkalldeplibs=yes + fi + + tmp_libs= + for deplib in $dependency_libs; do + case $deplib in + -L*) func_stripname '-L' '' "$deplib" + newlib_search_path="$newlib_search_path $func_stripname_result" + ;; + esac + # Need to link against all dependency_libs? + if test "$linkalldeplibs" = yes; then + deplibs="$deplib $deplibs" + else + # Need to hardcode shared library paths + # or/and link against static libraries + newdependency_libs="$deplib $newdependency_libs" + fi + if $opt_duplicate_deps ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done # for deplib + continue + fi # $linkmode = prog... + + if test "$linkmode,$pass" = "prog,link"; then + if test -n "$library_names" && + { { test "$prefer_static_libs" = no || + test "$prefer_static_libs,$installed" = "built,yes"; } || + test -z "$old_library"; }; then + # We need to hardcode the library path + if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath:" in + *"$absdir:"*) ;; + *) temp_rpath="$temp_rpath$absdir:" ;; + esac + fi + + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi # $linkmode,$pass = prog,link... + + if test "$alldeplibs" = yes && + { test "$deplibs_check_method" = pass_all || + { test "$build_libtool_libs" = yes && + test -n "$library_names"; }; }; then + # We only need to search for static libraries + continue + fi + fi + + link_static=no # Whether the deplib will be linked statically + use_static_libs=$prefer_static_libs + if test "$use_static_libs" = built && test "$installed" = yes; then + use_static_libs=no + fi + if test -n "$library_names" && + { test "$use_static_libs" = no || test -z "$old_library"; }; then + case $host in + *cygwin* | *mingw* | *cegcc*) + # No point in relinking DLLs because paths are not encoded + notinst_deplibs="$notinst_deplibs $lib" + need_relink=no + ;; + *) + if test "$installed" = no; then + notinst_deplibs="$notinst_deplibs $lib" + need_relink=yes + fi + ;; + esac + # This is a shared library + + # Warn about portability, can't link against -module's on some + # systems (darwin). Don't bleat about dlopened modules though! + dlopenmodule="" + for dlpremoduletest in $dlprefiles; do + if test "X$dlpremoduletest" = "X$lib"; then + dlopenmodule="$dlpremoduletest" + break + fi + done + if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then + $ECHO + if test "$linkmode" = prog; then + $ECHO "*** Warning: Linking the executable $output against the loadable module" + else + $ECHO "*** Warning: Linking the shared library $output against the loadable module" + fi + $ECHO "*** $linklib is not portable!" + fi + if test "$linkmode" = lib && + test "$hardcode_into_libs" = yes; then + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi + + if test -n "$old_archive_from_expsyms_cmds"; then + # figure out the soname + set dummy $library_names + shift + realname="$1" + shift + libname=`eval "\\$ECHO \"$libname_spec\""` + # use dlname if we got it. it's perfectly good, no? + if test -n "$dlname"; then + soname="$dlname" + elif test -n "$soname_spec"; then + # bleh windows + case $host in + *cygwin* | mingw* | *cegcc*) + func_arith $current - $age + major=$func_arith_result + versuffix="-$major" + ;; + esac + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + + # Make a new name for the extract_expsyms_cmds to use + soroot="$soname" + func_basename "$soroot" + soname="$func_basename_result" + func_stripname 'lib' '.dll' "$soname" + newlib=libimp-$func_stripname_result.a + + # If the library has no export list, then create one now + if test -f "$output_objdir/$soname-def"; then : + else + func_verbose "extracting exported symbol list from \`$soname'" + func_execute_cmds "$extract_expsyms_cmds" 'exit $?' + fi + + # Create $newlib + if test -f "$output_objdir/$newlib"; then :; else + func_verbose "generating import library for \`$soname'" + func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' + fi + # make sure the library variables are pointing to the new library + dir=$output_objdir + linklib=$newlib + fi # test -n "$old_archive_from_expsyms_cmds" + + if test "$linkmode" = prog || test "$mode" != relink; then + add_shlibpath= + add_dir= + add= + lib_linked=yes + case $hardcode_action in + immediate | unsupported) + if test "$hardcode_direct" = no; then + add="$dir/$linklib" + case $host in + *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; + *-*-sysv4*uw2*) add_dir="-L$dir" ;; + *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ + *-*-unixware7*) add_dir="-L$dir" ;; + *-*-darwin* ) + # if the lib is a (non-dlopened) module then we can not + # link against it, someone is ignoring the earlier warnings + if /usr/bin/file -L $add 2> /dev/null | + $GREP ": [^:]* bundle" >/dev/null ; then + if test "X$dlopenmodule" != "X$lib"; then + $ECHO "*** Warning: lib $linklib is a module, not a shared library" + if test -z "$old_library" ; then + $ECHO + $ECHO "*** And there doesn't seem to be a static archive available" + $ECHO "*** The link will probably fail, sorry" + else + add="$dir/$old_library" + fi + elif test -n "$old_library"; then + add="$dir/$old_library" + fi + fi + esac + elif test "$hardcode_minus_L" = no; then + case $host in + *-*-sunos*) add_shlibpath="$dir" ;; + esac + add_dir="-L$dir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = no; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + relink) + if test "$hardcode_direct" = yes && + test "$hardcode_direct_absolute" = no; then + add="$dir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$dir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + *) lib_linked=no ;; + esac + + if test "$lib_linked" != yes; then + func_fatal_configuration "unsupported hardcode properties" + fi + + if test -n "$add_shlibpath"; then + case :$compile_shlibpath: in + *":$add_shlibpath:"*) ;; + *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; + esac + fi + if test "$linkmode" = prog; then + test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" + test -n "$add" && compile_deplibs="$add $compile_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + if test "$hardcode_direct" != yes && + test "$hardcode_minus_L" != yes && + test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + fi + fi + fi + + if test "$linkmode" = prog || test "$mode" = relink; then + add_shlibpath= + add_dir= + add= + # Finalize command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes && + test "$hardcode_direct_absolute" = no; then + add="$libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$libdir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + add="-l$name" + elif test "$hardcode_automatic" = yes; then + if test -n "$inst_prefix_dir" && + test -f "$inst_prefix_dir$libdir/$linklib" ; then + add="$inst_prefix_dir$libdir/$linklib" + else + add="$libdir/$linklib" + fi + else + # We cannot seem to hardcode it, guess we'll fake it. + add_dir="-L$libdir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + fi + + if test "$linkmode" = prog; then + test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" + test -n "$add" && finalize_deplibs="$add $finalize_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + fi + fi + elif test "$linkmode" = prog; then + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test "$hardcode_direct" != unsupported; then + test -n "$old_library" && linklib="$old_library" + compile_deplibs="$dir/$linklib $compile_deplibs" + finalize_deplibs="$dir/$linklib $finalize_deplibs" + else + compile_deplibs="-l$name -L$dir $compile_deplibs" + finalize_deplibs="-l$name -L$dir $finalize_deplibs" + fi + elif test "$build_libtool_libs" = yes; then + # Not a shared library + if test "$deplibs_check_method" != pass_all; then + # We're trying link a shared library against a static one + # but the system doesn't support it. + + # Just print a warning and add the library to dependency_libs so + # that the program can be linked against the static library. + $ECHO + $ECHO "*** Warning: This system can not link to static lib archive $lib." + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which you do not appear to have." + if test "$module" = yes; then + $ECHO "*** But as you try to build a module library, libtool will still create " + $ECHO "*** a static module, that should work as long as the dlopening application" + $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime." + if test -z "$global_symbol_pipe"; then + $ECHO + $ECHO "*** However, this would only work if libtool was able to extract symbol" + $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could" + $ECHO "*** not find such a program. So, this module is probably useless." + $ECHO "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + else + deplibs="$dir/$old_library $deplibs" + link_static=yes + fi + fi # link shared/static library? + + if test "$linkmode" = lib; then + if test -n "$dependency_libs" && + { test "$hardcode_into_libs" != yes || + test "$build_old_libs" = yes || + test "$link_static" = yes; }; then + # Extract -R from dependency_libs + temp_deplibs= + for libdir in $dependency_libs; do + case $libdir in + -R*) func_stripname '-R' '' "$libdir" + temp_xrpath=$func_stripname_result + case " $xrpath " in + *" $temp_xrpath "*) ;; + *) xrpath="$xrpath $temp_xrpath";; + esac;; + *) temp_deplibs="$temp_deplibs $libdir";; + esac + done + dependency_libs="$temp_deplibs" + fi + + newlib_search_path="$newlib_search_path $absdir" + # Link against this library + test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" + # ... and its dependency_libs + tmp_libs= + for deplib in $dependency_libs; do + newdependency_libs="$deplib $newdependency_libs" + if $opt_duplicate_deps ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + + if test "$link_all_deplibs" != no; then + # Add the search paths of all dependency libraries + for deplib in $dependency_libs; do + case $deplib in + -L*) path="$deplib" ;; + *.la) + func_dirname "$deplib" "" "." + dir="$func_dirname_result" + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + func_warning "cannot determine absolute directory name of \`$dir'" + absdir="$dir" + fi + ;; + esac + if $GREP "^installed=no" $deplib > /dev/null; then + case $host in + *-*-darwin*) + depdepl= + eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` + if test -n "$deplibrary_names" ; then + for tmp in $deplibrary_names ; do + depdepl=$tmp + done + if test -f "$absdir/$objdir/$depdepl" ; then + depdepl="$absdir/$objdir/$depdepl" + darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + if test -z "$darwin_install_name"; then + darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + fi + compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" + linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}" + path= + fi + fi + ;; + *) + path="-L$absdir/$objdir" + ;; + esac + else + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + test -z "$libdir" && \ + func_fatal_error "\`$deplib' is not a valid libtool archive" + test "$absdir" != "$libdir" && \ + func_warning "\`$deplib' seems to be moved" + + path="-L$absdir" + fi + ;; + esac + case " $deplibs " in + *" $path "*) ;; + *) deplibs="$path $deplibs" ;; + esac + done + fi # link_all_deplibs != no + fi # linkmode = lib + done # for deplib in $libs + if test "$pass" = link; then + if test "$linkmode" = "prog"; then + compile_deplibs="$new_inherited_linker_flags $compile_deplibs" + finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" + else + compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + fi + fi + dependency_libs="$newdependency_libs" + if test "$pass" = dlpreopen; then + # Link the dlpreopened libraries before other libraries + for deplib in $save_deplibs; do + deplibs="$deplib $deplibs" + done + fi + if test "$pass" != dlopen; then + if test "$pass" != conv; then + # Make sure lib_search_path contains only unique directories. + lib_search_path= + for dir in $newlib_search_path; do + case "$lib_search_path " in + *" $dir "*) ;; + *) lib_search_path="$lib_search_path $dir" ;; + esac + done + newlib_search_path= + fi + + if test "$linkmode,$pass" != "prog,link"; then + vars="deplibs" + else + vars="compile_deplibs finalize_deplibs" + fi + for var in $vars dependency_libs; do + # Add libraries to $var in reverse order + eval tmp_libs=\"\$$var\" + new_libs= + for deplib in $tmp_libs; do + # FIXME: Pedantically, this is the right thing to do, so + # that some nasty dependency loop isn't accidentally + # broken: + #new_libs="$deplib $new_libs" + # Pragmatically, this seems to cause very few problems in + # practice: + case $deplib in + -L*) new_libs="$deplib $new_libs" ;; + -R*) ;; + *) + # And here is the reason: when a library appears more + # than once as an explicit dependence of a library, or + # is implicitly linked in more than once by the + # compiler, it is considered special, and multiple + # occurrences thereof are not removed. Compare this + # with having the same library being listed as a + # dependency of multiple other libraries: in this case, + # we know (pedantically, we assume) the library does not + # need to be listed more than once, so we keep only the + # last copy. This is not always right, but it is rare + # enough that we require users that really mean to play + # such unportable linking tricks to link the library + # using -Wl,-lname, so that libtool does not consider it + # for duplicate removal. + case " $specialdeplibs " in + *" $deplib "*) new_libs="$deplib $new_libs" ;; + *) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$deplib $new_libs" ;; + esac + ;; + esac + ;; + esac + done + tmp_libs= + for deplib in $new_libs; do + case $deplib in + -L*) + case " $tmp_libs " in + *" $deplib "*) ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + done + eval $var=\"$tmp_libs\" + done # for var + fi + # Last step: remove runtime libs from dependency_libs + # (they stay in deplibs) + tmp_libs= + for i in $dependency_libs ; do + case " $predeps $postdeps $compiler_lib_search_path " in + *" $i "*) + i="" + ;; + esac + if test -n "$i" ; then + tmp_libs="$tmp_libs $i" + fi + done + dependency_libs=$tmp_libs + done # for pass + if test "$linkmode" = prog; then + dlfiles="$newdlfiles" + fi + if test "$linkmode" = prog || test "$linkmode" = lib; then + dlprefiles="$newdlprefiles" + fi + + case $linkmode in + oldlib) + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + func_warning "\`-dlopen' is ignored for archives" + fi + + case " $deplibs" in + *\ -l* | *\ -L*) + func_warning "\`-l' and \`-L' are ignored for archives" ;; + esac + + test -n "$rpath" && \ + func_warning "\`-rpath' is ignored for archives" + + test -n "$xrpath" && \ + func_warning "\`-R' is ignored for archives" + + test -n "$vinfo" && \ + func_warning "\`-version-info/-version-number' is ignored for archives" + + test -n "$release" && \ + func_warning "\`-release' is ignored for archives" + + test -n "$export_symbols$export_symbols_regex" && \ + func_warning "\`-export-symbols' is ignored for archives" + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs="$output" + objs="$objs$old_deplibs" + ;; + + lib) + # Make sure we only generate libraries of the form `libNAME.la'. + case $outputname in + lib*) + func_stripname 'lib' '.la' "$outputname" + name=$func_stripname_result + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + ;; + *) + test "$module" = no && \ + func_fatal_help "libtool library \`$output' must begin with \`lib'" + + if test "$need_lib_prefix" != no; then + # Add the "lib" prefix for modules if required + func_stripname '' '.la' "$outputname" + name=$func_stripname_result + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + else + func_stripname '' '.la' "$outputname" + libname=$func_stripname_result + fi + ;; + esac + + if test -n "$objs"; then + if test "$deplibs_check_method" != pass_all; then + func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" + else + $ECHO + $ECHO "*** Warning: Linking the shared library $output against the non-libtool" + $ECHO "*** objects $objs is not portable!" + libobjs="$libobjs $objs" + fi + fi + + test "$dlself" != no && \ + func_warning "\`-dlopen self' is ignored for libtool libraries" + + set dummy $rpath + shift + test "$#" -gt 1 && \ + func_warning "ignoring multiple \`-rpath's for a libtool library" + + install_libdir="$1" + + oldlibs= + if test -z "$rpath"; then + if test "$build_libtool_libs" = yes; then + # Building a libtool convenience library. + # Some compilers have problems with a `.al' extension so + # convenience libraries should have the same extension an + # archive normally would. + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + + test -n "$vinfo" && \ + func_warning "\`-version-info/-version-number' is ignored for convenience libraries" + + test -n "$release" && \ + func_warning "\`-release' is ignored for convenience libraries" + else + + # Parse the version information argument. + save_ifs="$IFS"; IFS=':' + set dummy $vinfo 0 0 0 + shift + IFS="$save_ifs" + + test -n "$7" && \ + func_fatal_help "too many parameters to \`-version-info'" + + # convert absolute version numbers to libtool ages + # this retains compatibility with .la files and attempts + # to make the code below a bit more comprehensible + + case $vinfo_number in + yes) + number_major="$1" + number_minor="$2" + number_revision="$3" + # + # There are really only two kinds -- those that + # use the current revision as the major version + # and those that subtract age and use age as + # a minor version. But, then there is irix + # which has an extra 1 added just for fun + # + case $version_type in + darwin|linux|osf|windows|none) + func_arith $number_major + $number_minor + current=$func_arith_result + age="$number_minor" + revision="$number_revision" + ;; + freebsd-aout|freebsd-elf|sunos) + current="$number_major" + revision="$number_minor" + age="0" + ;; + irix|nonstopux) + func_arith $number_major + $number_minor + current=$func_arith_result + age="$number_minor" + revision="$number_minor" + lt_irix_increment=no + ;; + esac + ;; + no) + current="$1" + revision="$2" + age="$3" + ;; + esac + + # Check that each of the things are valid numbers. + case $current in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "CURRENT \`$current' must be a nonnegative integer" + func_fatal_error "\`$vinfo' is not valid version information" + ;; + esac + + case $revision in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "REVISION \`$revision' must be a nonnegative integer" + func_fatal_error "\`$vinfo' is not valid version information" + ;; + esac + + case $age in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "AGE \`$age' must be a nonnegative integer" + func_fatal_error "\`$vinfo' is not valid version information" + ;; + esac + + if test "$age" -gt "$current"; then + func_error "AGE \`$age' is greater than the current interface number \`$current'" + func_fatal_error "\`$vinfo' is not valid version information" + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case $version_type in + none) ;; + + darwin) + # Like Linux, but with the current version available in + # verstring for coding it into the library header + func_arith $current - $age + major=.$func_arith_result + versuffix="$major.$age.$revision" + # Darwin ld doesn't like 0 for these options... + func_arith $current + 1 + minor_current=$func_arith_result + xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + ;; + + freebsd-aout) + major=".$current" + versuffix=".$current.$revision"; + ;; + + freebsd-elf) + major=".$current" + versuffix=".$current" + ;; + + irix | nonstopux) + if test "X$lt_irix_increment" = "Xno"; then + func_arith $current - $age + else + func_arith $current - $age + 1 + fi + major=$func_arith_result + + case $version_type in + nonstopux) verstring_prefix=nonstopux ;; + *) verstring_prefix=sgi ;; + esac + verstring="$verstring_prefix$major.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test "$loop" -ne 0; do + func_arith $revision - $loop + iface=$func_arith_result + func_arith $loop - 1 + loop=$func_arith_result + verstring="$verstring_prefix$major.$iface:$verstring" + done + + # Before this point, $major must not contain `.'. + major=.$major + versuffix="$major.$revision" + ;; + + linux) + func_arith $current - $age + major=.$func_arith_result + versuffix="$major.$age.$revision" + ;; + + osf) + func_arith $current - $age + major=.$func_arith_result + versuffix=".$current.$age.$revision" + verstring="$current.$age.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$age + while test "$loop" -ne 0; do + func_arith $current - $loop + iface=$func_arith_result + func_arith $loop - 1 + loop=$func_arith_result + verstring="$verstring:${iface}.0" + done + + # Make executables depend on our current version. + verstring="$verstring:${current}.0" + ;; + + qnx) + major=".$current" + versuffix=".$current" + ;; + + sunos) + major=".$current" + versuffix=".$current.$revision" + ;; + + windows) + # Use '-' rather than '.', since we only want one + # extension on DOS 8.3 filesystems. + func_arith $current - $age + major=$func_arith_result + versuffix="-$major" + ;; + + *) + func_fatal_configuration "unknown library version type \`$version_type'" + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + case $version_type in + darwin) + # we can't check for "0.0" in archive_cmds due to quoting + # problems, so we reset it completely + verstring= + ;; + *) + verstring="0.0" + ;; + esac + if test "$need_version" = no; then + versuffix= + else + versuffix=".0.0" + fi + fi + + # Remove version info from name if versioning should be avoided + if test "$avoid_version" = yes && test "$need_version" = no; then + major= + versuffix= + verstring="" + fi + + # Check to see if the archive will have undefined symbols. + if test "$allow_undefined" = yes; then + if test "$allow_undefined_flag" = unsupported; then + func_warning "undefined symbols not allowed in $host shared libraries" + build_libtool_libs=no + build_old_libs=yes + fi + else + # Don't allow undefined symbols. + allow_undefined_flag="$no_undefined_flag" + fi + + fi + + func_generate_dlsyms "$libname" "$libname" "yes" + libobjs="$libobjs $symfileobj" + test "X$libobjs" = "X " && libobjs= + + if test "$mode" != relink; then + # Remove our outputs, but don't remove object files since they + # may have been created when compiling PIC objects. + removelist= + tempremovelist=`$ECHO "$output_objdir/*"` + for p in $tempremovelist; do + case $p in + *.$objext | *.gcno) + ;; + $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) + if test "X$precious_files_regex" != "X"; then + if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 + then + continue + fi + fi + removelist="$removelist $p" + ;; + *) ;; + esac + done + test -n "$removelist" && \ + func_show_eval "${RM}r \$removelist" + fi + + # Now set the variables for building old libraries. + if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then + oldlibs="$oldlibs $output_objdir/$libname.$libext" + + # Transform .lo files to .o files. + oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` + fi + + # Eliminate all temporary directories. + #for path in $notinst_path; do + # lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"` + # deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"` + # dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"` + #done + + if test -n "$xrpath"; then + # If the user specified any rpath flags, then add them. + temp_xrpath= + for libdir in $xrpath; do + temp_xrpath="$temp_xrpath -R$libdir" + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then + dependency_libs="$temp_xrpath $dependency_libs" + fi + fi + + # Make sure dlfiles contains only unique files that won't be dlpreopened + old_dlfiles="$dlfiles" + dlfiles= + for lib in $old_dlfiles; do + case " $dlprefiles $dlfiles " in + *" $lib "*) ;; + *) dlfiles="$dlfiles $lib" ;; + esac + done + + # Make sure dlprefiles contains only unique files + old_dlprefiles="$dlprefiles" + dlprefiles= + for lib in $old_dlprefiles; do + case "$dlprefiles " in + *" $lib "*) ;; + *) dlprefiles="$dlprefiles $lib" ;; + esac + done + + if test "$build_libtool_libs" = yes; then + if test -n "$rpath"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C library is in the System framework + deplibs="$deplibs System.ltframework" + ;; + *-*-netbsd*) + # Don't link with libc until the a.out ld.so is fixed. + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc due to us having libc/libc_r. + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + ;; + *) + # Add libc to deplibs on all other systems if necessary. + if test "$build_libtool_need_lc" = "yes"; then + deplibs="$deplibs -lc" + fi + ;; + esac + fi + + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release="" + versuffix="" + major="" + newdeplibs= + droppeddeps=no + case $deplibs_check_method in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behavior. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $opt_dry_run || $RM conftest.c + cat > conftest.c </dev/null` + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null | + $GREP " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib="$potent_lib" + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` + case $potliblink in + [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; + *) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | + $SED -e 10q | + $EGREP "$file_magic_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + $ECHO + $ECHO "*** Warning: linker path does not have real file for library $a_deplib." + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which you do not appear to have" + $ECHO "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $ECHO "*** with $libname but no candidates were found. (...for file magic test)" + else + $ECHO "*** with $libname and none of the candidates passed a file format test" + $ECHO "*** using a file magic. Last file checked: $potlib" + fi + fi + ;; + *) + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + ;; + esac + done # Gone through all deplibs. + ;; + match_pattern*) + set dummy $deplibs_check_method; shift + match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` + for a_deplib in $deplibs; do + case $a_deplib in + -l*) + func_stripname -l '' "$a_deplib" + name=$func_stripname_result + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $a_deplib "*) + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + ;; + esac + fi + if test -n "$a_deplib" ; then + libname=`eval "\\$ECHO \"$libname_spec\""` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + potlib="$potent_lib" # see symlink-check above in file_magic test + if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \ + $EGREP "$match_pattern_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + $ECHO + $ECHO "*** Warning: linker path does not have real file for library $a_deplib." + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which you do not appear to have" + $ECHO "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" + else + $ECHO "*** with $libname and none of the candidates passed a file format test" + $ECHO "*** using a regex pattern. Last file checked: $potlib" + fi + fi + ;; + *) + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + ;; + esac + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs="" + tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \ + -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'` + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + for i in $predeps $postdeps ; do + # can't use Xsed below, because $i might contain '/' + tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"` + done + fi + if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' | + $GREP . >/dev/null; then + $ECHO + if test "X$deplibs_check_method" = "Xnone"; then + $ECHO "*** Warning: inter-library dependencies are not supported in this platform." + else + $ECHO "*** Warning: inter-library dependencies are not known to be supported." + fi + $ECHO "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + fi + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library with the System framework + newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'` + ;; + esac + + if test "$droppeddeps" = yes; then + if test "$module" = yes; then + $ECHO + $ECHO "*** Warning: libtool could not satisfy all declared inter-library" + $ECHO "*** dependencies of module $libname. Therefore, libtool will create" + $ECHO "*** a static module, that should work as long as the dlopening" + $ECHO "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + $ECHO + $ECHO "*** However, this would only work if libtool was able to extract symbol" + $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could" + $ECHO "*** not find such a program. So, this module is probably useless." + $ECHO "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + $ECHO "*** The inter-library dependencies that have been dropped here will be" + $ECHO "*** automatically added whenever a program is linked with this library" + $ECHO "*** or is declared to -dlopen it." + + if test "$allow_undefined" = no; then + $ECHO + $ECHO "*** Since this library must not contain undefined symbols," + $ECHO "*** because either the platform does not support them or" + $ECHO "*** it was explicitly requested with -no-undefined," + $ECHO "*** libtool will only create a static version of it." + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + # Time to change all our "foo.ltframework" stuff back to "-framework foo" + case $host in + *-*-darwin*) + newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + ;; + esac + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $deplibs " in + *" -L$path/$objdir "*) + new_libs="$new_libs -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$new_libs $deplib" ;; + esac + ;; + *) new_libs="$new_libs $deplib" ;; + esac + done + deplibs="$new_libs" + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test "$build_libtool_libs" = yes; then + if test "$hardcode_into_libs" = yes; then + # Hardcode the library paths + hardcode_libdirs= + dep_rpath= + rpath="$finalize_rpath" + test "$mode" != relink && rpath="$compile_rpath$rpath" + for libdir in $rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + dep_rpath="$dep_rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + if test -n "$hardcode_libdir_flag_spec_ld"; then + eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" + else + eval dep_rpath=\"$hardcode_libdir_flag_spec\" + fi + fi + if test -n "$runpath_var" && test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" + fi + test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" + fi + + shlibpath="$finalize_shlibpath" + test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" + if test -n "$shlibpath"; then + eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" + fi + + # Get the real and link names of the library. + eval shared_ext=\"$shrext_cmds\" + eval library_names=\"$library_names_spec\" + set dummy $library_names + shift + realname="$1" + shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + if test -z "$dlname"; then + dlname=$soname + fi + + lib="$output_objdir/$realname" + linknames= + for link + do + linknames="$linknames $link" + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + test "X$libobjs" = "X " && libobjs= + + delfiles= + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" + export_symbols="$output_objdir/$libname.uexp" + delfiles="$delfiles $export_symbols" + fi + + orig_export_symbols= + case $host_os in + cygwin* | mingw* | cegcc*) + if test -n "$export_symbols" && test -z "$export_symbols_regex"; then + # exporting using user supplied symfile + if test "x`$SED 1q $export_symbols`" != xEXPORTS; then + # and it's NOT already a .def file. Must figure out + # which of the given symbols are data symbols and tag + # them as such. So, trigger use of export_symbols_cmds. + # export_symbols gets reassigned inside the "prepare + # the list of exported symbols" if statement, so the + # include_expsyms logic still works. + orig_export_symbols="$export_symbols" + export_symbols= + always_export_symbols=yes + fi + fi + ;; + esac + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then + func_verbose "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $opt_dry_run || $RM $export_symbols + cmds=$export_symbols_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + func_len " $cmd" + len=$func_len_result + if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + func_show_eval "$cmd" 'exit $?' + skipped_export=false + else + # The command line is too long to execute in one step. + func_verbose "using reloadable object file for export list..." + skipped_export=: + # Break out early, otherwise skipped_export may be + # set to false by a later but shorter cmd. + break + fi + done + IFS="$save_ifs" + if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then + func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + func_show_eval '$MV "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + tmp_export_symbols="$export_symbols" + test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" + $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"' + fi + + if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then + # The given exports_symbols file has to be filtered, so filter it. + func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" + # FIXME: $output_objdir/$libname.filter potentially contains lots of + # 's' commands which not all seds can handle. GNU sed should be fine + # though. Also, the filter scales superlinearly with the number of + # global variables. join(1) would be nice here, but unfortunately + # isn't a blessed tool. + $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter + delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" + export_symbols=$output_objdir/$libname.def + $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols + fi + + tmp_deplibs= + for test_deplib in $deplibs; do + case " $convenience " in + *" $test_deplib "*) ;; + *) + tmp_deplibs="$tmp_deplibs $test_deplib" + ;; + esac + done + deplibs="$tmp_deplibs" + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec" && + test "$compiler_needs_object" = yes && + test -z "$libobjs"; then + # extract the archives, so we have objects to list. + # TODO: could optimize this to just extract one archive. + whole_archive_flag_spec= + fi + if test -n "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + test "X$libobjs" = "X " && libobjs= + else + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $convenience + libobjs="$libobjs $func_extract_archives_result" + test "X$libobjs" = "X " && libobjs= + fi + fi + + if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then + eval flag=\"$thread_safe_flag_spec\" + linker_flags="$linker_flags $flag" + fi + + # Make a backup of the uninstalled library when relinking + if test "$mode" = relink; then + $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? + fi + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + eval test_cmds=\"$module_expsym_cmds\" + cmds=$module_expsym_cmds + else + eval test_cmds=\"$module_cmds\" + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval test_cmds=\"$archive_expsym_cmds\" + cmds=$archive_expsym_cmds + else + eval test_cmds=\"$archive_cmds\" + cmds=$archive_cmds + fi + fi + + if test "X$skipped_export" != "X:" && + func_len " $test_cmds" && + len=$func_len_result && + test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + : + else + # The command line is too long to link in one step, link piecewise + # or, if using GNU ld and skipped_export is not :, use a linker + # script. + + # Save the value of $output and $libobjs because we want to + # use them later. If we have whole_archive_flag_spec, we + # want to use save_libobjs as it was before + # whole_archive_flag_spec was expanded, because we can't + # assume the linker understands whole_archive_flag_spec. + # This may have to be revisited, in case too many + # convenience libraries get linked in and end up exceeding + # the spec. + if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + fi + save_output=$output + output_la=`$ECHO "X$output" | $Xsed -e "$basename"` + + # Clear the reloadable object creation command queue and + # initialize k to one. + test_cmds= + concat_cmds= + objlist= + last_robj= + k=1 + + if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then + output=${output_objdir}/${output_la}.lnkscript + func_verbose "creating GNU ld script: $output" + $ECHO 'INPUT (' > $output + for obj in $save_libobjs + do + $ECHO "$obj" >> $output + done + $ECHO ')' >> $output + delfiles="$delfiles $output" + elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then + output=${output_objdir}/${output_la}.lnk + func_verbose "creating linker input file list: $output" + : > $output + set x $save_libobjs + shift + firstobj= + if test "$compiler_needs_object" = yes; then + firstobj="$1 " + shift + fi + for obj + do + $ECHO "$obj" >> $output + done + delfiles="$delfiles $output" + output=$firstobj\"$file_list_spec$output\" + else + if test -n "$save_libobjs"; then + func_verbose "creating reloadable object files..." + output=$output_objdir/$output_la-${k}.$objext + eval test_cmds=\"$reload_cmds\" + func_len " $test_cmds" + len0=$func_len_result + len=$len0 + + # Loop over the list of objects to be linked. + for obj in $save_libobjs + do + func_len " $obj" + func_arith $len + $func_len_result + len=$func_arith_result + if test "X$objlist" = X || + test "$len" -lt "$max_cmd_len"; then + func_append objlist " $obj" + else + # The command $test_cmds is almost too long, add a + # command to the queue. + if test "$k" -eq 1 ; then + # The first file doesn't have a previous command to add. + eval concat_cmds=\"$reload_cmds $objlist $last_robj\" + else + # All subsequent reloadable object files will link in + # the last one created. + eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\" + fi + last_robj=$output_objdir/$output_la-${k}.$objext + func_arith $k + 1 + k=$func_arith_result + output=$output_objdir/$output_la-${k}.$objext + objlist=$obj + func_len " $last_robj" + func_arith $len0 + $func_len_result + len=$func_arith_result + fi + done + # Handle the remaining objects by creating one last + # reloadable object file. All subsequent reloadable object + # files will link in the last one created. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" + if test -n "$last_robj"; then + eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" + fi + delfiles="$delfiles $output" + + else + output= + fi + + if ${skipped_export-false}; then + func_verbose "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $opt_dry_run || $RM $export_symbols + libobjs=$output + # Append the command to create the export file. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" + if test -n "$last_robj"; then + eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" + fi + fi + + test -n "$save_libobjs" && + func_verbose "creating a temporary reloadable object file: $output" + + # Loop through the commands generated above and execute them. + save_ifs="$IFS"; IFS='~' + for cmd in $concat_cmds; do + IFS="$save_ifs" + $opt_silent || { + func_quote_for_expand "$cmd" + eval "func_echo $func_quote_for_expand_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + ( cd "$output_objdir" && \ + $RM "${realname}T" && \ + $MV "${realname}U" "$realname" ) + fi + + exit $lt_exit + } + done + IFS="$save_ifs" + + if test -n "$export_symbols_regex" && ${skipped_export-false}; then + func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + func_show_eval '$MV "${export_symbols}T" "$export_symbols"' + fi + fi + + if ${skipped_export-false}; then + if test -n "$export_symbols" && test -n "$include_expsyms"; then + tmp_export_symbols="$export_symbols" + test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" + $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"' + fi + + if test -n "$orig_export_symbols"; then + # The given exports_symbols file has to be filtered, so filter it. + func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" + # FIXME: $output_objdir/$libname.filter potentially contains lots of + # 's' commands which not all seds can handle. GNU sed should be fine + # though. Also, the filter scales superlinearly with the number of + # global variables. join(1) would be nice here, but unfortunately + # isn't a blessed tool. + $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter + delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" + export_symbols=$output_objdir/$libname.def + $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols + fi + fi + + libobjs=$output + # Restore the value of output. + output=$save_output + + if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + test "X$libobjs" = "X " && libobjs= + fi + # Expand the library linking commands again to reset the + # value of $libobjs for piecewise linking. + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + cmds=$module_expsym_cmds + else + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + cmds=$archive_expsym_cmds + else + cmds=$archive_cmds + fi + fi + fi + + if test -n "$delfiles"; then + # Append the command to remove temporary files to $cmds. + eval cmds=\"\$cmds~\$RM $delfiles\" + fi + + # Add any objects from preloaded convenience libraries + if test -n "$dlprefiles"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $dlprefiles + libobjs="$libobjs $func_extract_archives_result" + test "X$libobjs" = "X " && libobjs= + fi + + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $opt_silent || { + func_quote_for_expand "$cmd" + eval "func_echo $func_quote_for_expand_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + ( cd "$output_objdir" && \ + $RM "${realname}T" && \ + $MV "${realname}U" "$realname" ) + fi + + exit $lt_exit + } + done + IFS="$save_ifs" + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? + + if test -n "$convenience"; then + if test -z "$whole_archive_flag_spec"; then + func_show_eval '${RM}r "$gentop"' + fi + fi + + exit $EXIT_SUCCESS + fi + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test "$module" = yes || test "$export_dynamic" = yes; then + # On all known operating systems, these are identical. + dlname="$soname" + fi + fi + ;; + + obj) + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + func_warning "\`-dlopen' is ignored for objects" + fi + + case " $deplibs" in + *\ -l* | *\ -L*) + func_warning "\`-l' and \`-L' are ignored for objects" ;; + esac + + test -n "$rpath" && \ + func_warning "\`-rpath' is ignored for objects" + + test -n "$xrpath" && \ + func_warning "\`-R' is ignored for objects" + + test -n "$vinfo" && \ + func_warning "\`-version-info' is ignored for objects" + + test -n "$release" && \ + func_warning "\`-release' is ignored for objects" + + case $output in + *.lo) + test -n "$objs$old_deplibs" && \ + func_fatal_error "cannot build library object \`$output' from non-libtool objects" + + libobj=$output + func_lo2o "$libobj" + obj=$func_lo2o_result + ;; + *) + libobj= + obj="$output" + ;; + esac + + # Delete the old objects. + $opt_dry_run || $RM $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # reload_cmds runs $LD directly, so let us get rid of + # -Wl from whole_archive_flag_spec and hope we can get by with + # turning comma into space.. + wl= + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" + reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'` + else + gentop="$output_objdir/${obj}x" + generated="$generated $gentop" + + func_extract_archives $gentop $convenience + reload_conv_objs="$reload_objs $func_extract_archives_result" + fi + fi + + # Create the old-style object. + reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test + + output="$obj" + func_execute_cmds "$reload_cmds" 'exit $?' + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + exit $EXIT_SUCCESS + fi + + if test "$build_libtool_libs" != yes; then + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + # $show "echo timestamp > $libobj" + # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? + exit $EXIT_SUCCESS + fi + + if test -n "$pic_flag" || test "$pic_mode" != default; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output="$libobj" + func_execute_cmds "$reload_cmds" 'exit $?' + fi + + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + exit $EXIT_SUCCESS + ;; + + prog) + case $host in + *cygwin*) func_stripname '' '.exe' "$output" + output=$func_stripname_result.exe;; + esac + test -n "$vinfo" && \ + func_warning "\`-version-info' is ignored for programs" + + test -n "$release" && \ + func_warning "\`-release' is ignored for programs" + + test "$preload" = yes \ + && test "$dlopen_support" = unknown \ + && test "$dlopen_self" = unknown \ + && test "$dlopen_self_static" = unknown && \ + func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'` + finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'` + ;; + esac + + case $host in + *-*-darwin*) + # Don't allow lazy linking, it breaks C++ global constructors + # But is supposedly fixed on 10.4 or later (yay!). + if test "$tagname" = CXX ; then + case ${MACOSX_DEPLOYMENT_TARGET-10.0} in + 10.[0123]) + compile_command="$compile_command ${wl}-bind_at_load" + finalize_command="$finalize_command ${wl}-bind_at_load" + ;; + esac + fi + # Time to change all our "foo.ltframework" stuff back to "-framework foo" + compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + ;; + esac + + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $compile_deplibs " in + *" -L$path/$objdir "*) + new_libs="$new_libs -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $compile_deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$new_libs $deplib" ;; + esac + ;; + *) new_libs="$new_libs $deplib" ;; + esac + done + compile_deplibs="$new_libs" + + + compile_command="$compile_command $compile_deplibs" + finalize_command="$finalize_command $finalize_deplibs" + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$libdir:"*) ;; + ::) dllsearchpath=$libdir;; + *) dllsearchpath="$dllsearchpath:$libdir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + ::) dllsearchpath=$testbindir;; + *) dllsearchpath="$dllsearchpath:$testbindir";; + esac + ;; + esac + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath="$rpath" + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath="$rpath" + + if test -n "$libobjs" && test "$build_old_libs" = yes; then + # Transform all the library objects into standard objects. + compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + fi + + func_generate_dlsyms "$outputname" "@PROGRAM@" "no" + + # template prelinking step + if test -n "$prelink_cmds"; then + func_execute_cmds "$prelink_cmds" 'exit $?' + fi + + wrappers_required=yes + case $host in + *cygwin* | *mingw* ) + if test "$build_libtool_libs" != yes; then + wrappers_required=no + fi + ;; + *cegcc) + # Disable wrappers for cegcc, we are cross compiling anyway. + wrappers_required=no + ;; + *) + if test "$need_relink" = no || test "$build_libtool_libs" != yes; then + wrappers_required=no + fi + ;; + esac + if test "$wrappers_required" = no; then + # Replace the output file specification. + compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + link_command="$compile_command$compile_rpath" + + # We have no uninstalled library dependencies, so finalize right now. + exit_status=0 + func_show_eval "$link_command" 'exit_status=$?' + + # Delete the generated files. + if test -f "$output_objdir/${outputname}S.${objext}"; then + func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' + fi + + exit $exit_status + fi + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + rpath="$rpath$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test "$no_install" = yes; then + # We don't need to create a wrapper script. + link_command="$compile_var$compile_command$compile_rpath" + # Replace the output file specification. + link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + # Delete the old output file. + $opt_dry_run || $RM $output + # Link the executable and exit + func_show_eval "$link_command" 'exit $?' + exit $EXIT_SUCCESS + fi + + if test "$hardcode_action" = relink; then + # Fast installation is not supported + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + + func_warning "this platform does not like uninstalled shared libraries" + func_warning "\`$output' will be relinked during installation" + else + if test "$fast_install" != no; then + link_command="$finalize_var$compile_command$finalize_rpath" + if test "$fast_install" = yes; then + relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` + else + # fast_install is set to needless + relink_command= + fi + else + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + fi + fi + + # Replace the output file specification. + link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname + + func_show_eval "$link_command" 'exit $?' + + # Now create the wrapper script. + func_verbose "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + fi + done + relink_command="(cd `pwd`; $relink_command)" + relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"` + fi + + # Quote $ECHO for shipping. + if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then + case $progpath in + [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; + *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; + esac + qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"` + else + qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"` + fi + + # Only actually do things if not in dry run mode. + $opt_dry_run || { + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) func_stripname '' '.exe' "$output" + output=$func_stripname_result ;; + esac + # test for cygwin because mv fails w/o .exe extensions + case $host in + *cygwin*) + exeext=.exe + func_stripname '' '.exe' "$outputname" + outputname=$func_stripname_result ;; + *) exeext= ;; + esac + case $host in + *cygwin* | *mingw* ) + func_dirname_and_basename "$output" "" "." + output_name=$func_basename_result + output_path=$func_dirname_result + cwrappersource="$output_path/$objdir/lt-$output_name.c" + cwrapper="$output_path/$output_name.exe" + $RM $cwrappersource $cwrapper + trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 + + func_emit_cwrapperexe_src > $cwrappersource + + # The wrapper executable is built using the $host compiler, + # because it contains $host paths and files. If cross- + # compiling, it, like the target executable, must be + # executed on the $host or under an emulation environment. + $opt_dry_run || { + $LTCC $LTCFLAGS -o $cwrapper $cwrappersource + $STRIP $cwrapper + } + + # Now, create the wrapper script for func_source use: + func_ltwrapper_scriptname $cwrapper + $RM $func_ltwrapper_scriptname_result + trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 + $opt_dry_run || { + # note: this script will not be executed, so do not chmod. + if test "x$build" = "x$host" ; then + $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result + else + func_emit_wrapper no > $func_ltwrapper_scriptname_result + fi + } + ;; + * ) + $RM $output + trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 + + func_emit_wrapper no > $output + chmod +x $output + ;; + esac + } + exit $EXIT_SUCCESS + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + if test "$build_libtool_libs" = convenience; then + oldobjs="$libobjs_save $symfileobj" + addlibs="$convenience" + build_libtool_libs=no + else + if test "$build_libtool_libs" = module; then + oldobjs="$libobjs_save" + build_libtool_libs=no + else + oldobjs="$old_deplibs $non_pic_objects" + if test "$preload" = yes && test -f "$symfileobj"; then + oldobjs="$oldobjs $symfileobj" + fi + fi + addlibs="$old_convenience" + fi + + if test -n "$addlibs"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $addlibs + oldobjs="$oldobjs $func_extract_archives_result" + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + cmds=$old_archive_from_new_cmds + else + + # Add any objects from preloaded convenience libraries + if test -n "$dlprefiles"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $dlprefiles + oldobjs="$oldobjs $func_extract_archives_result" + fi + + # POSIX demands no paths to be encoded in archives. We have + # to avoid creating archives with duplicate basenames if we + # might have to extract them afterwards, e.g., when creating a + # static archive out of a convenience library, or when linking + # the entirety of a libtool archive into another (currently + # not supported by libtool). + if (for obj in $oldobjs + do + func_basename "$obj" + $ECHO "$func_basename_result" + done | sort | sort -uc >/dev/null 2>&1); then + : + else + $ECHO "copying selected object files to avoid basename conflicts..." + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + func_mkdir_p "$gentop" + save_oldobjs=$oldobjs + oldobjs= + counter=1 + for obj in $save_oldobjs + do + func_basename "$obj" + objbase="$func_basename_result" + case " $oldobjs " in + " ") oldobjs=$obj ;; + *[\ /]"$objbase "*) + while :; do + # Make sure we don't pick an alternate name that also + # overlaps. + newobj=lt$counter-$objbase + func_arith $counter + 1 + counter=$func_arith_result + case " $oldobjs " in + *[\ /]"$newobj "*) ;; + *) if test ! -f "$gentop/$newobj"; then break; fi ;; + esac + done + func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" + oldobjs="$oldobjs $gentop/$newobj" + ;; + *) oldobjs="$oldobjs $obj" ;; + esac + done + fi + eval cmds=\"$old_archive_cmds\" + + func_len " $cmds" + len=$func_len_result + if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + cmds=$old_archive_cmds + else + # the command line is too long to link in one step, link in parts + func_verbose "using piecewise archive linking..." + save_RANLIB=$RANLIB + RANLIB=: + objlist= + concat_cmds= + save_oldobjs=$oldobjs + oldobjs= + # Is there a better way of finding the last object in the list? + for obj in $save_oldobjs + do + last_oldobj=$obj + done + eval test_cmds=\"$old_archive_cmds\" + func_len " $test_cmds" + len0=$func_len_result + len=$len0 + for obj in $save_oldobjs + do + func_len " $obj" + func_arith $len + $func_len_result + len=$func_arith_result + func_append objlist " $obj" + if test "$len" -lt "$max_cmd_len"; then + : + else + # the above command should be used before it gets too long + oldobjs=$objlist + if test "$obj" = "$last_oldobj" ; then + RANLIB=$save_RANLIB + fi + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" + objlist= + len=$len0 + fi + done + RANLIB=$save_RANLIB + oldobjs=$objlist + if test "X$oldobjs" = "X" ; then + eval cmds=\"\$concat_cmds\" + else + eval cmds=\"\$concat_cmds~\$old_archive_cmds\" + fi + fi + fi + func_execute_cmds "$cmds" 'exit $?' + done + + test -n "$generated" && \ + func_show_eval "${RM}r$generated" + + # Now create the libtool archive. + case $output in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.$libext" + func_verbose "creating $output" + + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + fi + done + # Quote the link command for shipping. + relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" + relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"` + if test "$hardcode_automatic" = yes ; then + relink_command= + fi + + # Only create the output if not a dry run. + $opt_dry_run || { + for installed in no yes; do + if test "$installed" = yes; then + if test -z "$install_libdir"; then + break + fi + output="$output_objdir/$outputname"i + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do + case $deplib in + *.la) + func_basename "$deplib" + name="$func_basename_result" + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + test -z "$libdir" && \ + func_fatal_error "\`$deplib' is not a valid libtool archive" + newdependency_libs="$newdependency_libs $libdir/$name" + ;; + *) newdependency_libs="$newdependency_libs $deplib" ;; + esac + done + dependency_libs="$newdependency_libs" + newdlfiles= + + for lib in $dlfiles; do + case $lib in + *.la) + func_basename "$lib" + name="$func_basename_result" + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + test -z "$libdir" && \ + func_fatal_error "\`$lib' is not a valid libtool archive" + newdlfiles="$newdlfiles $libdir/$name" + ;; + *) newdlfiles="$newdlfiles $lib" ;; + esac + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + *.la) + # Only pass preopened files to the pseudo-archive (for + # eventual linking with the app. that links it) if we + # didn't already link the preopened objects directly into + # the library: + func_basename "$lib" + name="$func_basename_result" + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + test -z "$libdir" && \ + func_fatal_error "\`$lib' is not a valid libtool archive" + newdlprefiles="$newdlprefiles $libdir/$name" + ;; + esac + done + dlprefiles="$newdlprefiles" + else + newdlfiles= + for lib in $dlfiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlfiles="$newdlfiles $abs" + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlprefiles="$newdlprefiles $abs" + done + dlprefiles="$newdlprefiles" + fi + $RM $output + # place dlname in correct position for cygwin + tdlname=$dlname + case $host,$output,$installed,$module,$dlname in + *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; + esac + $ECHO > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$tdlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Linker flags that can not go in dependency_libs. +inherited_linker_flags='$new_inherited_linker_flags' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Names of additional weak libraries provided by this library +weak_library_names='$weak_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Should we warn about portability when linking against -modules? +shouldnotlink=$module + +# Files to dlopen/dlpreopen +dlopen='$dlfiles' +dlpreopen='$dlprefiles' + +# Directory that this library needs to be installed in: +libdir='$install_libdir'" + if test "$installed" = no && test "$need_relink" = yes; then + $ECHO >> $output "\ +relink_command=\"$relink_command\"" + fi + done + } + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' + ;; + esac + exit $EXIT_SUCCESS +} + +{ test "$mode" = link || test "$mode" = relink; } && + func_mode_link ${1+"$@"} + + +# func_mode_uninstall arg... +func_mode_uninstall () +{ + $opt_debug + RM="$nonopt" + files= + rmforce= + exit_status=0 + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + for arg + do + case $arg in + -f) RM="$RM $arg"; rmforce=yes ;; + -*) RM="$RM $arg" ;; + *) files="$files $arg" ;; + esac + done + + test -z "$RM" && \ + func_fatal_help "you must specify an RM program" + + rmdirs= + + origobjdir="$objdir" + for file in $files; do + func_dirname "$file" "" "." + dir="$func_dirname_result" + if test "X$dir" = X.; then + objdir="$origobjdir" + else + objdir="$dir/$origobjdir" + fi + func_basename "$file" + name="$func_basename_result" + test "$mode" = uninstall && objdir="$dir" + + # Remember objdir for removal later, being careful to avoid duplicates + if test "$mode" = clean; then + case " $rmdirs " in + *" $objdir "*) ;; + *) rmdirs="$rmdirs $objdir" ;; + esac + fi + + # Don't error if the file doesn't exist and rm -f was used. + if { test -L "$file"; } >/dev/null 2>&1 || + { test -h "$file"; } >/dev/null 2>&1 || + test -f "$file"; then + : + elif test -d "$file"; then + exit_status=1 + continue + elif test "$rmforce" = yes; then + continue + fi + + rmfiles="$file" + + case $name in + *.la) + # Possibly a libtool archive, so verify it. + if func_lalib_p "$file"; then + func_source $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $objdir/$n" + done + test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" + + case "$mode" in + clean) + case " $library_names " in + # " " in the beginning catches empty $dlname + *" $dlname "*) ;; + *) rmfiles="$rmfiles $objdir/$dlname" ;; + esac + test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" + ;; + uninstall) + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' + fi + # FIXME: should reinstall the best remaining shared library. + ;; + esac + fi + ;; + + *.lo) + # Possibly a libtool object, so verify it. + if func_lalib_p "$file"; then + + # Read the .lo file + func_source $dir/$name + + # Add PIC object to the list of files to remove. + if test -n "$pic_object" && + test "$pic_object" != none; then + rmfiles="$rmfiles $dir/$pic_object" + fi + + # Add non-PIC object to the list of files to remove. + if test -n "$non_pic_object" && + test "$non_pic_object" != none; then + rmfiles="$rmfiles $dir/$non_pic_object" + fi + fi + ;; + + *) + if test "$mode" = clean ; then + noexename=$name + case $file in + *.exe) + func_stripname '' '.exe' "$file" + file=$func_stripname_result + func_stripname '' '.exe' "$name" + noexename=$func_stripname_result + # $file with .exe has already been added to rmfiles, + # add $file without .exe + rmfiles="$rmfiles $file" + ;; + esac + # Do a test to see if this is a libtool program. + if func_ltwrapper_p "$file"; then + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + relink_command= + func_source $func_ltwrapper_scriptname_result + rmfiles="$rmfiles $func_ltwrapper_scriptname_result" + else + relink_command= + func_source $dir/$noexename + fi + + # note $name still contains .exe if it was in $file originally + # as does the version of $file that was added into $rmfiles + rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" + if test "$fast_install" = yes && test -n "$relink_command"; then + rmfiles="$rmfiles $objdir/lt-$name" + fi + if test "X$noexename" != "X$name" ; then + rmfiles="$rmfiles $objdir/lt-${noexename}.c" + fi + fi + fi + ;; + esac + func_show_eval "$RM $rmfiles" 'exit_status=1' + done + objdir="$origobjdir" + + # Try to remove the ${objdir}s in the directories where we deleted files + for dir in $rmdirs; do + if test -d "$dir"; then + func_show_eval "rmdir $dir >/dev/null 2>&1" + fi + done + + exit $exit_status +} + +{ test "$mode" = uninstall || test "$mode" = clean; } && + func_mode_uninstall ${1+"$@"} + +test -z "$mode" && { + help="$generic_help" + func_fatal_help "you must specify a MODE" +} + +test -z "$exec_cmd" && \ + func_fatal_help "invalid operation mode \`$mode'" + +if test -n "$exec_cmd"; then + eval exec "$exec_cmd" + exit $EXIT_FAILURE +fi + +exit $exit_status + + +# The TAGs below are defined such that we never get into a situation +# in which we disable both kinds of libraries. Given conflicting +# choices, we go for a static library, that is the most portable, +# since we can't tell whether shared libraries were disabled because +# the user asked for that or because the platform doesn't support +# them. This is particularly important on AIX, because we don't +# support having both static and shared libraries enabled at the same +# time on that platform, so we default to a shared-only configuration. +# If a disable-shared tag is given, we'll fallback to a static-only +# configuration. But we'll never go from static-only to shared-only. + +# ### BEGIN LIBTOOL TAG CONFIG: disable-shared +build_libtool_libs=no +build_old_libs=yes +# ### END LIBTOOL TAG CONFIG: disable-shared + +# ### BEGIN LIBTOOL TAG CONFIG: disable-static +build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` +# ### END LIBTOOL TAG CONFIG: disable-static + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: +# vi:sw=2 + diff --git a/m4/Makefile.am b/m4/Makefile.am new file mode 100644 index 0000000..80e2e72 --- /dev/null +++ b/m4/Makefile.am @@ -0,0 +1,5 @@ +m4datadir = $(datadir)/aclocal +m4data_DATA = eb4.m4 + +EXTRA_DIST = eb4.m4 gettext.m4 in6addr.m4 sockaddrin6.m4 sockinttypes.m4 \ + lcmessage.m4 libtool.m4 diff --git a/m4/Makefile.in b/m4/Makefile.in new file mode 100644 index 0000000..5af1476 --- /dev/null +++ b/m4/Makefile.in @@ -0,0 +1,394 @@ +# Makefile.in generated by automake 1.10.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = m4 +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/in6addr.m4 $(top_srcdir)/m4/largefile.m4 \ + $(top_srcdir)/m4/lcmessage.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/sockaddrin6.m4 \ + $(top_srcdir)/m4/sockinttypes.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(m4datadir)" +m4dataDATA_INSTALL = $(INSTALL_DATA) +DATA = $(m4data_DATA) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +EBCONF_EBINCS = @EBCONF_EBINCS@ +EBCONF_EBLIBS = @EBCONF_EBLIBS@ +EBCONF_INTLINCS = @EBCONF_INTLINCS@ +EBCONF_INTLLIBS = @EBCONF_INTLLIBS@ +EBCONF_ZLIBINCS = @EBCONF_ZLIBINCS@ +EBCONF_ZLIBLIBS = @EBCONF_ZLIBLIBS@ +EB_VERSION_MAJOR = @EB_VERSION_MAJOR@ +EB_VERSION_MINOR = @EB_VERSION_MINOR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_EBNET = @ENABLE_EBNET@ +ENABLE_NLS = @ENABLE_NLS@ +ENABLE_PTHREAD = @ENABLE_PTHREAD@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +ICONVINCS = @ICONVINCS@ +ICONVLIBS = @ICONVLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLINCS = @INTLINCS@ +INTLLIBS = @INTLLIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBEB_VERSION_INFO = @LIBEB_VERSION_INFO@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAILING_ADDRESS = @MAILING_ADDRESS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_CPPFLAGS = @PTHREAD_CPPFLAGS@ +PTHREAD_LDFLAGS = @PTHREAD_LDFLAGS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +ZLIBDEPS = @ZLIBDEPS@ +ZLIBINCS = @ZLIBINCS@ +ZLIBLIBS = @ZLIBLIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgdocdir = @pkgdocdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +m4datadir = $(datadir)/aclocal +m4data_DATA = eb4.m4 +EXTRA_DIST = eb4.m4 gettext.m4 in6addr.m4 sockaddrin6.m4 sockinttypes.m4 \ + lcmessage.m4 libtool.m4 + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu m4/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu m4/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-m4dataDATA: $(m4data_DATA) + @$(NORMAL_INSTALL) + test -z "$(m4datadir)" || $(MKDIR_P) "$(DESTDIR)$(m4datadir)" + @list='$(m4data_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(m4dataDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(m4datadir)/$$f'"; \ + $(m4dataDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(m4datadir)/$$f"; \ + done + +uninstall-m4dataDATA: + @$(NORMAL_UNINSTALL) + @list='$(m4data_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(m4datadir)/$$f'"; \ + rm -f "$(DESTDIR)$(m4datadir)/$$f"; \ + done +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(DATA) +installdirs: + for dir in "$(DESTDIR)$(m4datadir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-m4dataDATA + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-m4dataDATA + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-m4dataDATA install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + uninstall uninstall-am uninstall-m4dataDATA + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/m4/eb4.m4 b/m4/eb4.m4 new file mode 100644 index 0000000..5817a1f --- /dev/null +++ b/m4/eb4.m4 @@ -0,0 +1,116 @@ +dnl * +dnl * Make ready to link EB Library 3.x or 4.x. +dnl * +dnl * Copyright (c) 2000-2006 Motoyuki Kasahara +dnl * +dnl * Redistribution and use in source and binary forms, with or without +dnl * modification, are permitted provided that the following conditions +dnl * are met: +dnl * 1. Redistributions of source code must retain the above copyright +dnl * notice, this list of conditions and the following disclaimer. +dnl * 2. Redistributions in binary form must reproduce the above copyright +dnl * notice, this list of conditions and the following disclaimer in the +dnl * documentation and/or other materials provided with the distribution. +dnl * 3. Neither the name of the project nor the names of its contributors +dnl * may be used to endorse or promote products derived from this software +dnl * without specific prior written permission. +dnl * +dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +dnl * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +dnl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +dnl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +dnl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +dnl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +dnl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +dnl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +dnl * SUCH DAMAGE. +dnl * + +AC_DEFUN([eb_LIB_EB4], +[dnl +dnl * +dnl * Requirements. +dnl * +AC_REQUIRE([AC_PROG_CC]) +AC_REQUIRE([AC_PROG_LIBTOOL]) +AC_REQUIRE([AC_TYPE_OFF_T]) +AC_REQUIRE([AC_TYPE_SIZE_T]) + +AC_CHECK_HEADERS(limits.h) +AC_CHECK_TYPE(ssize_t, int) + +dnl * +dnl * --with-eb-conf option. +dnl * +AC_ARG_WITH(eb-conf, +AC_HELP_STRING([--with-eb-conf=FILE], + [eb.conf file is FILE [[SYSCONFDIR/eb.conf]]]), +[ebconf="${withval}"], [ebconf=$sysconfdir/eb.conf]) +if test X$prefix = XNONE; then + PREFIX=$ac_default_prefix +else + PREFIX=$prefix +fi +ebconf=`echo X$ebconf | sed -e 's/^X//' -e 's;\${prefix};'"$PREFIX;g" \ + -e 's;\$(prefix);'"$PREFIX;g"` + +dnl * +dnl * Read eb.conf +dnl * +AC_MSG_CHECKING(for eb.conf) +AC_MSG_RESULT($ebconf) +if test -f ${ebconf}; then + . ${ebconf} +else + AC_MSG_ERROR($ebconf not found) +fi + +if test X$EBCONF_ENABLE_PTHREAD = Xyes; then + AC_DEFINE(EBCONF_ENABLE_PTHREAD, 1, + [Define if EB Library supports pthread.]) +fi +if test X$EBCONF_ENABLE_NLS = Xyes; then + AC_DEFINE(EBCONF_ENABLE_NLS, 1, + [Define if EB Library supports native language.]) +fi +if test X$EBCONF_ENABLE_EBNET = Xyes; then + AC_DEFINE(EBCONF_ENABLE_EBNET, 1, + [Define if EB Library supports remote access.]) +fi + +AC_SUBST(EBCONF_EBINCS) +AC_SUBST(EBCONF_EBLIBS) +AC_SUBST(EBCONF_ZLIBINCS) +AC_SUBST(EBCONF_ZLIBLIBS) +AC_SUBST(EBCONF_PTHREAD_CPPFLAGS) +AC_SUBST(EBCONF_PTHREAD_CFLAGS) +AC_SUBST(EBCONF_PTHREAD_LDFLAGS) +AC_SUBST(EBCONF_INTLINCS) +AC_SUBST(EBCONF_INTLLIBS) + +dnl * +dnl * Check for EB Library. +dnl * +AC_MSG_CHECKING(for EB Library) +save_CPPFLAGS=$CPPFLAGS +save_CFLAGS=$CFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS +CPPFLAGS="$CPPFLAGS $EBCONF_PTHREAD_CPPFLAGS $EBCONF_EBINCS $EBCONF_ZLIBINCS $EBCONF_INTLINCS" +CFLAGS="$CFLAGS $EBCONF_PTHREAD_CFLAGS" +LDFLAGS="$LDFAGS $EBCONF_PTHREAD_LDFLAGS" +LIBS="$LIBS $EBCONF_EBLIBS $EBCONF_ZLIBLIBS $EBCONF_INTLLIBS" +AC_TRY_LINK([#include ], +[eb_initialize_library(); return 0;], +try_eb=yes, try_eb=no) +CPPFLAGS=$save_CPPFLAGS +CFLAGS=$save_CFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS +AC_MSG_RESULT($try_eb) +if test ${try_eb} != yes; then + AC_MSG_ERROR(EB Library not available) +fi +]) diff --git a/m4/gettext.m4 b/m4/gettext.m4 new file mode 100644 index 0000000..4a69f70 --- /dev/null +++ b/m4/gettext.m4 @@ -0,0 +1,293 @@ +dnl * +dnl * Copyright (c) 2004-2006 Motoyuki Kasahara +dnl * +dnl * Redistribution and use in source and binary forms, with or without +dnl * modification, are permitted provided that the following conditions +dnl * are met: +dnl * 1. Redistributions of source code must retain the above copyright +dnl * notice, this list of conditions and the following disclaimer. +dnl * 2. Redistributions in binary form must reproduce the above copyright +dnl * notice, this list of conditions and the following disclaimer in the +dnl * documentation and/or other materials provided with the distribution. +dnl * 3. Neither the name of the project nor the names of its contributors +dnl * may be used to endorse or promote products derived from this software +dnl * without specific prior written permission. +dnl * +dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +dnl * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +dnl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +dnl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +dnl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +dnl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +dnl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +dnl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +dnl * SUCH DAMAGE. +dnl * + +AC_DEFUN([eb_GNU_GETTEXT], [dnl + INTLINCS= + INTLDEPS= + INTLLIBS= + + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_PROG_LIBTOOL]) + + AC_CHECK_HEADERS([locale.h nl_types.h]) + AC_CHECK_FUNCS([setlocale]) + + AM_LC_MESSAGES + + dnl * + dnl * --enable-nls option + dnl * + AC_ARG_ENABLE(nls, + AC_HELP_STRING([--enable-nls], [Native Language Support [[yes]]]), + ENABLE_NLS=$enableval, ENABLE_NLS=auto) + + dnl * + dnl * --with-gettext-includes option + dnl * + AC_ARG_WITH(gettext-includes, + AC_HELP_STRING([--with-gettext-includes=DIR], + [gettext include files are in DIR]), + [gettext_includes="-I${withval}"], [gettext_includes='']) + + dnl * + dnl * --with-gettext-libraries option + dnl * + AC_ARG_WITH(gettext-libraries, + AC_HELP_STRING([--with-gettext-libraries=DIR], + [gettext library files are in DIR]), + [gettext_libraries="-L${withval}"], [gettext_libraries='']) + + dnl * + dnl * --with-iconv-includes option + dnl * + AC_ARG_WITH(iconv-includes, + AC_HELP_STRING([--with-iconv-includes=DIR], + [iconv include files are in DIR]), + [iconv_includes="-I${withval}"], [iconv_includes='']) + + dnl * + dnl * --with-iconv-libraries option + dnl * + AC_ARG_WITH(iconv-libraries, + AC_HELP_STRING([--with-iconv-libraries=DIR], + [iconv library files are in DIR]), + [iconv_libraries="-L${withval}"], [iconv_libraries='']) + + dnl * + dnl * Check iconv(), iconv.h and -liconv. + dnl * + ICONVINCS= + ICONVLIBS= + save_CPPFLAGS=$CPPFLAGS + save_LIBS=$LIBS + CPPFLAGS="$save_CPPFLAGS $iconv_includes" + LIBS="$save_LIBS $iconv_libraries" + AC_CHECK_LIB(iconv, iconv_open, + [ICONVLIBS="$iconv_libraries -liconv"; LIBS="$LIBS -liconv"]) + AC_CHECK_FUNCS(iconv_open locale_charset) + AC_CHECK_HEADERS(iconv.h libcharset.h) + if test $ac_cv_func_iconv_open != no; then + ICONVINCS="$iconv_includes" + fi + CPPFLAGS=$save_CPPFLAGS + LIBS=$save_LIBS + AC_SUBST(ICONVINCS) + AC_SUBST(ICONVLIBS) + + dnl * + dnl * Check gettext(). + dnl * + INTLINCS= + INTLLIBS= + try_nls=no + + AC_MSG_CHECKING([for NLS support]) + + if test $ENABLE_NLS != no; then + save_CPPFLAGS=$CPPFLAGS + save_LIBS=$LIBS + + dnl * + dnl * Test 1: Try to link both libintl and libiconv. + dnl * + CPPFLAGS="$save_CPPFLAGS $gettext_includes" + LIBS="$save_LIBS $gettext_libraries -lintl $iconv_libraries -liconv" + AC_LINK_IFELSE([ +#include +#ifdef ENABLE_NLS +#undef ENABLE_NLS +#endif +#define ENABLE_NLS 1 +#ifdef HAVE_LOCALE_H +#include +#endif +#include + +int +main() +{ +#ifdef HAVE_SETLOCALE + setlocale(LC_ALL, ""); +#endif + bindtextdomain("gttest", ".locale"); + textdomain("gttest"); + gettext("foo"); + return 0; +} +], + try_nls=yes, try_nls=no) + + if test "$try_nls" = yes; then + INTLINCS="$gettext_includes" + INTLLIBS="$gettext_libraries -lintl $iconv_libraries -liconv" + fi + + dnl * + dnl * Test 2: Try to link libintl. + dnl * + if test "$try_nls" = no; then + CPPFLAGS="$save_CPPFLAGS $gettext_includes" + LIBS="$save_LIBS $gettext_libraries -lintl" + AC_LINK_IFELSE([ +#include +#ifdef ENABLE_NLS +#undef ENABLE_NLS +#endif +#define ENABLE_NLS 1 +#ifdef HAVE_LOCALE_H +#include +#endif +#include + +int +main() +{ +#ifdef HAVE_SETLOCALE + setlocale(LC_ALL, ""); +#endif + bindtextdomain("gttest", ".locale"); + textdomain("gttest"); + gettext("foo"); + return 0; +} +], + try_nls=yes, try_nls=no) + + if test "$try_nls" = yes; then + INTLINCS="$gettext_includes" + INTLLIBS="$gettext_libraries -lintl" + fi + fi + + dnl * + dnl * Test 3: Try to link libiconv. + dnl * + if test "$try_nls" = no; then + CPPFLAGS="$save_CPPFLAGS" + LIBS="$save_LIBS $iconv_libraries -liconv" + AC_LINK_IFELSE([ +#include +#ifdef ENABLE_NLS +#undef ENABLE_NLS +#endif +#define ENABLE_NLS 1 +#ifdef HAVE_LOCALE_H +#include +#endif +#include + +int +main() +{ +#ifdef HAVE_SETLOCALE + setlocale(LC_ALL, ""); +#endif + bindtextdomain("gttest", ".locale"); + textdomain("gttest"); + gettext("foo"); + return 0; +} +], + try_nls=yes, try_nls=no) + + if test "$try_nls" = yes; then + INTLINCS= + INTLLIBS="$iconv_libraries -liconv" + fi + fi + + dnl * + dnl * Test 4: Try to link libc only. + dnl * + if test "$try_nls" = no; then + CPPFLAGS="$save_CPPFLAGS" + LIBS="$save_LIBS" + AC_LINK_IFELSE([ +#include +#ifdef ENABLE_NLS +#undef ENABLE_NLS +#endif +#define ENABLE_NLS 1 +#ifdef HAVE_LOCALE_H +#include +#endif +#include + +int +main() +{ +#ifdef HAVE_SETLOCALE + setlocale(LC_ALL, ""); +#endif + bindtextdomain("gttest", ".locale"); + textdomain("gttest"); + gettext("foo"); + return 0; +} +], + try_nls=yes, try_nls=no) + + if test "$try_nls" = yes; then + INTLINCS= + INTLLIBS= + fi + fi + + CPPFLAGS=$save_CPPFLAGS + LIBS=$save_LIBS + fi + + if test $ENABLE_NLS = auto; then + ENABLE_NLS=$try_nls + fi + + AC_MSG_RESULT($try_nls) + + if test $ENABLE_NLS = yes; then + if test $try_nls = no; then + AC_MSG_ERROR(gettext not available) + fi + fi + + AC_SUBST(ENABLE_NLS) + AC_SUBST(INTLINCS) + AC_SUBST(INTLLIBS) + localedir='$(datadir)/locale' + AC_SUBST(localedir) + if test $ENABLE_NLS = yes; then + AC_DEFINE(ENABLE_NLS, 1, [Define if NLS is requested]) + fi + + dnl * + dnl * Check msgfmt and xgettext commands. + dnl * + AC_PATH_PROGS(MSGFMT, gmsgfmt msgfmt, :) + AC_PATH_PROGS(XGETTEXT, gxgettext xgettext, :) + MSGMERGE=msgmerge + AC_SUBST(MSGMERGE) +]) diff --git a/m4/in6addr.m4 b/m4/in6addr.m4 new file mode 100644 index 0000000..9268bb8 --- /dev/null +++ b/m4/in6addr.m4 @@ -0,0 +1,99 @@ +dnl * +dnl * Copyright (c) 2001-2006 Motoyuki Kasahara +dnl * +dnl * Redistribution and use in source and binary forms, with or without +dnl * modification, are permitted provided that the following conditions +dnl * are met: +dnl * 1. Redistributions of source code must retain the above copyright +dnl * notice, this list of conditions and the following disclaimer. +dnl * 2. Redistributions in binary form must reproduce the above copyright +dnl * notice, this list of conditions and the following disclaimer in the +dnl * documentation and/or other materials provided with the distribution. +dnl * 3. Neither the name of the project nor the names of its contributors +dnl * may be used to endorse or promote products derived from this software +dnl * without specific prior written permission. +dnl * +dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +dnl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE +dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +dnl * THE POSSIBILITY OF SUCH DAMAGE. +dnl * + +dnl * +dnl * Check for struct in6_addr +dnl * +AC_DEFUN([AC_STRUCT_IN6_ADDR], +[AC_CACHE_CHECK(for struct in6_addr, ac_cv_struct_in6_addr, +[AC_COMPILE_IFELSE([ +#include +#include +#include +struct in6_addr address; +], [ac_cv_struct_in6_addr=yes], [ac_cv_struct_in6_addr=no])]) +if test "$ac_cv_struct_in6_addr" = yes; then + AC_DEFINE(HAVE_STRUCT_IN6_ADDR, 1, +[Define to 1 if defines `struct in6_addr']) +fi]) + +dnl * +dnl * Check for in6addr_any. +dnl * +AC_DEFUN([AC_DECL_IN6ADDR_ANY], +[AC_REQUIRE([AC_STRUCT_IN6_ADDR]) +if test $ac_cv_struct_in6_addr = no; then + ac_cv_decl_in6addr_any=no +else + AC_CACHE_CHECK(for in6addr_any declaration in netinet/in.h, + ac_cv_decl_in6addr_any, + [AC_COMPILE_IFELSE([ +#include +#include +#include + +void +testfunc() +{ + unsigned char *address; + address = (char *)&in6addr_any; +} +], [ac_cv_decl_in6addr_any=yes], [ac_cv_decl_in6addr_any=no])]) + if test "$ac_cv_decl_in6addr_any" = yes; then + AC_DEFINE(IN6ADDR_ANY_DECLARED, 1, +[Define to 1 if `in6addr_any' is declared by ]) + fi +fi]) + +dnl * +dnl * Check for in6addr_loopback. +dnl * +AC_DEFUN([AC_DECL_IN6ADDR_LOOPBACK], +[AC_REQUIRE([AC_STRUCT_IN6_ADDR]) +if test $ac_cv_struct_in6_addr = no; then + ac_cv_decl_in6addr_loopback=no +else + AC_CACHE_CHECK(for in6addr_loopback declaration in netinet/in.h, + ac_cv_decl_in6addr_loopback, + [AC_COMPILE_IFELSE([ +#include +#include +#include + +int +testfunc() +{ + unsigned char *address; + address = (char *)&in6addr_loopback; +} +], [ac_cv_decl_in6addr_loopback=yes], [ac_cv_decl_in6addr_loopback=no])]) + if test "$ac_cv_decl_in6addr_loopback" = yes; then + AC_DEFINE(IN6ADDR_LOOPBACK_DECLARED, 1, +[Define to 1 if `in6addr_loopback' is declared by ]) + fi +fi]) diff --git a/m4/largefile.m4 b/m4/largefile.m4 new file mode 100644 index 0000000..7d98cae --- /dev/null +++ b/m4/largefile.m4 @@ -0,0 +1,63 @@ +dnl * +dnl * Copyright (c) 2009 Motoyuki Kasahara +dnl * +dnl * Redistribution and use in source and binary forms, with or without +dnl * modification, are permitted provided that the following conditions +dnl * are met: +dnl * 1. Redistributions of source code must retain the above copyright +dnl * notice, this list of conditions and the following disclaimer. +dnl * 2. Redistributions in binary form must reproduce the above copyright +dnl * notice, this list of conditions and the following disclaimer in the +dnl * documentation and/or other materials provided with the distribution. +dnl * 3. Neither the name of the project nor the names of its contributors +dnl * may be used to endorse or promote products derived from this software +dnl * without specific prior written permission. +dnl * +dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +dnl * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +dnl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +dnl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +dnl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +dnl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +dnl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +dnl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +dnl * SUCH DAMAGE. +dnl * + +dnl * +dnl * Check for large file support. +dnl * +AC_DEFUN([eb_SYS_LARGEFILE], [dnl +AC_REQUIRE([AC_SYS_LARGEFILE]) +AC_CACHE_CHECK([for ll modifier of printf], ac_cv_func_printf_ll, +[AC_RUN_IFELSE([ + #include + #include + #include + int main() { + char buffer[[128]]; + sprintf(buffer, "%llx", (unsigned long long) 1 << 32); + return (strcmp(buffer, "100000000") == 0) ? 0 : 1; + } +], [ac_cv_func_printf_ll=yes], [ac_cv_func_printf_ll=no])]) +AC_CACHE_CHECK([for I64 modifier of printf], ac_cv_func_printf_i64, +[AC_RUN_IFELSE([ + #include + #include + #include + int main() { + char buffer[[128]]; + sprintf(buffer, "%I64x", (unsigned __int64) 1 << 32); + return (strcmp(buffer, "100000000") == 0) ? 0 : 1; + } +], [ac_cv_func_printf_i64=yes], [ac_cv_func_printf_i64=no])]) +if test "$ac_cv_func_printf_ll" = yes; then + AC_DEFINE(PRINTF_LL_MODIFIER, 1, +[Define to `1' if printf() recognizes "ll" modifier for long long]) +fi +if test "$ac_cv_func_printf_i64" = yes; then + AC_DEFINE(PRINTF_I64_MODIFIER, 1, +[Define to `1' if printf() recognizes "I64" modifier for __int64]) +fi]) diff --git a/m4/lcmessage.m4 b/m4/lcmessage.m4 new file mode 100644 index 0000000..288fe6f --- /dev/null +++ b/m4/lcmessage.m4 @@ -0,0 +1,27 @@ +# Check whether LC_MESSAGES is available in . +# Ulrich Drepper , 1995. +# +# This file can be copied and used freely without restrictions. It can +# be used in projects which are not available under the GNU Public License +# but which still want to provide support for the GNU gettext functionality. +# Please note that the actual code is *not* freely available. + +# serial 1 + +AC_DEFUN([AM_LC_MESSAGES], + [if test $ac_cv_header_locale_h = yes; then + AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES, + [AC_LINK_IFELSE([ +#include +int +main() +{ + return LC_MESSAGES; +} +], + am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)]) + if test $am_cv_val_LC_MESSAGES = yes; then + AC_DEFINE(HAVE_LC_MESSAGES, 1, + [Define to 1 if you have the `LC_MESSAGES' locale category]) + fi + fi]) diff --git a/m4/libtool.m4 b/m4/libtool.m4 new file mode 100644 index 0000000..39ba996 --- /dev/null +++ b/m4/libtool.m4 @@ -0,0 +1,7357 @@ +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +m4_define([_LT_COPYING], [dnl +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is part of GNU Libtool. +# +# GNU Libtool is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Libtool; see the file COPYING. If not, a copy +# can be downloaded from http://www.gnu.org/licenses/gpl.html, or +# obtained by writing to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +]) + +# serial 56 LT_INIT + + +# LT_PREREQ(VERSION) +# ------------------ +# Complain and exit if this libtool version is less that VERSION. +m4_defun([LT_PREREQ], +[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, + [m4_default([$3], + [m4_fatal([Libtool version $1 or higher is required], + 63)])], + [$2])]) + + +# _LT_CHECK_BUILDDIR +# ------------------ +# Complain if the absolute build directory name contains unusual characters +m4_defun([_LT_CHECK_BUILDDIR], +[case `pwd` in + *\ * | *\ *) + AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; +esac +]) + + +# LT_INIT([OPTIONS]) +# ------------------ +AC_DEFUN([LT_INIT], +[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT +AC_BEFORE([$0], [LT_LANG])dnl +AC_BEFORE([$0], [LT_OUTPUT])dnl +AC_BEFORE([$0], [LTDL_INIT])dnl +m4_require([_LT_CHECK_BUILDDIR])dnl + +dnl Autoconf doesn't catch unexpanded LT_ macros by default: +m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl +m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl +dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 +dnl unless we require an AC_DEFUNed macro: +AC_REQUIRE([LTOPTIONS_VERSION])dnl +AC_REQUIRE([LTSUGAR_VERSION])dnl +AC_REQUIRE([LTVERSION_VERSION])dnl +AC_REQUIRE([LTOBSOLETE_VERSION])dnl +m4_require([_LT_PROG_LTMAIN])dnl + +dnl Parse OPTIONS +_LT_SET_OPTIONS([$0], [$1]) + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ltmain" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +_LT_SETUP + +# Only expand once: +m4_define([LT_INIT]) +])# LT_INIT + +# Old names: +AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) +AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PROG_LIBTOOL], []) +dnl AC_DEFUN([AM_PROG_LIBTOOL], []) + + +# _LT_CC_BASENAME(CC) +# ------------------- +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +m4_defun([_LT_CC_BASENAME], +[for cc_temp in $1""; do + case $cc_temp in + compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; + distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` +]) + + +# _LT_FILEUTILS_DEFAULTS +# ---------------------- +# It is okay to use these file commands and assume they have been set +# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. +m4_defun([_LT_FILEUTILS_DEFAULTS], +[: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} +])# _LT_FILEUTILS_DEFAULTS + + +# _LT_SETUP +# --------- +m4_defun([_LT_SETUP], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +_LT_DECL([], [host_alias], [0], [The host system])dnl +_LT_DECL([], [host], [0])dnl +_LT_DECL([], [host_os], [0])dnl +dnl +_LT_DECL([], [build_alias], [0], [The build system])dnl +_LT_DECL([], [build], [0])dnl +_LT_DECL([], [build_os], [0])dnl +dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +test -z "$LN_S" && LN_S="ln -s" +_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl +dnl +AC_REQUIRE([LT_CMD_MAX_LEN])dnl +_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl +_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl +dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_CHECK_SHELL_FEATURES])dnl +m4_require([_LT_CMD_RELOAD])dnl +m4_require([_LT_CHECK_MAGIC_METHOD])dnl +m4_require([_LT_CMD_OLD_ARCHIVE])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl + +_LT_CONFIG_LIBTOOL_INIT([ +# See if we are running on zsh, and set the options which allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi +]) +if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi + +_LT_CHECK_OBJDIR + +m4_require([_LT_TAG_COMPILER])dnl +_LT_PROG_ECHO_BACKSLASH + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([["`\\]]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld="$lt_cv_prog_gnu_ld" + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +_LT_CC_BASENAME([$compiler]) + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + _LT_PATH_MAGIC + fi + ;; +esac + +# Use C for the default configuration in the libtool script +LT_SUPPORTED_TAG([CC]) +_LT_LANG_C_CONFIG +_LT_LANG_DEFAULT_CONFIG +_LT_CONFIG_COMMANDS +])# _LT_SETUP + + +# _LT_PROG_LTMAIN +# --------------- +# Note that this code is called both from `configure', and `config.status' +# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, +# `config.status' has no value for ac_aux_dir unless we are using Automake, +# so we pass a copy along to make sure it has a sensible value anyway. +m4_defun([_LT_PROG_LTMAIN], +[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl +_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) +ltmain="$ac_aux_dir/ltmain.sh" +])# _LT_PROG_LTMAIN + + +## ------------------------------------- ## +## Accumulate code for creating libtool. ## +## ------------------------------------- ## + +# So that we can recreate a full libtool script including additional +# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS +# in macros and then make a single call at the end using the `libtool' +# label. + + +# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) +# ---------------------------------------- +# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL_INIT], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_INIT], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_INIT]) + + +# _LT_CONFIG_LIBTOOL([COMMANDS]) +# ------------------------------ +# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) + + +# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) +# ----------------------------------------------------- +m4_defun([_LT_CONFIG_SAVE_COMMANDS], +[_LT_CONFIG_LIBTOOL([$1]) +_LT_CONFIG_LIBTOOL_INIT([$2]) +]) + + +# _LT_FORMAT_COMMENT([COMMENT]) +# ----------------------------- +# Add leading comment marks to the start of each line, and a trailing +# full-stop to the whole comment if one is not present already. +m4_define([_LT_FORMAT_COMMENT], +[m4_ifval([$1], [ +m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], + [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) +)]) + + + +## ------------------------ ## +## FIXME: Eliminate VARNAME ## +## ------------------------ ## + + +# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) +# ------------------------------------------------------------------- +# CONFIGNAME is the name given to the value in the libtool script. +# VARNAME is the (base) name used in the configure script. +# VALUE may be 0, 1 or 2 for a computed quote escaped value based on +# VARNAME. Any other value will be used directly. +m4_define([_LT_DECL], +[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], + [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], + [m4_ifval([$1], [$1], [$2])]) + lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) + m4_ifval([$4], + [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) + lt_dict_add_subkey([lt_decl_dict], [$2], + [tagged?], [m4_ifval([$5], [yes], [no])])]) +]) + + +# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) +# -------------------------------------------------------- +m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) + + +# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_tag_varnames], +[_lt_decl_filter([tagged?], [yes], $@)]) + + +# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) +# --------------------------------------------------------- +m4_define([_lt_decl_filter], +[m4_case([$#], + [0], [m4_fatal([$0: too few arguments: $#])], + [1], [m4_fatal([$0: too few arguments: $#: $1])], + [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], + [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], + [lt_dict_filter([lt_decl_dict], $@)])[]dnl +]) + + +# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) +# -------------------------------------------------- +m4_define([lt_decl_quote_varnames], +[_lt_decl_filter([value], [1], $@)]) + + +# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_dquote_varnames], +[_lt_decl_filter([value], [2], $@)]) + + +# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_varnames_tagged], +[m4_assert([$# <= 2])dnl +_$0(m4_quote(m4_default([$1], [[, ]])), + m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), + m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) +m4_define([_lt_decl_varnames_tagged], +[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) + + +# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_all_varnames], +[_$0(m4_quote(m4_default([$1], [[, ]])), + m4_if([$2], [], + m4_quote(lt_decl_varnames), + m4_quote(m4_shift($@))))[]dnl +]) +m4_define([_lt_decl_all_varnames], +[lt_join($@, lt_decl_varnames_tagged([$1], + lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl +]) + + +# _LT_CONFIG_STATUS_DECLARE([VARNAME]) +# ------------------------------------ +# Quote a variable value, and forward it to `config.status' so that its +# declaration there will have the same value as in `configure'. VARNAME +# must have a single quote delimited value for this to work. +m4_define([_LT_CONFIG_STATUS_DECLARE], +[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`']) + + +# _LT_CONFIG_STATUS_DECLARATIONS +# ------------------------------ +# We delimit libtool config variables with single quotes, so when +# we write them to config.status, we have to be sure to quote all +# embedded single quotes properly. In configure, this macro expands +# each variable declared with _LT_DECL (and _LT_TAGDECL) into: +# +# ='`$ECHO "X$" | $Xsed -e "$delay_single_quote_subst"`' +m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], +[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), + [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAGS +# ---------------- +# Output comment and list of tags supported by the script +m4_defun([_LT_LIBTOOL_TAGS], +[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl +available_tags="_LT_TAGS"dnl +]) + + +# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) +# ----------------------------------- +# Extract the dictionary values for VARNAME (optionally with TAG) and +# expand to a commented shell variable setting: +# +# # Some comment about what VAR is for. +# visible_name=$lt_internal_name +m4_define([_LT_LIBTOOL_DECLARE], +[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], + [description])))[]dnl +m4_pushdef([_libtool_name], + m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl +m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), + [0], [_libtool_name=[$]$1], + [1], [_libtool_name=$lt_[]$1], + [2], [_libtool_name=$lt_[]$1], + [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl +m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl +]) + + +# _LT_LIBTOOL_CONFIG_VARS +# ----------------------- +# Produce commented declarations of non-tagged libtool config variables +# suitable for insertion in the LIBTOOL CONFIG section of the `libtool' +# script. Tagged libtool config variables (even for the LIBTOOL CONFIG +# section) are produced by _LT_LIBTOOL_TAG_VARS. +m4_defun([_LT_LIBTOOL_CONFIG_VARS], +[m4_foreach([_lt_var], + m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAG_VARS(TAG) +# ------------------------- +m4_define([_LT_LIBTOOL_TAG_VARS], +[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) + + +# _LT_TAGVAR(VARNAME, [TAGNAME]) +# ------------------------------ +m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) + + +# _LT_CONFIG_COMMANDS +# ------------------- +# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of +# variables for single and double quote escaping we saved from calls +# to _LT_DECL, we can put quote escaped variables declarations +# into `config.status', and then the shell code to quote escape them in +# for loops in `config.status'. Finally, any additional code accumulated +# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. +m4_defun([_LT_CONFIG_COMMANDS], +[AC_PROVIDE_IFELSE([LT_OUTPUT], + dnl If the libtool generation code has been placed in $CONFIG_LT, + dnl instead of duplicating it all over again into config.status, + dnl then we will have config.status run $CONFIG_LT later, so it + dnl needs to know what name is stored there: + [AC_CONFIG_COMMANDS([libtool], + [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], + dnl If the libtool generation code is destined for config.status, + dnl expand the accumulated commands and init code now: + [AC_CONFIG_COMMANDS([libtool], + [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) +])#_LT_CONFIG_COMMANDS + + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], +[ + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +_LT_CONFIG_STATUS_DECLARATIONS +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# Quote evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_quote_varnames); do + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_dquote_varnames); do + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Fix-up fallback echo if it was mangled by the above quoting rules. +case \$lt_ECHO in +*'\\\[$]0 --fallback-echo"')dnl " + lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\` + ;; +esac + +_LT_OUTPUT_LIBTOOL_INIT +]) + + +# LT_OUTPUT +# --------- +# This macro allows early generation of the libtool script (before +# AC_OUTPUT is called), incase it is used in configure for compilation +# tests. +AC_DEFUN([LT_OUTPUT], +[: ${CONFIG_LT=./config.lt} +AC_MSG_NOTICE([creating $CONFIG_LT]) +cat >"$CONFIG_LT" <<_LTEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate a libtool stub with the current configuration. + +lt_cl_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_LTEOF + +cat >>"$CONFIG_LT" <<\_LTEOF +AS_SHELL_SANITIZE +_AS_PREPARE + +exec AS_MESSAGE_FD>&1 +exec AS_MESSAGE_LOG_FD>>config.log +{ + echo + AS_BOX([Running $as_me.]) +} >&AS_MESSAGE_LOG_FD + +lt_cl_help="\ +\`$as_me' creates a local libtool stub from the current configuration, +for use in further configure time tests before the real libtool is +generated. + +Usage: $[0] [[OPTIONS]] + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + +Report bugs to ." + +lt_cl_version="\ +m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl +m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) +configured by $[0], generated by m4_PACKAGE_STRING. + +Copyright (C) 2008 Free Software Foundation, Inc. +This config.lt script is free software; the Free Software Foundation +gives unlimited permision to copy, distribute and modify it." + +while test $[#] != 0 +do + case $[1] in + --version | --v* | -V ) + echo "$lt_cl_version"; exit 0 ;; + --help | --h* | -h ) + echo "$lt_cl_help"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --quiet | --q* | --silent | --s* | -q ) + lt_cl_silent=: ;; + + -*) AC_MSG_ERROR([unrecognized option: $[1] +Try \`$[0] --help' for more information.]) ;; + + *) AC_MSG_ERROR([unrecognized argument: $[1] +Try \`$[0] --help' for more information.]) ;; + esac + shift +done + +if $lt_cl_silent; then + exec AS_MESSAGE_FD>/dev/null +fi +_LTEOF + +cat >>"$CONFIG_LT" <<_LTEOF +_LT_OUTPUT_LIBTOOL_COMMANDS_INIT +_LTEOF + +cat >>"$CONFIG_LT" <<\_LTEOF +AC_MSG_NOTICE([creating $ofile]) +_LT_OUTPUT_LIBTOOL_COMMANDS +AS_EXIT(0) +_LTEOF +chmod +x "$CONFIG_LT" + +# configure is writing to config.log, but config.lt does its own redirection, +# appending to config.log, which fails on DOS, as config.log is still kept +# open by configure. Here we exec the FD to /dev/null, effectively closing +# config.log, so it can be properly (re)opened and appended to by config.lt. +if test "$no_create" != yes; then + lt_cl_success=: + test "$silent" = yes && + lt_config_lt_args="$lt_config_lt_args --quiet" + exec AS_MESSAGE_LOG_FD>/dev/null + $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false + exec AS_MESSAGE_LOG_FD>>config.log + $lt_cl_success || AS_EXIT(1) +fi +])# LT_OUTPUT + + +# _LT_CONFIG(TAG) +# --------------- +# If TAG is the built-in tag, create an initial libtool script with a +# default configuration from the untagged config vars. Otherwise add code +# to config.status for appending the configuration named by TAG from the +# matching tagged config vars. +m4_defun([_LT_CONFIG], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_CONFIG_SAVE_COMMANDS([ + m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl + m4_if(_LT_TAG, [C], [ + # See if we are running on zsh, and set the options which allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + + cfgfile="${ofile}T" + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL + +# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +_LT_COPYING +_LT_LIBTOOL_TAGS + +# ### BEGIN LIBTOOL CONFIG +_LT_LIBTOOL_CONFIG_VARS +_LT_LIBTOOL_TAG_VARS +# ### END LIBTOOL CONFIG + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + _LT_PROG_LTMAIN + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + _LT_PROG_XSI_SHELLFNS + + sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" +], +[cat <<_LT_EOF >> "$ofile" + +dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded +dnl in a comment (ie after a #). +# ### BEGIN LIBTOOL TAG CONFIG: $1 +_LT_LIBTOOL_TAG_VARS(_LT_TAG) +# ### END LIBTOOL TAG CONFIG: $1 +_LT_EOF +])dnl /m4_if +], +[m4_if([$1], [], [ + PACKAGE='$PACKAGE' + VERSION='$VERSION' + TIMESTAMP='$TIMESTAMP' + RM='$RM' + ofile='$ofile'], []) +])dnl /_LT_CONFIG_SAVE_COMMANDS +])# _LT_CONFIG + + +# LT_SUPPORTED_TAG(TAG) +# --------------------- +# Trace this macro to discover what tags are supported by the libtool +# --tag option, using: +# autoconf --trace 'LT_SUPPORTED_TAG:$1' +AC_DEFUN([LT_SUPPORTED_TAG], []) + + +# C support is built-in for now +m4_define([_LT_LANG_C_enabled], []) +m4_define([_LT_TAGS], []) + + +# LT_LANG(LANG) +# ------------- +# Enable libtool support for the given language if not already enabled. +AC_DEFUN([LT_LANG], +[AC_BEFORE([$0], [LT_OUTPUT])dnl +m4_case([$1], + [C], [_LT_LANG(C)], + [C++], [_LT_LANG(CXX)], + [Java], [_LT_LANG(GCJ)], + [Fortran 77], [_LT_LANG(F77)], + [Fortran], [_LT_LANG(FC)], + [Windows Resource], [_LT_LANG(RC)], + [m4_ifdef([_LT_LANG_]$1[_CONFIG], + [_LT_LANG($1)], + [m4_fatal([$0: unsupported language: "$1"])])])dnl +])# LT_LANG + + +# _LT_LANG(LANGNAME) +# ------------------ +m4_defun([_LT_LANG], +[m4_ifdef([_LT_LANG_]$1[_enabled], [], + [LT_SUPPORTED_TAG([$1])dnl + m4_append([_LT_TAGS], [$1 ])dnl + m4_define([_LT_LANG_]$1[_enabled], [])dnl + _LT_LANG_$1_CONFIG($1)])dnl +])# _LT_LANG + + +# _LT_LANG_DEFAULT_CONFIG +# ----------------------- +m4_defun([_LT_LANG_DEFAULT_CONFIG], +[AC_PROVIDE_IFELSE([AC_PROG_CXX], + [LT_LANG(CXX)], + [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) + +AC_PROVIDE_IFELSE([AC_PROG_F77], + [LT_LANG(F77)], + [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) + +AC_PROVIDE_IFELSE([AC_PROG_FC], + [LT_LANG(FC)], + [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) + +dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal +dnl pulling things in needlessly. +AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([LT_PROG_GCJ], + [LT_LANG(GCJ)], + [m4_ifdef([AC_PROG_GCJ], + [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([A][M_PROG_GCJ], + [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([LT_PROG_GCJ], + [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) + +AC_PROVIDE_IFELSE([LT_PROG_RC], + [LT_LANG(RC)], + [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) +])# _LT_LANG_DEFAULT_CONFIG + +# Obsolete macros: +AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) +AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) +AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) +AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_CXX], []) +dnl AC_DEFUN([AC_LIBTOOL_F77], []) +dnl AC_DEFUN([AC_LIBTOOL_FC], []) +dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) + + +# _LT_TAG_COMPILER +# ---------------- +m4_defun([_LT_TAG_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl +_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl +_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl +_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC +])# _LT_TAG_COMPILER + + +# _LT_COMPILER_BOILERPLATE +# ------------------------ +# Check for compiler boilerplate output or warnings with +# the simple compiler test code. +m4_defun([_LT_COMPILER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* +])# _LT_COMPILER_BOILERPLATE + + +# _LT_LINKER_BOILERPLATE +# ---------------------- +# Check for linker boilerplate output or warnings with +# the simple link test code. +m4_defun([_LT_LINKER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* +])# _LT_LINKER_BOILERPLATE + +# _LT_REQUIRED_DARWIN_CHECKS +# ------------------------- +m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ + case $host_os in + rhapsody* | darwin*) + AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) + AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) + AC_CHECK_TOOL([LIPO], [lipo], [:]) + AC_CHECK_TOOL([OTOOL], [otool], [:]) + AC_CHECK_TOOL([OTOOL64], [otool64], [:]) + _LT_DECL([], [DSYMUTIL], [1], + [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) + _LT_DECL([], [NMEDIT], [1], + [Tool to change global to local symbols on Mac OS X]) + _LT_DECL([], [LIPO], [1], + [Tool to manipulate fat objects and archives on Mac OS X]) + _LT_DECL([], [OTOOL], [1], + [ldd/readelf like tool for Mach-O binaries on Mac OS X]) + _LT_DECL([], [OTOOL64], [1], + [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) + + AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], + [lt_cv_apple_cc_single_mod=no + if test -z "${LT_MULTI_MODULE}"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&AS_MESSAGE_LOG_FD + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi]) + AC_CACHE_CHECK([for -exported_symbols_list linker flag], + [lt_cv_ld_exported_symbols_list], + [lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [lt_cv_ld_exported_symbols_list=yes], + [lt_cv_ld_exported_symbols_list=no]) + LDFLAGS="$save_LDFLAGS" + ]) + case $host_os in + rhapsody* | darwin1.[[012]]) + _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + 10.[[012]]*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test "$lt_cv_apple_cc_single_mod" = "yes"; then + _lt_dar_single_mod='$single_module' + fi + if test "$lt_cv_ld_exported_symbols_list" = "yes"; then + _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + if test "$DSYMUTIL" != ":"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac +]) + + +# _LT_DARWIN_LINKER_FEATURES +# -------------------------- +# Checks for linker and compiler features on darwin +m4_defun([_LT_DARWIN_LINKER_FEATURES], +[ + m4_require([_LT_REQUIRED_DARWIN_CHECKS]) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_automatic, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_TAGVAR(whole_archive_flag_spec, $1)='' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" + case $cc_basename in + ifort*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test "$_lt_dar_can_shared" = "yes"; then + output_verbose_link_cmd=echo + _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + m4_if([$1], [CXX], +[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then + _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" + fi +],[]) + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi +]) + +# _LT_SYS_MODULE_PATH_AIX +# ----------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +m4_defun([_LT_SYS_MODULE_PATH_AIX], +[m4_require([_LT_DECL_SED])dnl +AC_LINK_IFELSE(AC_LANG_PROGRAM,[ +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi],[]) +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +])# _LT_SYS_MODULE_PATH_AIX + + +# _LT_SHELL_INIT(ARG) +# ------------------- +m4_define([_LT_SHELL_INIT], +[ifdef([AC_DIVERSION_NOTICE], + [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], + [AC_DIVERT_PUSH(NOTICE)]) +$1 +AC_DIVERT_POP +])# _LT_SHELL_INIT + + +# _LT_PROG_ECHO_BACKSLASH +# ----------------------- +# Add some code to the start of the generated configure script which +# will find an echo command which doesn't interpret backslashes. +m4_defun([_LT_PROG_ECHO_BACKSLASH], +[_LT_SHELL_INIT([ +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$lt_ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` + ;; +esac + +ECHO=${lt_ECHO-echo} +if test "X[$]1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X[$]1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then + # Yippee, $ECHO works! + : +else + # Restart under the correct shell. + exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} +fi + +if test "X[$]1" = X--fallback-echo; then + # used as fallback echo + shift + cat <<_LT_EOF +[$]* +_LT_EOF + exit 0 +fi + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test -z "$lt_ECHO"; then + if test "X${echo_test_string+set}" != Xset; then + # find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if { echo_test_string=`eval $cmd`; } 2>/dev/null && + { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null + then + break + fi + done + fi + + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : + else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$ECHO" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + ECHO='print -r' + elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} + else + # Try using printf. + ECHO='printf %s\n' + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + ECHO="$CONFIG_SHELL [$]0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$CONFIG_SHELL [$]0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do + if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "[$]0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} + else + # Oops. We lost completely, so just stick with echo. + ECHO=echo + fi + fi + fi + fi + fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +lt_ECHO=$ECHO +if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then + lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" +fi + +AC_SUBST(lt_ECHO) +]) +_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) +_LT_DECL([], [ECHO], [1], + [An echo program that does not interpret backslashes]) +])# _LT_PROG_ECHO_BACKSLASH + + +# _LT_ENABLE_LOCK +# --------------- +m4_defun([_LT_ENABLE_LOCK], +[AC_ARG_ENABLE([libtool-lock], + [AS_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_PUSH(C) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_POP]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +sparc*-*solaris*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) LD="${LD-ld} -m elf64_sparc" ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; +esac + +need_locks="$enable_libtool_lock" +])# _LT_ENABLE_LOCK + + +# _LT_CMD_OLD_ARCHIVE +# ------------------- +m4_defun([_LT_CMD_OLD_ARCHIVE], +[AC_CHECK_TOOL(AR, ar, false) +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +_LT_DECL([], [AR], [1], [The archiver]) +_LT_DECL([], [AR_FLAGS], [1]) + +AC_CHECK_TOOL(STRIP, strip, :) +test -z "$STRIP" && STRIP=: +_LT_DECL([], [STRIP], [1], [A symbol stripping program]) + +AC_CHECK_TOOL(RANLIB, ranlib, :) +test -z "$RANLIB" && RANLIB=: +_LT_DECL([], [RANLIB], [1], + [Commands used to install an old-style archive]) + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi +_LT_DECL([], [old_postinstall_cmds], [2]) +_LT_DECL([], [old_postuninstall_cmds], [2]) +_LT_TAGDECL([], [old_archive_cmds], [2], + [Commands used to build an old-style archive]) +])# _LT_CMD_OLD_ARCHIVE + + +# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------------------- +# Check whether the given compiler option works +AC_DEFUN([_LT_COMPILER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$3" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + fi + $RM conftest* +]) + +if test x"[$]$2" = xyes; then + m4_if([$5], , :, [$5]) +else + m4_if([$6], , :, [$6]) +fi +])# _LT_COMPILER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) + + +# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------- +# Check whether the given linker option works +AC_DEFUN([_LT_LINKER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $3" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&AS_MESSAGE_LOG_FD + $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + else + $2=yes + fi + fi + $RM -r conftest* + LDFLAGS="$save_LDFLAGS" +]) + +if test x"[$]$2" = xyes; then + m4_if([$4], , :, [$4]) +else + m4_if([$5], , :, [$5]) +fi +])# _LT_LINKER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) + + +# LT_CMD_MAX_LEN +#--------------- +AC_DEFUN([LT_CMD_MAX_LEN], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +# find the maximum length of command line arguments +AC_MSG_CHECKING([the maximum length of command line arguments]) +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8 ; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ + = "XX$teststring$teststring"; } >/dev/null 2>&1 && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac +]) +if test -n $lt_cv_sys_max_cmd_len ; then + AC_MSG_RESULT($lt_cv_sys_max_cmd_len) +else + AC_MSG_RESULT(none) +fi +max_cmd_len=$lt_cv_sys_max_cmd_len +_LT_DECL([], [max_cmd_len], [0], + [What is the maximum length of a command?]) +])# LT_CMD_MAX_LEN + +# Old name: +AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) + + +# _LT_HEADER_DLFCN +# ---------------- +m4_defun([_LT_HEADER_DLFCN], +[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl +])# _LT_HEADER_DLFCN + + +# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# ---------------------------------------------------------------- +m4_defun([_LT_TRY_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test "$cross_compiling" = yes; then : + [$4] +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +[#line __oline__ "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +}] +_LT_EOF + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_dlunknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_TRY_DLOPEN_SELF + + +# LT_SYS_DLOPEN_SELF +# ------------------ +AC_DEFUN([LT_SYS_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32* | cegcc*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ]) + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen="shl_load"], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen="dlopen"], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test "x$lt_cv_dlopen_self" = xyes; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +_LT_DECL([dlopen_support], [enable_dlopen], [0], + [Whether dlopen is supported]) +_LT_DECL([dlopen_self], [enable_dlopen_self], [0], + [Whether dlopen of programs is supported]) +_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], + [Whether dlopen of statically linked programs is supported]) +])# LT_SYS_DLOPEN_SELF + +# Old name: +AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) + + +# _LT_COMPILER_C_O([TAGNAME]) +# --------------------------- +# Check to see if options -c and -o are simultaneously supported by compiler. +# This macro does not hard code the compiler like AC_PROG_CC_C_O. +m4_defun([_LT_COMPILER_C_O], +[m4_require([_LT_DECL_SED])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + fi + fi + chmod u+w . 2>&AS_MESSAGE_LOG_FD + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* +]) +_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], + [Does compiler simultaneously support -c and -o options?]) +])# _LT_COMPILER_C_O + + +# _LT_COMPILER_FILE_LOCKS([TAGNAME]) +# ---------------------------------- +# Check to see if we can do hard links to lock some files if needed +m4_defun([_LT_COMPILER_FILE_LOCKS], +[m4_require([_LT_ENABLE_LOCK])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_COMPILER_C_O([$1]) + +hard_links="nottested" +if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test "$hard_links" = no; then + AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) +])# _LT_COMPILER_FILE_LOCKS + + +# _LT_CHECK_OBJDIR +# ---------------- +m4_defun([_LT_CHECK_OBJDIR], +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], +[rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null]) +objdir=$lt_cv_objdir +_LT_DECL([], [objdir], [0], + [The name of the directory that contains temporary libtool files])dnl +m4_pattern_allow([LT_OBJDIR])dnl +AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", + [Define to the sub-directory in which libtool stores uninstalled libraries.]) +])# _LT_CHECK_OBJDIR + + +# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) +# -------------------------------------- +# Check hardcoding attributes. +m4_defun([_LT_LINKER_HARDCODE_LIBPATH], +[AC_MSG_CHECKING([how to hardcode library paths into programs]) +_LT_TAGVAR(hardcode_action, $1)= +if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || + test -n "$_LT_TAGVAR(runpath_var, $1)" || + test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then + + # We can hardcode non-existent directories. + if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && + test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then + # Linking always hardcodes the temporary library directory. + _LT_TAGVAR(hardcode_action, $1)=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + _LT_TAGVAR(hardcode_action, $1)=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + _LT_TAGVAR(hardcode_action, $1)=unsupported +fi +AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) + +if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || + test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi +_LT_TAGDECL([], [hardcode_action], [0], + [How to hardcode a shared library path into an executable]) +])# _LT_LINKER_HARDCODE_LIBPATH + + +# _LT_CMD_STRIPLIB +# ---------------- +m4_defun([_LT_CMD_STRIPLIB], +[m4_require([_LT_DECL_EGREP]) +striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac +fi +_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) +_LT_DECL([], [striplib], [1]) +])# _LT_CMD_STRIPLIB + + +# _LT_SYS_DYNAMIC_LINKER([TAG]) +# ----------------------------- +# PORTME Fill in your ld.so characteristics +m4_defun([_LT_SYS_DYNAMIC_LINKER], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_OBJDUMP])dnl +m4_require([_LT_DECL_SED])dnl +AC_MSG_CHECKING([dynamic linker characteristics]) +m4_if([$1], + [], [ +if test "$GCC" = yes; then + case $host_os in + darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; + *) lt_awk_arg="/^libraries:/" ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` + else + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary. + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path/$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" + else + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' +BEGIN {RS=" "; FS="/|\n";} { + lt_foo=""; + lt_count=0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo="/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[[lt_foo]]++; } + if (lt_freq[[lt_foo]] == 1) { print lt_foo; } +}'` + sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix[[4-9]]*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[[45]]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' +m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[[123]]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[[01]]* | freebsdelf3.[[01]]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ + freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix[[3-9]]*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # Some binutils ld are patched to set DT_RUNPATH + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ + LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], + [shlibpath_overrides_runpath=yes])]) + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[[89]] | openbsd2.[[89]].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then + sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +fi +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then + sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" +fi + +_LT_DECL([], [variables_saved_for_relink], [1], + [Variables whose values should be saved in libtool wrapper scripts and + restored at link time]) +_LT_DECL([], [need_lib_prefix], [0], + [Do we need the "lib" prefix for modules?]) +_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) +_LT_DECL([], [version_type], [0], [Library versioning type]) +_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) +_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) +_LT_DECL([], [shlibpath_overrides_runpath], [0], + [Is shlibpath searched before the hard-coded library search path?]) +_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) +_LT_DECL([], [library_names_spec], [1], + [[List of archive names. First name is the real one, the rest are links. + The last name is the one that the linker finds with -lNAME]]) +_LT_DECL([], [soname_spec], [1], + [[The coded name of the library, if different from the real name]]) +_LT_DECL([], [postinstall_cmds], [2], + [Command to use after installation of a shared archive]) +_LT_DECL([], [postuninstall_cmds], [2], + [Command to use after uninstallation of a shared archive]) +_LT_DECL([], [finish_cmds], [2], + [Commands used to finish a libtool library installation in a directory]) +_LT_DECL([], [finish_eval], [1], + [[As "finish_cmds", except a single script fragment to be evaled but + not shown]]) +_LT_DECL([], [hardcode_into_libs], [0], + [Whether we should hardcode library paths into libraries]) +_LT_DECL([], [sys_lib_search_path_spec], [2], + [Compile-time system search path for libraries]) +_LT_DECL([], [sys_lib_dlsearch_path_spec], [2], + [Run-time system search path for libraries]) +])# _LT_SYS_DYNAMIC_LINKER + + +# _LT_PATH_TOOL_PREFIX(TOOL) +# -------------------------- +# find a file program which can recognize shared library +AC_DEFUN([_LT_PATH_TOOL_PREFIX], +[m4_require([_LT_DECL_EGREP])dnl +AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in +[[\\/*] | ?:[\\/]*]) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="m4_if([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$1; then + lt_cv_path_MAGIC_CMD="$ac_dir/$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac]) +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +_LT_DECL([], [MAGIC_CMD], [0], + [Used to examine libraries when file_magic_cmd begins with "file"])dnl +])# _LT_PATH_TOOL_PREFIX + +# Old name: +AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) + + +# _LT_PATH_MAGIC +# -------------- +# find a file program which can recognize a shared library +m4_defun([_LT_PATH_MAGIC], +[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) + else + MAGIC_CMD=: + fi +fi +])# _LT_PATH_MAGIC + + +# LT_PATH_LD +# ---------- +# find the pathname to the GNU or non-GNU linker +AC_DEFUN([LT_PATH_LD], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl + +AC_ARG_WITH([gnu-ld], + [AS_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld @<:@default=no@:>@])], + [test "$withval" = no || with_gnu_ld=yes], + [with_gnu_ld=no])dnl + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +cegcc) + # use the weaker test based on 'objdump'. See mingw*. + lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[[3-9]]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +esac +]) +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + +_LT_DECL([], [deplibs_check_method], [1], + [Method to check whether dependent libraries are shared objects]) +_LT_DECL([], [file_magic_cmd], [1], + [Command to use when deplibs_check_method == "file_magic"]) +])# _LT_CHECK_MAGIC_METHOD + + +# LT_PATH_NM +# ---------- +# find the pathname to a BSD- or MS-compatible name lister +AC_DEFUN([LT_PATH_NM], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_nm_to_check="${ac_tool_prefix}nm" + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/$lt_tmp_nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS="$lt_save_ifs" + done + : ${lt_cv_path_NM=no} +fi]) +if test "$lt_cv_path_NM" != "no"; then + NM="$lt_cv_path_NM" +else + # Didn't find any BSD compatible name lister, look for dumpbin. + AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :) + AC_SUBST([DUMPBIN]) + if test "$DUMPBIN" != ":"; then + NM="$DUMPBIN" + fi +fi +test -z "$NM" && NM=nm +AC_SUBST([NM]) +_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl + +AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], + [lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD) + cat conftest.out >&AS_MESSAGE_LOG_FD + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest*]) +])# LT_PATH_NM + +# Old names: +AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) +AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_PROG_NM], []) +dnl AC_DEFUN([AC_PROG_NM], []) + + +# LT_LIB_M +# -------- +# check for math library +AC_DEFUN([LT_LIB_M], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, cos, LIBM="-lm") + ;; +esac +AC_SUBST([LIBM]) +])# LT_LIB_M + +# Old name: +AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_CHECK_LIBM], []) + + +# _LT_COMPILER_NO_RTTI([TAGNAME]) +# ------------------------------- +m4_defun([_LT_COMPILER_NO_RTTI], +[m4_require([_LT_TAG_COMPILER])dnl + +_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + +if test "$GCC" = yes; then + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + + _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], + lt_cv_prog_compiler_rtti_exceptions, + [-fno-rtti -fno-exceptions], [], + [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) +fi +_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], + [Compiler flag to turn off builtin functions]) +])# _LT_COMPILER_NO_RTTI + + +# _LT_CMD_GLOBAL_SYMBOLS +# ---------------------- +m4_defun([_LT_CMD_GLOBAL_SYMBOLS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_PATH_NM])dnl +AC_REQUIRE([LT_PATH_LD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_TAG_COMPILER])dnl + +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output from $compiler object]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], +[ +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[[BCDEGRST]]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[[BCDT]]' + ;; +cygwin* | mingw* | pw32* | cegcc*) + symcode='[[ABCDGISTW]]' + ;; +hpux*) + if test "$host_cpu" = ia64; then + symcode='[[ABCDEGRST]]' + fi + ;; +irix* | nonstopux*) + symcode='[[BCDEGRST]]' + ;; +osf*) + symcode='[[BCDEGQRST]]' + ;; +solaris*) + symcode='[[BDRT]]' + ;; +sco3.2v5*) + symcode='[[DT]]' + ;; +sysv4.2uw2*) + symcode='[[DT]]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[[ABDT]]' + ;; +sysv4) + symcode='[[DFNSTU]]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[[ABCDGIRSTW]]' ;; +esac + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function + # and D for any global variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK ['"\ +" {last_section=section; section=\$ 3};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ +" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ +" s[1]~/^[@?]/{print s[1], s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx]" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_LT_EOF + + if AC_TRY_EVAL(ac_compile); then + # Now try to grab the symbols. + nlist=conftest.nm + if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[[]] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi + +_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], + [Take the output of nm and produce a listing of raw symbols and C names]) +_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], + [Transform the output of nm in a proper C declaration]) +_LT_DECL([global_symbol_to_c_name_address], + [lt_cv_sys_global_symbol_to_c_name_address], [1], + [Transform the output of nm in a C name address pair]) +_LT_DECL([global_symbol_to_c_name_address_lib_prefix], + [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], + [Transform the output of nm in a C name address pair when lib prefix is needed]) +]) # _LT_CMD_GLOBAL_SYMBOLS + + +# _LT_COMPILER_PIC([TAGNAME]) +# --------------------------- +m4_defun([_LT_COMPILER_PIC], +[m4_require([_LT_TAG_COMPILER])dnl +_LT_TAGVAR(lt_prog_compiler_wl, $1)= +_LT_TAGVAR(lt_prog_compiler_pic, $1)= +_LT_TAGVAR(lt_prog_compiler_static, $1)= + +AC_MSG_CHECKING([for $compiler option to produce PIC]) +m4_if([$1], [CXX], [ + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + case $host_os in + aix[[4-9]]*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + dgux*) + case $cc_basename in + ec++*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + if test "$host_cpu" != ia64; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + fi + ;; + aCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # KAI C++ Compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + ecpc* ) + # old Intel C++ for x86_64 which still supported -KPIC. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + icpc* ) + # Intel C++, used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xlc* | xlC*) + # IBM XL 8.0 on PPC + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + esac + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd*) + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + cxx*) + # Digital/Compaq C++ + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + lcc*) + # Lucid + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + *) + ;; + esac + ;; + vxworks*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +], +[ + if test "$GCC" = yes; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + hpux9* | hpux10* | hpux11*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC (with -KPIC) is the default. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + linux* | k*bsd*-gnu) + case $cc_basename in + # old Intel for x86_64 which still supported -KPIC. + ecc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' + _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + ccc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All Alpha code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xl*) + # IBM XL C 8.0/Fortran 10.1 on PPC + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + *Sun\ F*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='' + ;; + esac + ;; + esac + ;; + + newsos6) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All OSF/1 code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + rdos*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + solaris*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; + *) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; + esac + ;; + + sunos4*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + unicos*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + + uts4*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +]) +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" + ;; +esac +AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) +_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], + [How to pass a linker flag through the compiler]) + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], + [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], + [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], + [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in + "" | " "*) ;; + *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; + esac], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) +fi +_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], + [Additional compiler flags for building library objects]) + +# +# Check to make sure the static flag actually works. +# +wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" +_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], + _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), + $lt_tmp_static_flag, + [], + [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) +_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], + [Compiler flag to prevent dynamic linking]) +])# _LT_COMPILER_PIC + + +# _LT_LINKER_SHLIBS([TAGNAME]) +# ---------------------------- +# See if the linker supports building shared libraries. +m4_defun([_LT_LINKER_SHLIBS], +[AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +m4_if([$1], [CXX], [ + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + case $host_os in + aix[[4-9]]*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" + ;; + cygwin* | mingw* | cegcc*) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] +], [ + runpath_var= + _LT_TAGVAR(allow_undefined_flag, $1)= + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(archive_cmds, $1)= + _LT_TAGVAR(archive_expsym_cmds, $1)= + _LT_TAGVAR(compiler_needs_object, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(hardcode_automatic, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= + _LT_TAGVAR(hardcode_libdir_separator, $1)= + _LT_TAGVAR(hardcode_minus_L, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_TAGVAR(inherit_rpath, $1)=no + _LT_TAGVAR(link_all_deplibs, $1)=unknown + _LT_TAGVAR(module_cmds, $1)= + _LT_TAGVAR(module_expsym_cmds, $1)= + _LT_TAGVAR(old_archive_from_new_cmds, $1)= + _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= + _LT_TAGVAR(thread_safe_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + _LT_TAGVAR(include_expsyms, $1)= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. +dnl Note also adjust exclude_expsyms for C++ above. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + _LT_TAGVAR(ld_shlibs, $1)=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + supports_anon_versioning=no + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[[3-9]]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu) + tmp_diet=no + if test "$host_os" = linux-dietlibc; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test "$tmp_diet" = no + then + tmp_addflag= + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + lf95*) # Lahey Fortran 8.1 + _LT_TAGVAR(whole_archive_flag_spec, $1)= + tmp_sharedflag='--shared' ;; + xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + xlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' + _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + sunos4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + + if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then + runpath_var= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + _LT_TAGVAR(hardcode_direct, $1)=unsupported + fi + ;; + + aix[[4-9]]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' + + if test "$GCC" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + bsdi[[45]]*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' + _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + freebsd1*) + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + hpux9*) + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" + AC_LINK_IFELSE(int foo(void) {}, + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' + ) + LDFLAGS="$save_LDFLAGS" + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + newsos6) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *nto* | *qnx*) + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + else + case $host_os in + openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + ;; + esac + fi + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + solaris*) + _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' + if test "$GCC" = yes; then + wlarc='${wl}' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='${wl}' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. GCC discards it without `$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test "$GCC" = yes; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + fi + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4) + case $host_vendor in + sni) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' + _LT_TAGVAR(hardcode_direct, $1)=no + ;; + motorola) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4.3*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + _LT_TAGVAR(ld_shlibs, $1)=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + if test x$host_vendor = xsni; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' + ;; + esac + fi + fi +]) +AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) +test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld + +_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl +_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl +_LT_DECL([], [extract_expsyms_cmds], [2], + [The commands to extract the exported symbol list from a shared archive]) + +# +# Do we need to explicitly link libc? +# +case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in +x|xyes) + # Assume -lc should be added + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $_LT_TAGVAR(archive_cmds, $1) in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_MSG_CHECKING([whether -lc should be explicitly linked in]) + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) + pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) + _LT_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) + then + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + else + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)]) + ;; + esac + fi + ;; +esac + +_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], + [Whether or not to add -lc for building shared libraries]) +_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], + [enable_shared_with_static_runtimes], [0], + [Whether or not to disallow shared libs when runtime libs are static]) +_LT_TAGDECL([], [export_dynamic_flag_spec], [1], + [Compiler flag to allow reflexive dlopens]) +_LT_TAGDECL([], [whole_archive_flag_spec], [1], + [Compiler flag to generate shared objects directly from archives]) +_LT_TAGDECL([], [compiler_needs_object], [1], + [Whether the compiler copes with passing no objects directly]) +_LT_TAGDECL([], [old_archive_from_new_cmds], [2], + [Create an old-style archive from a shared archive]) +_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], + [Create a temporary old-style archive to link instead of a shared archive]) +_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) +_LT_TAGDECL([], [archive_expsym_cmds], [2]) +_LT_TAGDECL([], [module_cmds], [2], + [Commands used to build a loadable module if different from building + a shared archive.]) +_LT_TAGDECL([], [module_expsym_cmds], [2]) +_LT_TAGDECL([], [with_gnu_ld], [1], + [Whether we are building with GNU ld or not]) +_LT_TAGDECL([], [allow_undefined_flag], [1], + [Flag that allows shared libraries with undefined symbols to be built]) +_LT_TAGDECL([], [no_undefined_flag], [1], + [Flag that enforces no undefined symbols]) +_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], + [Flag to hardcode $libdir into a binary during linking. + This must work even if $libdir does not exist]) +_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], + [[If ld is used when linking, flag to hardcode $libdir into a binary + during linking. This must work even if $libdir does not exist]]) +_LT_TAGDECL([], [hardcode_libdir_separator], [1], + [Whether we need a single "-rpath" flag with a separated argument]) +_LT_TAGDECL([], [hardcode_direct], [0], + [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes + DIR into the resulting binary]) +_LT_TAGDECL([], [hardcode_direct_absolute], [0], + [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes + DIR into the resulting binary and the resulting library dependency is + "absolute", i.e impossible to change by setting ${shlibpath_var} if the + library is relocated]) +_LT_TAGDECL([], [hardcode_minus_L], [0], + [Set to "yes" if using the -LDIR flag during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_shlibpath_var], [0], + [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_automatic], [0], + [Set to "yes" if building a shared library automatically hardcodes DIR + into the library and all subsequent libraries and executables linked + against it]) +_LT_TAGDECL([], [inherit_rpath], [0], + [Set to yes if linker adds runtime paths of dependent libraries + to runtime path list]) +_LT_TAGDECL([], [link_all_deplibs], [0], + [Whether libtool must link a program against all its dependency libraries]) +_LT_TAGDECL([], [fix_srcfile_path], [1], + [Fix the shell variable $srcfile for the compiler]) +_LT_TAGDECL([], [always_export_symbols], [0], + [Set to "yes" if exported symbols are required]) +_LT_TAGDECL([], [export_symbols_cmds], [2], + [The commands to list exported symbols]) +_LT_TAGDECL([], [exclude_expsyms], [1], + [Symbols that should not be listed in the preloaded symbols]) +_LT_TAGDECL([], [include_expsyms], [1], + [Symbols that must always be exported]) +_LT_TAGDECL([], [prelink_cmds], [2], + [Commands necessary for linking programs (against libraries) with templates]) +_LT_TAGDECL([], [file_list_spec], [1], + [Specify filename containing input files]) +dnl FIXME: Not yet implemented +dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], +dnl [Compiler flag to generate thread safe objects]) +])# _LT_LINKER_SHLIBS + + +# _LT_LANG_C_CONFIG([TAG]) +# ------------------------ +# Ensure that the configuration variables for a C compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to `libtool'. +m4_defun([_LT_LANG_C_CONFIG], +[m4_require([_LT_DECL_EGREP])dnl +lt_save_CC="$CC" +AC_LANG_PUSH(C) + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + +_LT_TAG_COMPILER +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + LT_SYS_DLOPEN_SELF + _LT_CMD_STRIPLIB + + # Report which library types will actually be built + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_CONFIG($1) +fi +AC_LANG_POP +CC="$lt_save_CC" +])# _LT_LANG_C_CONFIG + + +# _LT_PROG_CXX +# ------------ +# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++ +# compiler, we have our own version here. +m4_defun([_LT_PROG_CXX], +[ +pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes]) +AC_PROG_CXX +if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + AC_PROG_CXXCPP +else + _lt_caught_CXX_error=yes +fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_CXX + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_CXX], []) + + +# _LT_LANG_CXX_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a C++ compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to `libtool'. +m4_defun([_LT_LANG_CXX_CONFIG], +[AC_REQUIRE([_LT_PROG_CXX])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl + +AC_LANG_PUSH(C++) +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(compiler_needs_object, $1)=no +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the CXX compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_caught_CXX_error" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="int some_variable = 0;" + + # Code to be used in simple link tests + lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_LD=$LD + lt_save_GCC=$GCC + GCC=$GXX + lt_save_with_gnu_ld=$with_gnu_ld + lt_save_path_LD=$lt_cv_path_LD + if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx + else + $as_unset lt_cv_prog_gnu_ld + fi + if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX + else + $as_unset lt_cv_path_LD + fi + test -z "${LDCXX+set}" || LD=$LDCXX + CC=${CXX-"c++"} + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + # We don't want -fno-exception when compiling C++ code, so set the + # no_builtin_flag separately + if test "$GXX" = yes; then + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + else + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + fi + + if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + LT_PATH_LD + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | + $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + + else + GXX=no + with_gnu_ld=no + wlarc= + fi + + # PORTME: fill in a description of your system's C++ link characteristics + AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) + _LT_TAGVAR(ld_shlibs, $1)=yes + case $host_os in + aix3*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aix[[4-9]]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' + + if test "$GXX" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to + # export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty + # executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared + # libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + freebsd[[12]]*) + # C++ shared libraries reported to be fairly broken before + # switch to ELF + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + freebsd-elf*) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + + freebsd* | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + gnu*) + ;; + + hpux9*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib' + fi + fi + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + esac + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + ;; + + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc* | ecpc* ) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + case `$CC -V` in + *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*) + _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ + compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"' + _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ + $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~ + $RANLIB $oldlib' + _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + ;; + *) # Version 6 will use weak symbols + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + ;; + cxx*) + # Compaq C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + xl*) + # IBM XL 8.0 on PPC, with GNU ld + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + + # Not sure whether something based on + # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 + # would be better. + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + esac + ;; + esac + ;; + + lynxos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + m88k*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + + *nto* | *qnx*) + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + openbsd2*) + # C++ shared libraries are fairly broken + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + fi + output_verbose_link_cmd=echo + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + case $host in + osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; + *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; + esac + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + cxx*) + case $host in + osf3*) + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + ;; + *) + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~ + $RM $lib.exp' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + case $host in + osf3*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + psos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(archive_cmds_need_lc,$1)=yes + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. + # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' + if $CC --version | $GREP -v '^2\.7' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + fi + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + ;; + esac + fi + ;; + esac + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + vxworks*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) + test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + + _LT_TAGVAR(GCC, $1)="$GXX" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + CC=$lt_save_CC + LDCXX=$LD + LD=$lt_save_LD + GCC=$lt_save_GCC + with_gnu_ld=$lt_save_with_gnu_ld + lt_cv_path_LDCXX=$lt_cv_path_LD + lt_cv_path_LD=$lt_save_path_LD + lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld + lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +fi # test "$_lt_caught_CXX_error" != yes + +AC_LANG_POP +])# _LT_LANG_CXX_CONFIG + + +# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) +# --------------------------------- +# Figure out "hidden" library dependencies from verbose +# compiler output when linking a shared library. +# Parse the compiler output and extract the necessary +# objects, libraries and library flags. +m4_defun([_LT_SYS_HIDDEN_LIBDEPS], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +# Dependencies to place before and after the object being linked: +_LT_TAGVAR(predep_objects, $1)= +_LT_TAGVAR(postdep_objects, $1)= +_LT_TAGVAR(predeps, $1)= +_LT_TAGVAR(postdeps, $1)= +_LT_TAGVAR(compiler_lib_search_path, $1)= + +dnl we can't use the lt_simple_compile_test_code here, +dnl because it contains code intended for an executable, +dnl not a library. It's possible we should let each +dnl tag define a new lt_????_link_test_code variable, +dnl but it's only used here... +m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF +int a; +void foo (void) { a = 0; } +_LT_EOF +], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF +class Foo +{ +public: + Foo (void) { a = 0; } +private: + int a; +}; +_LT_EOF +], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer*4 a + a=0 + return + end +_LT_EOF +], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer a + a=0 + return + end +_LT_EOF +], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF +public class foo { + private int a; + public void bar (void) { + a = 0; + } +}; +_LT_EOF +]) +dnl Parse the compiler output and extract the necessary +dnl objects, libraries and library flags. +if AC_TRY_EVAL(ac_compile); then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + for p in `eval "$output_verbose_link_cmd"`; do + case $p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test $p = "-L" || + test $p = "-R"; then + prev=$p + continue + else + prev= + fi + + if test "$pre_test_object_deps_done" = no; then + case $p in + -L* | -R*) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then + _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" + else + _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$_LT_TAGVAR(postdeps, $1)"; then + _LT_TAGVAR(postdeps, $1)="${prev}${p}" + else + _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" + fi + fi + ;; + + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test "$pre_test_object_deps_done" = no; then + if test -z "$_LT_TAGVAR(predep_objects, $1)"; then + _LT_TAGVAR(predep_objects, $1)="$p" + else + _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" + fi + else + if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then + _LT_TAGVAR(postdep_objects, $1)="$p" + else + _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling $1 test program" +fi + +$RM -f confest.$objext + +# PORTME: override above test on systems where it is broken +m4_if([$1], [CXX], +[case $host_os in +interix[[3-9]]*) + # Interix 3.5 installs completely hosed .la files for C++, so rather than + # hack all around it, let's just trust "g++" to DTRT. + _LT_TAGVAR(predep_objects,$1)= + _LT_TAGVAR(postdep_objects,$1)= + _LT_TAGVAR(postdeps,$1)= + ;; + +linux*) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + + if test "$solaris_use_stlport4" != yes; then + _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' + fi + ;; + esac + ;; + +solaris*) + case $cc_basename in + CC*) + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + + # Adding this requires a known-good setup of shared libraries for + # Sun compiler versions before 5.6, else PIC objects from an old + # archive will be linked into the output, leading to subtle bugs. + if test "$solaris_use_stlport4" != yes; then + _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' + fi + ;; + esac + ;; +esac +]) + +case " $_LT_TAGVAR(postdeps, $1) " in +*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; +esac + _LT_TAGVAR(compiler_lib_search_dirs, $1)= +if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then + _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` +fi +_LT_TAGDECL([], [compiler_lib_search_dirs], [1], + [The directories searched by this compiler when creating a shared library]) +_LT_TAGDECL([], [predep_objects], [1], + [Dependencies to place before and after the objects being linked to + create a shared library]) +_LT_TAGDECL([], [postdep_objects], [1]) +_LT_TAGDECL([], [predeps], [1]) +_LT_TAGDECL([], [postdeps], [1]) +_LT_TAGDECL([], [compiler_lib_search_path], [1], + [The library search path used internally by the compiler when linking + a shared library]) +])# _LT_SYS_HIDDEN_LIBDEPS + + +# _LT_PROG_F77 +# ------------ +# Since AC_PROG_F77 is broken, in that it returns the empty string +# if there is no fortran compiler, we have our own version here. +m4_defun([_LT_PROG_F77], +[ +pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes]) +AC_PROG_F77 +if test -z "$F77" || test "X$F77" = "Xno"; then + _lt_disable_F77=yes +fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_F77 + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_F77], []) + + +# _LT_LANG_F77_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a Fortran 77 compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_F77_CONFIG], +[AC_REQUIRE([_LT_PROG_F77])dnl +AC_LANG_PUSH(Fortran 77) + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for f77 test sources. +ac_ext=f + +# Object file extension for compiled f77 test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the F77 compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_disable_F77" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC="$CC" + lt_save_GCC=$GCC + CC=${F77-"f77"} + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + GCC=$G77 + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)="$G77" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC="$lt_save_CC" +fi # test "$_lt_disable_F77" != yes + +AC_LANG_POP +])# _LT_LANG_F77_CONFIG + + +# _LT_PROG_FC +# ----------- +# Since AC_PROG_FC is broken, in that it returns the empty string +# if there is no fortran compiler, we have our own version here. +m4_defun([_LT_PROG_FC], +[ +pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes]) +AC_PROG_FC +if test -z "$FC" || test "X$FC" = "Xno"; then + _lt_disable_FC=yes +fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_FC + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_FC], []) + + +# _LT_LANG_FC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for a Fortran compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_FC_CONFIG], +[AC_REQUIRE([_LT_PROG_FC])dnl +AC_LANG_PUSH(Fortran) + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for fc test sources. +ac_ext=${ac_fc_srcext-f} + +# Object file extension for compiled fc test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the FC compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_disable_FC" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC="$CC" + lt_save_GCC=$GCC + CC=${FC-"f95"} + compiler=$CC + GCC=$ac_cv_fc_compiler_gnu + + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC="$lt_save_CC" +fi # test "$_lt_disable_FC" != yes + +AC_LANG_POP +])# _LT_LANG_FC_CONFIG + + +# _LT_LANG_GCJ_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Java Compiler compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_GCJ_CONFIG], +[AC_REQUIRE([LT_PROG_GCJ])dnl +AC_LANG_SAVE + +# Source file extension for Java test sources. +ac_ext=java + +# Object file extension for compiled Java test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="class foo {}" + +# Code to be used in simple link tests +lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +lt_save_GCC=$GCC +GCC=yes +CC=${GCJ-"gcj"} +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)="$LD" +_LT_CC_BASENAME([$compiler]) + +# GCJ did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC="$lt_save_CC" +])# _LT_LANG_GCJ_CONFIG + + +# _LT_LANG_RC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for the Windows resource compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_RC_CONFIG], +[AC_REQUIRE([LT_PROG_RC])dnl +AC_LANG_SAVE + +# Source file extension for RC test sources. +ac_ext=rc + +# Object file extension for compiled RC test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' + +# Code to be used in simple link tests +lt_simple_link_test_code="$lt_simple_compile_test_code" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +lt_save_GCC=$GCC +GCC= +CC=${RC-"windres"} +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) +_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + +if test -n "$compiler"; then + : + _LT_CONFIG($1) +fi + +GCC=$lt_save_GCC +AC_LANG_RESTORE +CC="$lt_save_CC" +])# _LT_LANG_RC_CONFIG + + +# LT_PROG_GCJ +# ----------- +AC_DEFUN([LT_PROG_GCJ], +[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], + [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], + [AC_CHECK_TOOL(GCJ, gcj,) + test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" + AC_SUBST(GCJFLAGS)])])[]dnl +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_GCJ], []) + + +# LT_PROG_RC +# ---------- +AC_DEFUN([LT_PROG_RC], +[AC_CHECK_TOOL(RC, windres,) +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_RC], []) + + +# _LT_DECL_EGREP +# -------------- +# If we don't have a new enough Autoconf to choose the best grep +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_EGREP], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_REQUIRE([AC_PROG_FGREP])dnl +test -z "$GREP" && GREP=grep +_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) +_LT_DECL([], [EGREP], [1], [An ERE matcher]) +_LT_DECL([], [FGREP], [1], [A literal string matcher]) +dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too +AC_SUBST([GREP]) +]) + + +# _LT_DECL_OBJDUMP +# -------------- +# If we don't have a new enough Autoconf to choose the best objdump +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_OBJDUMP], +[AC_CHECK_TOOL(OBJDUMP, objdump, false) +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) +AC_SUBST([OBJDUMP]) +]) + + +# _LT_DECL_SED +# ------------ +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. +m4_defun([_LT_DECL_SED], +[AC_PROG_SED +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" +_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) +_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], + [Sed that helps us avoid accidentally triggering echo(1) options like -n]) +])# _LT_DECL_SED + +m4_ifndef([AC_PROG_SED], [ +############################################################ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +############################################################ + +m4_defun([AC_PROG_SED], +[AC_MSG_CHECKING([for a sed that does not truncate output]) +AC_CACHE_VAL(lt_cv_path_SED, +[# Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +IFS=$as_save_IFS +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && continue + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +]) +SED=$lt_cv_path_SED +AC_SUBST([SED]) +AC_MSG_RESULT([$SED]) +])#AC_PROG_SED +])#m4_ifndef + +# Old name: +AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_SED], []) + + +# _LT_CHECK_SHELL_FEATURES +# ------------------------ +# Find out whether the shell is Bourne or XSI compatible, +# or has some other useful features. +m4_defun([_LT_CHECK_SHELL_FEATURES], +[AC_MSG_CHECKING([whether the shell understands some XSI constructs]) +# Try some XSI features +xsi_shell=no +( _lt_dummy="a/b/c" + test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,, \ + && eval 'test $(( 1 + 1 )) -eq 2 \ + && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ + && xsi_shell=yes +AC_MSG_RESULT([$xsi_shell]) +_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) + +AC_MSG_CHECKING([whether the shell understands "+="]) +lt_shell_append=no +( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ + >/dev/null 2>&1 \ + && lt_shell_append=yes +AC_MSG_RESULT([$lt_shell_append]) +_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) + +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi +_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl + +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac +_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl +_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl +])# _LT_CHECK_SHELL_FEATURES + + +# _LT_PROG_XSI_SHELLFNS +# --------------------- +# Bourne and XSI compatible variants of some useful shell functions. +m4_defun([_LT_PROG_XSI_SHELLFNS], +[case $xsi_shell in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac +} + +# func_basename file +func_basename () +{ + func_basename_result="${1##*/}" +} + +# func_dirname_and_basename file append nondir_replacement +# perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# Implementation must be kept synchronized with func_dirname +# and func_basename. For efficiency, we do not delegate to +# those functions but instead duplicate the functionality here. +func_dirname_and_basename () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac + func_basename_result="${1##*/}" +} + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +func_stripname () +{ + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary parameter first. + func_stripname_result=${3} + func_stripname_result=${func_stripname_result#"${1}"} + func_stripname_result=${func_stripname_result%"${2}"} +} + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=${1%%=*} + func_opt_split_arg=${1#*=} +} + +# func_lo2o object +func_lo2o () +{ + case ${1} in + *.lo) func_lo2o_result=${1%.lo}.${objext} ;; + *) func_lo2o_result=${1} ;; + esac +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=${1%.*}.lo +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=$(( $[*] )) +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=${#1} +} + +_LT_EOF + ;; + *) # Bourne compatible functions. + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi +} + +# func_basename file +func_basename () +{ + func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` +} + +dnl func_dirname_and_basename +dnl A portable version of this function is already defined in general.m4sh +dnl so there is no need for it here. + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# func_strip_suffix prefix name +func_stripname () +{ + case ${2} in + .*) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; + *) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; + esac +} + +# sed scripts: +my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q' +my_sed_long_arg='1s/^-[[^=]]*=//' + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` + func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` +} + +# func_lo2o object +func_lo2o () +{ + func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'` +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=`expr "$[@]"` +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len` +} + +_LT_EOF +esac + +case $lt_shell_append in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$[1]+=\$[2]" +} +_LT_EOF + ;; + *) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$[1]=\$$[1]\$[2]" +} + +_LT_EOF + ;; + esac +]) diff --git a/m4/ltoptions.m4 b/m4/ltoptions.m4 new file mode 100644 index 0000000..34151a3 --- /dev/null +++ b/m4/ltoptions.m4 @@ -0,0 +1,368 @@ +# Helper functions for option handling. -*- Autoconf -*- +# +# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 6 ltoptions.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) + + +# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) +# ------------------------------------------ +m4_define([_LT_MANGLE_OPTION], +[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) + + +# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) +# --------------------------------------- +# Set option OPTION-NAME for macro MACRO-NAME, and if there is a +# matching handler defined, dispatch to it. Other OPTION-NAMEs are +# saved as a flag. +m4_define([_LT_SET_OPTION], +[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl +m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), + _LT_MANGLE_DEFUN([$1], [$2]), + [m4_warning([Unknown $1 option `$2'])])[]dnl +]) + + +# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) +# ------------------------------------------------------------ +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +m4_define([_LT_IF_OPTION], +[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) + + +# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) +# ------------------------------------------------------- +# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME +# are set. +m4_define([_LT_UNLESS_OPTIONS], +[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), + [m4_define([$0_found])])])[]dnl +m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 +])[]dnl +]) + + +# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) +# ---------------------------------------- +# OPTION-LIST is a space-separated list of Libtool options associated +# with MACRO-NAME. If any OPTION has a matching handler declared with +# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about +# the unknown option and exit. +m4_defun([_LT_SET_OPTIONS], +[# Set options +m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [_LT_SET_OPTION([$1], _LT_Option)]) + +m4_if([$1],[LT_INIT],[ + dnl + dnl Simply set some default values (i.e off) if boolean options were not + dnl specified: + _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no + ]) + _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no + ]) + dnl + dnl If no reference was made to various pairs of opposing options, then + dnl we run the default mode handler for the pair. For example, if neither + dnl `shared' nor `disable-shared' was passed, we enable building of shared + dnl archives by default: + _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) + _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], + [_LT_ENABLE_FAST_INSTALL]) + ]) +])# _LT_SET_OPTIONS + + +## --------------------------------- ## +## Macros to handle LT_INIT options. ## +## --------------------------------- ## + +# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) +# ----------------------------------------- +m4_define([_LT_MANGLE_DEFUN], +[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) + + +# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) +# ----------------------------------------------- +m4_define([LT_OPTION_DEFINE], +[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl +])# LT_OPTION_DEFINE + + +# dlopen +# ------ +LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes +]) + +AU_DEFUN([AC_LIBTOOL_DLOPEN], +[_LT_SET_OPTION([LT_INIT], [dlopen]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `dlopen' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) + + +# win32-dll +# --------- +# Declare package support for building win32 dll's. +LT_OPTION_DEFINE([LT_INIT], [win32-dll], +[enable_win32_dll=yes + +case $host in +*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +esac + +test -z "$AS" && AS=as +_LT_DECL([], [AS], [0], [Assembler program])dnl + +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl + +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl +])# win32-dll + +AU_DEFUN([AC_LIBTOOL_WIN32_DLL], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +_LT_SET_OPTION([LT_INIT], [win32-dll]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `win32-dll' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) + + +# _LT_ENABLE_SHARED([DEFAULT]) +# ---------------------------- +# implement the --enable-shared flag, and supports the `shared' and +# `disable-shared' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_SHARED], +[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([shared], + [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], + [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) + + _LT_DECL([build_libtool_libs], [enable_shared], [0], + [Whether or not to build shared libraries]) +])# _LT_ENABLE_SHARED + +LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) +]) + +AC_DEFUN([AC_DISABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], [disable-shared]) +]) + +AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_SHARED], []) +dnl AC_DEFUN([AM_DISABLE_SHARED], []) + + + +# _LT_ENABLE_STATIC([DEFAULT]) +# ---------------------------- +# implement the --enable-static flag, and support the `static' and +# `disable-static' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_STATIC], +[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([static], + [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], + [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_static=]_LT_ENABLE_STATIC_DEFAULT) + + _LT_DECL([build_old_libs], [enable_static], [0], + [Whether or not to build static libraries]) +])# _LT_ENABLE_STATIC + +LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) +]) + +AC_DEFUN([AC_DISABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], [disable-static]) +]) + +AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_STATIC], []) +dnl AC_DEFUN([AM_DISABLE_STATIC], []) + + + +# _LT_ENABLE_FAST_INSTALL([DEFAULT]) +# ---------------------------------- +# implement the --enable-fast-install flag, and support the `fast-install' +# and `disable-fast-install' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_FAST_INSTALL], +[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([fast-install], + [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], + [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) + +_LT_DECL([fast_install], [enable_fast_install], [0], + [Whether or not to optimize for fast installation])dnl +])# _LT_ENABLE_FAST_INSTALL + +LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) + +# Old names: +AU_DEFUN([AC_ENABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the `fast-install' option into LT_INIT's first parameter.]) +]) + +AU_DEFUN([AC_DISABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the `disable-fast-install' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) +dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) + + +# _LT_WITH_PIC([MODE]) +# -------------------- +# implement the --with-pic flag, and support the `pic-only' and `no-pic' +# LT_INIT options. +# MODE is either `yes' or `no'. If omitted, it defaults to `both'. +m4_define([_LT_WITH_PIC], +[AC_ARG_WITH([pic], + [AS_HELP_STRING([--with-pic], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [pic_mode="$withval"], + [pic_mode=default]) + +test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) + +_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl +])# _LT_WITH_PIC + +LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) + +# Old name: +AU_DEFUN([AC_LIBTOOL_PICMODE], +[_LT_SET_OPTION([LT_INIT], [pic-only]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `pic-only' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) + +## ----------------- ## +## LTDL_INIT Options ## +## ----------------- ## + +m4_define([_LTDL_MODE], []) +LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], + [m4_define([_LTDL_MODE], [nonrecursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [recursive], + [m4_define([_LTDL_MODE], [recursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [subproject], + [m4_define([_LTDL_MODE], [subproject])]) + +m4_define([_LTDL_TYPE], []) +LT_OPTION_DEFINE([LTDL_INIT], [installable], + [m4_define([_LTDL_TYPE], [installable])]) +LT_OPTION_DEFINE([LTDL_INIT], [convenience], + [m4_define([_LTDL_TYPE], [convenience])]) diff --git a/m4/ltsugar.m4 b/m4/ltsugar.m4 new file mode 100644 index 0000000..9000a05 --- /dev/null +++ b/m4/ltsugar.m4 @@ -0,0 +1,123 @@ +# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- +# +# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 6 ltsugar.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) + + +# lt_join(SEP, ARG1, [ARG2...]) +# ----------------------------- +# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their +# associated separator. +# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier +# versions in m4sugar had bugs. +m4_define([lt_join], +[m4_if([$#], [1], [], + [$#], [2], [[$2]], + [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) +m4_define([_lt_join], +[m4_if([$#$2], [2], [], + [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) + + +# lt_car(LIST) +# lt_cdr(LIST) +# ------------ +# Manipulate m4 lists. +# These macros are necessary as long as will still need to support +# Autoconf-2.59 which quotes differently. +m4_define([lt_car], [[$1]]) +m4_define([lt_cdr], +[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], + [$#], 1, [], + [m4_dquote(m4_shift($@))])]) +m4_define([lt_unquote], $1) + + +# lt_append(MACRO-NAME, STRING, [SEPARATOR]) +# ------------------------------------------ +# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. +# Note that neither SEPARATOR nor STRING are expanded; they are appended +# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). +# No SEPARATOR is output if MACRO-NAME was previously undefined (different +# than defined and empty). +# +# This macro is needed until we can rely on Autoconf 2.62, since earlier +# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. +m4_define([lt_append], +[m4_define([$1], + m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) + + + +# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) +# ---------------------------------------------------------- +# Produce a SEP delimited list of all paired combinations of elements of +# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list +# has the form PREFIXmINFIXSUFFIXn. +# Needed until we can rely on m4_combine added in Autoconf 2.62. +m4_define([lt_combine], +[m4_if(m4_eval([$# > 3]), [1], + [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl +[[m4_foreach([_Lt_prefix], [$2], + [m4_foreach([_Lt_suffix], + ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, + [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) + + +# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) +# ----------------------------------------------------------------------- +# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited +# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. +m4_define([lt_if_append_uniq], +[m4_ifdef([$1], + [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], + [lt_append([$1], [$2], [$3])$4], + [$5])], + [lt_append([$1], [$2], [$3])$4])]) + + +# lt_dict_add(DICT, KEY, VALUE) +# ----------------------------- +m4_define([lt_dict_add], +[m4_define([$1($2)], [$3])]) + + +# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) +# -------------------------------------------- +m4_define([lt_dict_add_subkey], +[m4_define([$1($2:$3)], [$4])]) + + +# lt_dict_fetch(DICT, KEY, [SUBKEY]) +# ---------------------------------- +m4_define([lt_dict_fetch], +[m4_ifval([$3], + m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), + m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) + + +# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) +# ----------------------------------------------------------------- +m4_define([lt_if_dict_fetch], +[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], + [$5], + [$6])]) + + +# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) +# -------------------------------------------------------------- +m4_define([lt_dict_filter], +[m4_if([$5], [], [], + [lt_join(m4_quote(m4_default([$4], [[, ]])), + lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), + [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl +]) diff --git a/m4/ltversion.m4 b/m4/ltversion.m4 new file mode 100644 index 0000000..b8e154f --- /dev/null +++ b/m4/ltversion.m4 @@ -0,0 +1,23 @@ +# ltversion.m4 -- version numbers -*- Autoconf -*- +# +# Copyright (C) 2004 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# Generated from ltversion.in. + +# serial 3012 ltversion.m4 +# This file is part of GNU Libtool + +m4_define([LT_PACKAGE_VERSION], [2.2.6]) +m4_define([LT_PACKAGE_REVISION], [1.3012]) + +AC_DEFUN([LTVERSION_VERSION], +[macro_version='2.2.6' +macro_revision='1.3012' +_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) +_LT_DECL(, macro_revision, 0) +]) diff --git a/m4/lt~obsolete.m4 b/m4/lt~obsolete.m4 new file mode 100644 index 0000000..637bb20 --- /dev/null +++ b/m4/lt~obsolete.m4 @@ -0,0 +1,92 @@ +# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- +# +# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004. +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 4 lt~obsolete.m4 + +# These exist entirely to fool aclocal when bootstrapping libtool. +# +# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) +# which have later been changed to m4_define as they aren't part of the +# exported API, or moved to Autoconf or Automake where they belong. +# +# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN +# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us +# using a macro with the same name in our local m4/libtool.m4 it'll +# pull the old libtool.m4 in (it doesn't see our shiny new m4_define +# and doesn't know about Autoconf macros at all.) +# +# So we provide this file, which has a silly filename so it's always +# included after everything else. This provides aclocal with the +# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything +# because those macros already exist, or will be overwritten later. +# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. +# +# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. +# Yes, that means every name once taken will need to remain here until +# we give up compatibility with versions before 1.7, at which point +# we need to keep only those names which we still refer to. + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) + +m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) +m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) +m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) +m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) +m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) +m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) +m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) +m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) +m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) +m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) +m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) +m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) +m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) +m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) +m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) +m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) +m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) +m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) +m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) +m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) +m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) +m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) +m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) +m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) +m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) +m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) +m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) +m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) +m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) +m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) +m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) +m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) +m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) +m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) +m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) +m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) +m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) +m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) +m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])]) +m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) +m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) +m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) +m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) +m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) +m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) +m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) +m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) diff --git a/m4/sockaddrin6.m4 b/m4/sockaddrin6.m4 new file mode 100644 index 0000000..45f9eb0 --- /dev/null +++ b/m4/sockaddrin6.m4 @@ -0,0 +1,60 @@ +dnl * +dnl * Copyright (c) 2001-2006 Motoyuki Kasahara +dnl * +dnl * Redistribution and use in source and binary forms, with or without +dnl * modification, are permitted provided that the following conditions +dnl * are met: +dnl * 1. Redistributions of source code must retain the above copyright +dnl * notice, this list of conditions and the following disclaimer. +dnl * 2. Redistributions in binary form must reproduce the above copyright +dnl * notice, this list of conditions and the following disclaimer in the +dnl * documentation and/or other materials provided with the distribution. +dnl * 3. Neither the name of the project nor the names of its contributors +dnl * may be used to endorse or promote products derived from this software +dnl * without specific prior written permission. +dnl * +dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +dnl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE +dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +dnl * THE POSSIBILITY OF SUCH DAMAGE. +dnl * + +dnl * +dnl * Check for struct sockaddr_in6 +dnl * +AC_DEFUN([AC_STRUCT_SOCKADDR_IN6], +[AC_CACHE_CHECK(for struct sockaddr_in6, ac_cv_struct_sockaddr_in6, +[AC_COMPILE_IFELSE([ +#include +#include +#include +struct sockaddr_in6 address; +], [ac_cv_struct_sockaddr_in6=yes], [ac_cv_struct_sockaddr_in6=no])]) +if test "$ac_cv_struct_sockaddr_in6" = yes; then + AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1, +[Define to 1 if defines `struct sockaddr_in6']) +fi]) + +dnl * +dnl * Check for struct sockaddr_storage +dnl * +AC_DEFUN([AC_STRUCT_SOCKADDR_STORAGE], +[AC_CACHE_CHECK(for struct sockaddr_storage, ac_cv_struct_sockaddr_storage, +[AC_COMPILE_IFELSE([ +#include +#include +#include +struct sockaddr_storage address; +], [ac_cv_struct_sockaddr_storage=yes], [ac_cv_struct_sockaddr_storage=no])]) +if test "$ac_cv_struct_sockaddr_storage" = yes; then + AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, +[Define to 1 if defines `struct sockaddr_storage']) +fi]) + diff --git a/m4/sockinttypes.m4 b/m4/sockinttypes.m4 new file mode 100644 index 0000000..a003df4 --- /dev/null +++ b/m4/sockinttypes.m4 @@ -0,0 +1,154 @@ +dnl * +dnl * Copyright (c) 2001-2006 Motoyuki Kasahara +dnl * +dnl * Redistribution and use in source and binary forms, with or without +dnl * modification, are permitted provided that the following conditions +dnl * are met: +dnl * 1. Redistributions of source code must retain the above copyright +dnl * notice, this list of conditions and the following disclaimer. +dnl * 2. Redistributions in binary form must reproduce the above copyright +dnl * notice, this list of conditions and the following disclaimer in the +dnl * documentation and/or other materials provided with the distribution. +dnl * 3. Neither the name of the project nor the names of its contributors +dnl * may be used to endorse or promote products derived from this software +dnl * without specific prior written permission. +dnl * +dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +dnl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE +dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +dnl * THE POSSIBILITY OF SUCH DAMAGE. +dnl * + +dnl * +dnl * Check for socklen_t. +dnl * +AC_DEFUN([AC_TYPE_SOCKLEN_T], +[AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t, +[AC_COMPILE_IFELSE([ +#include +#include +socklen_t socklen; +], [ac_cv_type_socklen_t=yes], [ac_cv_type_socklen_t=no])]) +if test "$ac_cv_type_socklen_t" != yes; then + AC_DEFINE(socklen_t, int, +[Define to `int' if or does not define.]) +fi]) + +dnl * +dnl * Check for in_port_t. +dnl * +AC_DEFUN([AC_TYPE_IN_PORT_T], +[AC_CACHE_CHECK([for in_port_t], ac_cv_type_in_port_t, +[AC_COMPILE_IFELSE([ +#include +#include +#include +in_port_t in_port; +], [ac_cv_type_in_port_t=yes], [ac_cv_type_in_port_t=no])]) +if test "$ac_cv_type_in_port_t" != yes; then + ac_cv_sin_port_size=unknown + AC_RUN_IFELSE([ + #include + #include + #include + int main() { + struct sockaddr_in addr; + return (sizeof(addr.sin_port) == sizeof(long)) ? 0 : 1; + } + ], [ac_cv_sin_port_size=long]) + AC_RUN_IFELSE([ + #include + #include + #include + int main() { + struct sockaddr_in addr; + return (sizeof(addr.sin_port) == sizeof(int)) ? 0 : 1; + } + ], [ac_cv_sin_port_size=int]) + AC_RUN_IFELSE([ + #include + #include + #include + int main() { + struct sockaddr_in addr; + return (sizeof(addr.sin_port) == sizeof(short)) ? 0 : 1; + } + ], [ac_cv_sin_port_size=short]) + AC_RUN_IFELSE([ + #include + #include + #include + int main() { + struct sockaddr_in addr; + return (sizeof(addr.sin_port) == sizeof(char)) ? 0 : 1; + } + ], [ac_cv_sin_port_size=char]) + if test "$ac_cv_sin_port_size" = unknown; then + AC_MSG_ERROR([Failed to get size of sin_port in struct sockaddr_in.]) + fi + AC_DEFINE_UNQUOTED(in_port_t, unsigned $ac_cv_sin_port_size, +[Define to `unsigned char', `unsigned short', `unsigned int' or +`unsigned long' according with size of `sin_port' in `struct sockaddr_in', +if , or does not define +`in_port_t'.]) +fi]) + +dnl * +dnl * Check for sa_family_t. +dnl * +AC_DEFUN([AC_TYPE_SA_FAMILY_T], +[AC_CACHE_CHECK([for sa_family_t], ac_cv_type_sa_family_t, +[AC_COMPILE_IFELSE([ +#include +#include +sa_family_t sa_family; +], [ac_cv_type_sa_family_t=yes], [ac_cv_type_sa_family_t=no])]) +if test "$ac_cv_type_sa_family_t" != yes; then + ac_cv_sa_family_size=unknown + AC_RUN_IFELSE([ + #include + #include + int main() { + struct sockaddr addr; + return (sizeof(addr.sa_family) == sizeof(long)) ? 0 : 1; + } + ], [ac_cv_sa_family_size=long]) + AC_RUN_IFELSE([ + #include + #include + int main() { + struct sockaddr addr; + return (sizeof(addr.sa_family) == sizeof(int)) ? 0 : 1; + } + ], [ac_cv_sa_family_size=int]) + AC_RUN_IFELSE([ + #include + #include + int main() { + struct sockaddr addr; + return (sizeof(addr.sa_family) == sizeof(short)) ? 0 : 1; + } + ], [ac_cv_sa_family_size=short]) + AC_RUN_IFELSE([ + #include + #include + int main() { + struct sockaddr addr; + return (sizeof(addr.sa_family) == sizeof(char)) ? 0 : 1; + } + ], [ac_cv_sa_family_size=char]) + if test "$ac_cv_sa_family_size" = unknown; then + AC_MSG_ERROR([Failed to get size of sa_family in struct sockaddr.]) + fi + AC_DEFINE_UNQUOTED(sa_family_t, unsigned $ac_cv_sa_family_size, +[Define to `unsigned char', `unsigned short', `unsigned int' or +`unsigned long' according with size of `sa_family' in `struct sockaddr', +if or does not define `sa_family_t'.]) +fi]) diff --git a/misc/ebdump b/misc/ebdump new file mode 100755 index 0000000..bcf5ce6 --- /dev/null +++ b/misc/ebdump @@ -0,0 +1,79 @@ +#! /usr/bin/perl +# +# Copyright (c) 2004-2006 Motoyuki Kasahara +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +# +# Parse command line arguments. +# +die "usage: $0 file page[:offset]\n" if (@ARGV != 2); + +$file = $ARGV[0]; +if ($ARGV[1] =~ /^([0-9a-fA-F]+)$/) { + $offset = (hex($1) - 1) * 2048; +} elsif ($ARGV[1] =~ /^([0-9a-fA-F]+):([0-9a-fA-F]+)$/) { + $offset = (hex($1) - 1) * 2048 + hex($2); +} else { + die "$0: invalid offset\n"; +} +die "$0: invalid offset\n" if ($offset < 0); + +# +# Open a file. +# +open(FILE, $file) || die "$0: failed to open the file, $!: $file.\n"; +seek(FILE, $offset, 0) || die "$0: failed to seek the file, $!: $file.\n"; + +# +# Read the file. +# +$count = 0; +while ($count < 2048) { + last if (read(FILE, $buf, 16) != 16); + @data = unpack("C16", $buf); + printf '%04x:%03x ', $offset / 2048 + 1, $offset % 2048; + for ($i = $0; $i < 16; $i += 2) { + printf('%02x%02x', $data[$i], $data[$i + 1]); + } + print ' '; + for ($i = $0; $i < 16; $i += 2) { + if (0x21 <= $data[$i] && $data[$i] <= 0x7e + && 0x21 <= $data[$i + 1] && $data[$i + 1] <= 0x7e) { + printf('[%c%c]', $data[$i] | 0x80, $data[$i + 1] | 0x80); + } else { + printf('%02x%02x', $data[$i], $data[$i + 1]); + } + } + print "\n"; + $offset += 16; + $count += 16; +} + +# +# Close the file. +# +close(FILE); diff --git a/misc/ebfixlog b/misc/ebfixlog new file mode 100755 index 0000000..494b530 --- /dev/null +++ b/misc/ebfixlog @@ -0,0 +1,47 @@ +#! /usr/bin/perl +# +# Copyright (c) 2004-2006 Motoyuki Kasahara +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +use Getopt::Std; +getopts('zn') or die "Usage: $0 [-z|-n] [file...]\n"; +$opt_z = 1 if (defined($opt_n)); # `-n' implies `-z'. + +$indent = 0; + +while (<>) { + chomp; + if (/^\[EB\] (.*)$/) { + $message = $1; + next if (!$opt_z && $message =~ /^\S+: zio_/); + next if (!$opt_n && $message =~ /^\S+: ebnet_/); + $indent-- if ($message =~ /^out: /); + $_ = '[EB] ' . (' ' x ($indent * 2)) . $message; + $indent++ if ($message =~ /^in: /); + } + print $_, "\n"; +} diff --git a/missing b/missing new file mode 100755 index 0000000..1c8ff70 --- /dev/null +++ b/missing @@ -0,0 +1,367 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. + +scriptversion=2006-05-10.23 + +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006 +# Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: +sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' +sed_minuso='s/.* -o \([^ ]*\).*/\1/p' + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +msg="missing on your system" + +case $1 in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + # Exit code 63 means version mismatch. This often happens + # when the user try to use an ancient version of a tool on + # a file that requires a minimum version. In this case we + # we should proceed has if the program had been absent, or + # if --run hadn't been passed. + if test $? = 63; then + run=: + msg="probably too old" + fi + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + autom4te touch the output file, or create a stub one + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch] + +Send bug reports to ." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + +esac + +# Now exit if we have it, but it failed. Also exit now if we +# don't have it and --version was passed (most likely to detect +# the program). +case $1 in + lex|yacc) + # Not GNU programs, they don't have --version. + ;; + + tar) + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + exit 1 + fi + ;; + + *) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + # Could not run --version or --help. This is probably someone + # running `$TOOL --version' or `$TOOL --help' to check whether + # $TOOL exists and not knowing $TOOL uses missing. + exit 1 + fi + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case $1 in + aclocal*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case $f in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te) + echo 1>&2 "\ +WARNING: \`$1' is needed, but is $msg. + You might have modified some files without having the + proper tools for further handling them. + You can get \`$1' as part of \`Autoconf' from any GNU + archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' $msg. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if test $# -ne 1; then + eval LASTARG="\${$#}" + case $LASTARG in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if test ! -f y.tab.h; then + echo >y.tab.h + fi + if test ! -f y.tab.c; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if test $# -ne 1; then + eval LASTARG="\${$#}" + case $LASTARG in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if test ! -f lex.yy.c; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi + ;; + + makeinfo) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + # The file to touch is that specified with -o ... + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -z "$file"; then + # ... or it is the one specified with @setfilename ... + infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n ' + /^@setfilename/{ + s/.* \([^ ]*\) *$/\1/ + p + q + }' $infile` + # ... or it is derived from the source name (dir/f.texi becomes f.info) + test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info + fi + # If the file does not exist, the user really needs makeinfo; + # let's fail without touching anything. + test -f $file || exit 1 + touch $file + ;; + + tar) + shift + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar "$@" && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar "$@" && exit 0 + fi + firstarg="$1" + if shift; then + case $firstarg in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + case $firstarg in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and is $msg. + You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequisites for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/move-if-change b/move-if-change new file mode 100755 index 0000000..dae150f --- /dev/null +++ b/move-if-change @@ -0,0 +1,49 @@ +#! /bin/sh +# +# Copyright (c) 2004-2006 Motoyuki Kasahara +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the project nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +NEW_FILE=$1 +TARGET_FILE=$2 + +if [ ! -r $NEW_FILE ]; then + echo "$0: cannot read $NEW_FILE" 1>&2 + exit 1 +fi + +if [ ! -r $TARGET_FILE ]; then + mv -f $NEW_FILE $TARGET_FILE +else + if cmp $NEW_FILE $TARGET_FILE > /dev/null 2>&1; then + echo "$0: $TARGET_FILE is unchanged" 1>&2 + rm -f $NEW_FILE + else + mv -f $NEW_FILE $TARGET_FILE + fi +fi + +exit 0 diff --git a/po-eb/Makefile.in b/po-eb/Makefile.in new file mode 100644 index 0000000..e826bc8 --- /dev/null +++ b/po-eb/Makefile.in @@ -0,0 +1,154 @@ +# Makefile for program source directory in GNU NLS utilities package. +# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper +# +# This file file be copied and used freely without restrictions. It can +# be used in projects which are not available under the GNU Public License +# but which still want to provide support for the GNU gettext functionality. +# Please note that the actual code is *not* freely available. + +## Note that the following macros must be set by your hand. +top_builddir = .. +subdir = po-eb + +TEXTDOMAIN = eb +POFILES = ja.po +MOFILES = ja.mo +POTFILES = \ + $(top_srcdir)/eb/error.c +## end + +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +SHELL = /bin/sh + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +datarootdir = @datarootdir@ +datadir = @datadir@ +localedir = @localedir@ + +mkdir_p = @mkdir_p@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +mkinstalldirs = $(install_sh) -d +install_sh = @install_sh@ + +MSGFMT = @MSGFMT@ +XGETTEXT = @XGETTEXT@ +MSGMERGE = msgmerge + +DISTFILES = Makefile.in $(TEXTDOMAIN).pot $(MOFILES) $(POFILES) + +.SUFFIXES: +.SUFFIXES: .po .pox .mo + +.po.pox: + $(MAKE) $(TEXTDOMAIN).pot + $(MSGMERGE) $< $(srcdir)/$(TEXTDOMAIN).pot -o $*.pox + +.po.mo: + file=$(srcdir)/`echo $* | sed 's,.*/,,'`.mo \ + && rm -f $$file && $(MSGFMT) -o $$file $< + +all: all-@ENABLE_NLS@ + +all-yes: $(MOFILES) +all-no: + +$(TEXTDOMAIN).pot: $(POTFILES) + $(XGETTEXT) --default-domain=$(TEXTDOMAIN) --add-comments \ + --keyword=_ --keyword=N_ $(POTFILES) \ + && test ! -f $(TEXTDOMAIN).po \ + || ( rm -f $(srcdir)/$(TEXTDOMAIN).pot \ + && mv $(TEXTDOMAIN).po $(srcdir)/$(TEXTDOMAIN).pot ) + +install: install-exec install-data +install-exec: +install-data: install-data-@ENABLE_NLS@ +install-data-no: all +install-data-yes: all + $(mkinstalldirs) $(DESTDIR)$(datadir) + @catalogs='$(MOFILES)'; \ + for cat in $$catalogs; do \ + cat=`echo $$cat | sed 's/^.*\/\([^\/]*\)$$/\1/'` ; \ + lang=`echo $$cat | sed 's/\.mo$$//'`; \ + dir=$(localedir)/$$lang/LC_MESSAGES; \ + $(mkinstalldirs) $(DESTDIR)$$dir; \ + if test -r $$cat; then \ + $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(TEXTDOMAIN).mo; \ + echo "installing $$cat as" \ + "$(DESTDIR)$$dir/$(TEXTDOMAIN).mo"; \ + else \ + $(INSTALL_DATA) $(srcdir)/$$cat \ + $(DESTDIR)$$dir/$(TEXTDOMAIN).mo; \ + echo "installing $(srcdir)/$$cat as" \ + "$(DESTDIR)$$dir/$(TEXTDOMAIN).mo"; \ + fi; \ + done + +# Define this as empty until I found a useful application. +installcheck: + +uninstall: + catalogs='$(MOFILES)'; \ + for cat in $$catalogs; do \ + cat=`echo $$cat | sed 's/^.*\/\([^\/]*\)$$/\1/'` ; \ + lang=`echo $$cat | sed 's/\.mo$$//'`; \ + rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(TEXTDOMAIN).mo; \ + done + rm -f $(DESTDIR)$(gettextsrcdir)/po-Makefile.in + +check: all + +dvi info tags TAGS ID: + +mostlyclean: + rm -f core core.* *.pox $(TEXTDOMAIN).po *.old.po + rm -fr *.o + +clean: mostlyclean + +distclean: clean + rm -f Makefile *.mo + +maintainer-clean: distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + rm -f *.mo + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) +dist distdir: update-po $(DISTFILES) + dists="$(DISTFILES)"; \ + for file in $$dists; do \ + ln $(srcdir)/$$file $(distdir) 2> /dev/null \ + || cp -p $(srcdir)/$$file $(distdir); \ + done + +update-po: Makefile + $(MAKE) $(TEXTDOMAIN).pot + cd $(srcdir); \ + catalogs='$(MOFILES)'; \ + for cat in $$catalogs; do \ + cat=`echo $$cat | sed 's/^.*\/\([^\/]*\)$$/\1/'` ; \ + lang=`echo $$cat | sed 's/\.mo$$//'`; \ + mv $$lang.po $$lang.old.po; \ + echo "$$lang:"; \ + if $(MSGMERGE) $$lang.old.po $(TEXTDOMAIN).pot -o $$lang.po; then \ + rm -f $$lang.old.po; \ + else \ + echo "msgmerge for $$cat failed!"; \ + rm -f $$lang.po; \ + mv $$lang.old.po $$lang.po; \ + fi; \ + done + +Makefile: Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \ + $(SHELL) ./config.status + +# Tell versions [3.59,3.63) of GNU make not to export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/po-eb/eb.pot b/po-eb/eb.pot new file mode 100644 index 0000000..e6a0566 --- /dev/null +++ b/po-eb/eb.pot @@ -0,0 +1,311 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-01-03 22:27+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#. 0 -- 4 +#: ../eb/error.c:167 +msgid "no error" +msgstr "" + +#: ../eb/error.c:168 +msgid "memory exhausted" +msgstr "" + +#: ../eb/error.c:169 +msgid "an empty file name" +msgstr "" + +#: ../eb/error.c:170 +msgid "too long file name" +msgstr "" + +#: ../eb/error.c:171 +msgid "bad file name" +msgstr "" + +#. 5 -- 9 +#: ../eb/error.c:174 +msgid "bad directory name" +msgstr "" + +#: ../eb/error.c:175 +msgid "too long word" +msgstr "" + +#: ../eb/error.c:176 +msgid "a word contains bad character" +msgstr "" + +#: ../eb/error.c:177 +msgid "an empty word" +msgstr "" + +#: ../eb/error.c:178 +msgid "failed to get the current working directory" +msgstr "" + +#. 10 -- 14 +#: ../eb/error.c:181 +msgid "failed to open a catalog file" +msgstr "" + +#: ../eb/error.c:182 +msgid "failed to open an appendix catalog file" +msgstr "" + +#: ../eb/error.c:183 +msgid "failed to open a text file" +msgstr "" + +#: ../eb/error.c:184 +msgid "failed to open a font file" +msgstr "" + +#: ../eb/error.c:185 +msgid "failed to open an appendix file" +msgstr "" + +#. 15 -- 19 +#: ../eb/error.c:188 +msgid "failed to open a binary file" +msgstr "" + +#: ../eb/error.c:189 +msgid "failed to read a catalog file" +msgstr "" + +#: ../eb/error.c:190 +msgid "failed to read an appendix catalog file" +msgstr "" + +#: ../eb/error.c:191 +msgid "failed to read a text file" +msgstr "" + +#: ../eb/error.c:192 +msgid "failed to read a font file" +msgstr "" + +#. 20 -- 24 +#: ../eb/error.c:195 +msgid "failed to read an appendix file" +msgstr "" + +#: ../eb/error.c:196 +msgid "failed to read a binary file" +msgstr "" + +#: ../eb/error.c:197 +msgid "failed to seek a catalog file" +msgstr "" + +#: ../eb/error.c:198 +msgid "failed to seek an appendix catalog file" +msgstr "" + +#: ../eb/error.c:199 +msgid "failed to seek a text file" +msgstr "" + +#. 25 -- 29 +#: ../eb/error.c:202 +msgid "failed to seek a font file" +msgstr "" + +#: ../eb/error.c:203 +msgid "failed to seek an appendix file" +msgstr "" + +#: ../eb/error.c:204 +msgid "failed to seek a binary file" +msgstr "" + +#: ../eb/error.c:205 +msgid "unexpected format in a catalog file" +msgstr "" + +#: ../eb/error.c:206 +msgid "unexpected format in an appendix catalog file" +msgstr "" + +#. 30 -- 34 +#: ../eb/error.c:209 +msgid "unexpected format in a text file" +msgstr "" + +#: ../eb/error.c:210 +msgid "unexpected format in a font file" +msgstr "" + +#: ../eb/error.c:211 +msgid "unexpected format in an appendix file" +msgstr "" + +#: ../eb/error.c:212 +msgid "unexpected format in a binary file" +msgstr "" + +#: ../eb/error.c:213 +msgid "book not bound" +msgstr "" + +#. 35 -- 39 +#: ../eb/error.c:216 +msgid "appendix not bound" +msgstr "" + +#: ../eb/error.c:217 +msgid "no subbook" +msgstr "" + +#: ../eb/error.c:218 +msgid "no subbook in the appendix" +msgstr "" + +#: ../eb/error.c:219 +msgid "no font" +msgstr "" + +#: ../eb/error.c:220 +msgid "no text file" +msgstr "" + +#. 40 -- 44 +#: ../eb/error.c:223 +msgid "no stop-code" +msgstr "" + +#: ../eb/error.c:224 +msgid "no alternation string" +msgstr "" + +#: ../eb/error.c:225 +msgid "no current subbook" +msgstr "" + +#: ../eb/error.c:226 +msgid "no current appendix subbook" +msgstr "" + +#: ../eb/error.c:227 +msgid "no current font" +msgstr "" + +#. 45 -- 49 +#: ../eb/error.c:230 +msgid "no current binary" +msgstr "" + +#: ../eb/error.c:231 +msgid "no such subbook" +msgstr "" + +#: ../eb/error.c:232 +msgid "no such appendix subbook" +msgstr "" + +#: ../eb/error.c:233 +msgid "no such font" +msgstr "" + +#: ../eb/error.c:234 +msgid "no such character bitmap" +msgstr "" + +#. 50 -- 54 +#: ../eb/error.c:237 +msgid "no such character text" +msgstr "" + +#: ../eb/error.c:238 +msgid "no such search method" +msgstr "" + +#: ../eb/error.c:239 +msgid "no such hook" +msgstr "" + +#: ../eb/error.c:240 +msgid "no such binary" +msgstr "" + +#: ../eb/error.c:241 +msgid "different content type" +msgstr "" + +#. 55 -- 59 +#: ../eb/error.c:244 +msgid "no previous search" +msgstr "" + +#: ../eb/error.c:245 +msgid "no such multi search" +msgstr "" + +#: ../eb/error.c:246 +msgid "no such multi search entry" +msgstr "" + +#: ../eb/error.c:247 +msgid "too many words specified" +msgstr "" + +#: ../eb/error.c:248 +msgid "no word specified" +msgstr "" + +#. 60 -- 64 +#: ../eb/error.c:251 +msgid "no candidates" +msgstr "" + +#: ../eb/error.c:252 +msgid "end of content" +msgstr "" + +#: ../eb/error.c:253 +msgid "no previous seek" +msgstr "" + +#: ../eb/error.c:254 +msgid "ebnet is not supported" +msgstr "" + +#: ../eb/error.c:255 +msgid "failed to connect to an ebnet server" +msgstr "" + +#. 65 -- 69 +#: ../eb/error.c:258 +msgid "ebnet server is busy" +msgstr "" + +#: ../eb/error.c:259 +msgid "no access permission" +msgstr "" + +#: ../eb/error.c:260 +msgid "booklist not bound" +msgstr "" + +#: ../eb/error.c:261 +msgid "no such book" +msgstr "" + +#: ../eb/error.c:277 +msgid "unknown error" +msgstr "" diff --git a/po-eb/ja.mo b/po-eb/ja.mo new file mode 100644 index 0000000..e6bbf04 Binary files /dev/null and b/po-eb/ja.mo differ diff --git a/po-eb/ja.po b/po-eb/ja.po new file mode 100644 index 0000000..dc6134f --- /dev/null +++ b/po-eb/ja.po @@ -0,0 +1,308 @@ +# +# Copyright (C) 2004-2006 Motoyuki Kasahara +# +msgid "" +msgstr "" +"Project-Id-Version: eb 4.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-01-03 22:27+0900\n" +"PO-Revision-Date: 2001-03-31 22:10+0900\n" +"Last-Translator: Motoyuki Kasahara \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=EUC-JP\n" +"Content-Transfer-Encoding: 8bit\n" + +#. 0 -- 4 +#: ../eb/error.c:167 +msgid "no error" +msgstr "エラーはありません" + +#: ../eb/error.c:168 +msgid "memory exhausted" +msgstr "メモリを使い果たしました" + +#: ../eb/error.c:169 +msgid "an empty file name" +msgstr "空のファイル名です" + +#: ../eb/error.c:170 +msgid "too long file name" +msgstr "ファイル名が長すぎます" + +#: ../eb/error.c:171 +msgid "bad file name" +msgstr "不正なファイル名です" + +#. 5 -- 9 +#: ../eb/error.c:174 +msgid "bad directory name" +msgstr "不正なディレクトリ名です" + +#: ../eb/error.c:175 +msgid "too long word" +msgstr "単語が長すぎます" + +#: ../eb/error.c:176 +msgid "a word contains bad character" +msgstr "単語が不正な文字を含んでいます" + +#: ../eb/error.c:177 +msgid "an empty word" +msgstr "単語が空です" + +#: ../eb/error.c:178 +msgid "failed to get the current working directory" +msgstr "カレントディレクトリが分かりませんでした" + +#. 10 -- 14 +#: ../eb/error.c:181 +msgid "failed to open a catalog file" +msgstr "カタログファイルが開けませんでした" + +#: ../eb/error.c:182 +msgid "failed to open an appendix catalog file" +msgstr "付録のカタログファイルが開けませんでした" + +#: ../eb/error.c:183 +msgid "failed to open a text file" +msgstr "本文ファイルが開けませんでした" + +#: ../eb/error.c:184 +msgid "failed to open a font file" +msgstr "フォントファイルが開けませんでした" + +#: ../eb/error.c:185 +msgid "failed to open an appendix file" +msgstr "付録ファイルが開けませんでした" + +#. 15 -- 19 +#: ../eb/error.c:188 +msgid "failed to open a binary file" +msgstr "バイナリファイルが開けませんでした" + +#: ../eb/error.c:189 +msgid "failed to read a catalog file" +msgstr "カタログファイルが読めませんでした" + +#: ../eb/error.c:190 +msgid "failed to read an appendix catalog file" +msgstr "付録のカタログファイルが読めませんでした" + +#: ../eb/error.c:191 +msgid "failed to read a text file" +msgstr "本文ファイルが読めませんでした" + +#: ../eb/error.c:192 +msgid "failed to read a font file" +msgstr "フォントファイルが読めませんでした" + +#. 20 -- 24 +#: ../eb/error.c:195 +msgid "failed to read an appendix file" +msgstr "付録ファイルが開けませんでした" + +#: ../eb/error.c:196 +msgid "failed to read a binary file" +msgstr "バイナリファイルが読めませんでした" + +#: ../eb/error.c:197 +msgid "failed to seek a catalog file" +msgstr "カタログファイルがシークできませんでした" + +#: ../eb/error.c:198 +msgid "failed to seek an appendix catalog file" +msgstr "付録のカタログファイルがシークできませんでした" + +#: ../eb/error.c:199 +msgid "failed to seek a text file" +msgstr "本文ファイルがシークできませんでした" + +#. 25 -- 29 +#: ../eb/error.c:202 +msgid "failed to seek a font file" +msgstr "フォントファイルがシークできませんでした" + +#: ../eb/error.c:203 +msgid "failed to seek an appendix file" +msgstr "付録ファイルが読めませんでした" + +#: ../eb/error.c:204 +msgid "failed to seek a binary file" +msgstr "バイナリファイルがシークできませんでした" + +#: ../eb/error.c:205 +msgid "unexpected format in a catalog file" +msgstr "カタログファイルの形式が想定外です" + +#: ../eb/error.c:206 +msgid "unexpected format in an appendix catalog file" +msgstr "付録のカタログファイルの形式が想定外です" + +#. 30 -- 34 +#: ../eb/error.c:209 +msgid "unexpected format in a text file" +msgstr "本文ファイルの形式が想定外です" + +#: ../eb/error.c:210 +msgid "unexpected format in a font file" +msgstr "フォントファイルの形式が想定外です" + +#: ../eb/error.c:211 +msgid "unexpected format in an appendix file" +msgstr "付録ファイルの形式がが想定外です" + +#: ../eb/error.c:212 +msgid "unexpected format in a binary file" +msgstr "バイナリファイルの形式が想定外です" + +#: ../eb/error.c:213 +msgid "book not bound" +msgstr "書籍は結び付けられていません" + +#. 35 -- 39 +#: ../eb/error.c:216 +msgid "appendix not bound" +msgstr "appendix は結び付けられていません" + +#: ../eb/error.c:217 +msgid "no subbook" +msgstr "副本はありません" + +#: ../eb/error.c:218 +msgid "no subbook in the appendix" +msgstr "付録には副本がありません" + +#: ../eb/error.c:219 +msgid "no font" +msgstr "フォントはありません" + +#: ../eb/error.c:220 +msgid "no text file" +msgstr "本文ファイルはありません" + +#. 40 -- 44 +#: ../eb/error.c:223 +msgid "no stop-code" +msgstr "区切りコードはありません" + +#: ../eb/error.c:224 +msgid "no alternation string" +msgstr "代替文字列はありません" + +#: ../eb/error.c:225 +msgid "no current subbook" +msgstr "現時点で副本は選択していません" + +#: ../eb/error.c:226 +msgid "no current appendix subbook" +msgstr "現時点で付録の副本は選択していません" + +#: ../eb/error.c:227 +msgid "no current font" +msgstr "現時点でフォントは選択していません" + +#. 45 -- 49 +#: ../eb/error.c:230 +msgid "no current binary" +msgstr "現時点でバイナリは選択していません" + +#: ../eb/error.c:231 +msgid "no such subbook" +msgstr "そのような副本はありません" + +#: ../eb/error.c:232 +msgid "no such appendix subbook" +msgstr "付録にそのような副本はありません" + +#: ../eb/error.c:233 +msgid "no such font" +msgstr "そのようなフォントはありません" + +#: ../eb/error.c:234 +msgid "no such character bitmap" +msgstr "そのような文字のビットマップはありません" + +#. 50 -- 54 +#: ../eb/error.c:237 +msgid "no such character text" +msgstr "そのような文字のテキストはありません" + +#: ../eb/error.c:238 +msgid "no such search method" +msgstr "そのような検索方式はありません" + +#: ../eb/error.c:239 +msgid "no such hook" +msgstr "そのようなフックはありません" + +#: ../eb/error.c:240 +msgid "no such binary" +msgstr "そのようなバイナリはありません" + +#: ../eb/error.c:241 +msgid "different content type" +msgstr "データの型が異なっています" + +#. 55 -- 59 +#: ../eb/error.c:244 +msgid "no previous search" +msgstr "検索方式が前もって指定されていません" + +#: ../eb/error.c:245 +msgid "no such multi search" +msgstr "そのような複合検索はありません" + +#: ../eb/error.c:246 +msgid "no such multi search entry" +msgstr "そのような複合検索のエントリはありません" + +#: ../eb/error.c:247 +msgid "too many words specified" +msgstr "指定している単語の数が多すぎます" + +#: ../eb/error.c:248 +msgid "no word specified" +msgstr "単語が一つも指定されていません" + +#. 60 -- 64 +#: ../eb/error.c:251 +msgid "no candidates" +msgstr "候補はありません" + +#: ../eb/error.c:252 +msgid "end of content" +msgstr "本文は終わりです" + +#: ../eb/error.c:253 +msgid "no previous seek" +msgstr "事前にシークが実行されていません" + +#: ../eb/error.c:254 +msgid "ebnet is not supported" +msgstr "ebnet には対応していません" + +#: ../eb/error.c:255 +msgid "failed to connect to an ebnet server" +msgstr "ebnet サーバに接続できませんでした" + +#. 65 -- 69 +#: ../eb/error.c:258 +msgid "ebnet server is busy" +msgstr "ebnet サーバがビジー状態です" + +#: ../eb/error.c:259 +msgid "no access permission" +msgstr "アクセス許可がありません" + +#: ../eb/error.c:260 +msgid "booklist not bound" +msgstr "書籍一覧は結び付けられていません" + +#: ../eb/error.c:261 +msgid "no such book" +msgstr "そのような書籍はありません" + +#: ../eb/error.c:277 +msgid "unknown error" +msgstr "未知のエラーです" diff --git a/po-ebutils/Makefile.in b/po-ebutils/Makefile.in new file mode 100644 index 0000000..f858517 --- /dev/null +++ b/po-ebutils/Makefile.in @@ -0,0 +1,171 @@ +# Makefile for program source directory in GNU NLS utilities package. +# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper +# +# This file file be copied and used freely without restrictions. It can +# be used in projects which are not available under the GNU Public License +# but which still want to provide support for the GNU gettext functionality. +# Please note that the actual code is *not* freely available. + +## Note that the following macros must be set by your hand. +top_builddir = .. +subdir = po-ebutils + +TEXTDOMAIN = ebutils +POFILES = ja.po +MOFILES = ja.mo +POTFILES = \ + $(top_srcdir)/libebutils/ebutils.c \ + $(top_srcdir)/libebutils/getopt.c \ + $(top_srcdir)/ebfont/ebfont.c \ + $(top_srcdir)/ebinfo/ebinfo.c \ + $(top_srcdir)/ebrefile/ebrefile.c \ + $(top_srcdir)/ebstopcode/ebstopcode.c \ + $(top_srcdir)/ebzip/copyfile.c \ + $(top_srcdir)/ebzip/ebzip.c \ + $(top_srcdir)/ebzip/ebzip1.c \ + $(top_srcdir)/ebzip/sebxa.c \ + $(top_srcdir)/ebzip/speedup.c \ + $(top_srcdir)/ebzip/unlinkfile.c \ + $(top_srcdir)/ebzip/unzipbook.c \ + $(top_srcdir)/ebzip/unzipfile.c \ + $(top_srcdir)/ebzip/zipbook.c \ + $(top_srcdir)/ebzip/zipfile.c \ + $(top_srcdir)/ebzip/zipinfobook.c \ + $(top_srcdir)/ebzip/zipinfofile.c +## end + +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +SHELL = /bin/sh + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +datarootdir = @datarootdir@ +datadir = @datadir@ +localedir = @localedir@ + +mkdir_p = @mkdir_p@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +mkinstalldirs = $(install_sh) -d +install_sh = @install_sh@ + +MSGFMT = @MSGFMT@ +XGETTEXT = @XGETTEXT@ +MSGMERGE = msgmerge + +DISTFILES = Makefile.in $(TEXTDOMAIN).pot $(MOFILES) $(POFILES) + +.SUFFIXES: +.SUFFIXES: .po .pox .mo + +.po.pox: + $(MAKE) $(TEXTDOMAIN).pot + $(MSGMERGE) $< $(srcdir)/$(TEXTDOMAIN).pot -o $*.pox + +.po.mo: + file=$(srcdir)/`echo $* | sed 's,.*/,,'`.mo \ + && rm -f $$file && $(MSGFMT) -o $$file $< + +all: all-@ENABLE_NLS@ + +all-yes: $(MOFILES) +all-no: + +$(TEXTDOMAIN).pot: $(POTFILES) + $(XGETTEXT) --default-domain=$(TEXTDOMAIN) --add-comments \ + --keyword=_ --keyword=N_ $(POTFILES) \ + && test ! -f $(TEXTDOMAIN).po \ + || ( rm -f $(srcdir)/$(TEXTDOMAIN).pot \ + && mv $(TEXTDOMAIN).po $(srcdir)/$(TEXTDOMAIN).pot ) + +install: install-exec install-data +install-exec: +install-data: install-data-@ENABLE_NLS@ +install-data-no: all +install-data-yes: all + $(mkinstalldirs) $(DESTDIR)$(datadir) + @catalogs='$(MOFILES)'; \ + for cat in $$catalogs; do \ + cat=`echo $$cat | sed 's/^.*\/\([^\/]*\)$$/\1/'` ; \ + lang=`echo $$cat | sed 's/\.mo$$//'`; \ + dir=$(localedir)/$$lang/LC_MESSAGES; \ + $(mkinstalldirs) $(DESTDIR)$$dir; \ + if test -r $$cat; then \ + $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(TEXTDOMAIN).mo; \ + echo "installing $$cat as" \ + "$(DESTDIR)$$dir/$(TEXTDOMAIN).mo"; \ + else \ + $(INSTALL_DATA) $(srcdir)/$$cat \ + $(DESTDIR)$$dir/$(TEXTDOMAIN).mo; \ + echo "installing $(srcdir)/$$cat as" \ + "$(DESTDIR)$$dir/$(TEXTDOMAIN).mo"; \ + fi; \ + done + +# Define this as empty until I found a useful application. +installcheck: + +uninstall: + catalogs='$(MOFILES)'; \ + for cat in $$catalogs; do \ + cat=`echo $$cat | sed 's/^.*\/\([^\/]*\)$$/\1/'` ; \ + lang=`echo $$cat | sed 's/\.mo$$//'`; \ + rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(TEXTDOMAIN).mo; \ + done + rm -f $(DESTDIR)$(gettextsrcdir)/po-Makefile.in + +check: all + +dvi info tags TAGS ID: + +mostlyclean: + rm -f core core.* *.pox $(TEXTDOMAIN).po *.old.po + rm -fr *.o + +clean: mostlyclean + +distclean: clean + rm -f Makefile *.mo + +maintainer-clean: distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + rm -f *.mo + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) +dist distdir: update-po $(DISTFILES) + dists="$(DISTFILES)"; \ + for file in $$dists; do \ + ln $(srcdir)/$$file $(distdir) 2> /dev/null \ + || cp -p $(srcdir)/$$file $(distdir); \ + done + +update-po: Makefile + $(MAKE) $(TEXTDOMAIN).pot + cd $(srcdir); \ + catalogs='$(MOFILES)'; \ + for cat in $$catalogs; do \ + cat=`echo $$cat | sed 's/^.*\/\([^\/]*\)$$/\1/'` ; \ + lang=`echo $$cat | sed 's/\.mo$$//'`; \ + mv $$lang.po $$lang.old.po; \ + echo "$$lang:"; \ + if $(MSGMERGE) $$lang.old.po $(TEXTDOMAIN).pot -o $$lang.po; then \ + rm -f $$lang.old.po; \ + else \ + echo "msgmerge for $$cat failed!"; \ + rm -f $$lang.po; \ + mv $$lang.old.po $$lang.po; \ + fi; \ + done + +Makefile: Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \ + $(SHELL) ./config.status + +# Tell versions [3.59,3.63) of GNU make not to export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/po-ebutils/ebutils.pot b/po-ebutils/ebutils.pot new file mode 100644 index 0000000..c3048af --- /dev/null +++ b/po-ebutils/ebutils.pot @@ -0,0 +1,902 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-01-03 22:27+0900\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../libebutils/ebutils.c:107 +#, c-format +msgid "try `%s --help' for more information\n" +msgstr "" + +#: ../libebutils/ebutils.c:143 +#, c-format +msgid "%s: too many subbooks\n" +msgstr "" + +#: ../libebutils/ebutils.c:164 +#, c-format +msgid "%s: invalid subbook name `%s...'\n" +msgstr "" + +#: ../libebutils/getopt.c:105 +#, c-format +msgid "%s: option requires an argument -- %c\n" +msgstr "" + +#: ../libebutils/getopt.c:107 +#, c-format +msgid "%s: option `%.*s' requires an argument\n" +msgstr "" + +#: ../libebutils/getopt.c:109 +#, c-format +msgid "%s: option `--%.*s' is ambiguous\n" +msgstr "" + +#: ../libebutils/getopt.c:111 +#, c-format +msgid "%s: option `--%.*s' doesn't allow an argument\n" +msgstr "" + +#: ../libebutils/getopt.c:113 +#, c-format +msgid "%s: illegal option -- %c\n" +msgstr "" + +#: ../libebutils/getopt.c:115 +#, c-format +msgid "%s: invalid option -- %c\n" +msgstr "" + +#: ../libebutils/getopt.c:117 +#, c-format +msgid "%s: unrecognized option `--%.*s'\n" +msgstr "" + +#: ../ebfont/ebfont.c:307 ../ebfont/ebfont.c:316 ../ebrefile/ebrefile.c:221 +#: ../ebrefile/ebrefile.c:229 ../ebzip/ebzip.c:275 ../ebzip/ebzip.c:285 +#, c-format +msgid "%s: too long output directory path\n" +msgstr "" + +#: ../ebfont/ebfont.c:350 ../ebinfo/ebinfo.c:172 ../ebrefile/ebrefile.c:261 +#: ../ebstopcode/ebstopcode.c:257 ../ebzip/ebzip.c:371 +#, c-format +msgid "%s: too many arguments\n" +msgstr "" + +#: ../ebfont/ebfont.c:398 ../ebzip/unzipbook.c:93 ../ebzip/zipbook.c:94 +#: ../ebzip/zipinfobook.c:95 +#, c-format +msgid "%s: unknown subbook name `%s'\n" +msgstr "" + +#: ../ebfont/ebfont.c:461 +#, c-format +msgid "%s: unknown font height `%s...'\n" +msgstr "" + +#: ../ebfont/ebfont.c:478 +#, c-format +msgid "%s: unknown font height `%s'\n" +msgstr "" + +#: ../ebfont/ebfont.c:539 +#, c-format +msgid "%s: unknown image format name `%s...'\n" +msgstr "" + +#: ../ebfont/ebfont.c:552 +#, c-format +msgid "%s: unknown image format name `%s'\n" +msgstr "" + +#: ../ebfont/ebfont.c:589 ../ebinfo/ebinfo.c:607 ../ebrefile/ebrefile.c:328 +#: ../ebzip/ebzip.c:522 +#, c-format +msgid "Usage: %s [option...] [book-directory]\n" +msgstr "" + +#: ../ebfont/ebfont.c:590 ../ebinfo/ebinfo.c:609 ../ebrefile/ebrefile.c:329 +#: ../ebstopcode/ebstopcode.c:447 ../ebzip/ebzip.c:523 +#, c-format +msgid "Options:\n" +msgstr "" + +#: ../ebfont/ebfont.c:591 +#, c-format +msgid " -d --debug --verbose degug mode\n" +msgstr "" + +#: ../ebfont/ebfont.c:592 +#, c-format +msgid " -f HEIGHT[,HEIGHT...] --font-height HEIGHT[,HEIGHT...]\n" +msgstr "" + +#: ../ebfont/ebfont.c:593 +#, c-format +msgid "" +" generate fonts with HEIGHT; 16, 24, 30 or 48\n" +msgstr "" + +#: ../ebfont/ebfont.c:594 ../ebfont/ebfont.c:600 ../ebfont/ebfont.c:604 +#: ../ebfont/ebfont.c:612 ../ebinfo/ebinfo.c:616 ../ebrefile/ebrefile.c:333 +#: ../ebrefile/ebrefile.c:341 ../ebstopcode/ebstopcode.c:461 +#: ../ebzip/ebzip.c:538 ../ebzip/ebzip.c:556 +#, c-format +msgid " (default: %s)\n" +msgstr "" + +#: ../ebfont/ebfont.c:596 ../ebinfo/ebinfo.c:610 ../ebrefile/ebrefile.c:330 +#: ../ebstopcode/ebstopcode.c:450 ../ebzip/ebzip.c:526 +#, c-format +msgid " -h --help display this help, then exit\n" +msgstr "" + +#: ../ebfont/ebfont.c:597 +#, c-format +msgid " -i FORMAT[,FORMAT...] --image-format FORMAT[,FORMAT...]\n" +msgstr "" + +#: ../ebfont/ebfont.c:598 +#, c-format +msgid " generate fonts as FORMAT;\n" +msgstr "" + +#: ../ebfont/ebfont.c:599 +#, c-format +msgid " xbm, xpm, gif, bmp or png\n" +msgstr "" + +#: ../ebfont/ebfont.c:602 ../ebrefile/ebrefile.c:331 ../ebzip/ebzip.c:536 +#, c-format +msgid " -o DIRECTORY --output-directory DIRECTORY\n" +msgstr "" + +#: ../ebfont/ebfont.c:603 +#, c-format +msgid " output fonts under DIRECTORY\n" +msgstr "" + +#: ../ebfont/ebfont.c:606 ../ebrefile/ebrefile.c:335 ../ebzip/ebzip.c:544 +#, c-format +msgid " -S SUBBOOK[,SUBBOOK...] --subbook SUBBOOK[,SUBBOOK...]\n" +msgstr "" + +#: ../ebfont/ebfont.c:607 ../ebrefile/ebrefile.c:336 ../ebzip/ebzip.c:545 +#, c-format +msgid " target subbook\n" +msgstr "" + +#: ../ebfont/ebfont.c:608 ../ebrefile/ebrefile.c:337 ../ebzip/ebzip.c:546 +#, c-format +msgid " (default: all subbooks)\n" +msgstr "" + +#: ../ebfont/ebfont.c:609 ../ebinfo/ebinfo.c:613 ../ebrefile/ebrefile.c:338 +#: ../ebstopcode/ebstopcode.c:458 ../ebzip/ebzip.c:549 +#, c-format +msgid " -v --version display version number, then exit\n" +msgstr "" + +#: ../ebfont/ebfont.c:610 ../ebinfo/ebinfo.c:614 ../ebrefile/ebrefile.c:339 +#: ../ebstopcode/ebstopcode.c:459 ../ebzip/ebzip.c:554 +#, c-format +msgid "" +"\n" +"Argument:\n" +msgstr "" + +#: ../ebfont/ebfont.c:611 ../ebinfo/ebinfo.c:615 ../ebrefile/ebrefile.c:340 +#: ../ebstopcode/ebstopcode.c:460 ../ebzip/ebzip.c:555 +#, c-format +msgid " book-directory top directory of a CD-ROM book\n" +msgstr "" + +#: ../ebfont/ebfont.c:614 ../ebinfo/ebinfo.c:618 ../ebrefile/ebrefile.c:344 +#: ../ebstopcode/ebstopcode.c:463 ../ebzip/ebzip.c:568 +#, c-format +msgid "" +"\n" +"Report bugs to %s.\n" +msgstr "" + +#: ../ebfont/ebfont.c:1030 ../ebrefile/ebrefile.c:461 +#: ../ebrefile/ebrefile.c:477 ../ebrefile/ebrefile.c:692 +#: ../ebrefile/ebrefile.c:705 ../ebzip/copyfile.c:148 ../ebzip/copyfile.c:172 +#: ../ebzip/sebxa.c:69 ../ebzip/sebxa.c:211 ../ebzip/zipfile.c:218 +#, c-format +msgid "%s: failed to open the file, %s: %s\n" +msgstr "" + +#: ../ebfont/ebfont.c:1035 ../ebfont/ebfont.c:1040 ../ebrefile/ebrefile.c:732 +#: ../ebzip/copyfile.c:209 ../ebzip/unzipfile.c:282 ../ebzip/zipfile.c:429 +#: ../ebzip/zipfile.c:503 +#, c-format +msgid "%s: failed to write to the file, %s: %s\n" +msgstr "" + +#: ../ebfont/ebfont.c:1053 +#, c-format +msgid "%s: failed to close the file, %s: %s\n" +msgstr "" + +#: ../ebinfo/ebinfo.c:235 +msgid "Name" +msgstr "" + +#: ../ebinfo/ebinfo.c:235 +msgid "Title" +msgstr "" + +#: ../ebinfo/ebinfo.c:318 +#, c-format +msgid "disc type: " +msgstr "" + +#: ../ebinfo/ebinfo.c:333 +#, c-format +msgid "character code: " +msgstr "" + +#: ../ebinfo/ebinfo.c:345 +#, c-format +msgid "unknown\n" +msgstr "" + +#: ../ebinfo/ebinfo.c:358 +#, c-format +msgid "" +"the number of subbooks: %d\n" +"\n" +msgstr "" + +#: ../ebinfo/ebinfo.c:364 +#, c-format +msgid "subbook %d:\n" +msgstr "" + +#: ../ebinfo/ebinfo.c:374 +#, c-format +msgid " title: " +msgstr "" + +#: ../ebinfo/ebinfo.c:386 +#, c-format +msgid " directory: %s\n" +msgstr "" + +#. +#. * Output supported methods. +#. +#: ../ebinfo/ebinfo.c:401 +#, c-format +msgid " search methods: " +msgstr "" + +#: ../ebinfo/ebinfo.c:403 +msgid "word " +msgstr "" + +#: ../ebinfo/ebinfo.c:405 +msgid "endword " +msgstr "" + +#: ../ebinfo/ebinfo.c:407 +msgid "keyword " +msgstr "" + +#: ../ebinfo/ebinfo.c:409 +msgid "cross " +msgstr "" + +#: ../ebinfo/ebinfo.c:411 +msgid "multi " +msgstr "" + +#: ../ebinfo/ebinfo.c:413 +msgid "menu " +msgstr "" + +#: ../ebinfo/ebinfo.c:415 +msgid "image-menu " +msgstr "" + +#: ../ebinfo/ebinfo.c:417 +msgid "copyright " +msgstr "" + +#. +#. * Output a font list. +#. +#: ../ebinfo/ebinfo.c:423 +msgid " font sizes: " +msgstr "" + +#. +#. * Output character range of the narrow font. +#. +#: ../ebinfo/ebinfo.c:445 +msgid " narrow font characters: " +msgstr "" + +#. +#. * Output character range of the wide font. +#. +#: ../ebinfo/ebinfo.c:473 +#, c-format +msgid " wide font characters: " +msgstr "" + +#: ../ebinfo/ebinfo.c:556 +#, c-format +msgid " multi search %d:\n" +msgstr "" + +#: ../ebinfo/ebinfo.c:570 +#, c-format +msgid " title: " +msgstr "" + +#: ../ebinfo/ebinfo.c:583 +#, c-format +msgid " label %d: " +msgstr "" + +#: ../ebinfo/ebinfo.c:587 +msgid " candidates: " +msgstr "" + +#: ../ebinfo/ebinfo.c:589 +msgid "exist\n" +msgstr "" + +#: ../ebinfo/ebinfo.c:591 +msgid "not-exist\n" +msgstr "" + +#: ../ebinfo/ebinfo.c:611 +#, c-format +msgid "" +" -l --book-list output a list of books on an EBENT server\n" +msgstr "" + +#: ../ebinfo/ebinfo.c:612 +#, c-format +msgid " -m --multi-search also output multi-search information\n" +msgstr "" + +#: ../ebrefile/ebrefile.c:283 +#, c-format +msgid "%s: too long book directory path\n" +msgstr "" + +#: ../ebrefile/ebrefile.c:332 ../ebzip/ebzip.c:537 +#, c-format +msgid " ouput files under DIRECTORY\n" +msgstr "" + +#: ../ebrefile/ebrefile.c:377 +#, c-format +msgid "%s: no catalog file: %s\n" +msgstr "" + +#: ../ebrefile/ebrefile.c:416 +#, c-format +msgid "%s: failed to move the file, %s: %s -> %s\n" +msgstr "" + +#: ../ebrefile/ebrefile.c:486 ../ebrefile/ebrefile.c:507 +#: ../ebrefile/ebrefile.c:555 ../ebrefile/ebrefile.c:595 ../ebzip/sebxa.c:90 +#: ../ebzip/sebxa.c:232 +#, c-format +msgid "%s: failed to read the file, %s: %s\n" +msgstr "" + +#: ../ebrefile/ebrefile.c:493 ../ebrefile/ebrefile.c:541 +#: ../ebrefile/ebrefile.c:562 ../ebrefile/ebrefile.c:600 +#: ../ebrefile/ebrefile.c:616 ../ebrefile/ebrefile.c:638 ../ebzip/sebxa.c:142 +#, c-format +msgid "%s: failed to write the file, %s: %s\n" +msgstr "" + +#: ../ebrefile/ebrefile.c:580 +#, c-format +msgid "%s: warning: no such subbook: %s\n" +msgstr "" + +#: ../ebrefile/ebrefile.c:633 ../ebzip/sebxa.c:78 ../ebzip/sebxa.c:130 +#: ../ebzip/sebxa.c:220 ../ebzip/zipfile.c:365 ../ebzip/zipfile.c:423 +#: ../ebzip/zipfile.c:497 +#, c-format +msgid "%s: failed to seek the file, %s: %s\n" +msgstr "" + +#: ../ebrefile/ebrefile.c:682 ../ebzip/copyfile.c:74 ../ebzip/unzipfile.c:130 +#: ../ebzip/zipfile.c:113 +#, c-format +msgid "%s: no such file: %s\n" +msgstr "" + +#: ../ebrefile/ebrefile.c:723 ../ebzip/copyfile.c:191 +#, c-format +msgid "%s: failed to read from the file, %s: %s\n" +msgstr "" + +#: ../ebstopcode/ebstopcode.c:252 +#, c-format +msgid "%s: too few argument\n" +msgstr "" + +#: ../ebstopcode/ebstopcode.c:341 +#, c-format +msgid "%s: invalid stop code `%s'\n" +msgstr "" + +#: ../ebstopcode/ebstopcode.c:376 +#, c-format +msgid "%s: invalid text length `%s'\n" +msgstr "" + +#: ../ebstopcode/ebstopcode.c:433 +#, c-format +msgid "%s: invalid text position `%s'\n" +msgstr "" + +#: ../ebstopcode/ebstopcode.c:445 +#, c-format +msgid "Usage: %s [option...] [book-directory] subbook\n" +msgstr "" + +#: ../ebstopcode/ebstopcode.c:448 +#, c-format +msgid " -c CODE, --code CODE\n" +msgstr "" + +#: ../ebstopcode/ebstopcode.c:449 +#, c-format +msgid " set stop code manually\n" +msgstr "" + +#: ../ebstopcode/ebstopcode.c:451 +#, c-format +msgid " -l LENGTH, --text-length LENGTH\n" +msgstr "" + +#: ../ebstopcode/ebstopcode.c:452 +#, c-format +msgid " maximum length of output text\n" +msgstr "" + +#: ../ebstopcode/ebstopcode.c:453 ../ebzip/ebzip.c:532 +#, c-format +msgid " (default: %d)\n" +msgstr "" + +#: ../ebstopcode/ebstopcode.c:455 +#, c-format +msgid " -n --no-candidates suppress stop code candidates\n" +msgstr "" + +#: ../ebstopcode/ebstopcode.c:456 +#, c-format +msgid " -p PAGE:OFFSET, --text-position PAGE:OFFSET\n" +msgstr "" + +#: ../ebstopcode/ebstopcode.c:457 +#, c-format +msgid " start position of text\n" +msgstr "" + +#: ../ebstopcode/ebstopcode.c:499 +#, c-format +msgid "%s: failed to bind the book, %s: %s\n" +msgstr "" + +#: ../ebstopcode/ebstopcode.c:518 +#, c-format +msgid "%s: failed to set the current subbook, %s\n" +msgstr "" + +#: ../ebstopcode/ebstopcode.c:553 +#, c-format +msgid "%s: failed to get text information, %s\n" +msgstr "" + +#: ../ebstopcode/ebstopcode.c:583 +#, c-format +msgid "%s: failed to read text, %s\n" +msgstr "" + +#: ../ebzip/copyfile.c:65 +#, c-format +msgid "==> copy %s <==\n" +msgstr "" + +#: ../ebzip/copyfile.c:66 ../ebzip/unzipfile.c:122 ../ebzip/zipfile.c:105 +#, c-format +msgid "output to %s\n" +msgstr "" + +#: ../ebzip/copyfile.c:85 ../ebzip/unzipfile.c:141 ../ebzip/zipfile.c:124 +#, c-format +msgid "" +"the input and output files are the same, skipped.\n" +"\n" +msgstr "" + +#: ../ebzip/copyfile.c:96 ../ebzip/copyfile.c:244 ../ebzip/sebxa.c:152 +#: ../ebzip/unzipfile.c:318 ../ebzip/zipfile.c:516 +#, c-format +msgid "completed (%llu / %llu bytes)\n" +msgstr "" + +#: ../ebzip/copyfile.c:100 ../ebzip/copyfile.c:248 ../ebzip/sebxa.c:156 +#: ../ebzip/unzipfile.c:322 ../ebzip/zipfile.c:530 +msgid "completed (%I64u / %I64u bytes)\n" +msgstr "" + +#: ../ebzip/copyfile.c:104 ../ebzip/copyfile.c:252 ../ebzip/sebxa.c:160 +#: ../ebzip/zipfile.c:544 +#, c-format +msgid "completed (%lu / %lu bytes)\n" +msgstr "" + +#: ../ebzip/copyfile.c:120 ../ebzip/unzipfile.c:164 ../ebzip/zipfile.c:154 +msgid "" +"already exists, skip the file\n" +"\n" +msgstr "" + +#: ../ebzip/copyfile.c:128 ../ebzip/unzipfile.c:171 ../ebzip/zipfile.c:161 +#, c-format +msgid "" +"\n" +"the file already exists: %s\n" +msgstr "" + +#: ../ebzip/copyfile.c:130 ../ebzip/unzipfile.c:173 ../ebzip/zipfile.c:163 +msgid "do you wish to overwrite (y or n)? " +msgstr "" + +#: ../ebzip/copyfile.c:137 ../ebzip/unzipfile.c:180 ../ebzip/zipfile.c:170 +#, c-format +msgid "%s: failed to unlink the file: %s\n" +msgstr "" + +#: ../ebzip/copyfile.c:195 ../ebzip/copyfile.c:200 ../ebzip/sebxa.c:94 +#: ../ebzip/sebxa.c:236 ../ebzip/unzipfile.c:261 ../ebzip/unzipfile.c:266 +#: ../ebzip/zipfile.c:315 ../ebzip/zipfile.c:320 +#, c-format +msgid "%s: unexpected EOF: %s\n" +msgstr "" + +#: ../ebzip/copyfile.c:220 ../ebzip/unzipfile.c:294 ../ebzip/zipfile.c:443 +#, c-format +msgid "%4.1f%% done (%llu / %llu bytes)\n" +msgstr "" + +#: ../ebzip/copyfile.c:225 ../ebzip/unzipfile.c:299 ../ebzip/zipfile.c:448 +msgid "%4.1f%% done (%I64u / %I64u bytes)\n" +msgstr "" + +#: ../ebzip/copyfile.c:230 ../ebzip/unzipfile.c:304 ../ebzip/zipfile.c:453 +#, c-format +msgid "%4.1f%% done (%lu / %lu bytes)\n" +msgstr "" + +#: ../ebzip/copyfile.c:341 ../ebzip/unzipbook.c:172 ../ebzip/unzipbook.c:290 +#: ../ebzip/unzipbook.c:302 ../ebzip/unzipbook.c:379 ../ebzip/zipbook.c:174 +#: ../ebzip/zipbook.c:296 ../ebzip/zipbook.c:308 ../ebzip/zipbook.c:387 +#, c-format +msgid "%s: failed to create a directory, %s: %s\n" +msgstr "" + +#: ../ebzip/copyfile.c:351 +#, c-format +msgid "%s: failed to open the directory, %s: %s\n" +msgstr "" + +#: ../ebzip/ebzip.c:347 +#, c-format +msgid "%s: invalid overwrite mode: %s\n" +msgstr "" + +#: ../ebzip/ebzip.c:444 +#, c-format +msgid "%s: invalid compression level `%s'\n" +msgstr "" + +#: ../ebzip/ebzip.c:486 ../ebzip/ebzip.c:505 +#, c-format +msgid "%s: invalid content name `%s'\n" +msgstr "" + +#: ../ebzip/ebzip.c:524 +#, c-format +msgid " -f --force-overwrite set overwrite mode to `force'\n" +msgstr "" + +#: ../ebzip/ebzip.c:525 +#, c-format +msgid " (same as `--overwrite force')\n" +msgstr "" + +#: ../ebzip/ebzip.c:527 +#, c-format +msgid " -i --information list information of compressed files\n" +msgstr "" + +#: ../ebzip/ebzip.c:528 +#, c-format +msgid " -k --keep don't delete original files\n" +msgstr "" + +#: ../ebzip/ebzip.c:529 +#, c-format +msgid " -l INTEGER --level INTEGER\n" +msgstr "" + +#: ../ebzip/ebzip.c:530 +#, c-format +msgid " compression level; 0..%d\n" +msgstr "" + +#: ../ebzip/ebzip.c:534 +#, c-format +msgid " -n --no-overwrite set overwrite mode to `no'\n" +msgstr "" + +#: ../ebzip/ebzip.c:535 +#, c-format +msgid " (same as `--overwrite no')\n" +msgstr "" + +#: ../ebzip/ebzip.c:540 +#, c-format +msgid " -q --quiet --silence suppress all warnings\n" +msgstr "" + +#: ../ebzip/ebzip.c:541 +#, c-format +msgid " -s TYPE[,TYPE] --skip-content TYPE[,TYPE...]\n" +msgstr "" + +#: ../ebzip/ebzip.c:542 +#, c-format +msgid "" +" skip content; font, graphic, sound or movie\n" +msgstr "" + +#: ../ebzip/ebzip.c:543 +#, c-format +msgid " (default: none is skipped)\n" +msgstr "" + +#: ../ebzip/ebzip.c:547 +#, c-format +msgid " -t --test only check for input files\n" +msgstr "" + +#: ../ebzip/ebzip.c:548 +#, c-format +msgid " -u --uncompress uncompress files\n" +msgstr "" + +#: ../ebzip/ebzip.c:550 +#, c-format +msgid " -w MODE --overwrite MODE set overwrite mode of output files;\n" +msgstr "" + +#: ../ebzip/ebzip.c:551 +#, c-format +msgid " confirm, force or no\n" +msgstr "" + +#: ../ebzip/ebzip.c:552 +#, c-format +msgid " (default: confirm)\n" +msgstr "" + +#: ../ebzip/ebzip.c:553 +#, c-format +msgid " -z --compress compress files\n" +msgstr "" + +#: ../ebzip/ebzip.c:559 +#, c-format +msgid "" +"\n" +"Default action:\n" +msgstr "" + +#: ../ebzip/ebzip.c:561 +#, c-format +msgid " When invoked as `ebunzip', uncompression is the default action.\n" +msgstr "" + +#: ../ebzip/ebzip.c:562 +#, c-format +msgid "" +" When invoked as `ebzipinfo', listing information is the default action.\n" +msgstr "" + +#: ../ebzip/ebzip.c:564 +#, c-format +msgid " When invoked as `ebunzip.exe', uncompression is the default action.\n" +msgstr "" + +#: ../ebzip/ebzip.c:565 +#, c-format +msgid "" +" When invoked as `ebzipinf.exe', listing information is the default " +"action.\n" +msgstr "" + +#: ../ebzip/ebzip.c:567 +#, c-format +msgid " Otherwise, compression is the default action.\n" +msgstr "" + +#: ../ebzip/sebxa.c:60 +#, c-format +msgid "==> rewrite %s <==\n" +msgstr "" + +#: ../ebzip/speedup.c:79 ../ebzip/unzipfile.c:190 ../ebzip/unzipfile.c:228 +#: ../ebzip/zipfile.c:180 ../ebzip/zipinfofile.c:104 +#, c-format +msgid "%s: failed to open the file: %s\n" +msgstr "" + +#: ../ebzip/speedup.c:85 ../ebzip/speedup.c:90 ../ebzip/speedup.c:119 +#: ../ebzip/speedup.c:124 +#, c-format +msgid "%s: failed to read the file: %s\n" +msgstr "" + +#: ../ebzip/unlinkfile.c:39 +#, c-format +msgid "%s: warning: memory exhausted, file %s is not to be unlinked\n" +msgstr "" + +#: ../ebzip/unlinkfile.c:56 +#, c-format +msgid "%s: warning: failed to unlink the file: %s\n" +msgstr "" + +#: ../ebzip/unzipfile.c:121 +#, c-format +msgid "==> uncompress %s <==\n" +msgstr "" + +#: ../ebzip/unzipfile.c:152 ../ebzip/zipfile.c:135 ../ebzip/zipfile.c:142 +#: ../ebzip/zipfile.c:349 +#, c-format +msgid "%s: memory exhausted\n" +msgstr "" + +#: ../ebzip/unzipfile.c:251 ../ebzip/zipfile.c:305 +#, c-format +msgid "%s: failed to seek the file: %s\n" +msgstr "" + +#: ../ebzip/unzipfile.c:257 ../ebzip/zipfile.c:311 +#, c-format +msgid "%s: failed to read from the file: %s\n" +msgstr "" + +#: ../ebzip/unzipfile.c:326 ../ebzip/zipfile.c:553 +#, c-format +msgid "" +"%lu -> %lu bytes\n" +"\n" +msgstr "" + +#: ../ebzip/unzipfile.c:360 +#, c-format +msgid "%s: CRC error: %s\n" +msgstr "" + +#: ../ebzip/zipfile.c:104 +#, c-format +msgid "==> compress %s <==\n" +msgstr "" + +#: ../ebzip/zipfile.c:276 ../ebzip/zipfile.c:283 ../ebzip/zipfile.c:370 +#, c-format +msgid "%s: failed to write to the file: %s\n" +msgstr "" + +#: ../ebzip/zipfile.c:520 +#, c-format +msgid "" +"%llu -> %llu bytes (%4.1f%%)\n" +"\n" +msgstr "" + +#: ../ebzip/zipfile.c:525 +#, c-format +msgid "" +"%llu -> %llu bytes\n" +"\n" +msgstr "" + +#: ../ebzip/zipfile.c:534 +msgid "" +"%I64u -> %I64u bytes (%4.1f%%)\n" +"\n" +msgstr "" + +#: ../ebzip/zipfile.c:539 +msgid "" +"%I64u -> %I64u bytes\n" +"\n" +msgstr "" + +#: ../ebzip/zipfile.c:548 +#, c-format +msgid "" +"%lu -> %lu bytes (%4.1f%%)\n" +"\n" +msgstr "" + +#: ../ebzip/zipinfofile.c:132 +#, c-format +msgid "%llu bytes (not compressed)\n" +msgstr "" + +#: ../ebzip/zipinfofile.c:135 +msgid "%I64u bytes (not compressed)\n" +msgstr "" + +#: ../ebzip/zipinfofile.c:138 +#, c-format +msgid "%lu bytes (not compressed)\n" +msgstr "" + +#: ../ebzip/zipinfofile.c:143 +#, c-format +msgid "%llu -> %llu bytes " +msgstr "" + +#: ../ebzip/zipinfofile.c:147 +msgid "%I64u -> %I64u bytes " +msgstr "" + +#: ../ebzip/zipinfofile.c:151 +#, c-format +msgid "%lu -> %lu bytes " +msgstr "" + +#: ../ebzip/zipinfofile.c:156 +msgid "(empty original file, " +msgstr "" + +#: ../ebzip/zipinfofile.c:162 +#, c-format +msgid "ebzip level %d compression)\n" +msgstr "" + +#: ../ebzip/zipinfofile.c:164 +#, c-format +msgid "S-EBXA compression)\n" +msgstr "" + +#: ../ebzip/zipinfofile.c:166 +#, c-format +msgid "EPWING compression)\n" +msgstr "" diff --git a/po-ebutils/ja.mo b/po-ebutils/ja.mo new file mode 100644 index 0000000..e80e4e3 Binary files /dev/null and b/po-ebutils/ja.mo differ diff --git a/po-ebutils/ja.po b/po-ebutils/ja.po new file mode 100644 index 0000000..8bcced7 --- /dev/null +++ b/po-ebutils/ja.po @@ -0,0 +1,936 @@ +# +# Copyright (C) 2004-2006 Motoyuki Kasahara +# +# +msgid "" +msgstr "" +"Project-Id-Version: ebutils 4.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-01-03 22:27+0900\n" +"PO-Revision-Date: 2001-03-18 23:28+0900\n" +"Last-Translator: Motoyuki Kasahara \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=EUC-JP\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../libebutils/ebutils.c:107 +#, c-format +msgid "try `%s --help' for more information\n" +msgstr "`%s --help' でより詳しい情報が得られます\n" + +#: ../libebutils/ebutils.c:143 +#, c-format +msgid "%s: too many subbooks\n" +msgstr "%s: 副本の数が多すぎます\n" + +#: ../libebutils/ebutils.c:164 +#, c-format +msgid "%s: invalid subbook name `%s...'\n" +msgstr "%s: `%s...' という副本の名称が不正です\n" + +#: ../libebutils/getopt.c:105 +#, c-format +msgid "%s: option requires an argument -- %c\n" +msgstr "%s: オプションには引数が必要です -- %c\n" + +#: ../libebutils/getopt.c:107 +#, c-format +msgid "%s: option `%.*s' requires an argument\n" +msgstr "%s: オプション `%.*s' には引数が必要です\n" + +#: ../libebutils/getopt.c:109 +#, c-format +msgid "%s: option `--%.*s' is ambiguous\n" +msgstr "%s: オプション `--%.*s' は曖昧です\n" + +#: ../libebutils/getopt.c:111 +#, c-format +msgid "%s: option `--%.*s' doesn't allow an argument\n" +msgstr "%s: オプション `--%.*s' は引数を持てません\n" + +#: ../libebutils/getopt.c:113 +#, c-format +msgid "%s: illegal option -- %c\n" +msgstr "%s: 不正なオプションです -- %c\n" + +#: ../libebutils/getopt.c:115 +#, c-format +msgid "%s: invalid option -- %c\n" +msgstr "%s: 不正なオプションです -- %c\n" + +#: ../libebutils/getopt.c:117 +#, c-format +msgid "%s: unrecognized option `--%.*s'\n" +msgstr "%s: `--%.*s' は未知のオプションです\n" + +#: ../ebfont/ebfont.c:307 ../ebfont/ebfont.c:316 ../ebrefile/ebrefile.c:221 +#: ../ebrefile/ebrefile.c:229 ../ebzip/ebzip.c:275 ../ebzip/ebzip.c:285 +#, c-format +msgid "%s: too long output directory path\n" +msgstr "%s: 出力先のディレクトリのパス名が長すぎます\n" + +#: ../ebfont/ebfont.c:350 ../ebinfo/ebinfo.c:172 ../ebrefile/ebrefile.c:261 +#: ../ebstopcode/ebstopcode.c:257 ../ebzip/ebzip.c:371 +#, c-format +msgid "%s: too many arguments\n" +msgstr "%s: 引数が多すぎます\n" + +#: ../ebfont/ebfont.c:398 ../ebzip/unzipbook.c:93 ../ebzip/zipbook.c:94 +#: ../ebzip/zipinfobook.c:95 +#, c-format +msgid "%s: unknown subbook name `%s'\n" +msgstr "%s: `%s' は未知の副本名です\n" + +#: ../ebfont/ebfont.c:461 +#, c-format +msgid "%s: unknown font height `%s...'\n" +msgstr "%s: `%s...' は未知の高さのフォントです\n" + +#: ../ebfont/ebfont.c:478 +#, c-format +msgid "%s: unknown font height `%s'\n" +msgstr "%s: `%s' は未知の高さのフォントです\n" + +#: ../ebfont/ebfont.c:539 +#, c-format +msgid "%s: unknown image format name `%s...'\n" +msgstr "%s: `%s...' は未知の画像形式名です\n" + +#: ../ebfont/ebfont.c:552 +#, c-format +msgid "%s: unknown image format name `%s'\n" +msgstr "%s: `%s' は未知の画像形式名です\n" + +#: ../ebfont/ebfont.c:589 ../ebinfo/ebinfo.c:607 ../ebrefile/ebrefile.c:328 +#: ../ebzip/ebzip.c:522 +#, c-format +msgid "Usage: %s [option...] [book-directory]\n" +msgstr "使用法: %s [オプション...] [書籍のディレクトリ]\n" + +#: ../ebfont/ebfont.c:590 ../ebinfo/ebinfo.c:609 ../ebrefile/ebrefile.c:329 +#: ../ebstopcode/ebstopcode.c:447 ../ebzip/ebzip.c:523 +#, c-format +msgid "Options:\n" +msgstr "オプション:\n" + +#: ../ebfont/ebfont.c:591 +#, c-format +msgid " -d --debug --verbose degug mode\n" +msgstr " -d --debug --verbose デバッグモード\n" + +#: ../ebfont/ebfont.c:592 +#, c-format +msgid " -f HEIGHT[,HEIGHT...] --font-height HEIGHT[,HEIGHT...]\n" +msgstr " -f 高さ[,高さ...] --font-height 高さ[,高さ...]\n" + +#: ../ebfont/ebfont.c:593 +#, c-format +msgid "" +" generate fonts with HEIGHT; 16, 24, 30 or 48\n" +msgstr "" +" 「高さ」のフォントを生成\n" +" 高さは 16, 24, 30, 48 のいずれか\n" + +#: ../ebfont/ebfont.c:594 ../ebfont/ebfont.c:600 ../ebfont/ebfont.c:604 +#: ../ebfont/ebfont.c:612 ../ebinfo/ebinfo.c:616 ../ebrefile/ebrefile.c:333 +#: ../ebrefile/ebrefile.c:341 ../ebstopcode/ebstopcode.c:461 +#: ../ebzip/ebzip.c:538 ../ebzip/ebzip.c:556 +#, c-format +msgid " (default: %s)\n" +msgstr " (省略時: %s)\n" + +#: ../ebfont/ebfont.c:596 ../ebinfo/ebinfo.c:610 ../ebrefile/ebrefile.c:330 +#: ../ebstopcode/ebstopcode.c:450 ../ebzip/ebzip.c:526 +#, c-format +msgid " -h --help display this help, then exit\n" +msgstr " -h --help このヘルプを表示して終了\n" + +#: ../ebfont/ebfont.c:597 +#, c-format +msgid " -i FORMAT[,FORMAT...] --image-format FORMAT[,FORMAT...]\n" +msgstr " -i 画像形式[,画像形式...] --image-format 画像形式[,画像形式...]\n" + +#: ../ebfont/ebfont.c:598 +#, c-format +msgid " generate fonts as FORMAT;\n" +msgstr " 「画像形式」のフォントを生成\n" + +#: ../ebfont/ebfont.c:599 +#, c-format +msgid " xbm, xpm, gif, bmp or png\n" +msgstr " xbm, xpm, gif, bmp, png のいずれか\n" + +#: ../ebfont/ebfont.c:602 ../ebrefile/ebrefile.c:331 ../ebzip/ebzip.c:536 +#, c-format +msgid " -o DIRECTORY --output-directory DIRECTORY\n" +msgstr " -o ディレクトリ --output-directory ディレクトリ\n" + +#: ../ebfont/ebfont.c:603 +#, c-format +msgid " output fonts under DIRECTORY\n" +msgstr " フォントを「ディレクトリ」の下に生成\n" + +#: ../ebfont/ebfont.c:606 ../ebrefile/ebrefile.c:335 ../ebzip/ebzip.c:544 +#, c-format +msgid " -S SUBBOOK[,SUBBOOK...] --subbook SUBBOOK[,SUBBOOK...]\n" +msgstr " -S 副本[,副本...] --subbook 副本[,副本...]\n" + +#: ../ebfont/ebfont.c:607 ../ebrefile/ebrefile.c:336 ../ebzip/ebzip.c:545 +#, c-format +msgid " target subbook\n" +msgstr " 処理対象の副本\n" + +#: ../ebfont/ebfont.c:608 ../ebrefile/ebrefile.c:337 ../ebzip/ebzip.c:546 +#, c-format +msgid " (default: all subbooks)\n" +msgstr " (省略時: すべての副本)\n" + +#: ../ebfont/ebfont.c:609 ../ebinfo/ebinfo.c:613 ../ebrefile/ebrefile.c:338 +#: ../ebstopcode/ebstopcode.c:458 ../ebzip/ebzip.c:549 +#, c-format +msgid " -v --version display version number, then exit\n" +msgstr " -v --version バージョン番号を表示して終了\n" + +#: ../ebfont/ebfont.c:610 ../ebinfo/ebinfo.c:614 ../ebrefile/ebrefile.c:339 +#: ../ebstopcode/ebstopcode.c:459 ../ebzip/ebzip.c:554 +#, c-format +msgid "" +"\n" +"Argument:\n" +msgstr "" +"\n" +"引数:\n" + +#: ../ebfont/ebfont.c:611 ../ebinfo/ebinfo.c:615 ../ebrefile/ebrefile.c:340 +#: ../ebstopcode/ebstopcode.c:460 ../ebzip/ebzip.c:555 +#, c-format +msgid " book-directory top directory of a CD-ROM book\n" +msgstr " 書籍のディレクトリ CD-ROM 書籍のトップディレクトリ\n" + +#: ../ebfont/ebfont.c:614 ../ebinfo/ebinfo.c:618 ../ebrefile/ebrefile.c:344 +#: ../ebstopcode/ebstopcode.c:463 ../ebzip/ebzip.c:568 +#, c-format +msgid "" +"\n" +"Report bugs to %s.\n" +msgstr "" +"\n" +"バグは %s に報告して下さい\n" + +#: ../ebfont/ebfont.c:1030 ../ebrefile/ebrefile.c:461 +#: ../ebrefile/ebrefile.c:477 ../ebrefile/ebrefile.c:692 +#: ../ebrefile/ebrefile.c:705 ../ebzip/copyfile.c:148 ../ebzip/copyfile.c:172 +#: ../ebzip/sebxa.c:69 ../ebzip/sebxa.c:211 ../ebzip/zipfile.c:218 +#, c-format +msgid "%s: failed to open the file, %s: %s\n" +msgstr "%s: ファイルを開けませんでした, %s: %s\n" + +#: ../ebfont/ebfont.c:1035 ../ebfont/ebfont.c:1040 ../ebrefile/ebrefile.c:732 +#: ../ebzip/copyfile.c:209 ../ebzip/unzipfile.c:282 ../ebzip/zipfile.c:429 +#: ../ebzip/zipfile.c:503 +#, c-format +msgid "%s: failed to write to the file, %s: %s\n" +msgstr "%s: ファイルへ書き込めませんでした, %s: %s\n" + +#: ../ebfont/ebfont.c:1053 +#, c-format +msgid "%s: failed to close the file, %s: %s\n" +msgstr "%s: ファイルを閉じられませんでした, %s: %s\n" + +#: ../ebinfo/ebinfo.c:235 +msgid "Name" +msgstr "名前" + +#: ../ebinfo/ebinfo.c:235 +msgid "Title" +msgstr "題名" + +#: ../ebinfo/ebinfo.c:318 +#, c-format +msgid "disc type: " +msgstr "ディスクの形式: " + +#: ../ebinfo/ebinfo.c:333 +#, c-format +msgid "character code: " +msgstr "文字コード: " + +#: ../ebinfo/ebinfo.c:345 +#, c-format +msgid "unknown\n" +msgstr "未知\n" + +#: ../ebinfo/ebinfo.c:358 +#, c-format +msgid "" +"the number of subbooks: %d\n" +"\n" +msgstr "" +"副本の数: %d\n" +"\n" + +#: ../ebinfo/ebinfo.c:364 +#, c-format +msgid "subbook %d:\n" +msgstr "副本 %d:\n" + +#: ../ebinfo/ebinfo.c:374 +#, c-format +msgid " title: " +msgstr " 題名: " + +#: ../ebinfo/ebinfo.c:386 +#, c-format +msgid " directory: %s\n" +msgstr " ディレクトリ: %s\n" + +#. +#. * Output supported methods. +#. +#: ../ebinfo/ebinfo.c:401 +#, c-format +msgid " search methods: " +msgstr " 検索方式: " + +#: ../ebinfo/ebinfo.c:403 +msgid "word " +msgstr "前方一致 " + +#: ../ebinfo/ebinfo.c:405 +msgid "endword " +msgstr "後方一致 " + +#: ../ebinfo/ebinfo.c:407 +msgid "keyword " +msgstr "条件 " + +#: ../ebinfo/ebinfo.c:409 +msgid "cross " +msgstr "クロス " + +#: ../ebinfo/ebinfo.c:411 +msgid "multi " +msgstr "複合 " + +#: ../ebinfo/ebinfo.c:413 +msgid "menu " +msgstr "メニュー " + +#: ../ebinfo/ebinfo.c:415 +msgid "image-menu " +msgstr "画像メニュー " + +#: ../ebinfo/ebinfo.c:417 +msgid "copyright " +msgstr "著作権表示 " + +#. +#. * Output a font list. +#. +#: ../ebinfo/ebinfo.c:423 +msgid " font sizes: " +msgstr " フォントの大きさ: " + +#. +#. * Output character range of the narrow font. +#. +#: ../ebinfo/ebinfo.c:445 +msgid " narrow font characters: " +msgstr " 半角フォントの文字: " + +#. +#. * Output character range of the wide font. +#. +#: ../ebinfo/ebinfo.c:473 +#, c-format +msgid " wide font characters: " +msgstr " 全角フォントの文字: " + +#: ../ebinfo/ebinfo.c:556 +#, c-format +msgid " multi search %d:\n" +msgstr " 複合検索 %d:\n" + +#: ../ebinfo/ebinfo.c:570 +#, c-format +msgid " title: " +msgstr " 題名: " + +#: ../ebinfo/ebinfo.c:583 +#, c-format +msgid " label %d: " +msgstr " ラベル %d: " + +#: ../ebinfo/ebinfo.c:587 +msgid " candidates: " +msgstr " 候補: " + +#: ../ebinfo/ebinfo.c:589 +msgid "exist\n" +msgstr "有\n" + +#: ../ebinfo/ebinfo.c:591 +msgid "not-exist\n" +msgstr "無\n" + +#: ../ebinfo/ebinfo.c:611 +#, c-format +msgid "" +" -l --book-list output a list of books on an EBENT server\n" +msgstr " -l --book-list EBNET サーバ上の書籍リストを出力\n" + +#: ../ebinfo/ebinfo.c:612 +#, c-format +msgid " -m --multi-search also output multi-search information\n" +msgstr " -m --multi-search 複合検索の情報も出力\n" + +#: ../ebrefile/ebrefile.c:283 +#, c-format +msgid "%s: too long book directory path\n" +msgstr "%s: 書籍のディレクトリのパス名が長すぎます\n" + +#: ../ebrefile/ebrefile.c:332 ../ebzip/ebzip.c:537 +#, c-format +msgid " ouput files under DIRECTORY\n" +msgstr " ファイルを「ディレクトリ」に出力する\n" + +#: ../ebrefile/ebrefile.c:377 +#, c-format +msgid "%s: no catalog file: %s\n" +msgstr "%s: カタログファイルが見つかりません: %s\n" + +#: ../ebrefile/ebrefile.c:416 +#, c-format +msgid "%s: failed to move the file, %s: %s -> %s\n" +msgstr "%s: ファイルを移動できませんでした, %s: %s -> %s\n" + +#: ../ebrefile/ebrefile.c:486 ../ebrefile/ebrefile.c:507 +#: ../ebrefile/ebrefile.c:555 ../ebrefile/ebrefile.c:595 ../ebzip/sebxa.c:90 +#: ../ebzip/sebxa.c:232 +#, c-format +msgid "%s: failed to read the file, %s: %s\n" +msgstr "%s: ファイルを読み込めませんでした, %s: %s\n" + +#: ../ebrefile/ebrefile.c:493 ../ebrefile/ebrefile.c:541 +#: ../ebrefile/ebrefile.c:562 ../ebrefile/ebrefile.c:600 +#: ../ebrefile/ebrefile.c:616 ../ebrefile/ebrefile.c:638 ../ebzip/sebxa.c:142 +#, c-format +msgid "%s: failed to write the file, %s: %s\n" +msgstr "%s: ファイルへ書き込めませんでした, %s: %s\n" + +#: ../ebrefile/ebrefile.c:580 +#, c-format +msgid "%s: warning: no such subbook: %s\n" +msgstr "%s: 警告: そのような副本はありません: %s\n" + +#: ../ebrefile/ebrefile.c:633 ../ebzip/sebxa.c:78 ../ebzip/sebxa.c:130 +#: ../ebzip/sebxa.c:220 ../ebzip/zipfile.c:365 ../ebzip/zipfile.c:423 +#: ../ebzip/zipfile.c:497 +#, c-format +msgid "%s: failed to seek the file, %s: %s\n" +msgstr "%s: ファイルをシークできませんでした, %s: %s\n" + +#: ../ebrefile/ebrefile.c:682 ../ebzip/copyfile.c:74 ../ebzip/unzipfile.c:130 +#: ../ebzip/zipfile.c:113 +#, c-format +msgid "%s: no such file: %s\n" +msgstr "%s: そのようなファイルはありません: %s\n" + +#: ../ebrefile/ebrefile.c:723 ../ebzip/copyfile.c:191 +#, c-format +msgid "%s: failed to read from the file, %s: %s\n" +msgstr "%s: ファイルを読み込めませんでした, %s: %s\n" + +#: ../ebstopcode/ebstopcode.c:252 +#, c-format +msgid "%s: too few argument\n" +msgstr "%s: 引数が少なすぎます\n" + +#: ../ebstopcode/ebstopcode.c:341 +#, c-format +msgid "%s: invalid stop code `%s'\n" +msgstr "%s: `%s' という区切りコードの指定は不正です\n" + +#: ../ebstopcode/ebstopcode.c:376 +#, c-format +msgid "%s: invalid text length `%s'\n" +msgstr "%s: `%s' という長さの指定は不正です\n" + +#: ../ebstopcode/ebstopcode.c:433 +#, c-format +msgid "%s: invalid text position `%s'\n" +msgstr "%s: `%s' という本文の位置指定は不正です\n" + +#: ../ebstopcode/ebstopcode.c:445 +#, c-format +msgid "Usage: %s [option...] [book-directory] subbook\n" +msgstr "使用法: %s [オプション...] [書籍のディレクトリ] 副本\n" + +#: ../ebstopcode/ebstopcode.c:448 +#, c-format +msgid " -c CODE, --code CODE\n" +msgstr " -c コード, --code コード\n" + +#: ../ebstopcode/ebstopcode.c:449 +#, c-format +msgid " set stop code manually\n" +msgstr " 区切りコードを指定する\n" + +#: ../ebstopcode/ebstopcode.c:451 +#, c-format +msgid " -l LENGTH, --text-length LENGTH\n" +msgstr " -l 長さ, --text-length 長さ\n" + +#: ../ebstopcode/ebstopcode.c:452 +#, c-format +msgid " maximum length of output text\n" +msgstr " 出力する本文の最大長\n" + +#: ../ebstopcode/ebstopcode.c:453 ../ebzip/ebzip.c:532 +#, c-format +msgid " (default: %d)\n" +msgstr " (省略時: %d)\n" + +#: ../ebstopcode/ebstopcode.c:455 +#, c-format +msgid " -n --no-candidates suppress stop code candidates\n" +msgstr " -n --no-candidates 区切りコードの候補を出力しない\n" + +#: ../ebstopcode/ebstopcode.c:456 +#, c-format +msgid " -p PAGE:OFFSET, --text-position PAGE:OFFSET\n" +msgstr " -p ページ:オフセット, --text-position ページ:オフセット\n" + +#: ../ebstopcode/ebstopcode.c:457 +#, c-format +msgid " start position of text\n" +msgstr " 本文の開始位置\n" + +#: ../ebstopcode/ebstopcode.c:499 +#, c-format +msgid "%s: failed to bind the book, %s: %s\n" +msgstr "%s: 書籍は利用できません, %s: %s\n" + +#: ../ebstopcode/ebstopcode.c:518 +#, c-format +msgid "%s: failed to set the current subbook, %s\n" +msgstr "%s: 副本を選択できませんでした, %s: %s\n" + +#: ../ebstopcode/ebstopcode.c:553 +#, c-format +msgid "%s: failed to get text information, %s\n" +msgstr "%s: 本文に関する情報を取得できませんでした, %s: %s\n" + +#: ../ebstopcode/ebstopcode.c:583 +#, c-format +msgid "%s: failed to read text, %s\n" +msgstr "%s: 本文を読み込めませんでした, %s: %s\n" + +#: ../ebzip/copyfile.c:65 +#, c-format +msgid "==> copy %s <==\n" +msgstr "==> %s をコピー <==\n" + +#: ../ebzip/copyfile.c:66 ../ebzip/unzipfile.c:122 ../ebzip/zipfile.c:105 +#, c-format +msgid "output to %s\n" +msgstr "%s に出力\n" + +#: ../ebzip/copyfile.c:85 ../ebzip/unzipfile.c:141 ../ebzip/zipfile.c:124 +#, c-format +msgid "" +"the input and output files are the same, skipped.\n" +"\n" +msgstr "" +"入力と出力ファイルが同一なので、処理しません\n" +"\n" + +#: ../ebzip/copyfile.c:96 ../ebzip/copyfile.c:244 ../ebzip/sebxa.c:152 +#: ../ebzip/unzipfile.c:318 ../ebzip/zipfile.c:516 +#, c-format +msgid "completed (%llu / %llu bytes)\n" +msgstr "完了 (%llu / %llu バイト)\n" + +#: ../ebzip/copyfile.c:100 ../ebzip/copyfile.c:248 ../ebzip/sebxa.c:156 +#: ../ebzip/unzipfile.c:322 ../ebzip/zipfile.c:530 +msgid "completed (%I64u / %I64u bytes)\n" +msgstr "完了 (%I64u / %I64u バイト)\n" + +#: ../ebzip/copyfile.c:104 ../ebzip/copyfile.c:252 ../ebzip/sebxa.c:160 +#: ../ebzip/zipfile.c:544 +#, c-format +msgid "completed (%lu / %lu bytes)\n" +msgstr "完了 (%lu / %lu バイト)\n" + +#: ../ebzip/copyfile.c:120 ../ebzip/unzipfile.c:164 ../ebzip/zipfile.c:154 +msgid "" +"already exists, skip the file\n" +"\n" +msgstr "" +"このファイルはすでに存在するので、処理しません\n" +"\n" + +#: ../ebzip/copyfile.c:128 ../ebzip/unzipfile.c:171 ../ebzip/zipfile.c:161 +#, c-format +msgid "" +"\n" +"the file already exists: %s\n" +msgstr "" +"\n" +"ファイルがすでに存在します: %s\n" + +#: ../ebzip/copyfile.c:130 ../ebzip/unzipfile.c:173 ../ebzip/zipfile.c:163 +msgid "do you wish to overwrite (y or n)? " +msgstr "上書きしますか (はい:y, いいえ:n)? " + +#: ../ebzip/copyfile.c:137 ../ebzip/unzipfile.c:180 ../ebzip/zipfile.c:170 +#, c-format +msgid "%s: failed to unlink the file: %s\n" +msgstr "%s: ファイルを削除できませんでした: %s\n" + +#: ../ebzip/copyfile.c:195 ../ebzip/copyfile.c:200 ../ebzip/sebxa.c:94 +#: ../ebzip/sebxa.c:236 ../ebzip/unzipfile.c:261 ../ebzip/unzipfile.c:266 +#: ../ebzip/zipfile.c:315 ../ebzip/zipfile.c:320 +#, c-format +msgid "%s: unexpected EOF: %s\n" +msgstr "%s: 予期せぬ EOF を読み込みました: %s\n" + +#: ../ebzip/copyfile.c:220 ../ebzip/unzipfile.c:294 ../ebzip/zipfile.c:443 +#, c-format +msgid "%4.1f%% done (%llu / %llu bytes)\n" +msgstr "%4.1f%% 処理済み (%llu / %llu バイト)\n" + +#: ../ebzip/copyfile.c:225 ../ebzip/unzipfile.c:299 ../ebzip/zipfile.c:448 +msgid "%4.1f%% done (%I64u / %I64u bytes)\n" +msgstr "%4.1f%% 処理済み (%I64u / %I64u バイト)\n" + +#: ../ebzip/copyfile.c:230 ../ebzip/unzipfile.c:304 ../ebzip/zipfile.c:453 +#, c-format +msgid "%4.1f%% done (%lu / %lu bytes)\n" +msgstr "%4.1f%% 処理済み (%lu / %lu バイト)\n" + +#: ../ebzip/copyfile.c:341 ../ebzip/unzipbook.c:172 ../ebzip/unzipbook.c:290 +#: ../ebzip/unzipbook.c:302 ../ebzip/unzipbook.c:379 ../ebzip/zipbook.c:174 +#: ../ebzip/zipbook.c:296 ../ebzip/zipbook.c:308 ../ebzip/zipbook.c:387 +#, c-format +msgid "%s: failed to create a directory, %s: %s\n" +msgstr "%s: ディレクトリを作成できませんでした, %s: %s\n" + +#: ../ebzip/copyfile.c:351 +#, c-format +msgid "%s: failed to open the directory, %s: %s\n" +msgstr "%s: ディレクトリを開けませんでした, %s: %s\n" + +#: ../ebzip/ebzip.c:347 +#, c-format +msgid "%s: invalid overwrite mode: %s\n" +msgstr "%s: `%s' という上書きモードは不正です\n" + +#: ../ebzip/ebzip.c:444 +#, c-format +msgid "%s: invalid compression level `%s'\n" +msgstr "%s: `%s' は不正な圧縮レベルです\n" + +#: ../ebzip/ebzip.c:486 ../ebzip/ebzip.c:505 +#, c-format +msgid "%s: invalid content name `%s'\n" +msgstr "%s: `%s' というデータ型の名称は不正です\n" + +#: ../ebzip/ebzip.c:524 +#, c-format +msgid " -f --force-overwrite set overwrite mode to `force'\n" +msgstr " -f --force-overwrite 上書きモードを `force' にセットする\n" + +#: ../ebzip/ebzip.c:525 +#, c-format +msgid " (same as `--overwrite force')\n" +msgstr " (`--overwrite force' と等価)\n" + +#: ../ebzip/ebzip.c:527 +#, c-format +msgid " -i --information list information of compressed files\n" +msgstr " -i --information 圧縮されたファイルの情報を出力\n" + +#: ../ebzip/ebzip.c:528 +#, c-format +msgid " -k --keep don't delete original files\n" +msgstr " -k --keep 元のファイルを消去しない\n" + +#: ../ebzip/ebzip.c:529 +#, c-format +msgid " -l INTEGER --level INTEGER\n" +msgstr " -l 整数 --level 整数\n" + +#: ../ebzip/ebzip.c:530 +#, c-format +msgid " compression level; 0..%d\n" +msgstr " 圧縮レベル; 0..%d\n" + +#: ../ebzip/ebzip.c:534 +#, c-format +msgid " -n --no-overwrite set overwrite mode to `no'\n" +msgstr " -n --no-overwrite 上書きモードを `no' にセットする\n" + +#: ../ebzip/ebzip.c:535 +#, c-format +msgid " (same as `--overwrite no')\n" +msgstr " (`--overwrite no' と等価)\n" + +#: ../ebzip/ebzip.c:540 +#, c-format +msgid " -q --quiet --silence suppress all warnings\n" +msgstr " -q --quiet --silence 警告を抑制する\n" + +#: ../ebzip/ebzip.c:541 +#, c-format +msgid " -s TYPE[,TYPE] --skip-content TYPE[,TYPE...]\n" +msgstr " -s 型[,型...] --skip-content 型[,型...]\n" + +#: ../ebzip/ebzip.c:542 +#, c-format +msgid "" +" skip content; font, graphic, sound or movie\n" +msgstr "" +" 除外するデータ\n" +" 型は font, graphic, sound, movie のいずれか\n" + +#: ../ebzip/ebzip.c:543 +#, c-format +msgid " (default: none is skipped)\n" +msgstr " (省略時: 除外なし)\n" + +#: ../ebzip/ebzip.c:547 +#, c-format +msgid " -t --test only check for input files\n" +msgstr " -t --test 入力ファイルのチェックだけを行う\n" + +#: ../ebzip/ebzip.c:548 +#, c-format +msgid " -u --uncompress uncompress files\n" +msgstr " -u --uncompress ファイルを伸長\n" + +#: ../ebzip/ebzip.c:550 +#, c-format +msgid " -w MODE --overwrite MODE set overwrite mode of output files;\n" +msgstr "" +" -w モード --overwrite モード\n" +" 出力ファイルの上書きモードを指定する。\n" + +#: ../ebzip/ebzip.c:551 +#, c-format +msgid " confirm, force or no\n" +msgstr "" +" モードは confirm (確認)、force (強制実行)、\n" +" no (上書きしない) のいずれか\n" + +#: ../ebzip/ebzip.c:552 +#, c-format +msgid " (default: confirm)\n" +msgstr " (省略時: confirm)\n" + +#: ../ebzip/ebzip.c:553 +#, c-format +msgid " -z --compress compress files\n" +msgstr " -z --compress ファイルを圧縮\n" + +#: ../ebzip/ebzip.c:559 +#, c-format +msgid "" +"\n" +"Default action:\n" +msgstr "" +"\n" +"省略時の動作:\n" + +#: ../ebzip/ebzip.c:561 +#, c-format +msgid " When invoked as `ebunzip', uncompression is the default action.\n" +msgstr " `ebunzip' として起動されたときは、省略時の動作は伸長になる。\n" + +#: ../ebzip/ebzip.c:562 +#, c-format +msgid "" +" When invoked as `ebzipinfo', listing information is the default action.\n" +msgstr "" +" `ebunzipinfo' として起動されたときは、省略時の動作は情報の出力になる。\n" + +#: ../ebzip/ebzip.c:564 +#, c-format +msgid " When invoked as `ebunzip.exe', uncompression is the default action.\n" +msgstr " `ebunzip.exe' として起動されたときは、省略時の動作は伸長になる。\n" + +#: ../ebzip/ebzip.c:565 +#, c-format +msgid "" +" When invoked as `ebzipinf.exe', listing information is the default " +"action.\n" +msgstr "" +" `ebunzipinf.exe' として起動されたときは、省略時の動作は情報の出力になる。\n" + +#: ../ebzip/ebzip.c:567 +#, c-format +msgid " Otherwise, compression is the default action.\n" +msgstr " それ以外のときは、圧縮が省略時の動作になる。\n" + +#: ../ebzip/sebxa.c:60 +#, c-format +msgid "==> rewrite %s <==\n" +msgstr "==> %s を書き換え <==\n" + +#: ../ebzip/speedup.c:79 ../ebzip/unzipfile.c:190 ../ebzip/unzipfile.c:228 +#: ../ebzip/zipfile.c:180 ../ebzip/zipinfofile.c:104 +#, c-format +msgid "%s: failed to open the file: %s\n" +msgstr "%s: ファイルを開けませんでした: %s\n" + +#: ../ebzip/speedup.c:85 ../ebzip/speedup.c:90 ../ebzip/speedup.c:119 +#: ../ebzip/speedup.c:124 +#, c-format +msgid "%s: failed to read the file: %s\n" +msgstr "%s: ファイルを読み込めませんでした: %s\n" + +#: ../ebzip/unlinkfile.c:39 +#, c-format +msgid "%s: warning: memory exhausted, file %s is not to be unlinked\n" +msgstr "" + +#: ../ebzip/unlinkfile.c:56 +#, c-format +msgid "%s: warning: failed to unlink the file: %s\n" +msgstr "%s: 警告: ファイルを削除できませんでした: %s\n" + +#: ../ebzip/unzipfile.c:121 +#, c-format +msgid "==> uncompress %s <==\n" +msgstr "==> %s を伸長 <==\n" + +#: ../ebzip/unzipfile.c:152 ../ebzip/zipfile.c:135 ../ebzip/zipfile.c:142 +#: ../ebzip/zipfile.c:349 +#, c-format +msgid "%s: memory exhausted\n" +msgstr "%s: メモリを使い果たしました\n" + +#: ../ebzip/unzipfile.c:251 ../ebzip/zipfile.c:305 +#, c-format +msgid "%s: failed to seek the file: %s\n" +msgstr "%s: ファイルをシークできませんでした: %s\n" + +#: ../ebzip/unzipfile.c:257 ../ebzip/zipfile.c:311 +#, c-format +msgid "%s: failed to read from the file: %s\n" +msgstr "%s: ファイルを読み込めませんでした: %s\n" + +#: ../ebzip/unzipfile.c:326 ../ebzip/zipfile.c:553 +#, c-format +msgid "" +"%lu -> %lu bytes\n" +"\n" +msgstr "" +"%lu -> %lu バイト\n" +"\n" + +#: ../ebzip/unzipfile.c:360 +#, c-format +msgid "%s: CRC error: %s\n" +msgstr "%s: CRC エラー: %s\n" + +#: ../ebzip/zipfile.c:104 +#, c-format +msgid "==> compress %s <==\n" +msgstr "==> %s を圧縮 <==\n" + +#: ../ebzip/zipfile.c:276 ../ebzip/zipfile.c:283 ../ebzip/zipfile.c:370 +#, c-format +msgid "%s: failed to write to the file: %s\n" +msgstr "%s: ファイルに書き込めませんでした: %s\n" + +#: ../ebzip/zipfile.c:520 +#, c-format +msgid "" +"%llu -> %llu bytes (%4.1f%%)\n" +"\n" +msgstr "" +"%llu -> %llu バイト (%4.1f%%)\n" +"\n" + +#: ../ebzip/zipfile.c:525 +#, c-format +msgid "" +"%llu -> %llu bytes\n" +"\n" +msgstr "" +"%llu -> %llu バイト\n" +"\n" + +#: ../ebzip/zipfile.c:534 +msgid "" +"%I64u -> %I64u bytes (%4.1f%%)\n" +"\n" +msgstr "" +"%I64u -> %I64u バイト (%4.1f%%)\n" +"\n" + +#: ../ebzip/zipfile.c:539 +msgid "" +"%I64u -> %I64u bytes\n" +"\n" +msgstr "" +"%I64u -> %I64u バイト\n" +"\n" + +#: ../ebzip/zipfile.c:548 +#, c-format +msgid "" +"%lu -> %lu bytes (%4.1f%%)\n" +"\n" +msgstr "" +"%lu -> %lu バイト (%4.1f%%)\n" +"\n" + +#: ../ebzip/zipinfofile.c:132 +#, c-format +msgid "%llu bytes (not compressed)\n" +msgstr "%llu バイト (非圧縮)\n" + +#: ../ebzip/zipinfofile.c:135 +msgid "%I64u bytes (not compressed)\n" +msgstr "%I64u バイト (非圧縮)\n" + +#: ../ebzip/zipinfofile.c:138 +#, c-format +msgid "%lu bytes (not compressed)\n" +msgstr "%lu バイト (非圧縮)\n" + +#: ../ebzip/zipinfofile.c:143 +#, c-format +msgid "%llu -> %llu bytes " +msgstr "%llu -> %llu バイト " + +#: ../ebzip/zipinfofile.c:147 +msgid "%I64u -> %I64u bytes " +msgstr "%I64u -> %I64u バイト " + +#: ../ebzip/zipinfofile.c:151 +#, c-format +msgid "%lu -> %lu bytes " +msgstr "%lu -> %lu バイト " + +#: ../ebzip/zipinfofile.c:156 +msgid "(empty original file, " +msgstr "(もとのファイルは空, " + +#: ../ebzip/zipinfofile.c:162 +#, c-format +msgid "ebzip level %d compression)\n" +msgstr "ebzip 圧縮レベル %d)\n" + +#: ../ebzip/zipinfofile.c:164 +#, c-format +msgid "S-EBXA compression)\n" +msgstr "S-EBXA 圧縮)\n" + +#: ../ebzip/zipinfofile.c:166 +#, c-format +msgid "EPWING compression)\n" +msgstr "EPWING 圧縮)\n" diff --git a/samples/Makefile.am b/samples/Makefile.am new file mode 100644 index 0000000..6afa573 --- /dev/null +++ b/samples/Makefile.am @@ -0,0 +1,41 @@ +AUTOMAKE_OPTIONS = foreign + +LIBEB = ../eb/libeb.la + +noinst_PROGRAMS = initexit disctype subbook word text font appendix booklist + +initexit_SOURCES = initexit.c +initexit_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) +initexit_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) + +disctype_SOURCES = disctype.c +disctype_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) +disctype_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) + +subbook_SOURCES = subbook.c +subbook_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) +subbook_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) + +word_SOURCES = word.c +word_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) +word_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) + +text_SOURCES = text.c +text_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) +text_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) + +font_SOURCES = font.c +font_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) +font_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) + +appendix_SOURCES = appendix.c +appendix_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) +appendix_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) + +booklist_SOURCES = booklist.c +booklist_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) +booklist_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) + +EXTRA_DIST = README + +INCLUDES = -I$(srcdir)/.. diff --git a/samples/Makefile.in b/samples/Makefile.in new file mode 100644 index 0000000..ecfc4d5 --- /dev/null +++ b/samples/Makefile.in @@ -0,0 +1,542 @@ +# Makefile.in generated by automake 1.10.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +noinst_PROGRAMS = initexit$(EXEEXT) disctype$(EXEEXT) subbook$(EXEEXT) \ + word$(EXEEXT) text$(EXEEXT) font$(EXEEXT) appendix$(EXEEXT) \ + booklist$(EXEEXT) +subdir = samples +DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/in6addr.m4 $(top_srcdir)/m4/largefile.m4 \ + $(top_srcdir)/m4/lcmessage.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/sockaddrin6.m4 \ + $(top_srcdir)/m4/sockinttypes.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +PROGRAMS = $(noinst_PROGRAMS) +am_appendix_OBJECTS = appendix.$(OBJEXT) +appendix_OBJECTS = $(am_appendix_OBJECTS) +am__DEPENDENCIES_1 = +am_booklist_OBJECTS = booklist.$(OBJEXT) +booklist_OBJECTS = $(am_booklist_OBJECTS) +am_disctype_OBJECTS = disctype.$(OBJEXT) +disctype_OBJECTS = $(am_disctype_OBJECTS) +am_font_OBJECTS = font.$(OBJEXT) +font_OBJECTS = $(am_font_OBJECTS) +am_initexit_OBJECTS = initexit.$(OBJEXT) +initexit_OBJECTS = $(am_initexit_OBJECTS) +am_subbook_OBJECTS = subbook.$(OBJEXT) +subbook_OBJECTS = $(am_subbook_OBJECTS) +am_text_OBJECTS = text.$(OBJEXT) +text_OBJECTS = $(am_text_OBJECTS) +am_word_OBJECTS = word.$(OBJEXT) +word_OBJECTS = $(am_word_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(appendix_SOURCES) $(booklist_SOURCES) $(disctype_SOURCES) \ + $(font_SOURCES) $(initexit_SOURCES) $(subbook_SOURCES) \ + $(text_SOURCES) $(word_SOURCES) +DIST_SOURCES = $(appendix_SOURCES) $(booklist_SOURCES) \ + $(disctype_SOURCES) $(font_SOURCES) $(initexit_SOURCES) \ + $(subbook_SOURCES) $(text_SOURCES) $(word_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +EBCONF_EBINCS = @EBCONF_EBINCS@ +EBCONF_EBLIBS = @EBCONF_EBLIBS@ +EBCONF_INTLINCS = @EBCONF_INTLINCS@ +EBCONF_INTLLIBS = @EBCONF_INTLLIBS@ +EBCONF_ZLIBINCS = @EBCONF_ZLIBINCS@ +EBCONF_ZLIBLIBS = @EBCONF_ZLIBLIBS@ +EB_VERSION_MAJOR = @EB_VERSION_MAJOR@ +EB_VERSION_MINOR = @EB_VERSION_MINOR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_EBNET = @ENABLE_EBNET@ +ENABLE_NLS = @ENABLE_NLS@ +ENABLE_PTHREAD = @ENABLE_PTHREAD@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +ICONVINCS = @ICONVINCS@ +ICONVLIBS = @ICONVLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLINCS = @INTLINCS@ +INTLLIBS = @INTLLIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBEB_VERSION_INFO = @LIBEB_VERSION_INFO@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAILING_ADDRESS = @MAILING_ADDRESS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_CPPFLAGS = @PTHREAD_CPPFLAGS@ +PTHREAD_LDFLAGS = @PTHREAD_LDFLAGS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +ZLIBDEPS = @ZLIBDEPS@ +ZLIBINCS = @ZLIBINCS@ +ZLIBLIBS = @ZLIBLIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgdocdir = @pkgdocdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = foreign +LIBEB = ../eb/libeb.la +initexit_SOURCES = initexit.c +initexit_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) +initexit_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) +disctype_SOURCES = disctype.c +disctype_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) +disctype_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) +subbook_SOURCES = subbook.c +subbook_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) +subbook_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) +word_SOURCES = word.c +word_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) +word_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) +text_SOURCES = text.c +text_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) +text_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) +font_SOURCES = font.c +font_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) +font_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) +appendix_SOURCES = appendix.c +appendix_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) +appendix_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) +booklist_SOURCES = booklist.c +booklist_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) +booklist_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) +EXTRA_DIST = README +INCLUDES = -I$(srcdir)/.. +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign samples/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign samples/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +appendix$(EXEEXT): $(appendix_OBJECTS) $(appendix_DEPENDENCIES) + @rm -f appendix$(EXEEXT) + $(LINK) $(appendix_OBJECTS) $(appendix_LDADD) $(LIBS) +booklist$(EXEEXT): $(booklist_OBJECTS) $(booklist_DEPENDENCIES) + @rm -f booklist$(EXEEXT) + $(LINK) $(booklist_OBJECTS) $(booklist_LDADD) $(LIBS) +disctype$(EXEEXT): $(disctype_OBJECTS) $(disctype_DEPENDENCIES) + @rm -f disctype$(EXEEXT) + $(LINK) $(disctype_OBJECTS) $(disctype_LDADD) $(LIBS) +font$(EXEEXT): $(font_OBJECTS) $(font_DEPENDENCIES) + @rm -f font$(EXEEXT) + $(LINK) $(font_OBJECTS) $(font_LDADD) $(LIBS) +initexit$(EXEEXT): $(initexit_OBJECTS) $(initexit_DEPENDENCIES) + @rm -f initexit$(EXEEXT) + $(LINK) $(initexit_OBJECTS) $(initexit_LDADD) $(LIBS) +subbook$(EXEEXT): $(subbook_OBJECTS) $(subbook_DEPENDENCIES) + @rm -f subbook$(EXEEXT) + $(LINK) $(subbook_OBJECTS) $(subbook_LDADD) $(LIBS) +text$(EXEEXT): $(text_OBJECTS) $(text_DEPENDENCIES) + @rm -f text$(EXEEXT) + $(LINK) $(text_OBJECTS) $(text_LDADD) $(LIBS) +word$(EXEEXT): $(word_OBJECTS) $(word_DEPENDENCIES) + @rm -f word$(EXEEXT) + $(LINK) $(word_OBJECTS) $(word_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/appendix.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/booklist.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/disctype.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/font.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/initexit.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/subbook.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/text.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/word.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstPROGRAMS ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/samples/README b/samples/README new file mode 100644 index 0000000..fb969eb --- /dev/null +++ b/samples/README @@ -0,0 +1,17 @@ +$B$3$N%G%#%l%/%H%j$K$O(B EB $B%i%$%V%i%j$N%5%s%W%k%W%m%0%i%`$,4v$D$+CV$+$l$F(B +$B$$$^$9!#(B + +`configure' $B$r(B `--enable-samples' $B%*%W%7%g%sL5$7$Gl9g$O!" + * 例: + * font /cdrom 0 + * 説明: + * で指定した appendix から特定の副本を選び、そ + * の副本が定義している半角外字の代替文字列をすべて表示します。 + * + * その appendix が、半角外字の代替文字列を定義していないと、エ + * ラーになります。 + * + * には、操作対象の副本のインデックスを指定しま + * す。インデックスは、書籍の最初の副本から順に 0、1、2 ... に + * なります。 + */ +#include +#include + +#include +#include +#include + +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); +} diff --git a/samples/booklist.c b/samples/booklist.c new file mode 100644 index 0000000..a1af543 --- /dev/null +++ b/samples/booklist.c @@ -0,0 +1,111 @@ +/* -*- C -*- + * Copyright (c) 2003-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * 使用方法: + * booklist + * 例: + * booklist ebnet://localhost + * 説明: + * で指定した EBNET サーバに接続し + * て、サーバの提供する書籍、appendix の一覧を表示します。 + */ +#include +#include + +#include +#include +#include + +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); +} diff --git a/samples/disctype.c b/samples/disctype.c new file mode 100644 index 0000000..072ecf7 --- /dev/null +++ b/samples/disctype.c @@ -0,0 +1,100 @@ +/* -*- C -*- + * Copyright (c) 1999-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * 使用方法: + * disctype + * 例: + * disctype /cdrom + * 説明: + * で指定された CD-ROM 書籍の種類が、EB か EPWING か + * を調べて表示します。 + */ +#include +#include + +#include +#include + +int +main(int argc, char *argv[]) +{ + EB_Error_Code error_code; + EB_Book book; + EB_Disc_Code disc_code; + + /* コマンド行引数をチェック。*/ + if (argc != 2) { + fprintf(stderr, "Usage: %s book-path\n", argv[0]); + exit(1); + } + + /* EB ライブラリと `book' を初期化。*/ + error_code = eb_initialize_library(); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: failed to initialize EB Library, %s: %s\n", + argv[0], eb_error_message(error_code), argv[1]); + goto die; + } + 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_disc_type(&book, &disc_code); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: failed to get disc type, %s: %s\n", + argv[0], eb_error_message(error_code), argv[1]); + goto die; + } + + if (disc_code == EB_DISC_EB) { + fputs("EB\n", stdout); + } else if (disc_code == EB_DISC_EPWING) { + fputs("EPWING\n", stdout); + } else { + fputs("unknown\n", stdout); + } + + /* 書籍と EB ライブラリの利用を終了。*/ + eb_finalize_book(&book); + eb_finalize_library(); + exit(0); + + /* エラー発生で終了するときの処理。*/ + die: + eb_finalize_book(&book); + eb_finalize_library(); + exit(1); +} diff --git a/samples/font.c b/samples/font.c new file mode 100644 index 0000000..b8bd538 --- /dev/null +++ b/samples/font.c @@ -0,0 +1,160 @@ +/* -*- C -*- + * Copyright (c) 2002-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * 使用方法: + * font + * 例: + * font /cdrom 0 + * 説明: + * で指定した CD-ROM 書籍から特定の副本を選び、その + * 副本が定義している半角外字 (高さ 16 ピクセル) をすべてアスキー + * アートで表示します。 + * + * その副本が、高さ 16 ピクセルの半角外字を定義していないと、エ + * ラーになります。 + * + * には、検索対象の副本のインデックスを指定しま + * す。インデックスは、書籍の最初の副本から順に 0、1、2 ... に + * なります。 + */ +#include +#include + +#include +#include +#include + +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); +} diff --git a/samples/initexit.c b/samples/initexit.c new file mode 100644 index 0000000..f0a9190 --- /dev/null +++ b/samples/initexit.c @@ -0,0 +1,60 @@ +/* -*- C -*- + * Copyright (c) 2001-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * 使用方法: + * initexit + * 例: + * initexit + * 説明: + * EB ライブラリの初期化、後始末をしてみます。 + * プログラムの外側から見れば、これは何の意味もない動作です。 + */ +#include +#include + +#include +#include + +int +main(int argc, char *argv[]) +{ + EB_Error_Code error_code; + + /* EB ライブラリを初期化。*/ + error_code = eb_initialize_library(); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: failed to initialize EB Library, %s: %s\n", + argv[0], eb_error_message(error_code), argv[1]); + exit(1); + } + + /* EB ライブラリの利用を終了。*/ + eb_finalize_library(); + exit(0); +} diff --git a/samples/subbook.c b/samples/subbook.c new file mode 100644 index 0000000..2810544 --- /dev/null +++ b/samples/subbook.c @@ -0,0 +1,106 @@ +/* -*- C -*- + * Copyright (c) 1999-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * 使用方法: + * subbook + * 例: + * subbook /cdrom + * 説明: + * で指定され CD-ROM 書籍に含まれているすべての副本の + * 題名を表示します。 + */ +#include +#include + +#include +#include + +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; + char title[EB_MAX_TITLE_LENGTH + 1]; + int i; + + /* コマンド行引数をチェック。*/ + if (argc != 2) { + fprintf(stderr, "Usage: %s book-path\n", argv[0]); + exit(1); + } + + /* EB ライブラリと `book' を初期化。*/ + error_code = eb_initialize_library(); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: failed to initialize EB Library, %s: %s\n", + argv[0], eb_error_message(error_code), argv[1]); + goto die; + } + 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; + } + + /* 書籍に含まれている副本の題名を出力。*/ + for (i = 0; i < subbook_count; i++) { + error_code = eb_subbook_title2(&book, subbook_list[i], title); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: failed to get the title, %s\n", + argv[0], eb_error_message(error_code)); + continue; + } + printf("%d: %s\n", i, title); + } + + /* 書籍と EB ライブラリの利用を終了。*/ + eb_finalize_book(&book); + eb_finalize_library(); + exit(0); + + /* エラー発生で終了するときの処理。*/ + die: + eb_finalize_book(&book); + eb_finalize_library(); + exit(1); +} diff --git a/samples/text.c b/samples/text.c new file mode 100644 index 0000000..32b82dd --- /dev/null +++ b/samples/text.c @@ -0,0 +1,159 @@ +/* -*- C -*- + * Copyright (c) 1999-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * 使用方法: + * text + * 例: + * text /cdrom 0 10 + * 説明: + * で指定した CD-ROM 書籍から特定の副本を選び、本文 + * の先頭から 個分の単語の説明を出力します。 + * + * には、検索対象の副本のインデックスを指定しま + * す。インデックスは、書籍の最初の副本から順に 0、1、2 ... に + * なります。 + */ +#include +#include + +#include +#include +#include + +#define MAXLEN_TEXT 1023 + +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; + EB_Position text_position; + char text[MAXLEN_TEXT + 1]; + ssize_t text_length; + int text_count; + int i; + + /* コマンド行引数をチェック。*/ + if (argc != 4) { + fprintf(stderr, "Usage: %s book-path subbook-index number\n", + argv[0]); + exit(1); + } + text_count = atoi(argv[3]); + + /* 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; + } + + /* テキストの開始位置を取得。*/ + error_code = eb_text(&book, &text_position); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: failed to get text information, %s\n", + argv[0], eb_error_message(error_code)); + goto die; + } + + /* テキストをシーク。*/ + error_code = eb_seek_text(&book, &text_position); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: failed to seek text, %s\n", + argv[0], eb_error_message(error_code)); + goto die; + } + + i = 0; + while (i < text_count) { + /* テキストを取得。*/ + error_code = eb_read_text(&book, NULL, NULL, NULL, MAXLEN_TEXT, + text, &text_length); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: failed to read text, %s\n", + argv[0], eb_error_message(error_code)); + goto die; + } + fputs(text, stdout); + + if (!eb_is_text_stopped(&book)) + continue; + + fputs("\n----------------------------------------\n", stdout); + + /* 次の単語の説明へ移動。*/ + error_code = eb_forward_text(&book, NULL); + if (error_code == EB_ERR_END_OF_CONTENT) + fputs("\n[END]\n", stdout); + else if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: failed to read text, %s\n", + argv[0], eb_error_message(error_code)); + goto die; + } + i++; + } + + /* 書籍と EB ライブラリの利用を終了。*/ + eb_finalize_book(&book); + eb_finalize_library(); + exit(0); + + /* エラー発生で終了するときの処理。*/ + die: + eb_finalize_book(&book); + eb_finalize_library(); + exit(1); +} diff --git a/samples/word.c b/samples/word.c new file mode 100644 index 0000000..c20e0d4 --- /dev/null +++ b/samples/word.c @@ -0,0 +1,155 @@ +/* -*- C -*- + * Copyright (c) 1999-2006 Motoyuki Kasahara + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * 使用方法: + * word + * 例: + * word /cdrom 0 apple + * 説明: + * で指定した CD-ROM 書籍の特定の副本の中から + * という単語を完全一致検索で探し、ヒットしたすべてのエントリの + * 見出しを表示します。 + * + * には、検索対象の副本のインデックスを指定しま + * す。インデックスは、書籍の最初の副本から順に 0、1、2 ... に + * なります。 + */ +#include +#include + +#include +#include +#include + +#define MAX_HITS 50 +#define MAXLEN_HEADING 127 + +int +main(int argc, char *argv[]) +{ + EB_Error_Code error_code; + EB_Book book; + EB_Subbook_Code subbook_list[EB_MAX_SUBBOOKS]; + EB_Hit hits[MAX_HITS]; + char heading[MAXLEN_HEADING + 1]; + int subbook_count; + int subbook_index; + int hit_count; + ssize_t heading_length; + int i; + + /* コマンド行引数をチェック。*/ + if (argc != 4) { + fprintf(stderr, "Usage: %s book-path subbook-index word\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; + } + + /* 単語検索のリクエストを送出。*/ + error_code = eb_search_exactword(&book, argv[3]); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: failed to search for the word, %s: %s\n", + argv[0], eb_error_message(error_code), argv[3]); + goto die; + } + + for (;;) { + /* 残っているヒットエントリを取得。*/ + error_code = eb_hit_list(&book, MAX_HITS, hits, &hit_count); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: failed to get hit entries, %s\n", + argv[0], eb_error_message(error_code)); + goto die; + } + if (hit_count == 0) + break; + + for (i = 0; i < hit_count; i++) { + /* 見出しの位置へ移動。*/ + error_code = eb_seek_text(&book, &(hits[i].heading)); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: failed to seek the subbook, %s\n", + argv[0], eb_error_message(error_code)); + goto die; + } + + /* 見出しを取得して表示。*/ + error_code = eb_read_heading(&book, NULL, NULL, NULL, + MAXLEN_HEADING, heading, &heading_length); + if (error_code != EB_SUCCESS) { + fprintf(stderr, "%s: failed to read the subbook, %s\n", + argv[0], eb_error_message(error_code)); + goto die; + } + printf("%s\n", heading); + } + } + + /* 書籍と EB ライブラリの利用を終了。*/ + eb_finalize_book(&book); + eb_finalize_library(); + exit(0); + + /* エラー発生で終了するときの処理。*/ + die: + eb_finalize_book(&book); + eb_finalize_library(); + exit(1); +}