Initial commit

This commit is contained in:
Alex Yatskov 2016-10-28 20:02:30 -07:00
commit 5497a76516
186 changed files with 112315 additions and 0 deletions

1
AUTHORS Normal file
View File

@ -0,0 +1 @@
Motoyuki Kasahara <m-kasahr@sra.co.jp>

23
COPYING Normal file
View File

@ -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.

582
ChangeLog Normal file
View File

@ -0,0 +1,582 @@
2010-03-08 Motoyuki Kasahara <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* ebzip/zipinfofile.c (ebzip_zipinfo_file_internal): Don't close
`in_file' directly. On Windows, it raises an exception.
2008-01-28 Motoyuki Kasahara <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* Version 4.3.1.
* ltmain.sh, config.sub, config.guess: Imported from libtool-1.5.24.
2007-02-13 Motoyuki Kasahara <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* ltmain.sh, config.guess, config.sub, install-sh, m4/libtool.m4:
Import from libtool 1.5.18.
2005-04-10 Motoyuki Kasahara <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* ebzip/zipfile.c (ebzip_zip_file_internal): Output compression
result even when input is an empty file.
2004-05-08 Motoyuki Kasahara <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* 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 <m-kasahr@sra.co.jp>
* ebzip/zipinfobook.c (ebzip_zipinfo_book_epwing): Also display
movie files.
2004-01-30 Motoyuki Kasahara <m-kasahr@sra.co.jp>
* 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.

1464
ChangeLog.0 Normal file

File diff suppressed because it is too large Load Diff

2222
ChangeLog.1 Normal file

File diff suppressed because it is too large Load Diff

1409
ChangeLog.2 Normal file

File diff suppressed because it is too large Load Diff

203
INSTALL Normal file
View File

@ -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$O<!$N>l=j$+$iF~<j$9$k$3$H$,$G$-$^$9!#(B
http://www.gzip.org/zlib/
$B%7%9%F%`$K$h$C$F$O!":G=i$+$i(B zlib $B$,%$%s%9%H!<%k$5$l$F$$$k>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<!$NDL$j$G$9!#(B
1. $B%=%U%H%&%'%"$N%=!<%9%3!<%I$,CV$+$l$F$$$k%G%#%l%/%H%j$K0\F0(B (`cd')
$B$7!"(B`./configure' $B$r<B9T$7$^$9!#(B`configure' $B$N<B9T$K$O>/!9;~4V$,(B
$B$+$+$j$^$9!#(B
$B<B9T$7$F$$$k4V$O!"$I$N$h$&$J9`L\$r%A%'%C%/$7$F$$$k$N$+$r5-$7$?%a%C(B
$B%;!<%8$,=PNO$5$l$^$9!#(B
2. `make' $B$r<B9T$7$F%=%U%H%&%'%"$r%3%s%Q%$%k$7$^$9!#(B
3. $BG$0U$G!"%=%U%H%&%'%"$KIUB0$7$F$$$k%;%k%U%F%9%H$r<B9T$9$k>l9g$O!"(B
`make check' $B$r<B9T$7$^$9!#(B
4. `make install' $B$r<B9T$7$F!"%W%m%0%i%`$*$h$S%G!<%?%U%!%$%k!"%I%-%e(B
$B%a%s%H$r%$%s%9%H!<%k$7$^$9!#(B
5. `make clean' $B$r<B9T$9$k$H!"@8@.$5$l$?%W%m%0%i%`$N%P%$%J%j%U%!%$%k(B
$B$d%*%V%8%'%/%H%U%!%$%k$r!"%=!<%9%3!<%I$NCV$+$l$?%G%#%l%/%H%j$+$i(B
$B>C$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<oN`$N%3%s%T%e!<%?$G%=%U%H%&%'%"$r%3%s(B
$B%Q%$%k$G$-$^$9(B)$B!"(B `make distclean' $B$r<B9T$7$^$9!#(B
$B%3%s%Q%$%i$H%3%s%Q%$%k%*%W%7%g%s(B
================================
$B%7%9%F%`$K$h$C$F$O!"(B`configure' $B%9%/%j%W%H$,M}2r$7$F$$$J$$!"%3%s%Q%$(B
$B%k$d%j%s%/$N$?$a$NFCJL$J%*%W%7%g%s$rM?$($kI,MW$,$"$j$^$9!#%*%W%7%g%s$O(B
$B4D6-JQ?t$rDL$7$F!"(B`configure' $B$KBP$7$F=i4|CM$rM?$($k$3$H$,$G$-$^$9!#(B
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
$B%$%s%9%H!<%kL>(B
==============
$B%G%U%)%k%H$G$O!"(B`make install' $B$r<B9T$9$k$H!"%=%U%H%&%'%"Cf$N%U%!%$%k(B
$B$,(B `/usr/local/bin'$B!"(B`/usr/local/man' $B$J$I$K%$%s%9%H!<%k$5$l$^$9!#(B
`configure' $B$KBP$7$F(B `--prefix=$B%Q%9(B' $B%*%W%7%g%s$r;XDj$9$k$3$H$G!"(B
`/usr/local' $B0J30$N%$%s%9%H!<%k@h$r;XDj$9$k$H$,$G$-$^(B $B$^$9!#(B
$B%"!<%-%F%/%A%c$K0MB8$7$?%U%!%$%k$H$=$&$G$J$$%U%!%$%k$r!"$=$l$>$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<oN`(B
$B$N%U%!%$%k$N%$%s%9%H!<%k@h$@$1$rJQ$($k$3$H$,$G$-$^$9!#(B `configure
--help' $B$r<B9T$9$k$H!"$I$N$h$&$J%G%#%l%/%H%j$rJQ99$G$-$k$N$+!"$I$N$h$&(B
$B$J<oN`$N%U%!%$%k$,$I$N%G%#%l%/%H%j$K%$%s%9%H!<%k$5$l$k$N$+$,J,$+$j$^$9!#(B
$B%=%U%H%&%'%"$,%5%]!<%H$7$F$$$k$J$i$P!"(B`configure' $B$K(B `--program-prefix=
$B@\F,<-(B' $B$d(B `--program-suffix=$B@\Hx<-(B' $B$H$$$&%*%W%7%g%s$rM?$($k$3$H$G!"(B
$B%$%s%9%H!<%k;~$K%W%m%0%i%`L>$K@\F,<-$d@\Hx<-$rIU2C$9$k$3$H$,$G$-$^$9!#(B
`configure' $B$NF0:n$N@)8f(B
========================
`configure' $B$O<!$K5-$7$?%*%W%7%g%s$rG'<1$7$^$9!#(B
`--cache-file=$B%U%!%$%k(B'
$B%F%9%H$N7k2L$NFI$_9~$_$d=q$-=P$7$K;HMQ$9$k%U%!%$%k$O!"DL>o(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$d<B9T$K<:GT$9$k(B
$B$H!"%(%i!<$,Js9p$5$l$^$9!#(B
$BCm0U(B: pthread $B$X$NBP1~$O!"$^$@IT40A4$G<B83E*$J$b$N$G$9!#(B
`--with-pthread-cppflags=FLAGS'
`--with-pthread-cflags=FLAGS'
`--with-pthread-ldflags=FLAGS'
pthread $B%5%]!<%HHG$N(B EB $B%i%$%V%i%j$r:n@.$9$k:]$KIU2C$9$k(B
CPPFLAGS, CFLAGS, LDFLAGS $B$G$9!#(B
`--with-zlib-includes=DIR'
DIR $B%G%#%l%/%H%j$K%$%s%9%H!<%k$5$l$F$$$k(B zlib $B$N%X%C%@%U%!%$%k$r(B
$B;2>H$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$N<BAu$N$h(B
$B$&$K!"(BGNU gettext $B$HHs8_49$J(B gettext $B$K$OBP1~$7$F$$$^$;$s!#(B
$BL5;XDj;~$O!"(Bgettext $B$,MxMQ2DG=$G$"$l$P(B `yes' $B$K!"$=$&$G$J$1$l$P(B
`no' $B$K$J$j$^$9!#(B`yes' $B$r;XDj$7$?$K$b$+$+$o$i$:(B `configure' $B$,(B
gettext() $B4X?t$rMQ$$$?%5%s%W%k%W%m%0%i%`$N%3%s%Q%$%k$d<B9T$K<:GT(B
$B$9$k$H!"%(%i!<$,Js9p$5$l$^$9!#(B
`--with-gettext-includes=DIR'
DIR $B%G%#%l%/%H%j$K%$%s%9%H!<%k$5$l$F$$$k(B gettext $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!"$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

41
Makefile.am Normal file
View File

@ -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

761
Makefile.in Normal file
View File

@ -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:

535
NEWS Normal file
View File

@ -0,0 +1,535 @@
バージョン 4.4.3 における主な変更点:
* バージョン4.4.2で、共有ライブラリのバージョンが正しくなかったため、
本バージョンで修正した。
* 細かな不具合を修正した。
バージョン 4.4.2 における主な変更点:
* 図版メニューに関する処理で、初期化処理が一部抜けていたのを修正した。
* ebzip 伸長時に、正常終了時も終了コードが1になってしまう不具合を修正
した。
* ebzip テストモード時も、ファイルのコピーが実行されてしまう不具合を
修正した。
* ebzip のメモリ開放忘れを直した。
バージョン 4.4.1 における主な変更点:
* 画像、音声データを扱う際に、データが格納されているファイルの大きさが
2GB を正しく扱えなかったので修正した。
バージョン 4.4 における主な変更点:
* 2GB を超える大きさのファイルを扱えるようにした。ただし、システム側で
対応していることが前提条件。
* EBZIP形式の圧縮ファイルで、4294967296〜1099511627775バイト (4GB〜1TB)
のファイルの表現方法を規定した。ebzip, ebunzip はこの規定に沿って圧縮
および伸張を行なう。
* ebzip, ebunzip がディレクトリ作成に失敗したとき、何もエラーメッセージ
を出さずに終了する不具合を修正した。
バージョン 4.3.4 における主な変更点:
* 環境によっては、ebinfo の出力する副本の題名が文字化けするのを修正した。
* 注: ライブラリ本体には変更がないので、共有ライブラリのバージョンは更新
してしない。
バージョン 4.3.3 における主な変更点:
* Cygwin, MinGW で DLL を作成できるようにした。
* Windows で ebzipinfo が異常終了する不具合を修正した。
バージョン 4.3.2 における主な変更点:
* バージョン 4.3.1 で、共有ライブラリの番号付けが間違っていたので修正した。
* ebinfo の日本語メッセージに、空白文字が抜けているものがあったので修正した。
バージョン 4.3.1 における主な変更点:
* 動画ファイル名に英大文字が使われると、動画データを読み込めない不具合
を修正した。
* 電子ブックリーダー Panasonic KX-EBP2 付属品に対応した。
* ebnet でバッファオーバーランが起きる不具合を修正した。
バージョン 4.3 における主な変更点:
* EPWING で複数の副本がディレクトリを共有している場合、正しくアクセス
できない不具合を修正した。
* `ebunzip --test' が、電子ブックの本文ファイルを上書きしてしまう不具合
を修正した。
* ebappendix が、`catalogs.app' を読み込んでも電子ブック形式の appendix
を生成してしまう不具合を修正した。
* 参照先付きカラー図版に対応した。
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 が正しく扱えない不具合を修正した。
* eb.conf の EBCONF_ENABLE_NLS の値が正しくセットされない不具合を修正
した。
* 音声ファイルの取り出しがうまくいかない不具合を終始した。
* 一部の Linux 環境で configure 時に NLS (Native/National Language
Support) が有効にならない不具合を修正した。
* 細かな不具合をいくつか修正した。
バージョン 4.2.1 における主な変更点:
* 不具合をいくつか修正した。
バージョン 4.2 における主な変更点:
* クロス検索に対応した。
関数 eb_have_cross_search(), eb_search_cross() をライブラリに追加した。
また、ebinfo は、クロス検索の情報を出力するようになった。
* 動画ファイル名の絶対パス名を返す関数 eb_compose_movie_path_name() を
ライブラリに追加した。
* ebrefile は、カタログファイルを上書きするようにした。
上書き前のカタログファイルは、".old" という接尾子の付いたファイル名で
保存される。
* zlib を添付しないようにした。
configure から --with-included-zlib オプションを削除した。
* 不具合をいくつか修正した。
バージョン 4.1.3 における主な変更点:
* バージョン 4.1.2 で、共有ライブラリの番号付けが間違っていたので修正した。
* `make install' が失敗する不具合を修正した。
バージョン 4.1.2 における主な変更点:
* 特定の書籍で、EB ライブラリが書籍に載っている単語を検索できない
不具合を修正した。
* FreeBSD-5.3-RELEASE で make が失敗する不具合を修正した。
* Windows 環境において、ebzip コマンドの起動時のコマンド名 (ebunzip.exe,
ebzipinfo.exe など) をもとに、正しく動作を決定できない不具合を修正
した。
バージョン 4.1.1 における主な変更点:
* ユーティリティコマンドで、引数を取る長いオプション (例: ebzip の
--level) に対して引数を渡さないと、コマンドが異常終了する不具合を
修正した。
* eb_write_text_byte2() がおかしなデータを書き込む不具合を修正した。
* ドキュメントの 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 を返すようにた。
* ライブラリが、非圧縮ブロックデータのキャッシュをより効率的に行う
ようにした。
* `ebzip' が START/HONMON ファイルの部分圧縮に対応した。
これにより、前方一致検索が速くなった。
* 日本語ドキュメントを HTML 形式で配布するようにした。
* 英語のドキュメントを削除した。
バージョン 4.0.1 における主な変更点:
* ヘッダファイル内の EB_P, ZIO_P マクロの定義を修正した。
* `ebzipinfo' は `--skip-content movie' オプションを指定しない限り、
動画ファイルの情報も表示するようにした。
* `ebzip', `ebunzip' の進行状況メッセージは、標準出力ではなく標準エラー
出力に表示するようにした。
バージョン 4.0 における主な変更点:
* EB_BookList 関連の 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 される。
* 重大および軽度の不具合をいくつか修正した。
バージョン 4.0beta3 における主な変更点:
* EUC-JP 以外の日本語のエンコーディングに対応した。
* Windows 対応のためのコードをいくつか付加した。
Windows 上で EB ライブラリのビルドを行うには、`eb-win32' パッケージ
を使用して下さい。
* `ebstopcode' に `--text-position' (`-p') オプションを追加した。
バージョン 4.0beta2 における主な変更点:
* 検索メソッドの重大な不具合を修正した。
バージョン 4.0beta1 における主な変更点:
* `ebstopchk' を `ebstopcode' に改名した。
コマンドの `--stop-code' オプションも `--code' に改名した。
* `ebappendix' の `--case', `--suffix' オプションを削除した。
* `ebappendix' の日本語版ドキュメントを用意した。
* `ebinfo' に `--book-list' オプションを追加した。
* `ebdump', `ebfixlog' を `misc' サブディレクトリに入れた。
* 不具合をいくつか修正した。
バージョン 4.0beta0 における主な変更点:
* 遠隔アクセスに対応した。
* `ebstopchk' コマンドを追加した。
バージョン 3.3.2 における主な変更点:
* 共有ライブラリのバージョン番号を修正した。
* 「日英仏辞典」(YRRS-059) に対応した。
バージョン 3.3.1 における主な変更点:
* EPWING 版「ジーニアス英和大辞典」に対応した。
* 複合検索の処理の不具合を修正した。
* デバッグモードの不具合を修正した。
バージョン 3.3 における主な変更点:
* eb_read_binary_mpeg() の不具合を修正した。
バージョン 3.3beta3 における主な変更点:
* 複合検索を修正した。
* 軽度の不具合をいくつか修正した。
バージョン 3.3beta2 における主な変更点:
* 重大および軽度の不具合をいくつか修正した。
* `eb3.m4' は `$(datadir)/aclocal' にインストールするようにした。
バージョン 3.3beta1 における主な変更点:
* 不具合をいくつか修正した。
バージョン 3.3beta0 における主な変更点:
* EPWING のファイル名や圧縮タイプを見分けるコードを大幅に書き改めた。
* 関数 eb_multi_title() を追加した。
この関数は、特定の複合検索の題名を取得する。この関数の使用によって、
`ebinfo' コマンドで `--multi-search' (`-m') を指定した際に、複合検索
の題名を表示するようになった。
* `ebrefile' の不具合を修正した。
* インライン画像に対応するため、テキストデータへのフックを 2 種類追加
した。
バージョン 3.2.3 における主な変更点:
* PCM 音声データの処理における不具合を修正した。
* テキストのフックを 2 種類追加した。
バージョン 3.2.2 における主な変更点:
* appendix の処理における不具合を修正した。
* gettext のメッセージカタログを修正した。
バージョン 3.2.1 における主な変更点:
* テキストの読み込みルーチンを修正した。
* zlib-1.1.4 を取り込んだ。
バージョン 3.2 における主な変更点:
* 特になし。
バージョン 3.2beta3 における主な変更点:
* インストールの際に起こる不具合をいくつか修正した。
バージョン 3.2beta2 における主な変更点:
* 環境変数 EB_DEBUG が定義されていると、EB ライブラリがデバッグ
メッセージを出力するようにした。
`configure' の `--enable-debug' オプションを削除した。
* EBZIP 圧縮形式データの伸長における致命的な不具合を修正した。
バージョン 3.2beta1 における主な変更点:
* `ebzip' の最高圧縮レベルを 3 から 5 に変更した。
* 不具合をいくつか修正した。
バージョン 3.2beta0 における主な変更点:
* eb_backward_text() を実装し、eb_forward_text() を改良した。
* EB ライブラリのプログラミングドキュメント (日本語版) を復活させた。
* サンプルプログラムを復活させた。
バージョン 3.1 における主な変更点:
* 圧縮された S-EBXA へのサポートにおける不具合を修正した。
バージョン 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) への対応が復活した。
* ルートディレクトリにマウントされた CD-ROM の処理における不具合を
修正した。
* EB ライブラリ内の初期化および後始末ルーチンのオーバーホールを
行った。
* 軽度の不具合をいくつか修正した。
バージョン 3.1beta0 における主な変更点:
* 圧縮された S-EBXA に対応した。
* ソニーデータディスクマン DP-S1000 付属の「日本大百科全書」に対応した。
バージョン 3.0.1 における主な変更点:
* 不具合をいくつか修正した。
バージョン 3.0 における主な変更点:
* EB の LANGUAGE データへの対応をやめた。
バージョン 3.0beta1 における主な変更点:
* `ebrefile' を C で書き直した。
日本語のメッセージカタログも用意した。
* 不具合をいくつか修正した。
バージョン 3.0beta0 における主な変更点:
* GNU gettext 0.10.36 の libintl に対応した。
本パッケージのユーティリティツール群は、libiconv が利用可能なら
リンクするようになった。
`configure' に `--with-iconv-includes', `--with-iconv-libraries'
オプションを追加した。
* libintl のソースコードを削除した。
`configure' の `--with-included-gettext' オプションも削除した。
libintl がシステムになければ、NLS (Native/National Language Support)
は無効になる。
* EPWING および EB のモノクロ画像データに対応した。
* `ebzip' は動画、画像、音声の各データファイルに対応するようになった。
`ebzip' に `--skip-content' (`-s') オプションを追加した。
* 軽度の不具合をたくさん修正した。
バージョン 3.0alpha4 における主な変更点:
* EPWING の動画データ、カラー画像データに対応した。
* EB ライブラリを利用したアプリケーション向けに、M4 マクロファイル
`eb3.m4' を用意した。(Autoconf 2.49 が必要。)
バージョン 3.0alpha3 における主な変更点:
* テキストのフック関連の API を改めた。
バージョン 3.0alpha2 における主な変更点:
* たくさんの不具合を修正した。
バージョン 3.0alpha1 における主な変更点:
* EPWING V6 の圧縮形式に対応したい。
* ファイル名やディレクトリ名における、大文字/小文字や接尾子の一貫性
の欠如を無視するようにした。
* `ebzip' の `--suffix', `--case' オプションを削除した。
* フォント関連の API を若干ながら変更した。
* 軽度の不具合を、かなり色々と修正した。
バージョン 3.0alpha0 における主な変更点:
* 複合検索に対応した。
* 条件検索に対応した。
* GNU gettext を用いた NLS (Native/National Language Support)。
日本語のメッセージカタログを用意した。
* 実験的ながら Pthread に対応した。
`configure' に `--enable-pthreads' オプションを追加した。
* `configure' が、自動的に zlib を見つけ出すようにした。
* API を変更した。
バージョン 2.x の API とは、非互換な点がいくつかある。
* 軽度の不具合をたくさん修正した。
バージョン 2.3.7 における主な変更点:
* "DUDEN Die sinn-und sachverwandten Worter" (EBG) と "DUDEN Das
Fremdworterbuch" に対応した。
バージョン 2.3.6 における主な変更点:
* 「日本語語彙大系」 (EPWING, 岩波書店) で顕在化する不具合を修正した。
* "EDICT" (JIS X 4081, フリーの辞書) で顕在化する不具合を修正した。
バージョン 2.3.5 における主な変更点:
* 特になし。
バージョン 2.3.4 における主な変更点:
* EPWING の伸長ルーチンの不具合を修正した。
* 軽度の不具合をいくつか修正した。
バージョン 2.3.3 における主な変更点:
* 共有ライブラリのバージョン番号を修正した。
バージョン 2.3.2 における主な変更点:
* 軽度な不具合を修正した。
(バージョン 2.3.1 はリリースしていない。)
バージョン 2.3 における主な変更点:
* 特になし。
バージョン 2.3beta3 における主な変更点:
* 特になし。
バージョン 2.3beta2 における主な変更点:
* 特になし。
バージョン 2.3beta1 における主な変更点:
* 実験的ながら EBXA-C に対応した。
* 実験的ながら、区切り文字 (stop-code) の自動検出に対応した。
バージョン 2.3beta0 における主な変更点:
* EPWING 圧縮形式で圧縮された CD-ROM 書籍に対応した。
* `ebzip' の情報通知メッセージを変更した。
* `ebrefile' の不具合を修正した。
`ebrefile' は `ebzip' と同じ順序でカタログファイルを探しに行って
いなかった。
バージョン 2.2.1 における主な変更点:
* samples と samples-ja を統合した。
* `configure' に `--enable-samples' オプションを追加した。
* DOS, Windows, OS/2 への対応を改善した。
バージョン 2.2 における主な変更点:
* EB ライブラリのドキュメントを追加した。
バージョン 2.1.2 における主な変更点:
* 共有ライブラリのバージョン番号を修正した。
* FreeBSD-ELF に対応した libtool を使うようにした。
バージョン 2.1.1 における主な変更点:
* Windows VC++ 向けのコードをいくつか追加した。
* 不具合を修正した。
バージョン 2.1 における主な変更点:
* 不具合を修正した。
バージョン 2.1beta2 における主な変更点:
* `ebzip' に圧縮レベル 3 を新設した。
* 新たに `ebrefile' コマンドを追加した。
バージョン 2.1beta1 における主な変更点:
* 不具合を修正した。
バージョン 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' が生成するディレクトリの構造を変更した。
* zlib ソースコードを取り込むようにした。
* 不具合を修正した。
バージョン 2.0.3 における主な変更点:
* 不具合を修正した。
バージョン 2.0.2 における主な変更点:
* 不具合を修正した。
バージョン 2.0.1 における主な変更点:
* 特になし。
バージョン 2.0 における主な変更点:
* 不具合を修正した。
バージョン 2.0beta1 における主な変更点:
* `ebappendix' のオプション `--filename-cases' を `--filename-case' に
改名した。
* 不具合を修正した。
バージョン 2.0beta0 における主な変更点:
* GNU libtool の利用により、EB ライブラリの共有ライブラリ版をコンパイ
ルできるようにした。
* 関数のインターフェースを変更した。
EB ライブラリ 1.0.x と 2.0 で、いくつか非互換な箇所が生じた。
* `ebinfo' の Texinfo ドキュメントを追加した。
* JIS X 4081-1996 のほとんどの記述に対応した。
* ソースコード配布パッケージのディレクトリ構成を変更した。
* `ebappendix' の `--no-catalogs' オプションを削除した。
* 不具合を修正した。
バージョン 1.0.6 における主な変更点:
* 不具合を修正した。
バージョン 1.0.5 における主な変更点:
* 不具合を修正した。
バージョン 1.0.4 における主な変更点:
* 特になし。
バージョン 1.0.3 における主な変更点:
* "Concise Oxford dicitionary" に対応した。
* 複数のアーキテクチャ上でのコンパイルに関する Makefile.am の不具合
を修正した。
複数の種類のコンピュータ上で、同時に本パッケージをコンパイルできる
ようになった。
* ビットマップの変換関数のインターフェースを変更した。
* 不具合を修正した。
バージョン 1.0.2 における主な変更点:
* EB ライブラリに関数をいくつか追加した。
これらの関数は、CD-ROM 書籍が定義している外字の画像ファイルを生成
する。対応している画像形式は、XBM, XPM と GIF。
* 不具合を修正した。
バージョン 1.0.1 における主な変更点:
* JIS X 4081-1996 に記されている表示制御記述子を認識するようにした。
* いくつかの EPWING 書籍で、漢字による前方一致検索ができるようにした。
* EPWING 版リーダーズ英和辞典に対応した。
* 不具合を修正した。
バージョン 1.0 における主な変更点:
* 不具合を修正した。
バージョン 1.0beta2 における主な変更点:
* 不具合を修正した。
バージョン 1.0beta1 における主な変更点:
* appendix データファイルの形式を変更した。
* 不具合を修正した。

71
README Normal file
View File

@ -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!"<g$KF|K\$GHNGd$5$l$F$$$k<-=q$K(B
$B;H$o$l$F$$$^$9!#(BCD-ROM $B=q@R<+BN$O(B ISO 9660 $B7A<0$K$J$C$F$$$^$9$N$G!"B>(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!<%?$r<h$j=P$9(B
ebinfo CD-ROM $B=q@R$K4X$9$k>pJs$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!"<!$N$h$&$J7A<0$r$H(B
$B$j$^$9!#(B
ebnet://<$B%[%9%H(B>:<$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<u$1$F$$$k%]!<%H$NHV9f$G$9!#%[%9%H$,BT$A(B
$B<u$1$F$$$k%]!<%H$,I8=`$N(B 22010 $BHV$G$"$l$P!"(B`:<$B%]!<%H(B>' $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$O<!$N$H$3$m$+$iF~<j$G$-$^$9!#(B
ftp://ftp.sra.co.jp/pub/misc/eb/
EB $B%i%$%V%i%j$K4X$9$k>pJs$O<!$N$H$3$m$+$iF@$k$3$H$,$G$-$^$9!#(B
http://www.sra.co.jp/people/m-kasahr/eb/
$B%3%a%s%H$d%P%0$NJs9p$O(B
m-kasahr@sra.co.jp
$B08$K!"F|K\8l$+1Q8l$G$*Aw$j2<$5$$!#(B

888
aclocal.m4 vendored Normal file
View File

@ -0,0 +1,888 @@
# generated automatically by aclocal 1.10.2 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2007, 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.
# 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.
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.63],,
[m4_warning([this file was generated for autoconf 2.63.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically `autoreconf'.])])
# Copyright (C) 2002, 2003, 2005, 2006, 2007, 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.
# AM_AUTOMAKE_VERSION(VERSION)
# ----------------------------
# Automake X.Y traces this macro to ensure aclocal.m4 has been
# generated from the m4 files accompanying Automake X.Y.
# (This private macro should not be called outside this file.)
AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.10'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.10.2], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
# _AM_AUTOCONF_VERSION(VERSION)
# -----------------------------
# aclocal traces this macro to find the Autoconf version.
# This is a private macro too. Using m4_define simplifies
# the logic in aclocal, which can simply ignore this definition.
m4_define([_AM_AUTOCONF_VERSION], [])
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.10.2])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
# 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.
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
#
# Of course, Automake must honor this variable whenever it calls a
# tool from the auxiliary directory. The problem is that $srcdir (and
# therefore $ac_aux_dir as well) can be either absolute or relative,
# depending on how configure is run. This is pretty annoying, since
# it makes $ac_aux_dir quite unusable in subdirectories: in the top
# source directory, any form will work fine, but in subdirectories a
# relative path needs to be adjusted first.
#
# $ac_aux_dir/missing
# fails when called from a subdirectory if $ac_aux_dir is relative
# $top_srcdir/$ac_aux_dir/missing
# fails if $ac_aux_dir is absolute,
# fails when called from a subdirectory in a VPATH build with
# a relative $ac_aux_dir
#
# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
# are both prefixed by $srcdir. In an in-source build this is usually
# harmless because $srcdir is `.', but things will broke when you
# start a VPATH build or use an absolute $srcdir.
#
# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
# and then we would define $MISSING as
# MISSING="\${SHELL} $am_aux_dir/missing"
# This will work as long as MISSING is not called from configure, because
# unfortunately $(top_srcdir) has no meaning in configure.
# However there are other variables, like CC, which are often used in
# configure, and could therefore not use this "fixed" $ac_aux_dir.
#
# Another solution, used here, is to always expand $ac_aux_dir to an
# absolute PATH. The drawback is that using absolute paths prevent a
# configured tree to be moved without reconfiguration.
AC_DEFUN([AM_AUX_DIR_EXPAND],
[dnl Rely on autoconf to set up CDPATH properly.
AC_PREREQ([2.50])dnl
# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`
])
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997, 2000, 2001, 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.
# serial 8
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
# Define a conditional.
AC_DEFUN([AM_CONDITIONAL],
[AC_PREREQ(2.52)dnl
ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
AC_SUBST([$1_TRUE])dnl
AC_SUBST([$1_FALSE])dnl
_AM_SUBST_NOTMAKE([$1_TRUE])dnl
_AM_SUBST_NOTMAKE([$1_FALSE])dnl
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi
AC_CONFIG_COMMANDS_PRE(
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
AC_MSG_ERROR([[conditional "$1" was never defined.
Usually this means the macro was only invoked conditionally.]])
fi])])
# Copyright (C) 1999, 2000, 2001, 2002, 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.
# serial 9
# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
# written in clear, in which case automake, when reading aclocal.m4,
# will think it sees a *use*, and therefore will trigger all it's
# C support machinery. Also note that it means that autoscan, seeing
# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
# _AM_DEPENDENCIES(NAME)
# ----------------------
# See how the compiler implements dependency checking.
# NAME is "CC", "CXX", "GCJ", or "OBJC".
# We try a few techniques and use that to set a single cache variable.
#
# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
# dependency, and given that the user is not expected to run this macro,
# just rely on AC_PROG_CC.
AC_DEFUN([_AM_DEPENDENCIES],
[AC_REQUIRE([AM_SET_DEPDIR])dnl
AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
AC_REQUIRE([AM_MAKE_INCLUDE])dnl
AC_REQUIRE([AM_DEP_TRACK])dnl
ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
[$1], CXX, [depcc="$CXX" am_compiler_list=],
[$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
[$1], UPC, [depcc="$UPC" am_compiler_list=],
[$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
[depcc="$$1" am_compiler_list=])
AC_CACHE_CHECK([dependency style of $depcc],
[am_cv_$1_dependencies_compiler_type],
[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_$1_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_$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 <conftest.tar])
grep GrepMe conftest.dir/file >/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])

142
compile Executable file
View File

@ -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 <tromey@cygnus.com>.
#
# 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 <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
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 <bug-automake@gnu.org>.
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:

1526
config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

196
config.h.in Normal file
View File

@ -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 <direct.h> header file. */
#undef HAVE_DIRECT_H
/* Define to 1 if you have the <dlfcn.h> 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 <iconv.h> 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 <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <langinfo.h> 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 <libcharset.h> 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 <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define to 1 if you have the <mbstring.h> header file. */
#undef HAVE_MBSTRING_H
/* Define to 1 if you have the <memory.h> 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 <nl_types.h> header file. */
#undef HAVE_NL_TYPES_H
/* Define to 1 if you have the <pthread.h> 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 <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> 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 <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if <netinet/in.h> defines `struct in6_addr' */
#undef HAVE_STRUCT_IN6_ADDR
/* Define to 1 if <netinet/in.h> defines `struct sockaddr_in6' */
#undef HAVE_STRUCT_SOCKADDR_IN6
/* Define to 1 if <netinet/in.h> defines `struct sockaddr_storage' */
#undef HAVE_STRUCT_SOCKADDR_STORAGE
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> 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 <netinet/in.h> */
#undef IN6ADDR_ANY_DECLARED
/* Define to 1 if `in6addr_loopback' is declared by <netinet/in.h> */
#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
<sys/types.h>, <sys/socket.h> or <netinet/in.h> does not define
`in_port_t'. */
#undef in_port_t
/* Define to `int' if <sys/types.h> 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
<sys/types.h> or <sys/socket.h> does not define `sa_family_t'. */
#undef sa_family_t
/* Define to `int' if <sys/types.h> or <sys/socket.h> does not define. */
#undef socklen_t
/* Define to `int' if <sys/types.h> does not define. */
#undef ssize_t

1658
config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

17418
configure vendored Executable file

File diff suppressed because it is too large Load Diff

338
configure.ac Normal file
View File

@ -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 <pthread.h>
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 <zlib.h>
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

589
depcomp Executable file
View File

@ -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 <oliva@dcc.unicamp.br>.
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 <bug-automake@gnu.org>.
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:

160
doc/Makefile.am Normal file
View File

@ -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

552
doc/Makefile.in Normal file
View File

@ -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:

51
doc/c2html Executable file
View File

@ -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 "<blockquote>\n";
print "<pre>\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|&|&amp;|g;
s|<|&lt;|g;
s|>|&gt;|g;
print;
}
print "</pre>\n";
print "</blockquote>\n";

51
doc/eb.css Normal file
View File

@ -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;
}

9431
doc/eb.html.in Normal file

File diff suppressed because it is too large Load Diff

729
doc/ebappendix.html.in Normal file
View File

@ -0,0 +1,729 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-jp">
<link rel="stylesheet" type="text/css" href="ebutils.css">
<link rev="made" href="mailto:m-kasahr@sra.co.jp">
<title>ebappendix コマンド</title>
</head>
<body>
<h1><a name="toc">ebappendix コマンド</a></h1>
<p>
この文書は EB ライブラリバージョン
<!-- #include "version.html" -->
に対応しています。
</p>
<p>
目次:
</p>
<!-- #include "ebappendix-toc.html" -->
<p>
Copyright (c) 2003-2006 Motoyuki Kasahara
</p>
<!-- ================================================================ -->
<h2><a name="what-is-appendix">appendix (付録) とは</a></h2>
<p>
<dfn>appendix</dfn> (<dfn>付録</dfn>) とは CD-ROM 書籍の補助データのことです。
appendix は CD-ROM 書籍の出版社から提供されているものではなく、
EB ライブラリに固有のものです。
</p>
<p>
appendix は以下のデータを CD-ROM 書籍に対して提供します。
</p>
<dl>
<dt>本文の区切りコード</dt>
<dd>
あなたが EB ライブラリを使って CD-ROM 辞書の中のある単語を引く際、その
単語の説明が終了する箇所で、EB ライブラリが本文の出力を止めることを
あなたは期待するのではないでしょうか。
しかし、EB ライブラリはそのような動作を保証することができません。
なぜなら、CD-ROM 書籍の本文には、項目の終わりを示す印が存在しないから
です。
幸いにも、多くの CD-ROM 書籍には、項目の終わりを示す印の代替として
使える、<dfn>区切りコード</dfn> (<dfn>stop code</dfn>) というものを持って
います。
通常、EB ライブラリはこの区切りコードを自動的に推測するようになって
いるのですが、時々誤った区切りコードを導き出すことがあります。
appendix の区切りコードは、その書籍の正しい区切りコードを EB ライブラリ
に教えてやるために用います。
<dt>外字の代替文字列</dt>
<dd>
多くの CD-ROM 書籍は、外字 (独自に定義した文字) を持っており、本文中で
その外字を使っています。
CD-ROM 書籍では外字のビットマップフォントを用意しており、
クライアントアプリケーションが外字を出力するには、そのフォントを描画
しなくてはなりません。
appendix では、外字の <dfn>代替文字列</dfn> (<dfn>alternation text</dfn>)
を定義することができます。
アプリケーションは、ビットマップフォントを描画する代わりに、その
代替文字列を出力することにしても良いでしょう。
</dl>
<p>
appendix のレイアウトは CD-ROM 書籍のものとよく似ています。
トップディレクトリには <code>catalog</code> もしくは <code>catalogs</code>
ファイルが存在し、各副本のデータは対応するサブディレクトリに配置されて
います。
</p>
<!-- ================================================================ -->
<h2><a name="what-is-ebappendix"><code>ebappendix</code> コマンドとは</a></h2>
<p>
appendix はバイナリ形式のデータファイルで構成されますので、手で直接
編集するのは容易ではありません。
そこで、EB ライブラリでは <code>ebappendix</code> コマンドを用意しています。
<code>ebappendix</code> コマンドは、テキスト形式で書かれたデータを読み込み、
バイナリ形式の appendix を生成します。
</p>
<p>
EB ライブラリの公式な FTP サイト
<a href="ftp://ftp.sra.co.jp/pub/misc/eb/appendix/">ftp://ftp.sra.co.jp/pub/misc/eb/appendix/</a>
には、既にいくつかの書籍用の appendix が置いてあります。
ここに載っていない CD-ROM 書籍用の appendix を用意したい場合は、
<code>ebappendix</code> コマンドを使いましょう。
</p>
<!-- ================================================================ -->
<h2><a name="write-appendix-source">appendix のソースデータの書き方</a></h2>
<p>
この章では、appendix のソースデータの書き方を説明します。
ここで、「ソースデータ」と言っているのは、<code>ebappendix</code> が読み込む
テキスト形式で書かれたデータのことです。
</p>
<p>
appendix を生成するためには、次に挙げるソースデータファイルが必要です。
これらのファイルをすべて、同じディレクトリ上に用意するようにします。
</p>
<dl>
<dt><code>catalog.app</code> または <code>catalogs.app</code></dt>
<dd>
appendix には必ず、<code>catalog</code> または <code>catalogs</code> という
名前のファイルが必要です。
<code>catalog.app</code>, <code>catalogs.app</code> はその生成元となる
ファイルです。
appendix に収録されている <dfn>副本 (subbook)</dfn>
(詳しくは
<a href="#write-catalog.app"><code>catalog(s).app</code> の書き方」</a>
を参照) の一覧を記します。
<dt><var>副本</var><code>.app</code></dt>
<dd>
appendix が収録している副本それぞれに対して、一つずつ用意する必要が
あります (<var>副本</var> の部分は、実際は個々の副本の名前になります)。
appendix のメインデータである、本文の区切りコードや外字の代替文字列は、
このファイルに記します。
</dl>
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
<h3><a name="what-is-catalog.app"><code>catalog(s).app</code> とは</a></h3>
<p>
CD-ROM 書籍と同様に、appendix パッケージにも必ず <code>catalog</code>
もしくは <code>catalogs</code> という名前のファイルのどちらか一方が
必要です。
<code>catalog.app</code>, <code>catalogs.app</code> ファイルは、その
生成元となります。
</p>
<p>
<code>ebappendix</code> コマンドに appendix を生成させる際には、
<code>catalog.app</code><code>catalogs.app</code> のどちらかを必ず
用意しておく必要があります。
</p>
<p>
<code>ebappendix</code> の標準の動作では、<code>catalog.app</code> という
ファイル名にしておくと、生成するファイル名も <code>catalog</code>
なります。
また、appendix 全体のディレクトリ構造が、電子ブックに似た形式になります。
</p>
<p>
反対に、<code>catalogs.app</code> というファイル名にしておくと、生成する
ファイル名も <code>catalogs</code> になります。
また、appendix 全体のディレクトリ構造が、EPWING に似た形式になります。
</p>
<p>
ただし、EPWING の書籍に対して電子ブック形式の appendix を使用しても、
動作そのものには支障がありません。
逆も同様です。
</p>
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
<h3><a name="write-catalog.app"><code>catalog(s).app</code> の書き方</a></h3>
<p>
<code>catalog(s).app</code> には、書籍に収録されている副本のディレクトリ名を
1 行に 1 つずつ書き並べます。
副本のディレクトリ名は、<code>ebinfo</code> コマンドを使うと容易に分かります。
</p>
<p>
以下は、<code>ebinfo</code> の実行例です。
</p>
<blockquote>
<pre>
% 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
</pre>
</blockquote>
<p>
この辞書用の appendix を作成する場合、<code>catalog(s).app</code> には次の
ように記します。
</p>
<blockquote>
<pre>
ejdict
howto
</pre>
</blockquote>
<p>
(<code>ebinfo</code> コマンドに関しての詳細は、
<a href="ebinfo.html">ebinfo コマンドのマニュアル</a> を参照のこと。)
</p>
<p>
ディレクトリ名の大文字、小文字は、同じものとして扱われます。
また、空行およびおよび空白以外の最初の文字がハッシュ記号 (<samp>#</samp>)
である行は無視されます。
</p>
<p>
必ずもとの書籍の副本すべてを、同じ順序で <code>catalog(s).app</code>
記すようにして下さい。
</p>
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
<h3><a name="what-is-subbook.app"><var>副本</var><code>.app</code> とは</a></h3>
<p>
appendix が収録している副本それぞれに対して、ソースデータファイル
<var>副本</var><code>.app</code> を用意する必要があります。
<var>副本</var> の部分は、実際には個々の副本の使用する
ディレクトリ名になります。
</p>
<p>
たとえば、前節の例では、書籍が <code>ejdict</code><code>howto</code>
というディレクトリ名を持った副本を持っていました。
この場合、用意するファイルは <code>ejdict.app</code><code>howto.app</code>
になります。
</p>
<p>
<var>副本</var><code>.app</code> ファイルは appendix のメインデータである、
本文の区切りコードや外字の代替文字列を収録した <code>appendix</code>
<code>furoku</code> といったファイルの生成元になります。
(appendix を電子ブック形式で生成すると <code>appendix</code>、EPWING 形式
で生成すると <code>furoku</code> というファイル名になります。)
</p>
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
<h3><a name="subbook.app-syntax"><var>副本</var><code>.app</code> の文法</a></h3>
<p>
各副本のソースデータを記したファイル「<var>副本</var><code>.app</code>
の中では、空行、および空白以外の最初の文字がハッシュ記号 (<samp>#</samp>)
である行は無視されます。
</p>
<p>
他の行はすべて、<dfn>単独指示子 (single directive)</dfn>
<dfn>複合指示子 (group directive)</dfn> のいずれかでなくてはなりません。
単独指示子と複合指示子は、どのような順序で定義しても差し支えありません。
</p>
<p>
単独指示子とは、1 行で完結する指示子です。
単独指示子の一般形は次の通りです。
</p>
<blockquote>
<pre>
<var>指示子の名前</var> <var>指示子の値</var>
</pre>
</blockquote>
<p>
以下の例では、<code>stop-code</code> が指示子の名前、
<samp>0x1f09 0x0001</samp> がその値です。
</p>
<blockquote>
<pre>
stop-code 0x1f09 0x0001
</pre>
</blockquote>
<p>
指示子名の大文字と小文字は区別されますので、<samp>stop-code</samp>
<samp>Stop-Code</samp> と書くことはできません。
指示子の名前と値の区切りには、空白かタブを用います。
連続した空白とタブが、行頭および行末にあった場合、それらは無視されます。
</p>
<p>
複合指示子とは、記述が設定ファイル内の複数行に渡る指示子です。
複合指示子の一般形は次の通りです。
</p>
<blockquote>
<pre>
begin <var>複合指示子の名前</var>
<var>副指示子の名前</var> <var>副指示子の値</var>
:
: (繰り返し)
:
end
</pre>
</blockquote>
<p>
キーワード <code>begin</code> が、複合指示子の開始を表します。
<code>begin</code> は後ろに <var>複合指示子の名前</var> を引数として
取ります。
<code>begin</code><var>複合指示子の名前</var> は空白かタブで区切り、
両方とも同じ行の中に置きます。
キーワード <code>end</code> は、複合指示子の終了を表します。
<code>end</code> は、単独で 1 行にして置きます。
</p>
<p>
今のところ <var>副本</var><code>.app</code> で使用できる複合指示子の名前は、
<code>narrow</code><code>wide</code> の 2 つだけです。
それぞれの <dfn>副指示子</dfn> は、<code>begin</code><code>end</code>
の行の間に置きます。
副指示子に関する記述の一般的な規則は、単独指示子と変わりません
(たとえば、<var>副指示子の名前</var><var>副指示子の値</var> は空白か
タブで区切ることなど)。
</p>
<p>
以下は、 <code>narrow</code> 複合指示子の記述例です。
</p>
<blockquote>
<pre>
begin narrow
range-start 0xa121
range-end 0xa123
0xa121 [→参照]
0xa122 [→音声]
0xa123 [→図解]
end
</pre>
</blockquote>
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
<h3><a name="single-directives"><var>副本</var><code>.app</code> の単独指示子</a></h3>
<p>
単独指示子には次のようなものがあります。
</p>
<dl>
<dt><code>character-code</code></dt>
<dd>
appendix の文字コードを指定します。
文字コードは必ず、CD-ROM 書籍に合わせるようにします。
CD-ROM 書籍の文字コードは、<code>ebinfo</code> コマンドの出力を見れば確認
できます。
CD-ROM 書籍が ISO 8859-1 で書かれている場合は、指示子の値として
<samp>ISO8859-1</samp> を指定します。
それ以外の場合は、<samp>JISX0208</samp> を指定して下さい。
<blockquote>
<pre>
character-code JISX0208
</pre>
</blockquote>
この指示子は、<var>副本</var><code>.app</code> ファイル内で必ず一回定義
されなければなりません。
定義しなかったり、二度以上定義するとエラーになります。
<dt><code>stop-code</code></dt>
<dd>
副本の本文の区切りコードを指定します。
指示子の値は、区切りコードの文字番号を 2 つ書き並べたものになります。
<blockquote>
<pre>
stop-code 0x1f09 0x0001
</pre>
</blockquote>
文字番号は、<samp>0x</samp> ないし <samp>0X</samp> に続けて 16進数 4 桁
で記します。
ただし、1つ目の文字番号は、<samp>0x1f09</samp><samp>0x1f41</samp>
なければなりません。
それ以外だとエラーになります。
<code>ebstopcode</code> コマンドを使うと、副本に適切な区切りコードを
特定することができます (詳しくは
<a href="ebstopcode.html">ebstopcode コマンドのマニュアル</a> を参照の
こと)。
この指示子は定義しなくても構いませんが、二度以上定義するとエラーになります。
</dl>
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
<h3><a name="group-directives"><var>副本</var><code>.app</code> の複合指示子</a></h3>
<p>
<code>narrow</code> および <code>wide</code> 複合指示子は、それぞれ副本に
対する半角外字および全角外字に対する代替文字列を定義するために用います。
ただし、副本が外字を定義していても、代替文字列を利用する必要がなければ、
<code>narrow</code>, <code>wide</code> 複合指示子を記述する必要はありません。
</p>
<p>
<code>narrow</code><code>wide</code> 複合指示子内で定義できる副指示子は、
まったく同じです。
副指示子には次のようなものがあります。
</p>
<dl>
<dt><code>range-start</code></dt>
<dd>
外字の定義範囲を記します。
開始位置の文字番号を <code>range-start</code> で、終了位置の文字番号を
<code>range-end</code> で指定します。
文字番号は、<samp>0x</samp> ないし <samp>0X</samp> に続けて 16進数 4 桁で
記します。
以下は記述例です。
<blockquote>
<pre>
range-start 0xa121
range-end 0xa123
</pre>
</blockquote>
定義範囲は、<code>ebinfo</code> コマンドの出力結果の
「半角フォントの文字 (narrow font characters)」
「全角フォントの文字 (wide font characters)」
で記された範囲と一致させるようにして下さい。
<code>narrow</code> および <code>wide</code> 複合指示子内では、
必ず一回ずつ <code>range-start</code> および <code>range-end</code>
定義しなければなりません。
定義しなかったり、二度以上定義したりするとエラーになります。
<dt><code>0x<var>hhhh</var></code></dt>
<dd>
<var>hhhh</var> は、4 桁 の 16進数です。
文字番号 <code>0x</code><var>hhhh</var> の全角外字ないし半角外字に対して、
代替文字列を定義します。
<blockquote>
<pre>
0xa121 [名]
</pre>
</blockquote>
appendix が ISO 8859-1 で書かれている場合は、代替文字列も ISO 8859-1
で定義します。
それ以外の場合は、代替文字列を日本語 EUC で定義します。
いずれも、代替文字列は最長で 31 バイトまでで、それを超えるとエラーに
なります。
<code>range-start</code>, <code>range-end</code> で指定した定義範囲内の
外字すべてについて、代替文字列を設定する必要はありません。
ただし、同一の複合指示子内で、一つの文字番号の外字に対して代替文字列を
定義できるのは一回までです。
複数回設定しようとすると、エラーになります。
また、範囲外の文字番号の代替文字列を定義しようとしても、やはりエラーに
なります。
CD-ROM 書籍がどのような外字を定義しているのかは、<code>ebfont</code> コマンド
で調べることができます (詳しくは
<a href="ebfont.html">ebfont コマンドのマニュアル</a> を参照のこと)。
</dl>
<!-- ================================================================ -->
<h2><a name="generate-appendix">appendix の生成</a></h2>
<p>
appendix のソースデータが書けたら、<code>ebappendix</code> コマンドを用いて
実際の (バイナリ形式の) appendix を生成します。
</p>
<p>
以下、この章では <code>ebappendix</code> の実行方法について詳しく説明します。
</p>
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
<h3><a name="invoke-ebappendix"><code>ebappendix</code> の実行</a></h3>
<p>
<code>ebappendix</code> の一般的な起動方法は次の通りです。
</p>
<blockquote>
<pre>
% ebappendix <var>入力ディレクトリのパス</var>
</pre>
</blockquote>
<p>
<var>入力ディレクトリのパス</var> には、読み込む appendix ソースデータの
ディレクトリ、つまり <code>catalog.app</code> または <code>catalogs.app</code>
ファイルが存在するディレクトリを指定します。
省略した場合は、カレントディレクトリを指定したとみなされます。
</p>
<p>
標準では、出力ファイルはカレントディレクトリに作成されます。
</p>
<p>
<samp>--output-directory</samp> オプションを指定することで、
<code>ebappendix</code> はカレントディレクトリ以外の場所に出力することが
できます。
</p>
<blockquote>
<pre>
% ebappendix --output-directory <var>出力ディレクトリのパス</var> \
<var>入力ディレクトリのパス</var>
</pre>
</blockquote>
<p>
もし出力ディレクトリが存在していなければ、自動的に <code>ebappendix</code>
が生成します。
</p>
<p>
実行すると、<code>ebappendix</code> は出力ディレクトリの下にサブディレクトリ
を作り、いくつかのファイルを生成します。
</p>
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
<h3><a name="merge-appendix">appendix と CD-ROM 書籍の重ね合わせ</a></h3>
<p>
HDD 上にコピーした CD-ROM 書籍と同じディレクトリに、appendix を重ねて
置くことができます。
</p>
<p>
これには、<code>ebappendix</code><samp>--output-directory</samp>
<samp>--no-catalog</samp> オプションを使います。
<samp>--output-directory</samp> オプションには、CD-ROM 書籍の
トップディレクトリを指定します。
</p>
<blockquote>
<pre>
% ebappendix --no-catalog --output-directory <var>出力ディレクトリのパス</var> \
<var>入力ディレクトリのパス</var>
</pre>
</blockquote>
<p>
なお、appendix の形式 (電子ブックか EPWING か) は CD-ROM 書籍に合わせる
ようにします
(詳しくは
<a href="#write-catalog.app"><code>catalog(s).app</code> の書き方」</a>
を参照)。
</p>
<p>
<code>ebappendix</code> の実行前後で CD-ROM 書籍のディレクトリ構成が
どのように変化するのか、例を記してみます。
まず電子ブックの場合ですが、実行前のディレクトリ構成が次のように
なっていたとします。
</p>
<blockquote>
<pre>
catalog
ejdict/start
howto/start
</pre>
</blockquote>
<p>
<code>ebappendix</code> で appendix を重ね合わせると、次のような構成に
なります。
</p>
<blockquote>
<pre>
catalog
ejdict/start
ejdict/appendix ← appendix のファイル
howto/start
howto/appendix ← appendix のファイル
</pre>
</blockquote>
<p>
同様に、EPWING で実行前のディレクトリ構成が次のようになっていたと
すると、
</p>
<blockquote>
<pre>
catalogs
ejdict/data/honmon
howto/data/honmon
</pre>
</blockquote>
<p>
実行後は、次のような構成になります。
</p>
<blockquote>
<pre>
catalogs
ejdict/data/honmon
ejdict/data/furoku ← appendix のファイル
howto/data/honmon
howto/data/furoku ← appendix のファイル
</pre>
</blockquote>
<p>
CD-ROM 書籍によっては、ディレクトリ名に大文字が混じっていることが
ありますが、<code>ebappendix</code> はそれを検出しますので、名前を小文字に
変えたディレクトリを別途作ってしまうことはありません。
</p>
<p>
<samp>--no-catalog</samp> オプションを指定すると、<code>ebappendix</code>
カタログファイル <code>catalog</code><code>catalogs</code> ファイルを
生成しなくなります。
この appendix を EB ライブラリのアプリケーションから使う際は、
CD-ROM 書籍に最初から用意されている <code>catalog</code>
<code>catalogs</code> ファイルを CD-ROM 書籍、appendix 共用の
カタログファイルとして流用することになります。
</p>
<p>
appendix のカタログファイルは、CD-ROM 書籍のカタログファイルの部分集合
となっているため、こうした事が可能となっています。
<samp>--no-catalog</samp> オプションを指定し忘れると、
<code>ebappendix</code> は CD-ROM 書籍のカタログファイルを上書き
してしまいますので、注意して下さい。
</p>
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
<h3><a name="options-to-ebappendix"><code>ebappendix</code> のオプション</a></h3>
<p>
<code>ebappendix</code> コマンドは、伝統的な一文字オプション名と覚えやすい
長いオプション名の両方を扱うことができます。
長いオプション名を表すには、<samp>-</samp> ではなく <samp>--</samp>
用います。
オプション名が一意に決まる範囲内で、名前の後方部分を省略することができま
す。
</p>
<dl>
<dt><code>-b <var>書籍の形式</var></code></dt>
<dt><code>--booktype <var>書籍の形式</var></code></dt>
<dd>
appendix を電子ブック、EPWING のどちらの形式のレイアウトに似せて作る
のかを指定します。
電子ブック形式なら <code>eb</code>、EPWING 形式なら <code>epwing</code>
と指定します。
このオプションを指定しなかった場合、次の要領でどちらの形式で生成する
のかがが決定されます。
まず、入力ディレクトリに <code>catalog.app</code> ファイルが存在すれば
それが読み込まれ、電子ブック形式の appendix が生成されます。
<code>catalog.app</code> がなく、代わりに <code>catalogs.app</code>
存在すればそれが読み込まれ、EPWING 形式の appendix が生成されます。
(<code>catalogs.app</code><code>catalog.app</code> なければ、エラー
になります。)
<dt><code>-d</code></dt>
<dt><code>--debug</code></dt>
<dt><code>--verbose</code></dt>
<dd>
デバッグ用のメッセージを、標準エラー出力に出力します。
<dt><code>-h</code></dt>
<dt><code>--help</code></dt>
<dd>
ヘルプメッセージを標準出力に出力して、終了します。
<dt><code>-n</code></dt>
<dt><code>--no-catalog</code></dt>
<dd>
カタログファイル (<code>catalog</code> および <code>catalogs</code>) を
生成しません。
このオプションは、書籍と appendix を同じディレクトリに重ね合わせる際に
有効です
(詳しくは
<a href="#merge-appendix">「appendix と CD-ROM 書籍の重ね合わせ」</a>
を参照のこと)。
<dt><code>-o <var>ディレクトリ</var></code></dt>
<dt><code>--output-directory <var>ディレクトリ</var></code></dt>
<dd>
出力先のディレクトリを指定します。
このオプションを省略すると、カレントディレクトリ (<code>.</code>) に
出力します。
ディレクトリが存在しなければ、自動的に生成されます。
<dt><code>-t</code></dt>
<dt><code>--test</code></dt>
<dd>
ファイルを出力しません。
入力ファイルを読み込んで、内容のチェックだけを行います。
<dt><code>-v</code></dt>
<dt><code>--version</code></dt>
<dd>
バージョン番号を標準出力に出力して、終了します。
</dl>
</body>
</html>

387
doc/ebfont.html.in Normal file
View File

@ -0,0 +1,387 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-jp">
<link rel="stylesheet" type="text/css" href="ebutils.css">
<link rev="made" href="mailto:m-kasahr@sra.co.jp">
<title>ebfont コマンド</title>
</head>
<body>
<h1><a name="toc">ebfont コマンド</a></h1>
<p>
この文書は EB ライブラリバージョン
<!-- #include "version.html" -->
に対応しています。
</p>
<p>
目次:
</p>
<!-- #include "ebfont-toc.html" -->
<p>
Copyright (c) 1998-2006 Motoyuki Kasahara
</p>
<!-- ================================================================ -->
<h2><a name="introduction">はじめに</a></h2>
<p>
<code>ebfont</code> コマンドは、CD-ROM 書籍の外字のビットマップデータを
読み込み、それを指定された画像形式に変換し、ファイルに書き出します。
<code>ebfont</code> は EB ライブラリを使用しており、ライブラリと一緒に
配布されています。
</p>
<!-- ================================================================ -->
<h2><a name="what-is-local-character">外字とは</a></h2>
<p>
CD-ROM 書籍の多くは、書籍固有の文字、外字 (local characters) を定義して
います。
たとえば、CD-ROM 書籍に使われる文字セットは発音記号を持っていないため、
英和辞書の中には発音記号を定義しているものがあります。
</p>
<p>
CD-ROM 書籍は、外字のビットマップデータも持っています。
<code>ebfont</code> コマンドは、CD-ROM 書籍のビットマップデータを読み、
それを指定された画像形式に変換し、ファイルに書き出します。
<code>ebfont</code> は、XBM、XPM、GIF、BMP、PNG のうちのいずれか、
または複数の画像ファイルを生成することができます。
特に指定がなければ、XBM 形式が選択されます。
</p>
<p>
外字は、<dfn>半角</dfn> (<dfn>narrow</dfn>) と <dfn>全角</dfn>
(<dfn>wide</dfn>) の 2 種類に分類されます。
半角の文字のビットマップデータでは、高さは幅の約半分です。
全角の文字のビットマップデータでは、高さと幅はほぼ同じです。
CD-ROM 書籍は、一冊の中に両方の種類の外字を定義することが可能で、
<code>ebfont</code> は両方の種類の画像ファイルを生成します。
</p>
<p>
CD-ROM 書籍の内部形式の仕様書では、半角と全角の両方の外字に対して
4 種類のサイズを定義しています。
外字の幅、高さ、サイズは次の通りです。
</p>
<table summary="外字の幅、高さ、サイズの表">
<tr><td>高さ <td> 半角 <td> 全角</tr>
<tr><td>16 <td> 8x16 <td> 16x16</tr>
<tr><td>24 <td> 16x24 <td> 24x24</tr>
<tr><td>30 <td> 16x30 <td> 32x30</tr>
<tr><td>48 <td> 24x48 <td> 48x48</tr>
</table>
<p>
特に指定がなければ、<code>ebfont</code> は高さが 16 ピクセルのフォントの
画像ファイルを生成します。
</p>
<!-- ================================================================ -->
<h2><a name="invoke-ebfont"><code>ebfont</code> の実行</a></h2>
<p>
<code>ebfont</code> の一般的な起動方法は次の通りです。
</p>
<blockquote>
<pre>
% ebfont <var>書籍へのパス</var>
</pre>
</blockquote>
<p>
<var>書籍へのパス</var> には、CD-ROM 書籍のトップディレクトリ、つまり
<code>catalog</code> または <code>catalogs</code> ファイルが存在する
ディレクトリを指定します。
パスは、ローカルなパス (例: <samp>/mnt/dict</samp>) でも遠隔アクセス識別子
(例: <samp>ebnet://localhost/dict</samp>) でも構いません。
複数のパスを書くことはできませんが、以下のように、パスの指定を省くことは
できます。
</p>
<blockquote>
<pre>
% ebfont
</pre>
</blockquote>
<p>
この場合、<code>ebfont</code> はカレントディレクトリの下に画像ファイルを
生成します。
このとき、ファイル名の一般形式は次の通りです。
</p>
<blockquote>
<pre>
<var>副本</var>/<var>高さ</var>/narrow/<var>文字番号</var>.<var>拡張子</var>
<var>副本</var>/<var>高さ</var>/wide/<var>文字番号</var>.<var>拡張子</var>
</pre>
</blockquote>
<p>
<var>拡張子</var><samp>xbm</samp><samp>xpm</samp><samp>gif</samp>
<samp>bmp</samp> <samp>png</samp> のいずれかで、<var>文字番号</var>
16 進数 4 桁 (<samp>0</samp> から <samp>9</samp><samp>a</samp> から
<samp>f</samp>) で、次のようになります。
</p>
<blockquote>
<pre>
ejdict/16/narrow/a121.xbm
ejdict/16/wide/a321.xbm
</pre>
</blockquote>
<p>
<code>ejdict/16/xbm/narrow</code> などの中間のディレクトリは、もし
無ければ <code>ebfont</code> が生成します。
</p>
<p>
<samp>--output-directory</samp> オプションを指定することで、
<code>ebfont</code> はカレントディレクトリ以外のディレクトリに
画像ファイルを出力することができます。
そのトップディレクトリは、<code>ebfont</code> を実行する前に作成されて
いなければなりません。
</p>
<blockquote>
<pre>
% ebfont --output-directory <var>ディレクトリ</var> <var>書籍へのパス</var>
</pre>
</blockquote>
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
<h3><a name="image-formats">画像形式</a></h3>
<p>
<code>ebfont</code> は XBM, XPM, GIF89a, BMP, PNG 形式の画像ファイルを
生成することができます。
画像形式は <samp>--image-format</samp> (<samp>-i</samp>) オプションで
指定します。
<samp>--image-format</samp> オプションは引数を一つ取り、そこにカンマ
(<samp>,</samp>) で区切って、画像形式の名前を並べて書きます。
たとえば、以下のコマンドを実行すると、<code>ebfont</code> は XPM 形式と
GIF 形式の画像ファイルを生成します。
</p>
<blockquote>
<pre>
% ebfont --image-format xpm,gif <var>書籍へのパス</var>
</pre>
</blockquote>
<p>
<samp>--image-format</samp> の引数は、次のように分けて書くこともできます。
</p>
<blockquote>
<pre>
% ebfont --image-format xpm --image-format gif <var>書籍へのパス</var>
</pre>
</blockquote>
<p>
XPM, GIF, PNG 形式では、前景色は黒 (RGB の <samp>#000000</samp>) に、
背景色は透明になります。
BMP 形式では、前景色は黒に、背景色は白 (RGB の <samp>#ffffff</samp>) に
なります。
</p>
<p>
<code>ebzip</code> は GIF の画像を生成する際に LZW 圧縮アルゴリズムを
使わないため、ファイルのサイズは相当大きくなります。
</p>
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
<h3><a name="heights">高さ</a></h3>
<p>
特に指定がなければ、<code>ebfont</code> は、半角と全角それぞれについて、
高さ 16 ピクセルのフォントの画像ファイルを生成します。
<samp>--font-height</samp> (<samp>-f</samp>) オプションを使用することで、
他の高さのフォントの画像ファイルを生成することができます。
<samp>--font-height</samp> オプションは引数を一つ取り、そこにカンマ
(<samp>,</samp>) で区切って、フォントの高さを並べて書きます。
フォントの高さは、<samp>16</samp><samp>24</samp><samp>30</samp>
<samp>48</samp> のいずれかでなくてはいけません。
たとえば、以下のコマンドを実行すると、<code>ebfont</code> は高さ
16 ピクセルと 24 ピクセルのフォントの画像ファイルを生成します。
</p>
<blockquote>
<pre>
% ebfont --font-height 16,24 <var>書籍へのパス</var>
</pre>
</blockquote>
<p>
<samp>--font-height</samp> の引数は、次のように分けて書くこともできます。
</p>
<blockquote>
<pre>
% ebfont --font-height 16 --font-height 24 <var>書籍へのパス</var>
</pre>
</blockquote>
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
<h3><a name="subbooks">副本</a></h3>
<p>
なにも設定しないと、<code>ebzip</code> はすべての副本 (subbook) を対象に
して画像ファイルを生成しますが、<samp>--subbook</samp> (<samp>-S</samp>)
オプションを使うと、指定した副本の画像ファイルだけを生成することができます。
</p>
<p>
<samp>--subbook</samp> オプションは引数を一つ取り、そこにカンマ
(<samp>,</samp>) で区切って、副本のディレクトリ名を並べて書きます。
<code>ebinfo</code> コマンドを用いると、あなたの所有している書籍に
どのような副本が含まれているのかを知ることができます。
</p>
<blockquote>
<pre>
% 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
</pre>
</blockquote>
<p>
(<code>ebinfo</code> コマンドに関しての詳細は、
<a href="ebinfo.html">ebinfo コマンドのマニュアル</a> を参照のこと。)
この例では、3 つの副本が書籍には含まれており、そのディレクトリ名は
<code>english</code>, <code>french</code>, <code>german</code>
だということが分かります。
</p>
<p>
次のコマンドを実行すると, <code>ebfont</code><code>english</code>
<code>french</code> の画像ファイルだけを生成します。
</p>
<blockquote>
<pre>
% ebfont --subbook english,french /mnt/cdrom
</pre>
</blockquote>
<p>
ディレクトリ名の大文字・小文字の違いは、区別されません。
<samp>--subbook</samp> の引数は、次のように分けて書くこともできます。
</p>
<blockquote>
<pre>
% ebfont --subbook english --subbook french /mnt/cdrom
</pre>
</blockquote>
<!-- ================================================================ -->
<h2><a name="summary-of-options"><code>ebfont</code> のオプション一覧</a></h2>
<p>
<code>ebzip</code> コマンドは、伝統的な一文字オプション名と覚えやすい長い
オプション名の両方を扱うことができます。
長いオプション名を表すには、<samp>-</samp> ではなく <samp>--</samp>
用います。
オプション名が一意に決まる範囲内で、名前の後方部分を省略することができます。
</p>
<dl>
<dt><code>-d</code></dt>
<dt><code>--debug</code></dt>
<dt><code>--verbose</code></dt>
<dd>
デバッグ用の情報を、標準エラー出力に出力します。
<dt><code>-f <var>高さ</var></code></dt>
<dt><code>--font-height <var>高さ</var></code></dt>
<dd>
高さが <var>高さ</var> の外字の画像ファイルを生成します。
<var>高さ</var> は、高さをカンマ (<samp>,</samp>) で区切って並べたもので
なくてはなりません。
高さの指定として許されるのは、<samp>16</samp><samp>24</samp>
<samp>30</samp><samp>48</samp> です。
指定がなければ、<code>ebfont</code> は高さが 16 ピクセルのフォントのものを
生成します。
(詳しくは、<a href="#heights">「高さ」</a>を参照のこと。)
<dt><code>-h</code></dt>
<dt><code>--help</code></dt>
<dd>
ヘルプメッセージを標準出力に出力して、終了します。
<dt><code>-i <var>画像形式</var></code></dt>
<dt><code>--image-format <var>画像形式</var></code></dt>
<dd>
<var>画像形式</var> 形式の画像ファイルを生成します。
<var>画像形式</var> は、画像形式名をカンマ (<samp>,</samp>) で区切って
並べたものでなくてはなりません。
対応している画像形式の名前は <samp>xbm</samp><samp>xpm</samp>
<samp>gif</samp><samp>bmp</samp><samp>gif</samp><samp>png</samp>
です。
指定しなかったときは、<samp>ebfont</samp> は XBM 形式の画像ファイルを
生成します。
(詳しくは、<a href="#image-formats">「画像形式」</a>を参照のこと。)
<dt><code>-o <var>ディレクトリ</var></code></dt>
<dt><code>--output-directory <var>ディレクトリ</var></code></dt>
<dd>
画像ファイルを <var>ディレクトリ</var> 以下に出力します。
指定しなかったときは、<code>ebfont</code> はカレントディレクトリ
(<code>.</code>) の下に画像ファイルを生成します。
(詳しくは、<a href="#invoke-ebfont"><code>ebfont</code> の実行」</a>
を参照のこと。)
<dt><code>-S <var>副本</var></code></dt>
<dt><code>--subbook <var>副本</var></code></dt>
<dd>
<code>ebfont</code> に、どの副本の外字を生成させるのかを指定します。
<var>副本</var> は、副本のディレクトリ名をカンマ (<samp>,</samp>) で
区切って並べたものでなくてはなりません。
指定しなかったときは、すべての副本が生成の対象になります。
(詳しくは、<a href="#subbooks">「副本」</a>を参照のこと。)
<dt><code>-v</code></dt>
<dt><code>--version</code></dt>
<dd>
バージョン番号を標準出力に出力して、終了します。
</dl>
</body>
</html>

319
doc/ebinfo.html.in Normal file
View File

@ -0,0 +1,319 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-jp">
<link rel="stylesheet" type="text/css" href="ebutils.css">
<link rev="made" href="mailto:m-kasahr@sra.co.jp">
<title>ebinfo コマンド</title>
</head>
<body>
<h1><a name="toc">ebinfo コマンド</a></h1>
<p>
この文書は EB ライブラリバージョン
<!-- #include "version.html" -->
に対応しています。
</p>
<p>
目次:
</p>
<!-- #include "ebinfo-toc.html" -->
<p>
Copyright (c) 1997-2006 Motoyuki Kasahara
</p>
<!-- ================================================================ -->
<h2><a name="introduction">はじめに</a></h2>
<p>
<code>ebinfo</code> コマンドは CD-ROM 書籍に関する様々な情報を出力します。
<code>ebinfo</code> は EB ライブラリを使用しており、ライブラリと一緒に配布
されています。
</p>
<!-- ================================================================ -->
<h2><a name="invoke-ebinfo"><code>ebinfo</code> の実行</a></h2>
<p>
<code>ebinfo</code> の一般的な起動方法は次の通りです。
</p>
<blockquote>
<pre>
% ebinfo <var>書籍へのパス</var>
</pre>
</blockquote>
<p>
<var>書籍へのパス</var> には、CD-ROM 書籍のトップディレクトリ、つまり
<code>catalog</code> または <code>catalogs</code> ファイルが存在する
ディレクトリを指定します。
パスは、ローカルなパス (例: <samp>/mnt/dict</samp>) でも遠隔アクセス識別子
(例: <samp>ebnet://localhost/dict</samp>) でも構いません。
複数のパスを書くことはできませんが、以下のように、パスの指定を省くことは
できます。
</p>
<blockquote>
<pre>
% ebinfo
</pre>
</blockquote>
<p>
この場合、<code>ebinfo</code> はカレントディレクトリ (<code>.</code>) が
指定されたものと判断します。
<code>ebinfo</code> は指定された書籍に関する情報を、次のような感じで出力
します。
</p>
<blockquote>
<pre>
% 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
</pre>
</blockquote>
<p>
副本 (subbook) が複合検索 (multi-search) に対応している場合、
<samp>--multi-search</samp> (または <samp>-m</samp>) オプションを指定すると、
<code>ebinfo</code> は複合検索に関する詳細な情報も合わせて出力します。
複合検索に関する情報は、次のような感じになります。
</p>
<blockquote>
<pre>
複合検索 1:
ラベル 1: 国または地域
候補: 有
ラベル 2: 時期
候補: 無
ラベル 3: カテゴリ
候補: 有
ラベル 4: 出典
候補: 無
複合検索 2:
ラベル 1: 著者
候補: 無
ラベル 2: 題名
候補: 無
ラベル 3: 日付
候補: 無
ラベル 4: 出版社
候補: 無
</pre>
</blockquote>
<!-- ================================================================ -->
<h2><a name="details-about-information">出力される情報の詳細ついて</a></h2>
<p>
この節では、<code>ebinfo</code> が出力する情報の詳細について説明します。
</p>
<dl>
<dt>disc type:</dt>
<dd>
その書籍の形式。EB/EBG/EBXA/EBXA-C/S-EBXA または EPWING です。
<dt>character code:</dt>
<dd>
その書籍で使用されている文字コー。ISO 8859-1 または JIS X 0208 です。
<dt>the number of subbooks:</dt>
<dd>
その書籍に収録されている副本 (subbbok) の数。
</dl>
<p>
加えて、その書籍のそれぞれの副本について、以下の情報が出力されます。
</p>
<dl>
<dt>title:</dt>
<dd>
副本の題名。
書籍が JIS X 0208 に書かれているときは、題名は EUC (Extended UNIX Code)
で表示されます。
<dt>directory:</dt>
<dd>
その副本に関連するファイルが置かれるディレクトリの名前。
英小文字は大文字に変換されます。
<dt>search methods:</dt>
<dd>
副本が対応している検索方法の一覧。
この一覧は、以下に記した検索方法の一部、もしくは全部から構成されます。
<dl>
<dt>copyright</dt>
<dd>
著作権表示 (copyright notice)。
厳密に言えば、これは検索方法ではないのですが、CD-ROM 書籍の内部形式の
関係から、表示するようにしています。
<dt>word</dt>
<dd>
前方一致検索 (Word search)。
<dt>endword</dt>
<dd>
後方一致検索 (Endword search)。
<dt>keyword</dt>
<dd>
条件検索 (Keyword search)。
<dt>cross</dt>
<dd>
クロス検索 (Keyword search)。
<dt>multi</dt>
<dd>
複合検索 (Multi search)。
<dt>menu</dt>
<dd>
メニュー検索 (Menu search).
<dt>graphic</dt>
<dd>
グラフィック検索 (Graphic search).
</dl>
<p>
副本が持つ、フォントのサイズの一覧。
この一覧には、16, 24, 30, 48 という 4 つのサイズの一部、もしくは全部から
構成されます。
</p>
<p>
副本が定義している半角文字の文字番号の範囲。
</p>
<p>
副本が定義している全角文字の文字番号の範囲。
</p>
</dl>
<!-- ================================================================ -->
<h2><a name="book-list-on-ebnet-server">EBNET サーバの書籍一覧</a></h2>
<p>
通常の出力の代わりに、<code>ebinfo</code> は EBNET サーバが公開している
書籍の一覧を出力することもできます。
この場合のコマンド行の概要は、次のようになります。
</p>
<blockquote>
<pre>
% ebinfo --book-list <var>遠隔サーバ識別子</var>
</pre>
</blockquote>
<p>
ここで、<var>遠隔サーバ識別子</var> は、書籍名を含まない遠隔アクセス識別子
になります。
たとえば、
</p>
<blockquote>
<pre>
% ebinfo --book-list ebnet://dict.example.com
名前 題名
encycl ブラウンコンサイス百科事典
encycl.app ブラウンコンサイス百科事典 (appendix)
crossword クロスワードパズル辞典
travel ワールドトラベルガイド
</pre>
</blockquote>
<p>
「名前」の末尾に <samp>.app</samp> が付いているものは appendix (付録)、
それ以外は書籍本体です。
ただし、そのクライアントに対してアクセスを許可しない書籍や appendix は
出力されません。
</p>
<p>
続けて、この中の <samp>encycl</samp> という書籍の情報を見るには、次の
ようにします。
</p>
<blockquote>
<pre>
% 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
</pre>
</blockquote>
<!-- ================================================================ -->
<h2><a name="options-to-ebinfo"><code>ebinfo</code> のオプション</a></h2>
<p>
<code>ebinfo</code> コマンドは、伝統的な一文字オプション名と覚えやすい長い
オプション名の両方を扱うことができます。
長いオプション名を表すには、<samp>-</samp> ではなく <samp>--</samp>
用います。
オプション名が一意に決まる範囲内で、名前の後方部分を省略することができます。
</p>
<dl>
<dt><code>-h</code></dt>
<dt><code>--help</code></dt>
<dd>
ヘルプメッセージを標準出力に出力して、終了します。
<dt><code>-l</code></dt>
<dt><code>--book-list</code></dt>
<dd>
通常の出力の代わりに、EBNET サーバが公開している書籍の一覧を出力します。
コマンド行引数 <var>book-path</var> は遠隔アクセス識別子でなければなりません。
<dt><code>-m</code></dt>
<dt><code>--multi-search</code></dt>
<dd>
複合検索 (multi search) に関する情報も、合わせて出力します。
<dt><code>-v</code></dt>
<dt><code>--version</code></dt>
<dd>
バージョン番号を標準出力に出力して、終了します。
</dl>
</body>
</html>

355
doc/ebrefile.html.in Normal file
View File

@ -0,0 +1,355 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-jp">
<link rel="stylesheet" type="text/css" href="ebutils.css">
<link rev="made" href="mailto:m-kasahr@sra.co.jp">
<title>ebrefile コマンド</title>
</head>
<body>
<h1><a name="toc">ebrefile コマンド</a></h1>
<p>
この文書は EB ライブラリバージョン
<!-- #include "version.html" -->
に対応しています。
</p>
<p>
目次:
</p>
<!-- #include "ebrefile-toc.html" -->
<p>
Copyright (c) 1998-2006 Motoyuki Kasahara
</p>
<!-- ================================================================ -->
<h2><a name="introduction">はじめに</a></h2>
<p>
一冊の CD-ROM 書籍は、大抵複数の <dfn>副本</dfn> (<dfn>subbook</dfn>) を
持っています。
たとえばある CD-ROM 書籍は国語辞典、英和辞典、和英辞典の 3 つの副本を
収めています。
個々の副本は、それ自体が独立した「書籍」になっています。
</p>
<blockquote>
<pre>
(CD-ROM 書籍)
+-----------------------+
| [国語辞典] (副本) |
| [英和辞典] (副本) |
| [和英辞典] (副本) |
+-----------------------+
</pre>
</blockquote>
<p>
EB/EBG/EBXA/EBXA-C/S-EBXA 形式の CD-ROM 書籍は <code>catalog</code>
というファイルを、EPWING 形式の CD-ROM 書籍は <code>catalogs</code>
というファイルを持っています。
これらのファイルは、その CD-ROM 書籍にはどんな副本が収められているのかを
定義しています。
これらのファイルは、CD-ROM 書籍のトップディレクトリに置かれています。
</p>
<p>
<code>ebrefile</code> は元のカタログファイルを読み、ユーザから指定された
副本だけを取り込んだ新しいカタログファイルを生成します。
言い換えれば、<code>ebrefile</code> は特定の副本の定義を、カタログファイル
から削除します。
CD-ROM 書籍が 3 つの副本を持っている場合、<code>ebrefile</code>
そのうちの任意の 1 つまたは 2 つの副本を、新しいカタログファイルに
取り込むことができます。
ハードディスクに CD-ROM 書籍の一部だけをコピーしたいときに、
<code>ebrefile</code> は便利です。
<code>ebrefile</code> は EB ライブラリと一緒に配布されています。
</p>
<p>
あなたは、自分の所有する CD-ROM 書籍の使用許諾を守らなくてはいけません。
<code>ebrefile</code> はフリーソフトウェアですが、あなたの書籍が自由に
使えるものであるとは限りません。
<code>ebrefile</code> は、CD-ROM 書籍のあるファイルの内容に変更を加えます。
ご注意下さい。
</p>
<!-- ================================================================ -->
<h2><a name="invoke-ebrefile"><code>ebrefile</code> の実行</a></h2>
<p>
<code>ebrefile</code> の一般的な起動方法は次の通りです。
</p>
<blockquote>
<pre>
% ebrefile <var>書籍へのパス</var>
</pre>
</blockquote>
<p>
<var>書籍へのパス</var> には、CD-ROM 書籍のトップディレクトリ、つまり
<code>catalog</code> または <code>catalogs</code> ファイルが存在する
ディレクトリを指定します。
複数のパスを書くことはできませんが、以下のように、パスの指定を省くことは
できます。
</p>
<blockquote>
<pre>
% ebrefile
</pre>
</blockquote>
<p>
この場合、<code>ebrefile</code> はカレントディレクトリ (<code>.</code>)
が指定されたものと判断します。
</p>
<p>
遠隔アクセスには対応していませんので、遠隔アクセス識別子は使用できません。
</p>
<blockquote>
<pre>
% ebrefile ebnet://localhost/cdrom
ebrefile: ebnet には対応していません。
</pre>
</blockquote>
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
<h3><a name="select-subbooks">副本の選択</a></h3>
<p>
特に指定がないと、<code>ebrefile</code> は、元のカタログファイルで定義
されているすべての副本を新しい副本に取り込みます。
つまり、新しいカタログファイルは、単に元のファイルのコピーになります。
この振る舞いは、役に立ちません。
<code>ebrefile</code> は、通常 <samp>--subbook</samp> (<samp>-S</samp>)
オプションを指定して起動します。
</p>
<p>
<samp>--subbook</samp> (<samp>-S</samp>) オプションは引数を一つ取り、
そこにカンマ (<samp>,</samp>) で区切って、新しいカタログファイルに
取り込みたい副本のディレクトリ名を並べて書きます。
<code>ebinfo</code> コマンドを用いると、あなたの所有している書籍に
どのような副本が含まれているのかを知ることができます。
</p>
<blockquote>
<pre>
% 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
</pre>
</blockquote>
<p>
(<code>ebinfo</code> コマンドに関しての詳細は、
<a href="ebinfo.html">ebinfo コマンドのマニュアル</a> を参照のこと。)
この例では、3 つの副本が書籍には含まれており、その名前は <code>english</code>
<code>french</code>, <code>german</code> だということが分かります。
</p>
<p>
次のコマンドを実行すると、<code>ebrefile</code> は副本として
<code>english</code><code>french</code> だけを定義した新しいカタログ
を生成します。
</p>
<blockquote>
<pre>
% ebrefile --subbook english,french
</pre>
</blockquote>
<p>
ディレクトリ名の大文字・小文字の違いは、区別されません。
<samp>--subbook</samp> の引数は、次のように分けて書くこともできます。
</p>
<blockquote>
<pre>
% ebrefile --subbook english --subbook french
</pre>
</blockquote>
<p>
<code>ebrefile</code> は副本の定義順序を変えることはできませんので、
<samp>--subbook</samp> に与える引数の順序は任意です。
</p>
<p>
これで再構成は完了です。
もういちど <code>ebinfo</code> を起動してみましょう。
副本 <code>german</code> が消えています。
</p>
<blockquote>
<pre>
% 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
</pre>
</blockquote>
<p>
もし、CD-ROM 書籍全体をすでにハードディスクにコピーしているなら、
副本 <code>german</code> のファイルは削除しても構いません。
ディレクトリ名が小文字で構成されているなら、次のようにします。
</p>
<blockquote>
<pre>
% rm -r german
</pre>
</blockquote>
<p>
<code>ebrefile</code> は、読み込んだカタログファイルにそのまま上書きして
新たなカタログファイルを生成しますが、元のカタログファイルの複製が、
<code>catalog(s).old</code> というファイル名で保存されます。
副本の選択を間違えてしまった場合は、いったん元に戻しましょう。
(以下では、カタログファイルが <code>catalogs</code> だと仮定しています。)
</p>
<blockquote>
<pre>
% mv catalogs.old catalogs
</pre>
</blockquote>
<p>
ただし 実行時に <code>catalog(s).old</code> が既に存在していると、上書き
せずに残します。
この場合、カタログファイルの複製は新たに作られませんので、注意して下さい。
</p>
<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
<h3><a name="combination-with-ebzip"><code>ebzip</code> との連携</a></h3>
<p>
<code>ebrefile</code> は、<code>ebzip</code> という CD-ROM 書籍を圧縮する
コマンドと併用することができます
(<code>ebzip</code> コマンドに関しての詳細は、
<a href="ebzip.html">ebzip コマンドのマニュアル</a> を参照のこと。)
通常、 <code>ebzip</code><code>ebrefile</code> にはコマンド行で同じ
引数を与えます。
</p>
<p>
CD-ROM 書籍が <code>/cdrom</code> にマウントされ、この書籍には
<code>english</code><code>french</code><code>german</code> という
3 つの副本が収められているとします。
以下に記した操作によって、副本 <code>english</code><code>french</code>
は圧縮されてカレントディレクトリの下に置かれ、副本 <code>german</code>
副本のリストから削除されます。
</p>
<blockquote>
<pre>
% ebzip --subbook english,french /cdrom
% ebrefile --subbook english,french /cdrom
</pre>
</blockquote>
<p>
圧縮したファイルをカレントディレクトリ以外に置くには、次のようにします。
</p>
<blockquote>
<pre>
% ebzip --output-directory /dict --subbook english,french /cdrom
% ebrefile --output-directory /dict --subbook english,french /cdrom
</pre>
</blockquote>
<!-- ================================================================ -->
<h2><a name="summary-of-options"><code>ebrefile</code> のオプション一覧</a></h2>
<p>
<code>ebrefile</code> コマンドは、伝統的な一文字オプション名と覚えやすい
長いオプション名の両方を扱うことができます。
長いオプション名を表すには、<samp>-</samp> ではなく <samp>--</samp>
用います。
オプション名が一意に決まる範囲内で、名前の後方部分を省略することができます。
</p>
<dl>
<dt><code>-h</code></dt>
<dt><code>--help</code></dt>
<dd>
ヘルプメッセージを標準出力に出力して、終了します。
<dt><code>-o <var>ディレクトリ</var></code></dt>
<dt><code>--output-directory <var>ディレクトリ</var></code></dt>
<dd>
新しいカタログファイルを置くディレクトリを指定します。
指定しなかったときは、カレントディレクトリ (<samp>.</samp>) になります
(詳しくは、<a href="#invoke-ebrefile"><code>ebrefile</code> の実行」</a>
を参照のこと)。
<dt><code>-S <var>副本</var></code></dt>
<dt><code>--subbook <var>副本</var></code></dt>
<dd>
<code>ebrefile</code> が新しいカタログファイルに取り込むべき副本を指定します。
<var>副本</var> は、副本のディレクトリ名をカンマ (<samp>,</samp>) で区切って
並べたものでなくてはいけません。
指定しなかったときは、すべての副本が対象になります
(詳しくは、<a href="#select-subbooks">「副本の選択」</a> を参照のこと)。
<dt><code>-v</code></dt>
<dt><code>--version</code></dt>
<dd>
バージョン番号を標準出力に出力して、終了します。
</dl>
</body>
</html>

234
doc/ebstopcode.html.in Normal file
View File

@ -0,0 +1,234 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-jp">
<link rel="stylesheet" type="text/css" href="ebutils.css">
<link rev="made" href="mailto:m-kasahr@sra.co.jp">
<title>ebstopcode コマンド</title>
</head>
<body>
<h1><a name="toc">ebstopcode コマンド</a></h1>
<p>
この文書は EB ライブラリバージョン
<!-- #include "version.html" -->
に対応しています。
</p>
<p>
目次:
</p>
<!-- #include "ebstopcode-toc.html" -->
<p>
Copyright (c) 2003-2006 Motoyuki Kasahara
</p>
<!-- ================================================================ -->
<h2><a name="introduction">はじめに</a></h2>
<p>
あなたが EB ライブラリのアプリケーションを使って CD-ROM 書籍の中のある
単語を引く際、その単語の説明が終了する箇所で、アプリケーションが本文の
出力を止めることをあなたは期待するのではないでしょうか。
しかし、EB ライブラリはそのような動作を保証することができません。
なぜなら、CD-ROM 書籍の本文には、項目の終わりを示す印が存在しないから
です。
</p>
<p>
幸いにも、多くの CD-ROM 書籍には、項目の終わりを示す印の代替として
使える、<dfn>本文の区切りコード (text stop code)</dfn> というものを持って
います。
通常、EB ライブラリはこの区切りコードを自動的に推測するようになって
いるのですが、時々誤った区切りコードを導き出すことがあります。
その場合は、<dfn>appendix (付録)</dfn> というものを用いて、EB ライブラリに
正しい区切りコードを教えてやらなくてはなりません。
</p>
<p>
<code>ebstopcode</code> コマンドは、CD-ROM 書籍の本文の区切りコードを解析
するためのツールです。
</p>
<!-- ================================================================ -->
<h2><a name="invoke-ebstopcode"><code>ebstopcode</code> の実行</a></h2>
<p>
<code>ebstopcode</code> の一般的な起動方法は次の通りです。
</p>
<blockquote>
<pre>
% ebstopcode <var>書籍へのパス</var> <var>副本</var>
</pre>
</blockquote>
<p>
<var>書籍へのパス</var> には、CD-ROM 書籍のトップディレクトリ、つまり
<code>catalog</code> または <code>catalogs</code> ファイルが存在する
ディレクトリを指定します。
遠隔アクセス用の識別子 (<samp>ebnet://...</samp>) を指定することも可能です。
<var>書籍へのパス</var> が省略された場合は、カレントディレクトリが指定された
ものと見なされます。
</p>
<p>
<var>副本</var> には、処理の対象とする副本のディレクトリ名を指定します。
<code>ebinfo</code> コマンドを用いると、CD-ROM 書籍にどのような副本が
含まれているのかを知ることができます。
</p>
<blockquote>
<pre>
% 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
</pre>
</blockquote>
<p>
(<code>ebinfo</code> コマンドに関しての詳細は、
<a href="ebinfo.html">ebinfo コマンドのマニュアル</a> を参照のこと。)
この例では、2 つの副本が書籍には含まれており、その名前は <code>english</code>
<code>french</code> だということが分かります。
</p>
<p>
副本 <code>english</code> の区切りコードを解析するには、以下を実行します。
</p>
<blockquote>
<pre>
% ebstopcode /cdrom english
</pre>
</blockquote>
<p>
<code>ebstopcode</code> は、副本の本文と区切りコードの候補を次のように
出力します。
</p>
<blockquote>
<pre>
=== 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 ===
(以下略)
</pre>
</blockquote>
<p>
<samp>stop-code?:</samp> と書かれた行はそれぞれ、区切りコードの候補を
示しています。
これを区切りコードとして指定すると、EB ライブラリはその地点で本文の
出力を停止します。
</p>
<p>
この <code>english</code> という副本の適切な区切りコードは、"0x1f41 0x0100"
になります。
<samp>--no-candidate</samp><samp>--code</samp> オプションを使用して、この
区切りコードを試してみます。
</p>
<blockquote>
<pre>
% ebstopcode --no-candidate --code "0x1f41 0x0100" /cdrom english
A
[名] 1: A 抗原を有する赤血球を持つ血液型。
2: メートル基準の長さの単位。10億分の 1 メートル。
3: アンペア。電流の基本単位で、SI単位系の一つ。
</pre>
</blockquote>
<!-- ================================================================ -->
<h2><a name="summary-of-options"><code>ebstopcode</code> のオプション一覧</a></h2>
<p>
<code>ebstopcode</code> コマンドは、伝統的な一文字オプション名と覚えやすい長い
オプション名の両方を扱うことができます。
長いオプション名を表すには、<samp>-</samp> ではなく <samp>--</samp>
用います。
オプション名が一意に決まる範囲内で、名前の後方部分を省略することが
できます。
</p>
<dl>
<dt><code>-c <var>コード</var></code></dt>
<dt><code>--code <var>コード</var></code></dt>
<dd>
<var>コード</var> を区切りコードに指定します (例: "0x1f09 0x0001")。
<code>ebstopcode</code> は、<var>コード</var> を見つけるまで本文を出力します。
<dt><code>-h</code></dt>
<dt><code>--help</code></dt>
<dd>
ヘルプメッセージを標準出力に出力して、終了します。
<dt><code>-l <var>長さ</var></code></dt>
<dt><code>--length <var>長さ</var></code></dt>
<dd>
本文データを最長で <var>長さ</var> バイトまで出力します。
<var>長さ</var> を 0 にすると、<code>ebstopcode</code> は本文全体を出力します。
このオプションを指定しなかったときは、2048 になります。
<dt><code>-n</code></dt>
<dt><code>--no-candidates</code></dt>
<dd>
区切りコードの候補を出力しないようにします。
<dt><code>-p <var>ページ:オフセット</var></code></dt>
<dt><code>--text-position <var>ページ:オフセット</var></code></dt>
<dd>
本文データの出力をこの位置から開始します。
<var>ページ</var> には 0 より大きい 16進整数を、<var>オフセット</var> には、
00x7FF の間の 16進整数をそれぞれ指定します。
このオプションを指定しなかったときは、本文データの先頭位置から出力します。
<dt><code>-v</code></dt>
<dt><code>--version</code></dt>
<dd>
バージョン番号を標準出力に出力して、終了します。
</dl>
<p>
<samp>--code</samp> (<samp>-c</samp>) と <samp>--length</samp>
(<samp>-l</samp>) オプションは、互いにもう一方のオプションを打ち消します。
</p>
</body>
</html>

37
doc/ebutils.css Normal file
View File

@ -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;
}

1314
doc/ebzip.html.in Normal file

File diff suppressed because it is too large Load Diff

211
doc/html-include Executable file
View File

@ -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:
#
# <!-- #include "file-name" -->
#
# Note that "<!--" must located at the beginning of the line.
#
# `html-include' outputs contents of "file-name" instead of the directive
# line itself. If `file-name' also contains the file inclusion directive,
# `html-include' processes the line as well.
#
# If `input-file' is specified, `html-include' reads it. Otherwise,
# it reads HTML from standard input. `html-include' outputs the result
# to standard out by default, but you can specify output file by using
# `-o' option.
#
# Options:
# -o output-file output the result to the file.
# -c add inclusion log lines to the result.
# -I path add file search path.
#
require 5.005;
use FileHandle;
#
# Usage
#
my $usage = "Usage: $0 [-o output-file] [input-file]\n";
#
# Variables
#
my @in_files = ();
my $out_file;
my @search_paths = ();
my $max_nest_level = 5;
my $comment_mode = 0;
$in_files[0] = {'handle' => new FileHandle,
'name' => '-',
'lineno' => 0};
$out_file = {'handle' => new FileHandle,
'name' => '-',
'lineno' => 0};
#
# Parse command line arguments.
#
while (@ARGV > 0 && $ARGV[0] =~ /^-(.)(.*)/) {
my ($first, $rest) = ($1, $2);
if ($ARGV[0] eq '--') {
shift;
last;
}
if ($first eq 'o') {
if ($rest ne '') {
$out_file->{name} = $rest;
shift;
} elsif (@ARGV > 1) {
$out_file->{name} = $ARGV[1];
shift;
shift;
} else {
die "$0: option requires an argument -- $first\n";
}
} elsif ($first eq 'c') {
$comment_mode = 1;
if ($rest ne '') {
$ARGV[0] = "-$rest";
} else {
shift;
}
} elsif ($first eq 'I') {
if ($rest ne '') {
push(@search_paths, $rest);
shift;
} elsif (@ARGV > 1) {
push(@search_paths, $rest);
shift;
shift;
} else {
die "$0: option requires an argument -- $first\n";
}
} else {
die "$0: invalid option -- $first\n";
}
}
die $usage if (@ARGV > 1);
#
# Open input and output files.
#
if (@ARGV == 0 || $ARGV[0] eq '-') {
$in_files[0]->{name} = 'stdin';
$in_files[0]->{handle}->open("<& STDIN");
} else {
$in_files[0]->{name} = $ARGV[0];
if (!$in_files[0]->{handle}->open('<' . $in_files[0]->{name})) {
die "$0: failed to open the file, $!: " . $in_files[0]->{name} . "\n";
}
}
if ($out_file->{name} eq '-') {
$out_file->{name} = 'stdout';
$out_file->{handle}->open(">& STDOUT");
} else {
if (!$out_file->{handle}->open('>' . $out_file->{name})) {
die "$0: failed to open the file, $!: " . $out_file->{name} . "\n";
}
}
#
# Read input files and write the result.
#
my $i = 0;
for (;;) {
for (;;) {
$_ = $in_files[$i]->{handle}->getline();
last if (!defined($_));
$in_files[$i]->{lineno}++;
chomp;
if (m|^<!--[ \t]+\#include[ \t]+\"([^\"]+)\"[ \t]+-->[ \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("<!-- \"%s\" line %d -->\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("<!-- \"%s\" line %d -->\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;
}

157
doc/html-index Executable file
View File

@ -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 <a> tags in the HTML files. Since `html-index'
# doesn't parse HTML precisely, `<' and `>' in <a> tag must be in the same
# line and be the following form:
#
# <a name="category:name">
#
# The corresponding reference in the index looks like:
#
# <a href="#category:name">name</a>
#
# or, if two or more input files are specified:
#
# <a href="file#category:name">name</a>
#
# `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-<category>.html' for each index
# category.
#
# In input HTML files, the following line has the special meaning:
#
# <!-- #file "file-name" -->
#
# It sets file name in <a href="..."> 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 <a href="....">.
#
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 (<IN_FILE>) {
chomp;
if (m|^<!--[ \t]+\#file[ \t]+\"([^\"]+)\"[ \t]+-->[ \t]*$|) {
$in_file_name = $1;
} elsif (m|<a name=\"([^\"]+)\">|) {
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 "<dl>\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 '<dt>', $cur_head_char, "\n";
}
if ($fragment_only) {
printf(OUT_FILE "<dd><a href=\"#%s:%s\">%s</a>\n",
$i, $j, $j);
} else {
printf(OUT_FILE "<dd><a href=\"%s\#%s:%s\">%s</a>\n",
$indice{$i}->{$j}, $i, $j, $j);
}
$prev_head_char = $cur_head_char;
}
print OUT_FILE "</dl>\n";
close(OUT_FILE);
}

238
doc/html-split Executable file
View File

@ -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 (<h1>...<h6>).
# 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 (<IN_FILE>) {
last if (m|^<body>|);
push(@preamble, $_);
}
while (<IN_FILE>) {
chomp;
last if (m|^</body>|);
if (m|^<h([1-6])>| && $1 <= $split_level) {
$page++ if (@toc > 0);
push(@toc, $_);
}
if (m|<a name=\"([^\"]+)\">|) {
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: <a name=\"$toc_tag\"> not found\n";
}
#
# Generate splitted HTML files.
#
if (!open(IN_FILE, "< $in_file")) {
die "$0: failed to open the file, $!: $in_file\n";
}
while (<IN_FILE>) {
last if (m|^<body>|);
}
for (my $page = 0; $page < @toc; $page++) {
my $bar = '';
if ($page > 0) {
$bar .= sprintf("[<a href=\"%s\">Á°¤Ø</a>] ",
splitted_file_name($page - 1));
}
if ($page + 1 < @toc) {
$bar .= sprintf("[<a href=\"%s\">¼¡¤Ø</a>] ",
splitted_file_name($page + 1));
}
$bar .= sprintf("[<a href=\"%s\#%s\">Ìܼ¡</a>] ",
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 "<body>\n";
print OUT_FILE "<p>\n", $bar, "\n</p>\n<hr>\n";
print OUT_FILE $toc[$page], "\n";
for (;;) {
$_ = <IN_FILE>;
chomp;
if (!defined($_) || m|^</body>|) {
1 while (<IN_FILE>);
last;
}
elsif (m|^<h([1-6])>| && $1 <= $split_level) {
next if ($page == 0 && $_ eq $toc[$page]);
last;
}
1 while (s|<a href="\#([^\"]+)">|&rewrite_href($1)|e);
print OUT_FILE $_, "\n";
}
print OUT_FILE "<hr>\n<p>\n", $bar, "\n</p>\n";
print OUT_FILE "</body>\n";
print OUT_FILE "</html>\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 <a href="...">.
#
sub rewrite_href ($) {
my ($tag) = @_;
for (my $i = 0; $i < @indice; $i++) {
if ($indice[$i]->{tag} eq $tag) {
return sprintf("<a href=\"%s\#%s\">",
splitted_file_name($indice[$i]->{page}), $tag);
}
}
warn "$0: unknown tag \`$tag'\n";
return "<a href=\"$tag\">";
}

151
doc/html-toc Executable file
View File

@ -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 <h1>...<h6> tags and
# <a name="..."> tag in the HTML files. Since `html-toc' doesn't parse
# HTML precisely, the tags must be the following form:
#
# <h?><a name="...">heading</a></h?>
#
# where `?' is 1..6. Note that <h?> and </h?> 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 <a href="....">.
# -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 "<ul>\n";
foreach my $in_file (@ARGV) {
if (!open(IN_FILE, "< $in_file")) {
die "$0: failed to open the file, $!: $in_file\n";
}
while (<IN_FILE>) {
chomp;
next unless (m|^<h([1-6])><a name="([^\"]+)">(.*)</a>|);
my ($level, $tag, $heading) = ($1, $2, $3);
if ($level >= $min_level && $level <= $max_level) {
while ($current_level > $level) {
$current_level--;
print OUT_FILE ' ' x ($current_level - $min_level + 1);
print OUT_FILE "</ul>\n";
}
while ($current_level < $level) {
print OUT_FILE ' ' x ($current_level - $min_level + 1);
print OUT_FILE "<ul>\n";
$current_level++;
}
print OUT_FILE ' ' x ($current_level - $min_level + 1);
if ($fragment_only) {
print OUT_FILE sprintf("<li><a href=\"\#%s\">%s</a>\n",
$tag, $heading);
} else {
print OUT_FILE sprintf("<li><a href=\"%s\#%s\">%s</a>\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 "</ul>\n";
}
print OUT_FILE "</ul>\n";
close(OUT_FILE);

53
eb.conf.in Normal file
View File

@ -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@"

77
eb/Makefile.am Normal file
View File

@ -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

681
eb/Makefile.in Normal file
View File

@ -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:

447
eb/appendix.c Normal file
View File

@ -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;
}

100
eb/appendix.h Normal file
View File

@ -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 <eb/eb.h>
#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 */

750
eb/appsub.c Normal file
View File

@ -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);
}

99
eb/bcd.c Normal file
View File

@ -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;
}

1404
eb/binary.c Normal file

File diff suppressed because it is too large Load Diff

73
eb/binary.h Normal file
View File

@ -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 <sys/types.h>
#ifdef EB_BUILD_LIBRARY
#include "defs.h"
#else
#include <eb/defs.h>
#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 */

1362
eb/bitmap.c Normal file

File diff suppressed because it is too large Load Diff

1003
eb/book.c Normal file

File diff suppressed because it is too large Load Diff

326
eb/booklist.c Normal file
View File

@ -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;
}

60
eb/booklist.h Normal file
View File

@ -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 <eb/eb.h>
#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 */

366
eb/build-post.h.in Normal file
View File

@ -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 */

151
eb/build-pre.h Normal file
View File

@ -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 <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <limits.h>
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
#include <sys/time.h>
#ifdef HAVE_DIRECT_H
#include <direct.h>
#endif
#ifdef HAVE__GETDCWD
#define getcwd _getcwd
#define getdcwd _getdcwd
#endif
#ifdef ENABLE_PTHREAD
#include <pthread.h>
#endif
#ifdef ENABLE_NLS
#include <libintl.h>
#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 */

121
eb/copyright.c Normal file
View File

@ -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;
}

190
eb/cross.c Normal file
View File

@ -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;
}

1040
eb/defs.h Normal file

File diff suppressed because it is too large Load Diff

58
eb/dummyin6.c Normal file
View File

@ -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;

167
eb/dummyin6.h Normal file
View File

@ -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 <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#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 */

89
eb/eb.c Normal file
View File

@ -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()"));
}

155
eb/eb.h Normal file
View File

@ -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 <eb/defs.h>
#endif
#include <stdarg.h>
/*
* 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 */

1166
eb/ebnet.c Normal file

File diff suppressed because it is too large Load Diff

108
eb/ebnet.h Normal file
View File

@ -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 <sys/types.h>
#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 */

191
eb/endword.c Normal file
View File

@ -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;
}

284
eb/error.c Normal file
View File

@ -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;
}

150
eb/error.h Normal file
View File

@ -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 <eb/defs.h>
#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 */

188
eb/exactword.c Normal file
View File

@ -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;
}

783
eb/filename.c Normal file
View File

@ -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 <mbstring.h>
#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:
*
* <target name> == <entry name>
* <target name>+";1' == <entry name>
* <target name>+"." == <entry name>
* <target name>+".;1" == <entry name>
* <target name>+".ebz" == <entry name>
* <target name>+".ebz;1" == <entry name>
* <target name>+".org" == <entry name>
* <target name>+".org;1" == <entry name>
*
* 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;
}

551
eb/font.c Normal file
View File

@ -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;
}

200
eb/font.h Normal file
View File

@ -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 <sys/types.h>
#ifdef EB_BUILD_LIBRARY
#include "defs.h"
#else
#include <eb/defs.h>
#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 */

551
eb/getaddrinfo.c Normal file
View File

@ -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 <sys/types.h>
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <string.h>
#include <stdlib.h>
#ifdef ENABLE_PTHREAD
#include <pthread.h>
#endif
#ifdef ENABLE_NLS
#include <libintl.h>
#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;
}

222
eb/getaddrinfo.h Normal file
View File

@ -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 <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include "build-pre.h"
/********************************************************************/
/*
* Undefine all the macros.
* <netdb.h> 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.
* <netdb.h> 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 */

321
eb/hook.c Normal file
View File

@ -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;
}

110
eb/jacode.c Normal file
View File

@ -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';
}

191
eb/keyword.c Normal file
View File

@ -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;
}

417
eb/linebuf.c Normal file
View File

@ -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 <stdio.h>
#include <sys/types.h>
#include <errno.h>
#include <sys/socket.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#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;
}

70
eb/linebuf.h Normal file
View File

@ -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 <sys/types.h>
/*
* 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 */

103
eb/lock.c Normal file
View File

@ -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 */

200
eb/log.c Normal file
View File

@ -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 <stdarg.h>
/*
* 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));
}

585
eb/match.c Normal file
View File

@ -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;
}

206
eb/menu.c Normal file
View File

@ -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;
}

841
eb/multi.c Normal file
View File

@ -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;
}

966
eb/multiplex.c Normal file
View File

@ -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 <sys/types.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#ifdef HAVE_NET_IF_H
#include <net/if.h>
#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;
}

628
eb/narwalt.c Normal file
View File

@ -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;
}

1099
eb/narwfont.c Normal file

File diff suppressed because it is too large Load Diff

2148
eb/readtext.c Normal file

File diff suppressed because it is too large Load Diff

1656
eb/search.c Normal file

File diff suppressed because it is too large Load Diff

1311
eb/setword.c Normal file

File diff suppressed because it is too large Load Diff

1
eb/stamp-widealt-h Normal file
View File

@ -0,0 +1 @@
timestamp

1
eb/stamp-widefont-h Normal file
View File

@ -0,0 +1 @@
timestamp

113
eb/stopcode.c Normal file
View File

@ -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;
}

117
eb/strcasecmp.c Normal file
View File

@ -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 <sys/types.h>
/*
* 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);
}

1142
eb/subbook.c Normal file

File diff suppressed because it is too large Load Diff

121
eb/text.c Normal file
View File

@ -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;
}

166
eb/text.h Normal file
View File

@ -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 <sys/types.h>
#ifdef EB_BUILD_LIBRARY
#include "defs.h"
#else
#include <eb/defs.h>
#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 */

714
eb/urlparts.c Normal file
View File

@ -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 <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/*
* 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 ":"] ["//" [<user>][":" 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 "<user>:<password>" and "<host>:<port>".
*/
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 "<segment>/.." segments where <segment> 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 "%<HEX><HEX>" 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 "%<HEX><HEX>" 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') {
/*
* "%<HEX><HEX>" 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

71
eb/urlparts.h Normal file
View File

@ -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 */

629
eb/widealt.c Normal file
View File

@ -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;
}

1100
eb/widefont.c Normal file

File diff suppressed because it is too large Load Diff

185
eb/word.c Normal file
View File

@ -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;
}

2087
eb/zio.c Normal file

File diff suppressed because it is too large Load Diff

237
eb/zio.h Normal file
View File

@ -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 <sys/types.h>
#include <time.h>
/*
* 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 */

16
ebappendix/Makefile.am Normal file
View File

@ -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

401
ebappendix/Makefile.in Normal file
View File

@ -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:

Some files were not shown because too many files have changed in this diff Show More