├── eb ├── stamp-widealt-h ├── stamp-widefont-h ├── booklist.h ├── dummyin6.c ├── urlparts.h ├── linebuf.h ├── eb.c ├── binary.h ├── Makefile.am ├── lock.c ├── jacode.c ├── bcd.c ├── strcasecmp.c ├── text.c ├── stopcode.c ├── copyright.c ├── ebnet.h ├── appendix.h ├── build-pre.h ├── error.h ├── log.c ├── menu.c └── cross.c ├── AUTHORS ├── po-eb ├── ja.mo ├── ja.po └── Makefile.in ├── doc ├── html-split ├── ebutils.css ├── c2html ├── eb.css ├── html-toc ├── html-index ├── Makefile.am └── ebstopcode.html.in ├── samples ├── font.c ├── text.c ├── word.c ├── subbook.c ├── appendix.c ├── booklist.c ├── disctype.c ├── initexit.c ├── README └── Makefile.am ├── po-ebutils ├── ja.mo ├── ja.po └── Makefile.in ├── m4 ├── Makefile.am ├── ltversion.m4 ├── lcmessage.m4 ├── sockaddrin6.m4 ├── largefile.m4 ├── in6addr.m4 ├── eb4.m4 ├── ltsugar.m4 └── lt~obsolete.m4 ├── ebfont └── Makefile.am ├── ebinfo └── Makefile.am ├── ebrefile └── Makefile.am ├── ebstopcode └── Makefile.am ├── ebappendix └── Makefile.am ├── libebutils ├── Makefile.am ├── yesno.h ├── makedir.h ├── samefile.h ├── getumask.h ├── getumask.c ├── makedir.c ├── strlist.h ├── samefile.c ├── ebutils.h.in ├── yesno.c ├── getopt.h ├── strcasecmp.c ├── puts_eucjp.c └── strlist.c ├── Makefile.am ├── eb.conf.in ├── COPYING ├── ebzip ├── Makefile.am ├── unlinkfile.c └── ebzip1.c ├── README ├── move-if-change ├── misc ├── ebfixlog └── ebdump ├── compile └── INSTALL /eb/stamp-widealt-h: -------------------------------------------------------------------------------- 1 | timestamp 2 | -------------------------------------------------------------------------------- /eb/stamp-widefont-h: -------------------------------------------------------------------------------- 1 | timestamp 2 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Motoyuki Kasahara 2 | -------------------------------------------------------------------------------- /po-eb/ja.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mistydemeo/eb/HEAD/po-eb/ja.mo -------------------------------------------------------------------------------- /po-eb/ja.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mistydemeo/eb/HEAD/po-eb/ja.po -------------------------------------------------------------------------------- /doc/html-split: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mistydemeo/eb/HEAD/doc/html-split -------------------------------------------------------------------------------- /samples/font.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mistydemeo/eb/HEAD/samples/font.c -------------------------------------------------------------------------------- /samples/text.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mistydemeo/eb/HEAD/samples/text.c -------------------------------------------------------------------------------- /samples/word.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mistydemeo/eb/HEAD/samples/word.c -------------------------------------------------------------------------------- /po-ebutils/ja.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mistydemeo/eb/HEAD/po-ebutils/ja.mo -------------------------------------------------------------------------------- /po-ebutils/ja.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mistydemeo/eb/HEAD/po-ebutils/ja.po -------------------------------------------------------------------------------- /samples/subbook.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mistydemeo/eb/HEAD/samples/subbook.c -------------------------------------------------------------------------------- /samples/appendix.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mistydemeo/eb/HEAD/samples/appendix.c -------------------------------------------------------------------------------- /samples/booklist.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mistydemeo/eb/HEAD/samples/booklist.c -------------------------------------------------------------------------------- /samples/disctype.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mistydemeo/eb/HEAD/samples/disctype.c -------------------------------------------------------------------------------- /samples/initexit.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mistydemeo/eb/HEAD/samples/initexit.c -------------------------------------------------------------------------------- /m4/Makefile.am: -------------------------------------------------------------------------------- 1 | m4datadir = $(datadir)/aclocal 2 | m4data_DATA = eb4.m4 3 | 4 | EXTRA_DIST = eb4.m4 gettext.m4 in6addr.m4 sockaddrin6.m4 sockinttypes.m4 \ 5 | lcmessage.m4 libtool.m4 6 | -------------------------------------------------------------------------------- /ebfont/Makefile.am: -------------------------------------------------------------------------------- 1 | localedir = $(datadir)/locale 2 | 3 | LIBEB = $(top_builddir)/eb/libeb.la 4 | LIBEBUTILS = $(top_builddir)/libebutils/libebutils.a 5 | 6 | bin_PROGRAMS = ebfont 7 | 8 | ebfont_SOURCES = ebfont.c 9 | ebfont_LDADD = $(LIBEBUTILS) $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) $(ICONVLIBS) 10 | ebfont_DEPENDENCIES = $(LIBEBUTILS) $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) \ 11 | $(ICONVDEPS) 12 | 13 | INCLUDES = -I../libebutils -I$(top_srcdir)/libebutils -I$(top_srcdir) \ 14 | $(INTLINCS) 15 | -------------------------------------------------------------------------------- /ebinfo/Makefile.am: -------------------------------------------------------------------------------- 1 | localedir = $(datadir)/locale 2 | 3 | LIBEB = $(top_builddir)/eb/libeb.la 4 | LIBEBUTILS = $(top_builddir)/libebutils/libebutils.a 5 | 6 | bin_PROGRAMS = ebinfo 7 | 8 | ebinfo_SOURCES = ebinfo.c 9 | ebinfo_LDADD = $(LIBEBUTILS) $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) $(ICONVLIBS) 10 | ebinfo_DEPENDENCIES = $(LIBEBUTILS) $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) \ 11 | $(ICONVDEPS) 12 | 13 | INCLUDES = -I../libebutils -I$(top_srcdir)/libebutils -I$(top_srcdir) \ 14 | $(INTLINCS) 15 | -------------------------------------------------------------------------------- /ebrefile/Makefile.am: -------------------------------------------------------------------------------- 1 | localedir = $(datadir)/locale 2 | 3 | LIBEB = $(top_builddir)/eb/libeb.la 4 | LIBEBUTILS = $(top_builddir)/libebutils/libebutils.a 5 | 6 | bin_PROGRAMS = ebrefile 7 | 8 | ebrefile_SOURCES = ebrefile.c 9 | ebrefile_LDADD = $(LIBEBUTILS) $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) $(ICONVLIBS) 10 | ebrefile_DEPENDENCIES = $(LIBEBUTILS) $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) \ 11 | $(ICONVDEPS) 12 | 13 | INCLUDES = -I../libebutils -I$(top_srcdir)/libebutils \ 14 | -I../eb -I$(top_srcdir)/eb $(INTLINCS) 15 | -------------------------------------------------------------------------------- /ebstopcode/Makefile.am: -------------------------------------------------------------------------------- 1 | localedir = $(datadir)/locale 2 | 3 | LIBEB = $(top_builddir)/eb/libeb.la 4 | LIBEBUTILS = $(top_builddir)/libebutils/libebutils.a 5 | 6 | bin_PROGRAMS = ebstopcode 7 | 8 | ebstopcode_SOURCES = ebstopcode.c 9 | ebstopcode_LDADD = $(LIBEBUTILS) $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) $(ICONVLIBS) 10 | ebstopcode_DEPENDENCIES = $(LIBEBUTILS) $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) \ 11 | $(ICONVDEPS) 12 | 13 | INCLUDES = -I../libebutils -I$(top_srcdir)/libebutils -I$(top_srcdir) \ 14 | $(INTLINCS) 15 | -------------------------------------------------------------------------------- /samples/README: -------------------------------------------------------------------------------- 1 | このディレクトリには EB ライブラリのサンプルプログラムが幾つか置かれて 2 | います。 3 | 4 | `configure' を `--enable-samples' オプション無しで実行しない限り、これ 5 | らのサンプルプログラムは EB ライブラリと一緒にはコンパイルされません。 6 | `--enable-samples' を指定せずに (あるいは `--disable-samples' か 7 | `--enable-samples=no' を指定して) `configure' を指定して起動したけれど 8 | もサンプルプログラムをコンパイルしたいという場合は、次の手順をとって下 9 | さい。 10 | 11 | 1. EB ライブラリをコンパイルします。 12 | 2. このディレクトリに移動 (`cd') します。 13 | 3. `make all' とタイプします。 14 | (`make install' ターゲットは提供していません。) 15 | 16 | サンプルプログラムの使用方法は、各ソースファイルの先頭部分で説明して 17 | います。 18 | -------------------------------------------------------------------------------- /ebappendix/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_SCRIPTS = ebappendix 2 | 3 | EXTRA_DIST = ebappendix.in 4 | CLEANFILES = ebappendix ebappendix.tmp 5 | 6 | ebappendix: ebappendix.in $(top_srcdir)/libebutils/getopt_long.pl Makefile 7 | rm -f ebappendix 8 | sed -e 's;\@PERL\@;$(PERL);' \ 9 | $(srcdir)/ebappendix.in | sed '/^$$/q' > ebappendix.tmp 10 | cat $(top_srcdir)/libebutils/getopt_long.pl >> ebappendix.tmp 11 | sed -e 's;\@VERSION\@;$(VERSION);' \ 12 | -e 's;\@MAILING_ADDRESS\@;$(MAILING_ADDRESS);' \ 13 | $(srcdir)/ebappendix.in | sed '1,/^$$/d' >> ebappendix.tmp 14 | cp ebappendix.tmp ebappendix 15 | chmod +x ebappendix 16 | rm -f ebappendix.tmp 17 | -------------------------------------------------------------------------------- /doc/ebutils.css: -------------------------------------------------------------------------------- 1 | body { 2 | color: #000000; 3 | background-color: #ffffff; 4 | } 5 | 6 | td { 7 | border-style: solid; 8 | border-width: 1px; 9 | } 10 | 11 | table { 12 | border-style: solid; 13 | border-width: 2px; 14 | } 15 | 16 | h2 { 17 | font-size: x-large; 18 | background-color: #cfcfcf; 19 | padding: 3px; 20 | border-style: solid; 21 | border-width: 1px; 22 | } 23 | 24 | h3 { 25 | font-size: large; 26 | background-color: #cfcfcf; 27 | padding: 3px; 28 | border-style: solid; 29 | border-width: 1px; 30 | } 31 | 32 | h4 { 33 | font-size: medium; 34 | border-style: solid; 35 | border-width: 2px; 36 | padding: 8px; 37 | } 38 | -------------------------------------------------------------------------------- /m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # Generated from ltversion.in. 11 | 12 | # serial 3012 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.2.6]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3012]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.2.6' 20 | macro_revision='1.3012' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /libebutils/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LIBRARIES = libebutils.a 2 | libebutils_a_SOURCES = ebutils.c getopt.c getumask.c makedir.c puts_eucjp.c \ 3 | samefile.c strlist.c yesno.c 4 | libebutils_a_LIBADD = @LIBOBJS@ 5 | 6 | dist_noinst_HEADERS = getopt.h getumask.h makedir.h samefile.h strlist.h \ 7 | yesno.h 8 | nodist_noinst_HEADERS = ebutils.h 9 | 10 | EXTRA_DIST = getopt_long.pl ebutils.h.in 11 | CLEANFILES = stamp-ebutils-h ebutils.h 12 | BUILT_SOURCES = ebutils.h 13 | 14 | INCLUDES = -I$(top_srcdir) @INTLINCS@ @ICONVINCS@ 15 | 16 | ebutils.h: stamp-ebutils-h 17 | stamp-ebutils-h: ebutils.h.in Makefile 18 | rm -f ebutils.h.tmp 19 | echo '/* automatically generated from ebutils.h.in. */' \ 20 | > ebutils.h.tmp 21 | sed -e 's;\@localedir\@;$(localedir);' \ 22 | $(srcdir)/ebutils.h.in >> ebutils.h.tmp 23 | $(top_srcdir)/move-if-change ebutils.h.tmp ebutils.h 24 | @echo timestamp > stamp-ebutils-h 25 | -------------------------------------------------------------------------------- /m4/lcmessage.m4: -------------------------------------------------------------------------------- 1 | # Check whether LC_MESSAGES is available in . 2 | # Ulrich Drepper , 1995. 3 | # 4 | # This file can be copied and used freely without restrictions. It can 5 | # be used in projects which are not available under the GNU Public License 6 | # but which still want to provide support for the GNU gettext functionality. 7 | # Please note that the actual code is *not* freely available. 8 | 9 | # serial 1 10 | 11 | AC_DEFUN([AM_LC_MESSAGES], 12 | [if test $ac_cv_header_locale_h = yes; then 13 | AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES, 14 | [AC_LINK_IFELSE([ 15 | #include 16 | int 17 | main() 18 | { 19 | return LC_MESSAGES; 20 | } 21 | ], 22 | am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)]) 23 | if test $am_cv_val_LC_MESSAGES = yes; then 24 | AC_DEFINE(HAVE_LC_MESSAGES, 1, 25 | [Define to 1 if you have the `LC_MESSAGES' locale category]) 26 | fi 27 | fi]) 28 | -------------------------------------------------------------------------------- /doc/c2html: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | 3 | require 5.005; 4 | use Getopt::Std; 5 | 6 | # 7 | # Usage 8 | # 9 | my $usage = "Usage: $0 [-t tab-width] [input-file...]\n"; 10 | 11 | # 12 | # Variables 13 | # 14 | my $tab_width = 8; 15 | my $out_file_name = '-'; 16 | 17 | # 18 | # Parse command line arguments. 19 | # 20 | getopts(':t:', \%options) or die $usage; 21 | $tab_width = $options{t} if (defined($options{t})); 22 | 23 | # 24 | # Convert C to HTML. 25 | # 26 | print "
\n"; 27 | print "
\n";
28 | 
29 | while (<>) {
30 |     s/^([ \t]*)//;
31 |     my $spaces = $1;
32 | 
33 |     my $col = 0;
34 |     foreach my $c (unpack('C*', $spaces)) {
35 | 	if ($c eq ord(' ')) {
36 | 	    $col++;
37 | 	} else {
38 | 	    $col = ($col + $tab_width) - ($col % $tab_width);
39 | 	}
40 | 	
41 |     }
42 |     print ' ' x $col;
43 | 
44 |     s|&|&|g;
45 |     s|<|<|g;
46 |     s|>|>|g;
47 |     print;
48 | }
49 | 
50 | print "
\n"; 51 | print "
\n"; 52 | -------------------------------------------------------------------------------- /doc/eb.css: -------------------------------------------------------------------------------- 1 | body { 2 | color: #000000; 3 | background-color: #ffffff; 4 | } 5 | 6 | td { 7 | border-style: solid; 8 | border-width: 1px; 9 | } 10 | 11 | table { 12 | border-style: solid; 13 | border-width: 2px; 14 | } 15 | 16 | h2 { 17 | color: #000000; 18 | font-size: x-large; 19 | padding: 3px; 20 | } 21 | 22 | h3 { 23 | color: #ffffff; 24 | background-color: #8787a7; 25 | font-size: large; 26 | padding: 5px; 27 | border-style: solid; 28 | border-width: 4px; 29 | border-bottom-color: #3f3f5f; 30 | border-right-color: #3f3f5f; 31 | border-top-color: #dfdfff; 32 | border-left-color: #dfdfff; 33 | } 34 | 35 | h4 { 36 | color: #000000; 37 | background-color: #dfdfff; 38 | font-size: medium; 39 | border-color: #3f3f5f; 40 | border-left-style: solid; 41 | border-bottom-style: solid; 42 | border-left-width: 8px; 43 | border-bottom-width: 2px; 44 | padding: 6px; 45 | } 46 | 47 | blockquote.program { 48 | border-style: dotted; 49 | border-width: 1px; 50 | padding-left: 8px; 51 | } 52 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | 3 | if ENABLE_SAMPLES 4 | SAMPLES_SUBDIR = samples 5 | else 6 | SAMPLES_SUBDIR = 7 | endif 8 | 9 | SUBDIRS = eb libebutils ebappendix ebfont ebinfo ebrefile ebstopcode ebzip \ 10 | doc po-eb po-ebutils m4 $(SAMPLES_SUBDIR) 11 | 12 | EXTRA_DIST = ChangeLog.0 ChangeLog.1 ChangeLog.2 move-if-change \ 13 | eb.conf.in misc/ebfixlog misc/ebdump 14 | CLEANFILES = eb.conf 15 | 16 | appendixdir = $(pkgdatadir)/appendix 17 | appendix_DATA = 18 | sysconf_DATA = eb.conf 19 | 20 | eb.conf: eb.conf.in Makefile 21 | rm -f $@ 22 | sed -e 's;\@VERSION\@;$(VERSION);' \ 23 | -e 's;\@EBCONF_EBINCS\@;$(EBCONF_EBINCS);' \ 24 | -e 's;\@EBCONF_EBLIBS\@;$(EBCONF_EBLIBS);' \ 25 | -e 's;\@EBCONF_ZLIBINCS\@;$(EBCONF_ZLIBINCS);' \ 26 | -e 's;\@EBCONF_ZLIBLIBS\@;$(EBCONF_ZLIBLIBS);' \ 27 | -e 's;\@ENABLE_PTHREAD\@;$(ENABLE_PTHREAD);' \ 28 | -e 's;\@PTHREAD_CPPFLAGS\@;$(PTHREAD_CPPFLAGS);' \ 29 | -e 's;\@PTHREAD_CFLAGS\@;$(PTHREAD_CFLAGS);' \ 30 | -e 's;\@PTHREAD_LDFLAGS\@;$(PTHREAD_LDFLAGS);' \ 31 | -e 's;\@ENABLE_NLS\@;$(ENABLE_NLS);' \ 32 | -e 's;\@EBCONF_INTLINCS\@;$(EBCONF_INTLINCS);' \ 33 | -e 's;\@EBCONF_INTLLIBS\@;$(EBCONF_INTLLIBS);' \ 34 | -e 's;\@ENABLE_EBNET\@;$(ENABLE_EBNET);' \ 35 | $(srcdir)/$@.in > $@.tmp 36 | cp $@.tmp $@ 37 | chmod 644 $@ 38 | rm -f $@.tmp 39 | 40 | gttest.mo: gttest.po 41 | $(MSGFMT) -o gttest.mo gttest.po 42 | -------------------------------------------------------------------------------- /samples/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | LIBEB = ../eb/libeb.la 4 | 5 | noinst_PROGRAMS = initexit disctype subbook word text font appendix booklist 6 | 7 | initexit_SOURCES = initexit.c 8 | initexit_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) 9 | initexit_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) 10 | 11 | disctype_SOURCES = disctype.c 12 | disctype_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) 13 | disctype_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) 14 | 15 | subbook_SOURCES = subbook.c 16 | subbook_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) 17 | subbook_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) 18 | 19 | word_SOURCES = word.c 20 | word_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) 21 | word_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) 22 | 23 | text_SOURCES = text.c 24 | text_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) 25 | text_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) 26 | 27 | font_SOURCES = font.c 28 | font_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) 29 | font_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) 30 | 31 | appendix_SOURCES = appendix.c 32 | appendix_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) 33 | appendix_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) 34 | 35 | booklist_SOURCES = booklist.c 36 | booklist_LDADD = $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) 37 | booklist_DEPENDENCIES = $(LIBEB) $(ZLIBDEPS) $(INTLDEPS) 38 | 39 | EXTRA_DIST = README 40 | 41 | INCLUDES = -I$(srcdir)/.. 42 | -------------------------------------------------------------------------------- /eb.conf.in: -------------------------------------------------------------------------------- 1 | # 2 | # Installation status of EB Library. 3 | # 4 | 5 | # Version. 6 | EBCONF_VERSION="@VERSION@" 7 | 8 | # EB Libarry include files are in DIR. 9 | # (--with-eb-includes) 10 | EBCONF_EBINCS="@EBCONF_EBINCS@" 11 | 12 | # EB Libarry files are in DIR. 13 | # (--with-eb-libraries) 14 | EBCONF_EBLIBS="@EBCONF_EBLIBS@" 15 | 16 | # zlib include files are in DIR. 17 | # (--with-zlib-includes) 18 | EBCONF_ZLIBINCS="@EBCONF_ZLIBINCS@" 19 | 20 | # zlib libarry files are in DIR. 21 | # (--with-zlib-libraries) 22 | EBCONF_ZLIBLIBS="@EBCONF_ZLIBLIBS@" 23 | 24 | # pthread is supported or not. 25 | # (--enable-pthread) 26 | EBCONF_ENABLE_PTHREAD="@ENABLE_PTHREAD@" 27 | 28 | # additional CPPFLAGS for pthread support 29 | # (--with-pthread-cppflags) 30 | EBCONF_PTHREAD_CPPFLAGS="@PTHREAD_CPPFLAGS@" 31 | 32 | # additional CFLAGS for pthread support 33 | # (--with-pthread-cflags) 34 | EBCONF_PTHREAD_CFLAGS="@PTHREAD_CFLAGS@" 35 | 36 | # additional LDFLAGS for pthread support 37 | # (--with-pthread-ldflags) 38 | EBCONF_PTHREAD_LDFLAGS="@PTHREAD_LDFLAGS@" 39 | 40 | # native language is supported or not. 41 | # (--enable-nls) 42 | EBCONF_ENABLE_NLS="@ENABLE_NLS@" 43 | 44 | # gettext include files are in DIR. 45 | # (--with-gettext-includes) 46 | EBCONF_INTLINCS="@EBCONF_INTLINCS@" 47 | 48 | # gettext library files are in DIR. 49 | # (--with-gettext-libraries) 50 | EBCONF_INTLLIBS="@EBCONF_INTLLIBS@" 51 | 52 | # remote access is supported or not. 53 | EBCONF_ENABLE_EBNET="@ENABLE_EBNET@" 54 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Redistribution and use in source and binary forms, with or without 2 | modification, are permitted provided that the following conditions are met: 3 | 4 | * Redistributions of source code must retain the above copyright notice, this 5 | list of conditions and the following disclaimer. 6 | 7 | * Redistributions in binary form must reproduce the above copyright notice, 8 | this list of conditions and the following disclaimer in the documentation 9 | and/or other materials provided with the distribution. 10 | 11 | * Neither the name of the copyright holder nor the names of its 12 | contributors may be used to endorse or promote products derived from 13 | this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /ebzip/Makefile.am: -------------------------------------------------------------------------------- 1 | localedir = $(datadir)/locale 2 | 3 | LIBEB = $(top_builddir)/eb/libeb.la 4 | LIBEBUTILS = $(top_builddir)/libebutils/libebutils.a 5 | 6 | bin_PROGRAMS = ebzip 7 | noinst_HEADERS = ebzip.h 8 | 9 | ebzip_SOURCES = ebzip.c ebzip1.c copyfile.c unzipbook.c unzipfile.c \ 10 | zipbook.c zipfile.c zipinfobook.c zipinfofile.c sebxa.c speedup.c \ 11 | unlinkfile.c 12 | ebzip_LDADD = $(LIBEBUTILS) $(LIBEB) $(ZLIBLIBS) $(INTLLIBS) $(ICONVLIBS) 13 | ebzip_DEPENDENCIES = $(LIBEB) $(LIBEBUTILS) $(ZLIBDEPS) $(INTLDEPS) \ 14 | $(ICONVDEPS) 15 | 16 | INCLUDES = -I../libebutils -I$(top_srcdir)/libebutils \ 17 | -I../eb -I$(top_srcdir)/eb $(INTLINCS) $(ZLIBINCS) 18 | 19 | # Shorten command name `ebzipinfo' for DOS & Win32. 20 | if EXEEXT_EXE 21 | ebzipinfo = ebzipinf 22 | else 23 | ebzipinfo = ebzipinfo 24 | endif 25 | 26 | install-exec-hook: 27 | rm -f $(DESTDIR)$(bindir)/ebunzip$(EXEEXT) 28 | ln $(DESTDIR)$(bindir)/`echo ebzip|sed '$(transform)'`$(EXEEXT) \ 29 | $(DESTDIR)$(bindir)/`echo ebunzip|sed '$(transform)'`$(EXEEXT) \ 30 | || cp $(DESTDIR)$(bindir)/`echo ebzip|sed '$(transform)'`$(EXEEXT) \ 31 | $(DESTDIR)$(bindir)/`echo ebunzip|sed '$(transform)'`$(EXEEXT) 32 | rm -f $(DESTDIR)$(bindir)/ebzipinfo$(EXEEXT) 33 | ln $(DESTDIR)$(bindir)/`echo ebzip|sed '$(transform)'`$(EXEEXT) \ 34 | $(DESTDIR)$(bindir)/`echo $(ebzipinfo)|sed '$(transform)'`$(EXEEXT) \ 35 | || cp $(DESTDIR)$(bindir)/`echo ebzip|sed '$(transform)'`$(EXEEXT) \ 36 | $(DESTDIR)$(bindir)/`echo $(ebzipinfo)|sed '$(transform)'`$(EXEEXT) 37 | 38 | uninstall-hook: 39 | rm -f $(DESTDIR)$(bindir)/`echo ebunzip|sed '$(transform)'`$(EXEEXT) 40 | rm -f $(DESTDIR)$(bindir)/`echo $(ebzipinfo)|sed '$(transform)'`$(EXEEXT) 41 | -------------------------------------------------------------------------------- /libebutils/yesno.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1998-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef YESNO_H 30 | #define YESNO_H 31 | 32 | #ifdef HAVE_CONFIG_H 33 | #include "config.h" 34 | #endif 35 | 36 | /* 37 | * Function declarations. 38 | */ 39 | int query_y_or_n(const char *); 40 | 41 | #endif /* not YESNO_H */ 42 | -------------------------------------------------------------------------------- /libebutils/makedir.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef MAKEDIR_H 30 | #define MAKEDIR_H 31 | 32 | #ifdef HAVE_CONFIG_H 33 | #include "config.h" 34 | #endif 35 | 36 | 37 | /* 38 | * Function declarations. 39 | */ 40 | int make_missing_directory(const char *, int); 41 | 42 | #endif /* not MAKEDIR_H */ 43 | -------------------------------------------------------------------------------- /libebutils/samefile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1998-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef SAMEFILE_H 30 | #define SAMEFILE_H 31 | 32 | #ifdef HAVE_CONFIG_H 33 | #include "config.h" 34 | #endif 35 | 36 | /* 37 | * Function declarations. 38 | */ 39 | int is_same_file(const char *, const char *); 40 | 41 | #endif /* not SAMEFILE_H */ 42 | -------------------------------------------------------------------------------- /libebutils/getumask.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1998-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef GETUMASK_H 30 | #define GETUMASK_H 31 | 32 | #ifdef HAVE_CONFIG_H 33 | #include "config.h" 34 | #endif 35 | 36 | #include 37 | 38 | /* 39 | * Function declarations. 40 | */ 41 | mode_t get_umask(void); 42 | 43 | #endif /* not GETUMASK_H */ 44 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 2 | EB ライブラリ 3 | CD-ROM 書籍にアクセスするための C のライブラリ 4 | 5 | 6 | EB ライブラリは CD-ROM 書籍にアクセスするための C のライブラリです。 7 | UNIX 系 OS および Windows (2000以降) のシステム上で動作させることがで 8 | きます。(ただし、Windows でコンパイルするには、別パッケージが必要です。) 9 | 10 | EB ライブラリは EB, EBG, EBXA, EBXA-C, S-EBXA および EPWING 形式の 11 | CD-ROM 書籍に対応しています。これらは、主に日本で販売されている辞書に 12 | 使われています。CD-ROM 書籍自体は ISO 9660 形式になっていますので、他 13 | の ISO 9660 形式と同じ要領でマウントすることができます。 14 | 15 | また、EB ライブラリは幾つかのユーテリティコマンドも提供しています。 16 | 17 | ebappendix appendix (付録) データを整形する 18 | ebfont CD-ROM 書籍内の外字のフォントデータを取り出す 19 | ebinfo CD-ROM 書籍に関する情報を出力する 20 | ebrefile CD-ROM 書籍のカタログファイルを構成し直す 21 | ebstopcode CD-ROM 書籍の本文の区切りコードを検査する 22 | ebunzip CD-ROM 書籍を伸長する 23 | ebzip CD-ROM 書籍を圧縮する 24 | ebzipinfo CD-ROM 書籍の圧縮情報を出力する 25 | 26 | 27 | バージョン 4.0 から、EB ライブラリは他のホストの書籍にアクセスできる 28 | ようになりました。遠隔アクセス用の識別子を使うことで、他ホスト上の 29 | CD-ROM 書籍を指定することができます。この識別子は、次のような形式をと 30 | ります。 31 | 32 | ebnet://<ホスト>:<ポート>/<書籍名> (CD-ROM 書籍本体) 33 | ebnet://<ホスト>:<ポート>/<書籍名>.app (付録パッケージ) 34 | 35 | <ホスト> は遠隔ホストの IP アドレスもしくはホスト名です。ただし、IPv6 36 | アドレスを指定する場合は、アドレスを `[' と `]' で囲む必要があります。 37 | <ポート> は、そのホストが待ち受けているポートの番号です。ホストが待ち 38 | 受けているポートが標準の 22010 番であれば、`:<ポート>' の部分は省略可 39 | 能です。 40 | 41 | 以下に例を記します。 42 | ebnet://eb.example.com/dict 43 | ebnet://eb.example.com:22010/dict.app 44 | ebnet://192.168.1.1/dict.app 45 | ebnet://192.168.1.1:22010/dict 46 | ebnet://[fe80::290:27ff:fe3]/dict.app 47 | ebnet://[fe80::290:27ff:fe3]:22010/dict 48 | 49 | 遠隔アクセスを行うには、EBNETD を <ホスト> 上にインストールする必要が 50 | あります。EBNETD は、EB Library 用の遠隔アクセスサーバのソフトウェア 51 | です。 52 | 53 | EB ライブラリはフリーソフトウェアです。ソースコードおよびバイナリを、 54 | いわゆる Modified BSD ライセンス の下で使用することが可能です。 55 | (バージョン 4.1よりも前のものは、GPL を採用していました。) 56 | ライセンスに関して、詳しくは COPYING という英文のファイルを参照して 57 | 下さい。 58 | 59 | 最新の EB ライブラリは次のところから入手できます。 60 | 61 | https://github.com/mistydemeo/eb/releases 62 | 63 | EB ライブラリに関する情報は次のところから得ることができます。 64 | 65 | http://www.mistys-internet.website/eb/ 66 | 67 | コメントやバグの報告は 68 | 69 | m-kasahr@sra.co.jp 70 | 71 | 宛に、日本語か英語でお送り下さい。 72 | -------------------------------------------------------------------------------- /move-if-change: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Copyright (c) 2004-2006 Motoyuki Kasahara 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 1. Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 2. Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # 3. Neither the name of the project nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software 15 | # without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 21 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | # SUCH DAMAGE. 28 | # 29 | 30 | NEW_FILE=$1 31 | TARGET_FILE=$2 32 | 33 | if [ ! -r $NEW_FILE ]; then 34 | echo "$0: cannot read $NEW_FILE" 1>&2 35 | exit 1 36 | fi 37 | 38 | if [ ! -r $TARGET_FILE ]; then 39 | mv -f $NEW_FILE $TARGET_FILE 40 | else 41 | if cmp $NEW_FILE $TARGET_FILE > /dev/null 2>&1; then 42 | echo "$0: $TARGET_FILE is unchanged" 1>&2 43 | rm -f $NEW_FILE 44 | else 45 | mv -f $NEW_FILE $TARGET_FILE 46 | fi 47 | fi 48 | 49 | exit 0 50 | -------------------------------------------------------------------------------- /libebutils/getumask.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1998-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | /* 30 | * This program requires the following Autoconf macros: 31 | * AC_TYPE_MODE_T 32 | */ 33 | 34 | #ifdef HAVE_CONFIG_H 35 | #include "config.h" 36 | #endif 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | /* 43 | * Get the current umask. 44 | */ 45 | mode_t 46 | get_umask(void) 47 | { 48 | mode_t current_umask; 49 | 50 | current_umask = umask((mode_t)022); 51 | umask(current_umask); 52 | 53 | return current_umask; 54 | } 55 | -------------------------------------------------------------------------------- /misc/ebfixlog: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | # 3 | # Copyright (c) 2004-2006 Motoyuki Kasahara 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 1. Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 2. Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # 3. Neither the name of the project nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software 15 | # without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 21 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | # SUCH DAMAGE. 28 | # 29 | 30 | use Getopt::Std; 31 | getopts('zn') or die "Usage: $0 [-z|-n] [file...]\n"; 32 | $opt_z = 1 if (defined($opt_n)); # `-n' implies `-z'. 33 | 34 | $indent = 0; 35 | 36 | while (<>) { 37 | chomp; 38 | if (/^\[EB\] (.*)$/) { 39 | $message = $1; 40 | next if (!$opt_z && $message =~ /^\S+: zio_/); 41 | next if (!$opt_n && $message =~ /^\S+: ebnet_/); 42 | $indent-- if ($message =~ /^out: /); 43 | $_ = '[EB] ' . (' ' x ($indent * 2)) . $message; 44 | $indent++ if ($message =~ /^in: /); 45 | } 46 | print $_, "\n"; 47 | } 48 | -------------------------------------------------------------------------------- /eb/booklist.h: -------------------------------------------------------------------------------- 1 | /* -*- C -*- 2 | * Copyright (c) 1997-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef EB_BOOKLIST_H 30 | #define EB_BOOKLIST_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | #ifdef EB_BUILD_LIBRARY 37 | #include "eb.h" 38 | #else 39 | #include 40 | #endif 41 | 42 | /* 43 | * Function declarations. 44 | */ 45 | /* booklist.c */ 46 | void eb_initialize_booklist(EB_BookList *booklist); 47 | void eb_finalize_booklist(EB_BookList *booklist); 48 | EB_Error_Code eb_bind_booklist(EB_BookList *booklist, const char *path); 49 | EB_Error_Code eb_booklist_book_count(EB_BookList *booklist, int *book_count); 50 | EB_Error_Code eb_booklist_book_name(EB_BookList *booklist, int book_index, 51 | char **book_name); 52 | EB_Error_Code eb_booklist_book_title(EB_BookList *booklist, int book_index, 53 | char **book_title); 54 | 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* not EB_BOOKLIST_H */ 61 | -------------------------------------------------------------------------------- /ebzip/unlinkfile.c: -------------------------------------------------------------------------------- 1 | /* -*- C -*- 2 | * Copyright (c) 2008-2009 Kazuhiro Ito 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #include "ebzip.h" 30 | 31 | /* 32 | * Add a file to the list of unlinking files. 33 | * If it succeeds, 0 is returned. Otherwise -1 is returned. 34 | */ 35 | int unlink_files_add(const char *file_name) 36 | { 37 | if (string_list_add(&unlinking_files, file_name)) { 38 | if (!ebzip_quiet_flag) { 39 | fprintf(stderr, _("%s: warning: memory exhausted, file %s is not to be unlinked\n"), invoked_name, file_name); 40 | } 41 | return -1; 42 | } 43 | 44 | return 0; 45 | } 46 | 47 | /* 48 | * Unlink files. 49 | */ 50 | void unlink_files() 51 | { 52 | String_List_Node *p = unlinking_files.head; 53 | 54 | while (p != NULL) { 55 | if (unlink(p->string) < 0 && !ebzip_quiet_flag) { 56 | fprintf(stderr, _("%s: warning: failed to unlink the file: %s\n"), 57 | invoked_name, p->string); 58 | } 59 | p = p->next; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /eb/dummyin6.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | /* 30 | * This program provides macros, types and external variables related 31 | * to basic IPv6 programming such as PF_INET6. This program is useful 32 | * for application which supports both IPv6 and traditional IPv4 systems. 33 | * 34 | * To use this program, include the header file. 35 | * 36 | * #include "dummyin6.h" 37 | * 38 | * This program is intended to be used in combination with GNU Autoconf. 39 | * (see below). 40 | * 41 | * Restriction: 42 | * `struct sockaddr_storage' has no ss_ or __ss_ member (e.g. ss_family) 43 | * since the structure is merely alias of `sturct sockaddr_in'. 44 | */ 45 | 46 | /* 47 | * This program requires the following Autoconf macros: 48 | * AC_STRUCT_IN6_ADDR 49 | * AC_STRUCT_SOCKADDR_IN6 50 | * AX_STRUCT_SOCKADDR_STORAGE 51 | * AC_DECL_IN6ADDR_ANY 52 | * AC_DECL_IN6ADDR_LOOPBACK 53 | */ 54 | #include "dummyin6.h" 55 | 56 | const struct in6_addr ebnet_in6addr_any = IN6ADDR_ANY_INIT; 57 | const struct in6_addr ebnet_in6addr_loopback = IN6ADDR_LOOPBACK_INIT; 58 | 59 | -------------------------------------------------------------------------------- /libebutils/makedir.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | /* 30 | * This program requires the following Autoconf macros: 31 | * AC_TYPE_MODE_T 32 | */ 33 | 34 | #ifdef HAVE_CONFIG_H 35 | #include "config.h" 36 | #endif 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | #ifdef HAVE_DIRECT_H 43 | #include 44 | #endif 45 | 46 | #ifndef S_ISREG 47 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 48 | #endif 49 | #ifndef S_ISDIR 50 | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 51 | #endif 52 | 53 | /* 54 | * Make a directory if the directory doesn't exist. 55 | * 56 | * If making the directory is succeeded or the directory has already 57 | * created, 0 is returned. Otherwise -1 is returned. 58 | */ 59 | int 60 | make_missing_directory(const char *path, mode_t mode) 61 | { 62 | struct stat status; 63 | 64 | if (stat(path, &status) == 0 && S_ISDIR(status.st_mode)) 65 | return 0; 66 | 67 | #ifndef WIN32 68 | if (mkdir(path, mode) < 0) 69 | return -1; 70 | #else 71 | if (mkdir(path) < 0) 72 | return -1; 73 | #endif 74 | 75 | return 0; 76 | } 77 | -------------------------------------------------------------------------------- /libebutils/strlist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef STRLIST_H 30 | #define STRLIST_H 31 | 32 | #ifdef HAVE_CONFIG_H 33 | #include "config.h" 34 | #endif 35 | 36 | /* 37 | * Type definitions. 38 | */ 39 | typedef struct String_List_Struct String_List; 40 | typedef struct String_List_Node_Struct String_List_Node; 41 | 42 | struct String_List_Struct { 43 | int node_count; 44 | String_List_Node *head; 45 | String_List_Node *tail; 46 | }; 47 | 48 | 49 | struct String_List_Node_Struct { 50 | char *string; 51 | String_List_Node *next; 52 | String_List_Node *back; 53 | }; 54 | 55 | 56 | /* 57 | * Function declarations. 58 | */ 59 | void 60 | string_list_initialize(String_List *list); 61 | 62 | void 63 | string_list_finalize(String_List *list); 64 | 65 | int 66 | string_list_add(String_List *list, const char *string); 67 | 68 | void 69 | string_list_delete(String_List *list, const char *string); 70 | 71 | void 72 | string_list_delete_all(String_List *list); 73 | 74 | int 75 | string_list_find(String_List *list, const char *string); 76 | 77 | int 78 | string_list_count_node(String_List *list); 79 | 80 | #endif /* not STRLIST_H */ 81 | -------------------------------------------------------------------------------- /libebutils/samefile.c: -------------------------------------------------------------------------------- 1 | /* -*- C -*- 2 | * Copyright (c) 1998-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifdef HAVE_CONFIG_H 30 | #include "config.h" 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | /* 38 | * If the files `file_name1' and `file_name2' are identical (i.e. the are 39 | * written on a same device and a same i-node is assigned to them), 1 is 40 | * returned. Otherwise, 0 is returned. 41 | */ 42 | int 43 | is_same_file(const char *file_name1, const char *file_name2) 44 | { 45 | struct stat st1, st2; 46 | 47 | if (stat(file_name1, &st1) != 0 || stat(file_name2, &st2) != 0) 48 | return 0; 49 | 50 | #ifndef DOS_FILE_PATH 51 | if (st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino) 52 | return 0; 53 | 54 | #else /* DOS_FILE_PATH */ 55 | /* Can't rely on st_ino and st_dev, use other fields: */ 56 | if (st1.st_mode != st2.st_mode 57 | || st1.st_uid != st2.st_uid 58 | || st1.st_gid != st2.st_gid 59 | || st1.st_size != st2.st_size 60 | || st1.st_atime != st2.st_atime 61 | || st1.st_mtime != st2.st_mtime 62 | || st1.st_ctime != st2.st_ctime) 63 | return 0; 64 | #endif /* DOS_FILE_PATH */ 65 | 66 | return 1; 67 | } 68 | -------------------------------------------------------------------------------- /libebutils/ebutils.h.in: -------------------------------------------------------------------------------- 1 | /* -*- C -*- 2 | * Copyright (c) 2000-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef EBUTILS_H 30 | #define EBUTILS_H 31 | 32 | #ifdef HAVE_CONFIG_H 33 | #include "config.h" 34 | #endif 35 | 36 | #include "eb/eb.h" 37 | 38 | /* 39 | * Text domain name for message catalog. 40 | */ 41 | #define TEXT_DOMAIN_NAME "ebutils" 42 | 43 | /* 44 | * Path to the locale directory. 45 | */ 46 | #ifndef WIN32 47 | #define LOCALEDIR "@localedir@" 48 | #else 49 | #define LOCALEDIR localedir() 50 | #endif 51 | 52 | /* 53 | * Function declarations. 54 | */ 55 | /* ebutils.c */ 56 | void output_try_help(const char *invoked_name); 57 | void output_version(const char *program_name, const char *program_version); 58 | int parse_subbook_name_argument(const char *invoked_name, const char *argument, 59 | char name_list[][EB_MAX_DIRECTORY_NAME_LENGTH + 1], int *name_count); 60 | EB_Subbook_Code find_subbook(EB_Book *book, const char *directory, 61 | EB_Subbook_Code *subbook_code); 62 | void canonicalize_path(char *path); 63 | 64 | /* puts_eucjp.c */ 65 | int fputs_eucjp_to_locale(const char *string, FILE *stream); 66 | int puts_eucjp_to_locale(const char *string); 67 | 68 | #endif /* not EBUTILS_H */ 69 | -------------------------------------------------------------------------------- /ebzip/ebzip1.c: -------------------------------------------------------------------------------- 1 | /* -*- C -*- 2 | * Copyright (c) 1998-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifdef HAVE_CONFIG_H 30 | #include "config.h" 31 | #endif 32 | 33 | #include 34 | #include 35 | 36 | #include 37 | 38 | #include "eb/eb.h" 39 | 40 | /* 41 | * Compress a slice with the ebzip compression format. 42 | * 43 | * If it succeeds, 0 is returned. Otherwise, -1 is returned. 44 | */ 45 | int 46 | ebzip1_slice(char *out_buffer, size_t *out_byte_length, char *in_buffer, 47 | size_t in_byte_length) 48 | { 49 | z_stream stream; 50 | 51 | stream.zalloc = Z_NULL; 52 | stream.zfree = Z_NULL; 53 | stream.opaque = Z_NULL; 54 | 55 | if (deflateInit(&stream, Z_DEFAULT_COMPRESSION) != Z_OK) 56 | return -1; 57 | 58 | stream.next_in = (Bytef *) in_buffer; 59 | stream.avail_in = in_byte_length; 60 | stream.next_out = (Bytef *) out_buffer; 61 | stream.avail_out = in_byte_length; 62 | 63 | if (deflate(&stream, Z_FINISH) != Z_STREAM_END) { 64 | *out_byte_length = in_byte_length; 65 | deflateEnd(&stream); 66 | return 0; 67 | } 68 | 69 | if (deflateEnd(&stream) != Z_OK) 70 | return -1; 71 | 72 | *out_byte_length = stream.total_out; 73 | return 0; 74 | } 75 | 76 | 77 | -------------------------------------------------------------------------------- /eb/urlparts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef URLPARTS_H 30 | #define URLPARTS_H 31 | 32 | #ifdef HAVE_CONFIG_H 33 | #include "config.h" 34 | #endif 35 | 36 | /* 37 | * URL Parts. 38 | */ 39 | typedef struct { 40 | char *url; 41 | char *scheme; 42 | char *user; 43 | char *password; 44 | char *host; 45 | char *port; 46 | char *path; 47 | char *params; 48 | char *query; 49 | char *fragment; 50 | char *buffer; 51 | } URL_Parts; 52 | 53 | /* 54 | * Function Declarations. 55 | */ 56 | void url_parts_initialize(URL_Parts *parts); 57 | void url_parts_finalize(URL_Parts *parts); 58 | const char *url_parts_url(URL_Parts *parts); 59 | const char *url_parts_scheme(URL_Parts *parts); 60 | const char *url_parts_user(URL_Parts *parts); 61 | const char *url_parts_password(URL_Parts *parts); 62 | const char *url_parts_host(URL_Parts *parts); 63 | const char *url_parts_port(URL_Parts *parts); 64 | const char *url_parts_path(URL_Parts *parts); 65 | const char *url_parts_params(URL_Parts *parts); 66 | const char *url_parts_query(URL_Parts *parts); 67 | const char *url_parts_fragment(URL_Parts *parts); 68 | int url_parts_parse(URL_Parts *, const char *parts); 69 | void url_parts_print(URL_Parts *parts); 70 | 71 | #endif /* not URLPARTS_H */ 72 | -------------------------------------------------------------------------------- /m4/sockaddrin6.m4: -------------------------------------------------------------------------------- 1 | dnl * 2 | dnl * Copyright (c) 2001-2006 Motoyuki Kasahara 3 | dnl * 4 | dnl * Redistribution and use in source and binary forms, with or without 5 | dnl * modification, are permitted provided that the following conditions 6 | dnl * are met: 7 | dnl * 1. Redistributions of source code must retain the above copyright 8 | dnl * notice, this list of conditions and the following disclaimer. 9 | dnl * 2. Redistributions in binary form must reproduce the above copyright 10 | dnl * notice, this list of conditions and the following disclaimer in the 11 | dnl * documentation and/or other materials provided with the distribution. 12 | dnl * 3. Neither the name of the project nor the names of its contributors 13 | dnl * may be used to endorse or promote products derived from this software 14 | dnl * without specific prior written permission. 15 | dnl * 16 | dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | dnl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE 20 | dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 | dnl * THE POSSIBILITY OF SUCH DAMAGE. 27 | dnl * 28 | 29 | dnl * 30 | dnl * Check for struct sockaddr_in6 31 | dnl * 32 | AC_DEFUN([AC_STRUCT_SOCKADDR_IN6], 33 | [AC_CACHE_CHECK(for struct sockaddr_in6, ac_cv_struct_sockaddr_in6, 34 | [AC_COMPILE_IFELSE([ 35 | #include 36 | #include 37 | #include 38 | struct sockaddr_in6 address; 39 | ], [ac_cv_struct_sockaddr_in6=yes], [ac_cv_struct_sockaddr_in6=no])]) 40 | if test "$ac_cv_struct_sockaddr_in6" = yes; then 41 | AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1, 42 | [Define to 1 if defines `struct sockaddr_in6']) 43 | fi]) 44 | 45 | dnl * 46 | dnl * Check for struct sockaddr_storage 47 | dnl * 48 | AC_DEFUN([AC_STRUCT_SOCKADDR_STORAGE], 49 | [AC_CACHE_CHECK(for struct sockaddr_storage, ac_cv_struct_sockaddr_storage, 50 | [AC_COMPILE_IFELSE([ 51 | #include 52 | #include 53 | #include 54 | struct sockaddr_storage address; 55 | ], [ac_cv_struct_sockaddr_storage=yes], [ac_cv_struct_sockaddr_storage=no])]) 56 | if test "$ac_cv_struct_sockaddr_storage" = yes; then 57 | AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, 58 | [Define to 1 if defines `struct sockaddr_storage']) 59 | fi]) 60 | 61 | -------------------------------------------------------------------------------- /eb/linebuf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef LINEBUF_H 30 | #define LINEBUF_H 31 | 32 | #ifdef HAVE_CONFIG_H 33 | #include "config.h" 34 | #endif 35 | 36 | #include 37 | 38 | /* 39 | * Buffer size of `Line_Buffer' struct. 40 | */ 41 | #define LINEBUF_BUFFER_SIZE 256 42 | 43 | /* 44 | * Line buffer manager. 45 | */ 46 | typedef struct { 47 | int file; /* file descriptor */ 48 | int timeout; /* idle timeout interval */ 49 | size_t cache_length; /* length of cache data */ 50 | char buffer[LINEBUF_BUFFER_SIZE]; /* buffer */ 51 | } Line_Buffer; 52 | 53 | 54 | /* 55 | * Function declarations. 56 | */ 57 | void initialize_line_buffer(Line_Buffer *line_buffer); 58 | void finalize_line_buffer(Line_Buffer *line_buffer); 59 | void set_line_buffer_timeout(Line_Buffer *line_buffer, int timeout); 60 | void bind_file_to_line_buffer(Line_Buffer *line_buffer, int file); 61 | int file_bound_to_line_buffer(Line_Buffer *line_buffer); 62 | void discard_cache_in_line_buffer(Line_Buffer *line_buffer); 63 | size_t cache_length_in_line_buffer(Line_Buffer *line_buffer); 64 | ssize_t read_line_buffer(Line_Buffer *line_buffer, char *line, 65 | size_t max_line_length); 66 | ssize_t binary_read_line_buffer(Line_Buffer *line_buffer, char *stream, 67 | size_t stream_length); 68 | int skip_line_buffer(Line_Buffer *line_buffer); 69 | 70 | #endif /* not LINEBUF_H */ 71 | -------------------------------------------------------------------------------- /m4/largefile.m4: -------------------------------------------------------------------------------- 1 | dnl * 2 | dnl * Copyright (c) 2009 Motoyuki Kasahara 3 | dnl * 4 | dnl * Redistribution and use in source and binary forms, with or without 5 | dnl * modification, are permitted provided that the following conditions 6 | dnl * are met: 7 | dnl * 1. Redistributions of source code must retain the above copyright 8 | dnl * notice, this list of conditions and the following disclaimer. 9 | dnl * 2. Redistributions in binary form must reproduce the above copyright 10 | dnl * notice, this list of conditions and the following disclaimer in the 11 | dnl * documentation and/or other materials provided with the distribution. 12 | dnl * 3. Neither the name of the project nor the names of its contributors 13 | dnl * may be used to endorse or promote products derived from this software 14 | dnl * without specific prior written permission. 15 | dnl * 16 | dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | dnl * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | dnl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | dnl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | dnl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | dnl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | dnl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | dnl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | dnl * SUCH DAMAGE. 27 | dnl * 28 | 29 | dnl * 30 | dnl * Check for large file support. 31 | dnl * 32 | AC_DEFUN([eb_SYS_LARGEFILE], [dnl 33 | AC_REQUIRE([AC_SYS_LARGEFILE]) 34 | AC_CACHE_CHECK([for ll modifier of printf], ac_cv_func_printf_ll, 35 | [AC_RUN_IFELSE([ 36 | #include 37 | #include 38 | #include 39 | int main() { 40 | char buffer[[128]]; 41 | sprintf(buffer, "%llx", (unsigned long long) 1 << 32); 42 | return (strcmp(buffer, "100000000") == 0) ? 0 : 1; 43 | } 44 | ], [ac_cv_func_printf_ll=yes], [ac_cv_func_printf_ll=no])]) 45 | AC_CACHE_CHECK([for I64 modifier of printf], ac_cv_func_printf_i64, 46 | [AC_RUN_IFELSE([ 47 | #include 48 | #include 49 | #include 50 | int main() { 51 | char buffer[[128]]; 52 | sprintf(buffer, "%I64x", (unsigned __int64) 1 << 32); 53 | return (strcmp(buffer, "100000000") == 0) ? 0 : 1; 54 | } 55 | ], [ac_cv_func_printf_i64=yes], [ac_cv_func_printf_i64=no])]) 56 | if test "$ac_cv_func_printf_ll" = yes; then 57 | AC_DEFINE(PRINTF_LL_MODIFIER, 1, 58 | [Define to `1' if printf() recognizes "ll" modifier for long long]) 59 | fi 60 | if test "$ac_cv_func_printf_i64" = yes; then 61 | AC_DEFINE(PRINTF_I64_MODIFIER, 1, 62 | [Define to `1' if printf() recognizes "I64" modifier for __int64]) 63 | fi]) 64 | -------------------------------------------------------------------------------- /eb/eb.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #include "build-pre.h" 30 | #include "eb.h" 31 | #include "error.h" 32 | #ifdef ENABLE_EBNET 33 | #include "ebnet.h" 34 | #endif 35 | #include "build-post.h" 36 | 37 | /* 38 | * Initialize the library. 39 | */ 40 | EB_Error_Code 41 | eb_initialize_library(void) 42 | { 43 | EB_Error_Code error_code; 44 | 45 | eb_initialize_log(); 46 | 47 | LOG(("in: eb_initialize_library()")); 48 | LOG(("aux: EB Library version %s", EB_VERSION_STRING)); 49 | 50 | eb_initialize_default_hookset(); 51 | #ifdef ENABLE_NLS 52 | bindtextdomain(EB_TEXT_DOMAIN_NAME, EB_LOCALEDIR); 53 | #endif 54 | #ifdef ENABLE_EBNET 55 | ebnet_initialize(); 56 | #endif 57 | if (zio_initialize_library() < 0) { 58 | error_code = EB_ERR_MEMORY_EXHAUSTED; 59 | goto failed; 60 | } 61 | 62 | LOG(("out: eb_initialize_library() = %s", eb_error_string(EB_SUCCESS))); 63 | 64 | return EB_SUCCESS; 65 | 66 | /* 67 | * An error occurs... 68 | */ 69 | failed: 70 | LOG(("out: eb_initialize_library() = %s", eb_error_string(error_code))); 71 | return error_code; 72 | } 73 | 74 | 75 | /* 76 | * Finalize the library. 77 | */ 78 | void 79 | eb_finalize_library(void) 80 | { 81 | LOG(("in: eb_finalize_library()")); 82 | 83 | zio_finalize_library(); 84 | #ifdef ENABLE_EBNET 85 | ebnet_finalize(); 86 | #endif 87 | 88 | LOG(("out: eb_finalize_library()")); 89 | } 90 | -------------------------------------------------------------------------------- /misc/ebdump: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | # 3 | # Copyright (c) 2004-2006 Motoyuki Kasahara 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 1. Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 2. Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # 3. Neither the name of the project nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software 15 | # without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 21 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | # SUCH DAMAGE. 28 | # 29 | 30 | # 31 | # Parse command line arguments. 32 | # 33 | die "usage: $0 file page[:offset]\n" if (@ARGV != 2); 34 | 35 | $file = $ARGV[0]; 36 | if ($ARGV[1] =~ /^([0-9a-fA-F]+)$/) { 37 | $offset = (hex($1) - 1) * 2048; 38 | } elsif ($ARGV[1] =~ /^([0-9a-fA-F]+):([0-9a-fA-F]+)$/) { 39 | $offset = (hex($1) - 1) * 2048 + hex($2); 40 | } else { 41 | die "$0: invalid offset\n"; 42 | } 43 | die "$0: invalid offset\n" if ($offset < 0); 44 | 45 | # 46 | # Open a file. 47 | # 48 | open(FILE, $file) || die "$0: failed to open the file, $!: $file.\n"; 49 | seek(FILE, $offset, 0) || die "$0: failed to seek the file, $!: $file.\n"; 50 | 51 | # 52 | # Read the file. 53 | # 54 | $count = 0; 55 | while ($count < 2048) { 56 | last if (read(FILE, $buf, 16) != 16); 57 | @data = unpack("C16", $buf); 58 | printf '%04x:%03x ', $offset / 2048 + 1, $offset % 2048; 59 | for ($i = $0; $i < 16; $i += 2) { 60 | printf('%02x%02x', $data[$i], $data[$i + 1]); 61 | } 62 | print ' '; 63 | for ($i = $0; $i < 16; $i += 2) { 64 | if (0x21 <= $data[$i] && $data[$i] <= 0x7e 65 | && 0x21 <= $data[$i + 1] && $data[$i + 1] <= 0x7e) { 66 | printf('[%c%c]', $data[$i] | 0x80, $data[$i + 1] | 0x80); 67 | } else { 68 | printf('%02x%02x', $data[$i], $data[$i + 1]); 69 | } 70 | } 71 | print "\n"; 72 | $offset += 16; 73 | $count += 16; 74 | } 75 | 76 | # 77 | # Close the file. 78 | # 79 | close(FILE); 80 | -------------------------------------------------------------------------------- /libebutils/yesno.c: -------------------------------------------------------------------------------- 1 | /* -*- C -*- 2 | * Copyright (c) 1998-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifdef HAVE_CONFIG_H 30 | #include "config.h" 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | #define YESNO_RESPONSE_SIZE 80 38 | 39 | /* 40 | * Get y/n response to `message'. 41 | * If `y' is selected, 1 is returned. Otherwise 0 is returned. 42 | */ 43 | int 44 | query_y_or_n(const char *message) 45 | { 46 | char response[YESNO_RESPONSE_SIZE]; 47 | char *head, *tail; 48 | 49 | for (;;) { 50 | /* 51 | * Output `message' to standard error. 52 | */ 53 | fputs(message, stderr); 54 | fflush(stderr); 55 | 56 | /* 57 | * Get a line from standard in. 58 | */ 59 | if (fgets(response, YESNO_RESPONSE_SIZE, stdin) == NULL) 60 | return 0; 61 | if (strchr(response, '\n') == NULL) 62 | continue; 63 | 64 | /* 65 | * Delete spaces and tabs in the beginning and end of the 66 | * line. 67 | */ 68 | for (head = response; *head == ' ' || *head == '\t'; head++) 69 | ; 70 | for (tail = head + strlen(head) - 1; 71 | head <= tail && (*tail == ' ' || *tail == '\t' || *tail == '\n'); 72 | tail--) 73 | *tail = '\0'; 74 | 75 | /* 76 | * Return if the line is `y' or `n'. 77 | */ 78 | if ((*head == 'Y' || *head == 'y') && *(head + 1) == '\0') 79 | return 1; 80 | if ((*head == 'N' || *head == 'n') && *(head + 1) == '\0') 81 | return 0; 82 | } 83 | 84 | /* not reached */ 85 | return 0; 86 | } 87 | -------------------------------------------------------------------------------- /eb/binary.h: -------------------------------------------------------------------------------- 1 | /* -*- C -*- 2 | * Copyright (c) 2001-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef EB_BINARY_H 30 | #define EB_BINARY_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | #include 37 | 38 | #ifdef EB_BUILD_LIBRARY 39 | #include "defs.h" 40 | #else 41 | #include 42 | #endif 43 | 44 | /* 45 | * Function declarations. 46 | */ 47 | /* binary.c */ 48 | EB_Error_Code eb_set_binary_mono_graphic(EB_Book *book, 49 | const EB_Position *position, int width, int height); 50 | EB_Error_Code eb_set_binary_gray_graphic(EB_Book *book, 51 | const EB_Position *position, int width, int height); 52 | EB_Error_Code eb_set_binary_wave(EB_Book *book, 53 | const EB_Position *start_position, const EB_Position *end_position); 54 | EB_Error_Code eb_set_binary_color_graphic(EB_Book *book, 55 | const EB_Position *position); 56 | EB_Error_Code eb_set_binary_mpeg(EB_Book *book, const unsigned int *argv); 57 | EB_Error_Code eb_read_binary(EB_Book *book, size_t binary_max_length, 58 | char *binary, ssize_t *binary_length); 59 | void eb_unset_binary(EB_Book *book); 60 | 61 | /* filename.c */ 62 | EB_Error_Code eb_compose_movie_file_name(const unsigned int *argv, 63 | char *composed_file_name); 64 | EB_Error_Code eb_compose_movie_path_name(EB_Book *book, 65 | const unsigned int *argv, char *composed_path_name); 66 | EB_Error_Code eb_decompose_movie_file_name(unsigned int *argv, 67 | const char *composed_file_name); 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* not EB_BINARY_H */ 74 | -------------------------------------------------------------------------------- /libebutils/getopt.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: getopt.h,v 1.3 2000/04/02 22:03:29 christos Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 2000 The NetBSD Foundation, Inc. 5 | * All rights reserved. 6 | * 7 | * This code is derived from software contributed to The NetBSD Foundation 8 | * by Dieter Baron and Thomas Klausner. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 3. All advertising materials mentioning features or use of this software 19 | * must display the following acknowledgement: 20 | * This product includes software developed by the NetBSD 21 | * Foundation, Inc. and its contributors. 22 | * 4. Neither the name of The NetBSD Foundation nor the names of its 23 | * contributors may be used to endorse or promote products derived 24 | * from this software without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 | * POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | #ifndef GETOPT_H 40 | #define GETOPT_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #ifdef HAVE_CONFIG_H 47 | #include "config.h" 48 | #endif 49 | 50 | #include 51 | 52 | /* 53 | * Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions 54 | */ 55 | #define no_argument 0 56 | #define required_argument 1 57 | #define optional_argument 2 58 | 59 | extern int opterr; 60 | extern int optind; 61 | extern int optopt; 62 | extern char *optarg; 63 | 64 | struct option { 65 | /* name of long option */ 66 | const char *name; 67 | /* 68 | * one of no_argument, required_argument, and optional_argument: 69 | * whether option takes an argument 70 | */ 71 | int has_arg; 72 | /* if not NULL, set *flag to val when option found */ 73 | int *flag; 74 | /* if flag not NULL, value to set *flag to; else return value */ 75 | int val; 76 | }; 77 | 78 | int getopt_long (int, char * const *, const char *, 79 | const struct option *, int *); 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif /* !_GETOPT_H_ */ 86 | -------------------------------------------------------------------------------- /eb/Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LTLIBRARIES = libeb.la 2 | 3 | if ENABLE_EBNET 4 | libeb_ebnet_sources = ebnet.c multiplex.c linebuf.c urlparts.c getaddrinfo.c \ 5 | dummyin6.c 6 | else 7 | libeb_ebnet_sources = 8 | endif 9 | 10 | libeb_la_SOURCES = appendix.c appsub.c bcd.c binary.c bitmap.c book.c \ 11 | booklist.c copyright.c cross.c eb.c endword.c error.c exactword.c \ 12 | filename.c font.c hook.c jacode.c keyword.c lock.c log.c match.c \ 13 | menu.c multi.c narwalt.c narwfont.c readtext.c search.c setword.c \ 14 | stopcode.c strcasecmp.c subbook.c text.c widealt.c widefont.c word.c \ 15 | zio.c $(libeb_ebnet_sources) 16 | libeb_la_LDFLAGS = -no-undefined -version-info @LIBEB_VERSION_INFO@ \ 17 | $(ZLIBLIBS) $(INTLLIBS) 18 | 19 | dist_pkginclude_HEADERS = appendix.h binary.h booklist.h defs.h eb.h error.h \ 20 | font.h text.h zio.h 21 | nodist_pkginclude_HEADERS = sysdefs.h 22 | dist_noinst_HEADERS = build-pre.h dummyin6.h ebnet.h getaddrinfo.h linebuf.h \ 23 | urlparts.h 24 | nodist_noinst_HEADERS = build-post.h 25 | 26 | INCLUDES = -DEB_BUILD_LIBRARY $(INTLINCS) $(ZLIBINCS) 27 | 28 | EXTRA_DIST = stamp-widealt-h stamp-widefont-h build-post.h.in 29 | CLEANFILES = stamp-build-post-h stamp-sysdefs-h build-post.h sysdefs.h 30 | MAINTAINERCLEANFILES = stamp-widealt-h stamp-widefont-h widealt.c widefont.c 31 | BUILT_SOURCES = build-post.h sysdefs.h widealt.c widefont.c 32 | 33 | sysdefs.h: stamp-sysdefs-h 34 | stamp-sysdefs-h: Makefile 35 | rm -f sysdefs.h.tmp 36 | echo '/* automatically generated by Makefile. */' > sysdefs.h.tmp 37 | echo '#define EB_VERSION_STRING "$(VERSION)"' >> sysdefs.h.tmp 38 | echo '#define EB_VERSION_MAJOR $(EB_VERSION_MAJOR)' >> sysdefs.h.tmp 39 | echo '#define EB_VERSION_MINOR $(EB_VERSION_MINOR)' >> sysdefs.h.tmp 40 | if test X$(ENABLE_EBNET) = Xyes; then \ 41 | echo '#define EB_ENABLE_EBNET 1' >> sysdefs.h.tmp; \ 42 | fi 43 | if test X$(ENABLE_PTHREAD) = Xyes; then \ 44 | echo '#define EB_ENABLE_PTHREAD 1' >> sysdefs.h.tmp; \ 45 | fi 46 | $(top_srcdir)/move-if-change sysdefs.h.tmp sysdefs.h 47 | @echo timestamp > stamp-sysdefs-h 48 | 49 | build-post.h: stamp-build-post-h 50 | stamp-build-post-h: build-post.h.in Makefile 51 | rm -f build-post.h.tmp 52 | echo '/* automatically generated from build-post.h.in. */' \ 53 | > build-post.h 54 | sed -e 's;\@localedir\@;$(localedir);' \ 55 | $(srcdir)/build-post.h.in >> build-post.h.tmp 56 | $(top_srcdir)/move-if-change build-post.h.tmp build-post.h 57 | @echo timestamp > stamp-build-post-h 58 | 59 | widealt.c: stamp-widealt-h 60 | stamp-widealt-h: narwalt.c Makefile 61 | rm -f widealt.c.tmp 62 | echo '/* automatically generated from narwalt.c. */' \ 63 | > widealt.c.tmp 64 | sed -e s/narrow/wide/g -e s/Narrow/Wide/g -e s/NARROW/WIDE/g \ 65 | $(srcdir)/narwalt.c >> widealt.c.tmp 66 | $(top_srcdir)/move-if-change widealt.c.tmp widealt.c 67 | @echo timestamp > stamp-widealt-h 68 | 69 | widefont.c: stamp-widefont-h 70 | stamp-widefont-h: narwfont.c Makefile 71 | rm -f widefont.c.tmp 72 | echo '/* automatically generated from narwfont.c. */' \ 73 | > widefont.c.tmp 74 | sed -e s/narrow/wide/g -e s/Narrow/Wide/g -e s/NARROW/WIDE/g \ 75 | $(srcdir)/narwfont.c >> widefont.c.tmp 76 | $(top_srcdir)/move-if-change widefont.c.tmp widefont.c 77 | @echo timestamp > stamp-widefont-h 78 | -------------------------------------------------------------------------------- /eb/lock.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #include "build-pre.h" 30 | #include "defs.h" 31 | #include "build-post.h" 32 | 33 | /* 34 | * Examine whether built library supports Pthread. 35 | */ 36 | int 37 | eb_pthread_enabled(void) 38 | { 39 | #ifdef ENABLE_PTHREAD 40 | return 1; 41 | #else 42 | return 0; 43 | #endif 44 | } 45 | 46 | 47 | /* 48 | * These functions are compiled only when ENABLE_PTHREAD is defined. 49 | */ 50 | #ifdef ENABLE_PTHREAD 51 | 52 | /* 53 | * Ininialize a lock manager. 54 | */ 55 | void 56 | eb_initialize_lock(EB_Lock *lock) 57 | { 58 | pthread_mutex_init(&lock->lock_count_mutex, NULL); 59 | pthread_mutex_init(&lock->entity_mutex, NULL); 60 | lock->lock_count = 0; 61 | } 62 | 63 | 64 | /* 65 | * Finalize a lock manager. 66 | */ 67 | void 68 | eb_finalize_lock(EB_Lock *lock) 69 | { 70 | /* Nothing to be done. */ 71 | } 72 | 73 | 74 | /* 75 | * Lock an entity. 76 | */ 77 | void 78 | eb_lock(EB_Lock *lock) 79 | { 80 | pthread_mutex_lock(&lock->lock_count_mutex); 81 | if (lock->lock_count == 0) 82 | pthread_mutex_lock(&lock->entity_mutex); 83 | lock->lock_count++; 84 | pthread_mutex_unlock(&lock->lock_count_mutex); 85 | } 86 | 87 | 88 | /* 89 | * Unlock an entity. 90 | */ 91 | void 92 | eb_unlock(EB_Lock *lock) 93 | { 94 | pthread_mutex_lock(&lock->lock_count_mutex); 95 | if (0 < lock->lock_count) { 96 | lock->lock_count--; 97 | if (lock->lock_count == 0) 98 | pthread_mutex_unlock(&lock->entity_mutex); 99 | } 100 | pthread_mutex_unlock(&lock->lock_count_mutex); 101 | } 102 | 103 | #endif /* ENABLE_PTHREAD */ 104 | -------------------------------------------------------------------------------- /eb/jacode.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #include "build-pre.h" 30 | 31 | /* 32 | * Convert a string from JIS X 0208 to EUC JP. 33 | */ 34 | void 35 | eb_jisx0208_to_euc(char *out_string, const char *in_string) 36 | { 37 | unsigned char *out_p = (unsigned char *)out_string; 38 | const unsigned char *in_p = (unsigned char *)in_string; 39 | 40 | while (*in_p != '\0') 41 | *out_p++ = ((*in_p++) | 0x80); 42 | 43 | *out_p = '\0'; 44 | } 45 | 46 | 47 | /* 48 | * Convert a string from shift-JIS to EUC JP. 49 | * (Shift-JIS is used only in the `LANGUAGE' file.) 50 | */ 51 | void 52 | eb_sjis_to_euc(char *out_string, const char *in_string) 53 | { 54 | unsigned char *out_p = (unsigned char *)out_string; 55 | const unsigned char *in_p = (unsigned char *)in_string; 56 | unsigned char c1, c2; 57 | 58 | for (;;) { 59 | /* 60 | * Break at '\0'. 61 | */ 62 | c1 = *in_p++; 63 | if (c1 == '\0') 64 | break; 65 | 66 | if (c1 <= 0x7f) { 67 | /* 68 | * JIS X 0201 Roman character. 69 | */ 70 | *out_p++ = c1; 71 | } else if (0xa1 <= c1 && c1 <= 0xdf) { 72 | /* 73 | * JIS X 0201 Kana. 74 | */ 75 | *out_p++ = ' '; 76 | } else { 77 | /* 78 | * JIS X 0208 character. 79 | */ 80 | c2 = *in_p++; 81 | if (c2 == 0x00) 82 | break; 83 | 84 | if (c2 < 0x9f) { 85 | if (c1 < 0xdf) 86 | c1 = ((c1 - 0x30) << 1) - 1; 87 | else 88 | c1 = ((c1 - 0x70) << 1) - 1; 89 | 90 | if (c2 < 0x7f) 91 | c2 += 0x61; 92 | else 93 | c2 += 0x60; 94 | } else { 95 | if (c1 < 0xdf) 96 | c1 = (c1 - 0x30) << 1; 97 | else 98 | c1 = (c1 - 0x70) << 1; 99 | c2 += 0x02; 100 | } 101 | 102 | *out_p++ = c1; 103 | *out_p++ = c2; 104 | } 105 | } 106 | 107 | *out_p = '\0'; 108 | } 109 | 110 | 111 | -------------------------------------------------------------------------------- /libebutils/strcasecmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifdef HAVE_CONFIG_H 30 | #include "config.h" 31 | #endif 32 | 33 | #include 34 | 35 | /* 36 | * Compare strings. 37 | * Cases in the strings are insensitive. 38 | */ 39 | int 40 | strcasecmp(const char *string1, const char *string2) 41 | { 42 | const unsigned char *string1_p = (const unsigned char *)string1; 43 | const unsigned char *string2_p = (const unsigned char *)string2; 44 | int c1, c2; 45 | 46 | while (*string1_p != '\0') { 47 | if ('a' <= *string1_p && *string1_p <= 'z') 48 | c1 = *string1_p - ('a' - 'A'); 49 | else 50 | c1 = *string1_p; 51 | 52 | if ('a' <= *string2_p && *string2_p <= 'z') 53 | c2 = *string2_p - ('a' - 'A'); 54 | else 55 | c2 = *string2_p; 56 | 57 | if (c1 != c2) 58 | return c1 - c2; 59 | 60 | string1_p++; 61 | string2_p++; 62 | } 63 | 64 | return -(*string2_p); 65 | } 66 | 67 | 68 | /* 69 | * Compare strings within `n' characters. 70 | * Cases in the strings are insensitive. 71 | */ 72 | int 73 | strncasecmp(const char *string1, const char *string2, size_t n) 74 | { 75 | const unsigned char *string1_p = (const unsigned char *)string1; 76 | const unsigned char *string2_p = (const unsigned char *)string2; 77 | size_t i = n; 78 | int c1, c2; 79 | 80 | if (i <= 0) 81 | return 0; 82 | 83 | while (*string1_p != '\0') { 84 | if ('a' <= *string1_p && *string1_p <= 'z') 85 | c1 = *string1_p - ('a' - 'A'); 86 | else 87 | c1 = *string1_p; 88 | 89 | if ('a' <= *string2_p && *string2_p <= 'z') 90 | c2 = *string2_p - ('a' - 'A'); 91 | else 92 | c2 = *string2_p; 93 | 94 | if (c1 != c2) 95 | return c1 - c2; 96 | 97 | string1_p++; 98 | string2_p++; 99 | i--; 100 | if (i <= 0) 101 | return 0; 102 | } 103 | 104 | return -(*string2_p); 105 | } 106 | -------------------------------------------------------------------------------- /eb/bcd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #include "build-pre.h" 30 | #include "eb.h" 31 | #include "error.h" 32 | #include "build-post.h" 33 | 34 | /* 35 | * Get a BCD (binary coded decimal) packed integer with 2 bytes 36 | * from an octet stream. 37 | */ 38 | unsigned 39 | eb_bcd2(const char *stream) 40 | { 41 | unsigned value; 42 | const unsigned char *s = (const unsigned char *)stream; 43 | 44 | value = ((*(s ) >> 4) & 0x0f) * 1000; 45 | value += ((*(s ) ) & 0x0f) * 100; 46 | value += ((*(s + 1) >> 4) & 0x0f) * 10; 47 | value += ((*(s + 1) ) & 0x0f); 48 | 49 | return value; 50 | } 51 | 52 | 53 | /* 54 | * Get a BCD (binary coded decimal) packed integer with 4 bytes 55 | * from an octet stream. 56 | */ 57 | unsigned 58 | eb_bcd4(const char *stream) 59 | { 60 | unsigned value; 61 | const unsigned char *s = (const unsigned char *)stream; 62 | 63 | value = ((*(s ) >> 4) & 0x0f) * 10000000; 64 | value += ((*(s ) ) & 0x0f) * 1000000; 65 | value += ((*(s + 1) >> 4) & 0x0f) * 100000; 66 | value += ((*(s + 1) ) & 0x0f) * 10000; 67 | value += ((*(s + 2) >> 4) & 0x0f) * 1000; 68 | value += ((*(s + 2) ) & 0x0f) * 100; 69 | value += ((*(s + 3) >> 4) & 0x0f) * 10; 70 | value += ((*(s + 3) ) & 0x0f); 71 | 72 | return value; 73 | } 74 | 75 | 76 | /* 77 | * Get a BCD (binary coded decimal) packed integer with 6 bytes 78 | * from an octet stream. 79 | */ 80 | unsigned 81 | eb_bcd6(const char *stream) 82 | { 83 | unsigned value; 84 | const unsigned char *s = (const unsigned char *)stream; 85 | 86 | value = ((*(s + 1) ) & 0x0f); 87 | value += ((*(s + 2) >> 4) & 0x0f) * 10; 88 | value += ((*(s + 2) ) & 0x0f) * 100; 89 | value += ((*(s + 3) >> 4) & 0x0f) * 1000; 90 | value += ((*(s + 3) ) & 0x0f) * 10000; 91 | value += ((*(s + 4) >> 4) & 0x0f) * 100000; 92 | value += ((*(s + 4) ) & 0x0f) * 1000000; 93 | value += ((*(s + 5) >> 4) & 0x0f) * 10000000; 94 | value += ((*(s + 5) ) & 0x0f) * 100000000; 95 | 96 | return value; 97 | } 98 | 99 | 100 | -------------------------------------------------------------------------------- /eb/strcasecmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | /* 30 | * This program requires the following Autoconf macros: 31 | */ 32 | 33 | #ifdef HAVE_CONFIG_H 34 | #include "config.h" 35 | #else 36 | 37 | /* Define to empty if the keyword `const' does not work. */ 38 | /* #define const */ 39 | 40 | /* Define if `size_t' is not defined. */ 41 | /* #define size_t unsigned */ 42 | 43 | #endif /* not HAVE_CONFIG_H */ 44 | 45 | #include 46 | 47 | /* 48 | * Compare strings. 49 | * Cases in the strings are insensitive. 50 | */ 51 | int 52 | eb_strcasecmp(const char *string1, const char *string2) 53 | { 54 | const unsigned char *string1_p = (const unsigned char *)string1; 55 | const unsigned char *string2_p = (const unsigned char *)string2; 56 | int c1, c2; 57 | 58 | while (*string1_p != '\0') { 59 | if ('a' <= *string1_p && *string1_p <= 'z') 60 | c1 = *string1_p - ('a' - 'A'); 61 | else 62 | c1 = *string1_p; 63 | 64 | if ('a' <= *string2_p && *string2_p <= 'z') 65 | c2 = *string2_p - ('a' - 'A'); 66 | else 67 | c2 = *string2_p; 68 | 69 | if (c1 != c2) 70 | return c1 - c2; 71 | 72 | string1_p++; 73 | string2_p++; 74 | } 75 | 76 | return -(*string2_p); 77 | } 78 | 79 | 80 | /* 81 | * Compare strings within `n' characters. 82 | * Cases in the strings are insensitive. 83 | */ 84 | int 85 | eb_strncasecmp(const char *string1, const char *string2, size_t n) 86 | { 87 | const unsigned char *string1_p = (const unsigned char *)string1; 88 | const unsigned char *string2_p = (const unsigned char *)string2; 89 | size_t i = n; 90 | int c1, c2; 91 | 92 | if (i <= 0) 93 | return 0; 94 | 95 | while (*string1_p != '\0') { 96 | if ('a' <= *string1_p && *string1_p <= 'z') 97 | c1 = *string1_p - ('a' - 'A'); 98 | else 99 | c1 = *string1_p; 100 | 101 | if ('a' <= *string2_p && *string2_p <= 'z') 102 | c2 = *string2_p - ('a' - 'A'); 103 | else 104 | c2 = *string2_p; 105 | 106 | if (c1 != c2) 107 | return c1 - c2; 108 | 109 | string1_p++; 110 | string2_p++; 111 | i--; 112 | if (i <= 0) 113 | return 0; 114 | } 115 | 116 | return -(*string2_p); 117 | } 118 | -------------------------------------------------------------------------------- /eb/text.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #include "build-pre.h" 30 | #include "eb.h" 31 | #include "error.h" 32 | #include "build-post.h" 33 | 34 | /* 35 | * Examine whether the current subbook in `book' has text body. 36 | * or not. 37 | */ 38 | int 39 | eb_have_text(EB_Book *book) 40 | { 41 | eb_lock(&book->lock); 42 | LOG(("in: eb_have_text(book=%d)", (int)book->code)); 43 | 44 | /* 45 | * Current subbook must have been set. 46 | */ 47 | if (book->subbook_current == NULL) 48 | goto failed; 49 | 50 | /* 51 | * Check for the index page of text. 52 | */ 53 | if (book->subbook_current->text.start_page == 0) 54 | goto failed; 55 | 56 | LOG(("out: eb_have_text() = %d", 1)); 57 | eb_unlock(&book->lock); 58 | 59 | return 1; 60 | 61 | /* 62 | * An error occurs... 63 | */ 64 | failed: 65 | LOG(("out: eb_have_text() = %d", 0)); 66 | eb_unlock(&book->lock); 67 | return 0; 68 | } 69 | 70 | 71 | /* 72 | * Menu. 73 | */ 74 | EB_Error_Code 75 | eb_text(EB_Book *book, EB_Position *position) 76 | { 77 | EB_Error_Code error_code; 78 | int page; 79 | 80 | eb_lock(&book->lock); 81 | LOG(("in: eb_text(book=%d)", (int)book->code)); 82 | 83 | /* 84 | * Current subbook must have been set. 85 | */ 86 | if (book->subbook_current == NULL) { 87 | error_code = EB_ERR_NO_CUR_SUB; 88 | goto failed; 89 | } 90 | 91 | /* 92 | * Check for the page number of text. 93 | */ 94 | page = book->subbook_current->text.start_page; 95 | if (page == 0) { 96 | error_code = EB_ERR_NO_SUCH_SEARCH; 97 | goto failed; 98 | } 99 | 100 | /* 101 | * Copy the position to `position'. 102 | */ 103 | position->page = page; 104 | position->offset = 0; 105 | 106 | LOG(("out: eb_text(position={%d,%d}) = %s", 107 | position->page, position->offset, eb_error_string(EB_SUCCESS))); 108 | eb_unlock(&book->lock); 109 | 110 | return EB_SUCCESS; 111 | 112 | /* 113 | * An error occurs... 114 | */ 115 | failed: 116 | LOG(("out: eb_text() = %s", eb_error_string(error_code))); 117 | eb_unlock(&book->lock); 118 | return error_code; 119 | } 120 | 121 | 122 | -------------------------------------------------------------------------------- /eb/stopcode.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #include "build-pre.h" 30 | #include "eb.h" 31 | #include "error.h" 32 | #include "appendix.h" 33 | #include "text.h" 34 | #include "build-post.h" 35 | 36 | /* 37 | * Examine whether the current subbook in `appendix' has a stop-code. 38 | */ 39 | int 40 | eb_have_stop_code(EB_Appendix *appendix) 41 | { 42 | eb_lock(&appendix->lock); 43 | LOG(("in: eb_have_stop_code(appendix=%d)", (int)appendix->code)); 44 | 45 | /* 46 | * Current subbook must have been set. 47 | */ 48 | if (appendix->subbook_current == NULL) 49 | goto failed; 50 | 51 | if (appendix->subbook_current->stop_code0 == 0) 52 | goto failed; 53 | 54 | LOG(("out: eb_have_stop_code() = %d", 1)); 55 | eb_unlock(&appendix->lock); 56 | 57 | return 1; 58 | 59 | /* 60 | * An error occurs... 61 | */ 62 | failed: 63 | LOG(("out: eb_have_stop_code() = %d", 0)); 64 | eb_unlock(&appendix->lock); 65 | return 0; 66 | } 67 | 68 | 69 | /* 70 | * Return the stop-code of the current subbook in `appendix'. 71 | */ 72 | EB_Error_Code 73 | eb_stop_code(EB_Appendix *appendix, int *stop_code) 74 | { 75 | EB_Error_Code error_code; 76 | 77 | eb_lock(&appendix->lock); 78 | LOG(("in: eb_stop_code(appendix=%d)", (int)appendix->code)); 79 | 80 | /* 81 | * Current subbook must have been set. 82 | */ 83 | if (appendix->subbook_current == NULL) { 84 | error_code = EB_ERR_NO_CUR_APPSUB; 85 | goto failed; 86 | } 87 | 88 | if (appendix->subbook_current->stop_code0 == 0) { 89 | error_code = EB_ERR_NO_STOPCODE; 90 | goto failed; 91 | } 92 | 93 | stop_code[0] = appendix->subbook_current->stop_code0; 94 | stop_code[1] = appendix->subbook_current->stop_code1; 95 | 96 | LOG(("out: eb_stop_code(stop_code=%d,%d) = %s", 97 | stop_code[0], stop_code[1], eb_error_string(EB_SUCCESS))); 98 | eb_unlock(&appendix->lock); 99 | 100 | return EB_SUCCESS; 101 | 102 | /* 103 | * An error occurs... 104 | */ 105 | failed: 106 | stop_code[0] = -1; 107 | stop_code[1] = -1; 108 | LOG(("out: eb_stop_code() = %s", eb_error_string(error_code))); 109 | eb_unlock(&appendix->lock); 110 | return error_code; 111 | } 112 | 113 | 114 | -------------------------------------------------------------------------------- /eb/copyright.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #include "build-pre.h" 30 | #include "eb.h" 31 | #include "error.h" 32 | #include "build-post.h" 33 | 34 | /* 35 | * Examine whether the current subbook in `book' have a copyright 36 | * notice or not. 37 | */ 38 | int 39 | eb_have_copyright(EB_Book *book) 40 | { 41 | eb_lock(&book->lock); 42 | LOG(("in: eb_have_copyright(book=%d)", (int)book->code)); 43 | 44 | /* 45 | * Check for the current status. 46 | */ 47 | if (book->subbook_current == NULL) 48 | goto failed; 49 | 50 | /* 51 | * Check for the index page of copyright notice. 52 | */ 53 | if (book->subbook_current->copyright.start_page == 0) 54 | goto failed; 55 | 56 | LOG(("out: eb_have_copyright() = %d", 1)); 57 | eb_unlock(&book->lock); 58 | 59 | return 1; 60 | 61 | /* 62 | * An error occurs... 63 | */ 64 | failed: 65 | LOG(("out: eb_have_copyright() = %d", 0)); 66 | eb_unlock(&book->lock); 67 | return 0; 68 | } 69 | 70 | 71 | /* 72 | * Get a position of copyright notice. 73 | */ 74 | EB_Error_Code 75 | eb_copyright(EB_Book *book, EB_Position *position) 76 | { 77 | EB_Error_Code error_code; 78 | int page; 79 | 80 | eb_lock(&book->lock); 81 | LOG(("in: eb_copyright(book=%d)", (int)book->code)); 82 | 83 | /* 84 | * Check for the current status. 85 | */ 86 | if (book->subbook_current == NULL) { 87 | error_code = EB_ERR_NO_CUR_SUB; 88 | goto failed; 89 | } 90 | 91 | /* 92 | * Check for the page number of COPYRIGHT NOTICE. 93 | */ 94 | page = book->subbook_current->copyright.start_page; 95 | if (page == 0) { 96 | error_code = EB_ERR_NO_SUCH_SEARCH; 97 | goto failed; 98 | } 99 | 100 | /* 101 | * Copy the position to `position'. 102 | */ 103 | position->page = page; 104 | position->offset = 0; 105 | 106 | LOG(("out: eb_copyright(position={%d,%d}) = %s", 107 | position->page, position->offset, eb_error_string(EB_SUCCESS))); 108 | eb_unlock(&book->lock); 109 | 110 | return EB_SUCCESS; 111 | 112 | /* 113 | * An error occurs... 114 | */ 115 | failed: 116 | LOG(("out: eb_copyright() = %s", eb_error_string(error_code))); 117 | eb_unlock(&book->lock); 118 | return error_code; 119 | } 120 | 121 | 122 | -------------------------------------------------------------------------------- /m4/in6addr.m4: -------------------------------------------------------------------------------- 1 | dnl * 2 | dnl * Copyright (c) 2001-2006 Motoyuki Kasahara 3 | dnl * 4 | dnl * Redistribution and use in source and binary forms, with or without 5 | dnl * modification, are permitted provided that the following conditions 6 | dnl * are met: 7 | dnl * 1. Redistributions of source code must retain the above copyright 8 | dnl * notice, this list of conditions and the following disclaimer. 9 | dnl * 2. Redistributions in binary form must reproduce the above copyright 10 | dnl * notice, this list of conditions and the following disclaimer in the 11 | dnl * documentation and/or other materials provided with the distribution. 12 | dnl * 3. Neither the name of the project nor the names of its contributors 13 | dnl * may be used to endorse or promote products derived from this software 14 | dnl * without specific prior written permission. 15 | dnl * 16 | dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | dnl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE 20 | dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 | dnl * THE POSSIBILITY OF SUCH DAMAGE. 27 | dnl * 28 | 29 | dnl * 30 | dnl * Check for struct in6_addr 31 | dnl * 32 | AC_DEFUN([AC_STRUCT_IN6_ADDR], 33 | [AC_CACHE_CHECK(for struct in6_addr, ac_cv_struct_in6_addr, 34 | [AC_COMPILE_IFELSE([ 35 | #include 36 | #include 37 | #include 38 | struct in6_addr address; 39 | ], [ac_cv_struct_in6_addr=yes], [ac_cv_struct_in6_addr=no])]) 40 | if test "$ac_cv_struct_in6_addr" = yes; then 41 | AC_DEFINE(HAVE_STRUCT_IN6_ADDR, 1, 42 | [Define to 1 if defines `struct in6_addr']) 43 | fi]) 44 | 45 | dnl * 46 | dnl * Check for in6addr_any. 47 | dnl * 48 | AC_DEFUN([AC_DECL_IN6ADDR_ANY], 49 | [AC_REQUIRE([AC_STRUCT_IN6_ADDR]) 50 | if test $ac_cv_struct_in6_addr = no; then 51 | ac_cv_decl_in6addr_any=no 52 | else 53 | AC_CACHE_CHECK(for in6addr_any declaration in netinet/in.h, 54 | ac_cv_decl_in6addr_any, 55 | [AC_COMPILE_IFELSE([ 56 | #include 57 | #include 58 | #include 59 | 60 | void 61 | testfunc() 62 | { 63 | unsigned char *address; 64 | address = (char *)&in6addr_any; 65 | } 66 | ], [ac_cv_decl_in6addr_any=yes], [ac_cv_decl_in6addr_any=no])]) 67 | if test "$ac_cv_decl_in6addr_any" = yes; then 68 | AC_DEFINE(IN6ADDR_ANY_DECLARED, 1, 69 | [Define to 1 if `in6addr_any' is declared by ]) 70 | fi 71 | fi]) 72 | 73 | dnl * 74 | dnl * Check for in6addr_loopback. 75 | dnl * 76 | AC_DEFUN([AC_DECL_IN6ADDR_LOOPBACK], 77 | [AC_REQUIRE([AC_STRUCT_IN6_ADDR]) 78 | if test $ac_cv_struct_in6_addr = no; then 79 | ac_cv_decl_in6addr_loopback=no 80 | else 81 | AC_CACHE_CHECK(for in6addr_loopback declaration in netinet/in.h, 82 | ac_cv_decl_in6addr_loopback, 83 | [AC_COMPILE_IFELSE([ 84 | #include 85 | #include 86 | #include 87 | 88 | int 89 | testfunc() 90 | { 91 | unsigned char *address; 92 | address = (char *)&in6addr_loopback; 93 | } 94 | ], [ac_cv_decl_in6addr_loopback=yes], [ac_cv_decl_in6addr_loopback=no])]) 95 | if test "$ac_cv_decl_in6addr_loopback" = yes; then 96 | AC_DEFINE(IN6ADDR_LOOPBACK_DECLARED, 1, 97 | [Define to 1 if `in6addr_loopback' is declared by ]) 98 | fi 99 | fi]) 100 | -------------------------------------------------------------------------------- /eb/ebnet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef EBNET_H 30 | #define EBNET_H 31 | 32 | #ifdef HAVE_CONFIG_H 33 | #include "config.h" 34 | #endif 35 | 36 | #include 37 | #include "eb.h" 38 | 39 | /* 40 | * Service name. 41 | */ 42 | #define EBNET_SERVICE_NAME "ebnet" 43 | 44 | /* 45 | * Default port number. 46 | */ 47 | #define EBNET_DEFAULT_PORT "22010" 48 | 49 | /* 50 | * Maximum length of book name. 51 | * EBNETD defins 14, but we add +4 for the ".app" suffix here. 52 | */ 53 | #define EBNET_MAX_BOOK_NAME_LENGTH 18 54 | 55 | /* 56 | * Maximum length of book title. 57 | * EBNETD defins 80, and EB Library uses the same value. 58 | */ 59 | #define EBNET_MAX_BOOK_TITLE_LENGTH 80 60 | 61 | /* 62 | * Maximum length of an EBNET request or response line. 63 | */ 64 | #define EBNET_MAX_LINE_LENGTH 511 65 | 66 | /* 67 | * Timeout period in seconds. 68 | */ 69 | #define EBNET_TIMEOUT_SECONDS 30 70 | 71 | /* 72 | * Function declarations. 73 | */ 74 | /* multiplex.c */ 75 | void ebnet_initialize_multiplex(void); 76 | void ebnet_finalize(void); 77 | void ebnet_set_hello_hook(int (*hook)(int file)); 78 | void ebnet_set_bye_hook(int (*hook)(int file)); 79 | int ebnet_connect_socket(const char *host, int port, int family); 80 | void ebnet_disconnect_socket(int file); 81 | int ebnet_reconnect_socket(int file); 82 | int ebnet_set_lost_sync(int file); 83 | int ebnet_set_book_name(int file, const char *book_name); 84 | const char *ebnet_get_book_name(int file); 85 | int ebnet_set_file_path(int file, const char *file_path); 86 | const char *ebnet_get_file_path(int file); 87 | int ebnet_set_offset(int file, off_t offset); 88 | off_t ebnet_get_offset(int file); 89 | int ebnet_set_file_size(int file, off_t file_size); 90 | off_t ebnet_get_file_size(int file); 91 | 92 | /* ebnet.c */ 93 | void ebnet_initialize(void); 94 | EB_Error_Code ebnet_bind_booklist(EB_BookList *booklist, const char *url); 95 | EB_Error_Code ebnet_bind(EB_Book *book, const char *url); 96 | EB_Error_Code ebnet_bind_appendix(EB_Appendix *appendix, const char *url); 97 | void ebnet_finalize_book(EB_Book *book); 98 | void ebnet_finalize_appendix(EB_Appendix *appendix); 99 | int ebnet_open(const char *url); 100 | int ebnet_close(int file); 101 | off_t ebnet_lseek(int file, off_t offset, int whence); 102 | ssize_t ebnet_read(int *file, char *buffer, size_t length); 103 | EB_Error_Code ebnet_fix_directory_name(const char *url, char *directory_name); 104 | EB_Error_Code ebnet_find_file_name(const char *url, 105 | const char *target_file_name, char *found_file_name); 106 | EB_Error_Code ebnet_canonicalize_url(char *url); 107 | 108 | #endif /* EBNET_H */ 109 | -------------------------------------------------------------------------------- /m4/eb4.m4: -------------------------------------------------------------------------------- 1 | dnl * 2 | dnl * Make ready to link EB Library 3.x or 4.x. 3 | dnl * 4 | dnl * Copyright (c) 2000-2006 Motoyuki Kasahara 5 | dnl * 6 | dnl * Redistribution and use in source and binary forms, with or without 7 | dnl * modification, are permitted provided that the following conditions 8 | dnl * are met: 9 | dnl * 1. Redistributions of source code must retain the above copyright 10 | dnl * notice, this list of conditions and the following disclaimer. 11 | dnl * 2. Redistributions in binary form must reproduce the above copyright 12 | dnl * notice, this list of conditions and the following disclaimer in the 13 | dnl * documentation and/or other materials provided with the distribution. 14 | dnl * 3. Neither the name of the project nor the names of its contributors 15 | dnl * may be used to endorse or promote products derived from this software 16 | dnl * without specific prior written permission. 17 | dnl * 18 | dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | dnl * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | dnl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | dnl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | dnl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | dnl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | dnl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | dnl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | dnl * SUCH DAMAGE. 29 | dnl * 30 | 31 | AC_DEFUN([eb_LIB_EB4], 32 | [dnl 33 | dnl * 34 | dnl * Requirements. 35 | dnl * 36 | AC_REQUIRE([AC_PROG_CC]) 37 | AC_REQUIRE([AC_PROG_LIBTOOL]) 38 | AC_REQUIRE([AC_TYPE_OFF_T]) 39 | AC_REQUIRE([AC_TYPE_SIZE_T]) 40 | 41 | AC_CHECK_HEADERS(limits.h) 42 | AC_CHECK_TYPE(ssize_t, int) 43 | 44 | dnl * 45 | dnl * --with-eb-conf option. 46 | dnl * 47 | AC_ARG_WITH(eb-conf, 48 | AC_HELP_STRING([--with-eb-conf=FILE], 49 | [eb.conf file is FILE [[SYSCONFDIR/eb.conf]]]), 50 | [ebconf="${withval}"], [ebconf=$sysconfdir/eb.conf]) 51 | if test X$prefix = XNONE; then 52 | PREFIX=$ac_default_prefix 53 | else 54 | PREFIX=$prefix 55 | fi 56 | ebconf=`echo X$ebconf | sed -e 's/^X//' -e 's;\${prefix};'"$PREFIX;g" \ 57 | -e 's;\$(prefix);'"$PREFIX;g"` 58 | 59 | dnl * 60 | dnl * Read eb.conf 61 | dnl * 62 | AC_MSG_CHECKING(for eb.conf) 63 | AC_MSG_RESULT($ebconf) 64 | if test -f ${ebconf}; then 65 | . ${ebconf} 66 | else 67 | AC_MSG_ERROR($ebconf not found) 68 | fi 69 | 70 | if test X$EBCONF_ENABLE_PTHREAD = Xyes; then 71 | AC_DEFINE(EBCONF_ENABLE_PTHREAD, 1, 72 | [Define if EB Library supports pthread.]) 73 | fi 74 | if test X$EBCONF_ENABLE_NLS = Xyes; then 75 | AC_DEFINE(EBCONF_ENABLE_NLS, 1, 76 | [Define if EB Library supports native language.]) 77 | fi 78 | if test X$EBCONF_ENABLE_EBNET = Xyes; then 79 | AC_DEFINE(EBCONF_ENABLE_EBNET, 1, 80 | [Define if EB Library supports remote access.]) 81 | fi 82 | 83 | AC_SUBST(EBCONF_EBINCS) 84 | AC_SUBST(EBCONF_EBLIBS) 85 | AC_SUBST(EBCONF_ZLIBINCS) 86 | AC_SUBST(EBCONF_ZLIBLIBS) 87 | AC_SUBST(EBCONF_PTHREAD_CPPFLAGS) 88 | AC_SUBST(EBCONF_PTHREAD_CFLAGS) 89 | AC_SUBST(EBCONF_PTHREAD_LDFLAGS) 90 | AC_SUBST(EBCONF_INTLINCS) 91 | AC_SUBST(EBCONF_INTLLIBS) 92 | 93 | dnl * 94 | dnl * Check for EB Library. 95 | dnl * 96 | AC_MSG_CHECKING(for EB Library) 97 | save_CPPFLAGS=$CPPFLAGS 98 | save_CFLAGS=$CFLAGS 99 | save_LDFLAGS=$LDFLAGS 100 | save_LIBS=$LIBS 101 | CPPFLAGS="$CPPFLAGS $EBCONF_PTHREAD_CPPFLAGS $EBCONF_EBINCS $EBCONF_ZLIBINCS $EBCONF_INTLINCS" 102 | CFLAGS="$CFLAGS $EBCONF_PTHREAD_CFLAGS" 103 | LDFLAGS="$LDFAGS $EBCONF_PTHREAD_LDFLAGS" 104 | LIBS="$LIBS $EBCONF_EBLIBS $EBCONF_ZLIBLIBS $EBCONF_INTLLIBS" 105 | AC_TRY_LINK([#include ], 106 | [eb_initialize_library(); return 0;], 107 | try_eb=yes, try_eb=no) 108 | CPPFLAGS=$save_CPPFLAGS 109 | CFLAGS=$save_CFLAGS 110 | LDFLAGS=$save_LDFLAGS 111 | LIBS=$save_LIBS 112 | AC_MSG_RESULT($try_eb) 113 | if test ${try_eb} != yes; then 114 | AC_MSG_ERROR(EB Library not available) 115 | fi 116 | ]) 117 | -------------------------------------------------------------------------------- /compile: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Wrapper for compilers which do not understand `-c -o'. 3 | 4 | scriptversion=2005-05-14.22 5 | 6 | # Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 7 | # Written by Tom Tromey . 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | 23 | # As a special exception to the GNU General Public License, if you 24 | # distribute this file as part of a program that contains a 25 | # configuration script generated by Autoconf, you may include it under 26 | # the same distribution terms that you use for the rest of that program. 27 | 28 | # This file is maintained in Automake, please report 29 | # bugs to or send patches to 30 | # . 31 | 32 | case $1 in 33 | '') 34 | echo "$0: No command. Try \`$0 --help' for more information." 1>&2 35 | exit 1; 36 | ;; 37 | -h | --h*) 38 | cat <<\EOF 39 | Usage: compile [--help] [--version] PROGRAM [ARGS] 40 | 41 | Wrapper for compilers which do not understand `-c -o'. 42 | Remove `-o dest.o' from ARGS, run PROGRAM with the remaining 43 | arguments, and rename the output as expected. 44 | 45 | If you are trying to build a whole package this is not the 46 | right script to run: please start by reading the file `INSTALL'. 47 | 48 | Report bugs to . 49 | EOF 50 | exit $? 51 | ;; 52 | -v | --v*) 53 | echo "compile $scriptversion" 54 | exit $? 55 | ;; 56 | esac 57 | 58 | ofile= 59 | cfile= 60 | eat= 61 | 62 | for arg 63 | do 64 | if test -n "$eat"; then 65 | eat= 66 | else 67 | case $1 in 68 | -o) 69 | # configure might choose to run compile as `compile cc -o foo foo.c'. 70 | # So we strip `-o arg' only if arg is an object. 71 | eat=1 72 | case $2 in 73 | *.o | *.obj) 74 | ofile=$2 75 | ;; 76 | *) 77 | set x "$@" -o "$2" 78 | shift 79 | ;; 80 | esac 81 | ;; 82 | *.c) 83 | cfile=$1 84 | set x "$@" "$1" 85 | shift 86 | ;; 87 | *) 88 | set x "$@" "$1" 89 | shift 90 | ;; 91 | esac 92 | fi 93 | shift 94 | done 95 | 96 | if test -z "$ofile" || test -z "$cfile"; then 97 | # If no `-o' option was seen then we might have been invoked from a 98 | # pattern rule where we don't need one. That is ok -- this is a 99 | # normal compilation that the losing compiler can handle. If no 100 | # `.c' file was seen then we are probably linking. That is also 101 | # ok. 102 | exec "$@" 103 | fi 104 | 105 | # Name of file we expect compiler to create. 106 | cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'` 107 | 108 | # Create the lock directory. 109 | # Note: use `[/.-]' here to ensure that we don't use the same name 110 | # that we are using for the .o file. Also, base the name on the expected 111 | # object file name, since that is what matters with a parallel build. 112 | lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d 113 | while true; do 114 | if mkdir "$lockdir" >/dev/null 2>&1; then 115 | break 116 | fi 117 | sleep 1 118 | done 119 | # FIXME: race condition here if user kills between mkdir and trap. 120 | trap "rmdir '$lockdir'; exit 1" 1 2 15 121 | 122 | # Run the compile. 123 | "$@" 124 | ret=$? 125 | 126 | if test -f "$cofile"; then 127 | mv "$cofile" "$ofile" 128 | elif test -f "${cofile}bj"; then 129 | mv "${cofile}bj" "$ofile" 130 | fi 131 | 132 | rmdir "$lockdir" 133 | exit $ret 134 | 135 | # Local Variables: 136 | # mode: shell-script 137 | # sh-indentation: 2 138 | # eval: (add-hook 'write-file-hooks 'time-stamp) 139 | # time-stamp-start: "scriptversion=" 140 | # time-stamp-format: "%:y-%02m-%02d.%02H" 141 | # time-stamp-end: "$" 142 | # End: 143 | -------------------------------------------------------------------------------- /eb/appendix.h: -------------------------------------------------------------------------------- 1 | /* -*- C -*- 2 | * Copyright (c) 1997-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef EB_APPENDIX_H 30 | #define EB_APPENDIX_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | #ifdef EB_BUILD_LIBRARY 37 | #include "eb.h" 38 | #else 39 | #include 40 | #endif 41 | 42 | /* 43 | * Function declarations. 44 | */ 45 | /* appendix.c */ 46 | void eb_initialize_appendix(EB_Appendix *appendix); 47 | void eb_finalize_appendix(EB_Appendix *appendix); 48 | EB_Error_Code eb_bind_appendix(EB_Appendix *appendix, const char *path); 49 | int eb_is_appendix_bound(EB_Appendix *appendix); 50 | EB_Error_Code eb_appendix_path(EB_Appendix *appendix, char *path); 51 | 52 | /* appsub.c */ 53 | EB_Error_Code eb_load_all_appendix_subbooks(EB_Appendix *appendix); 54 | EB_Error_Code eb_appendix_subbook_list(EB_Appendix *appendix, 55 | EB_Subbook_Code *subbook_list, int *subbook_count); 56 | EB_Error_Code eb_appendix_subbook(EB_Appendix *appendix, 57 | EB_Subbook_Code *subbook_code); 58 | EB_Error_Code eb_appendix_subbook_directory(EB_Appendix *appendix, 59 | char *directory); 60 | EB_Error_Code eb_appendix_subbook_directory2(EB_Appendix *appendix, 61 | EB_Subbook_Code subbook_code, char *directory); 62 | EB_Error_Code eb_set_appendix_subbook(EB_Appendix *appendix, 63 | EB_Subbook_Code subbook_code); 64 | void eb_unset_appendix_subbook(EB_Appendix *appendix); 65 | 66 | /* narwalt.c */ 67 | int eb_have_narrow_alt(EB_Appendix *appendix); 68 | EB_Error_Code eb_narrow_alt_start(EB_Appendix *appendix, int *start); 69 | EB_Error_Code eb_narrow_alt_end(EB_Appendix *appendix, int *end); 70 | EB_Error_Code eb_narrow_alt_character_text(EB_Appendix *appendix, 71 | int character_number, char *text); 72 | EB_Error_Code eb_forward_narrow_alt_character(EB_Appendix *appendix, 73 | int n, int *character_number); 74 | EB_Error_Code eb_backward_narrow_alt_character(EB_Appendix *appendix, 75 | int n, int *character_number); 76 | 77 | /* stopcode.c */ 78 | int eb_have_stop_code(EB_Appendix *appendix); 79 | EB_Error_Code eb_stop_code(EB_Appendix *appendix, int *); 80 | 81 | /* widealt.c */ 82 | int eb_have_wide_alt(EB_Appendix *appendix); 83 | EB_Error_Code eb_wide_alt_start(EB_Appendix *appendix, int *start); 84 | EB_Error_Code eb_wide_alt_end(EB_Appendix *appendix, int *end); 85 | EB_Error_Code eb_wide_alt_character_text(EB_Appendix *appendix, 86 | int character_number, char *text); 87 | EB_Error_Code eb_forward_wide_alt_character(EB_Appendix *appendix, int n, 88 | int *character_number); 89 | EB_Error_Code eb_backward_wide_alt_character(EB_Appendix *appendix, int n, 90 | int *character_number); 91 | 92 | /* for backward compatibility */ 93 | #define eb_suspend_appendix eb_unset_appendix_subbook 94 | #define eb_initialize_all_appendix_subbooks eb_load_all_appendix_subbooks 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #endif /* not EB_APPENDIX_H */ 101 | -------------------------------------------------------------------------------- /eb/build-pre.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef EB_BUILD_PRE_H 30 | #define EB_BUILD_PRE_H 31 | 32 | #ifdef HAVE_CONFIG_H 33 | #include "config.h" 34 | #endif 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | #ifdef HAVE_DIRECT_H 50 | #include 51 | #endif 52 | 53 | #ifdef HAVE__GETDCWD 54 | #define getcwd _getcwd 55 | #define getdcwd _getdcwd 56 | #endif 57 | 58 | #ifdef ENABLE_PTHREAD 59 | #include 60 | #endif 61 | 62 | #ifdef ENABLE_NLS 63 | #include 64 | #endif 65 | 66 | /* 67 | * Mutual exclusion lock of Pthreads. 68 | */ 69 | #ifndef ENABLE_PTHREAD 70 | #define pthread_mutex_lock(m) 71 | #define pthread_mutex_unlock(m) 72 | #endif 73 | 74 | /* 75 | * stat() macros. 76 | */ 77 | #ifndef S_ISREG 78 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 79 | #endif 80 | #ifndef S_ISDIR 81 | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 82 | #endif 83 | 84 | /* 85 | * Flags for open(). 86 | */ 87 | #ifndef O_BINARY 88 | #define O_BINARY 0 89 | #endif 90 | 91 | /* 92 | * Character type tests and conversions. 93 | */ 94 | #define ASCII_ISDIGIT(c) ('0' <= (c) && (c) <= '9') 95 | #define ASCII_ISUPPER(c) ('A' <= (c) && (c) <= 'Z') 96 | #define ASCII_ISLOWER(c) ('a' <= (c) && (c) <= 'z') 97 | #define ASCII_ISALPHA(c) \ 98 | (ASCII_ISUPPER(c) || ASCII_ISLOWER(c)) 99 | #define ASCII_ISALNUM(c) \ 100 | (ASCII_ISUPPER(c) || ASCII_ISLOWER(c) || ASCII_ISDIGIT(c)) 101 | #define ASCII_ISXDIGIT(c) \ 102 | (ASCII_ISDIGIT(c) || ('A' <= (c) && (c) <= 'F') || ('a' <= (c) && (c) <= 'f')) 103 | #define ASCII_TOUPPER(c) (('a' <= (c) && (c) <= 'z') ? (c) - 0x20 : (c)) 104 | #define ASCII_TOLOWER(c) (('A' <= (c) && (c) <= 'Z') ? (c) + 0x20 : (c)) 105 | 106 | /* 107 | * Tricks for gettext. 108 | */ 109 | #ifdef ENABLE_NLS 110 | #define _(string) gettext(string) 111 | #ifdef gettext_noop 112 | #define N_(string) gettext_noop(string) 113 | #else 114 | #define N_(string) (string) 115 | #endif 116 | #else 117 | #define _(string) (string) 118 | #define N_(string) (string) 119 | #endif 120 | 121 | /* 122 | * Fake missing function names. 123 | */ 124 | #ifndef HAVE_STRCASECMP 125 | #define strcasecmp eb_strcasecmp 126 | #define strncasecmp eb_strncasecmp 127 | #endif 128 | 129 | #ifndef HAVE_GETADDRINFO 130 | #define addrinfo ebnet_addrinfo 131 | #define getaddrinfo ebnet_getaddrinfo 132 | #define freeaddrinfo ebnet_freeaddrinfo 133 | #endif 134 | 135 | #ifndef HAVE_GETNAMEINFO 136 | #define getnameinfo ebnet_getnameinfo 137 | #endif 138 | 139 | #ifndef HAVE_GAI_STRERROR 140 | #define gai_strerror ebnet_gai_strerror 141 | #endif 142 | 143 | #ifndef IN6ADDR_ANY_DECLARED 144 | #define in6addr_any ebnet_in6addr_any 145 | #endif 146 | 147 | #ifndef IN6ADDR_LOOPBACK_DECLARED 148 | #define in6addr_loopback ebnet_in6addr_loopback 149 | #endif 150 | 151 | #endif /* EB_BUILD_PRE_H */ 152 | -------------------------------------------------------------------------------- /po-eb/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile for program source directory in GNU NLS utilities package. 2 | # Copyright (C) 1995, 1996, 1997 by Ulrich Drepper 3 | # 4 | # This file file be copied and used freely without restrictions. It can 5 | # be used in projects which are not available under the GNU Public License 6 | # but which still want to provide support for the GNU gettext functionality. 7 | # Please note that the actual code is *not* freely available. 8 | 9 | ## Note that the following macros must be set by your hand. 10 | top_builddir = .. 11 | subdir = po-eb 12 | 13 | TEXTDOMAIN = eb 14 | POFILES = ja.po 15 | MOFILES = ja.mo 16 | POTFILES = \ 17 | $(top_srcdir)/eb/error.c 18 | ## end 19 | 20 | PACKAGE = @PACKAGE@ 21 | VERSION = @VERSION@ 22 | 23 | SHELL = /bin/sh 24 | 25 | srcdir = @srcdir@ 26 | top_srcdir = @top_srcdir@ 27 | VPATH = @srcdir@ 28 | prefix = @prefix@ 29 | datarootdir = @datarootdir@ 30 | datadir = @datadir@ 31 | localedir = @localedir@ 32 | 33 | mkdir_p = @mkdir_p@ 34 | INSTALL = @INSTALL@ 35 | INSTALL_DATA = @INSTALL_DATA@ 36 | mkinstalldirs = $(install_sh) -d 37 | install_sh = @install_sh@ 38 | 39 | MSGFMT = @MSGFMT@ 40 | XGETTEXT = @XGETTEXT@ 41 | MSGMERGE = msgmerge 42 | 43 | DISTFILES = Makefile.in $(TEXTDOMAIN).pot $(MOFILES) $(POFILES) 44 | 45 | .SUFFIXES: 46 | .SUFFIXES: .po .pox .mo 47 | 48 | .po.pox: 49 | $(MAKE) $(TEXTDOMAIN).pot 50 | $(MSGMERGE) $< $(srcdir)/$(TEXTDOMAIN).pot -o $*.pox 51 | 52 | .po.mo: 53 | file=$(srcdir)/`echo $* | sed 's,.*/,,'`.mo \ 54 | && rm -f $$file && $(MSGFMT) -o $$file $< 55 | 56 | all: all-@ENABLE_NLS@ 57 | 58 | all-yes: $(MOFILES) 59 | all-no: 60 | 61 | $(TEXTDOMAIN).pot: $(POTFILES) 62 | $(XGETTEXT) --default-domain=$(TEXTDOMAIN) --add-comments \ 63 | --keyword=_ --keyword=N_ $(POTFILES) \ 64 | && test ! -f $(TEXTDOMAIN).po \ 65 | || ( rm -f $(srcdir)/$(TEXTDOMAIN).pot \ 66 | && mv $(TEXTDOMAIN).po $(srcdir)/$(TEXTDOMAIN).pot ) 67 | 68 | install: install-exec install-data 69 | install-exec: 70 | install-data: install-data-@ENABLE_NLS@ 71 | install-data-no: all 72 | install-data-yes: all 73 | $(mkinstalldirs) $(DESTDIR)$(datadir) 74 | @catalogs='$(MOFILES)'; \ 75 | for cat in $$catalogs; do \ 76 | cat=`echo $$cat | sed 's/^.*\/\([^\/]*\)$$/\1/'` ; \ 77 | lang=`echo $$cat | sed 's/\.mo$$//'`; \ 78 | dir=$(localedir)/$$lang/LC_MESSAGES; \ 79 | $(mkinstalldirs) $(DESTDIR)$$dir; \ 80 | if test -r $$cat; then \ 81 | $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(TEXTDOMAIN).mo; \ 82 | echo "installing $$cat as" \ 83 | "$(DESTDIR)$$dir/$(TEXTDOMAIN).mo"; \ 84 | else \ 85 | $(INSTALL_DATA) $(srcdir)/$$cat \ 86 | $(DESTDIR)$$dir/$(TEXTDOMAIN).mo; \ 87 | echo "installing $(srcdir)/$$cat as" \ 88 | "$(DESTDIR)$$dir/$(TEXTDOMAIN).mo"; \ 89 | fi; \ 90 | done 91 | 92 | # Define this as empty until I found a useful application. 93 | installcheck: 94 | 95 | uninstall: 96 | catalogs='$(MOFILES)'; \ 97 | for cat in $$catalogs; do \ 98 | cat=`echo $$cat | sed 's/^.*\/\([^\/]*\)$$/\1/'` ; \ 99 | lang=`echo $$cat | sed 's/\.mo$$//'`; \ 100 | rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(TEXTDOMAIN).mo; \ 101 | done 102 | rm -f $(DESTDIR)$(gettextsrcdir)/po-Makefile.in 103 | 104 | check: all 105 | 106 | dvi info tags TAGS ID: 107 | 108 | mostlyclean: 109 | rm -f core core.* *.pox $(TEXTDOMAIN).po *.old.po 110 | rm -fr *.o 111 | 112 | clean: mostlyclean 113 | 114 | distclean: clean 115 | rm -f Makefile *.mo 116 | 117 | maintainer-clean: distclean 118 | @echo "This command is intended for maintainers to use;" 119 | @echo "it deletes files that may require special tools to rebuild." 120 | rm -f *.mo 121 | 122 | distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) 123 | dist distdir: update-po $(DISTFILES) 124 | dists="$(DISTFILES)"; \ 125 | for file in $$dists; do \ 126 | ln $(srcdir)/$$file $(distdir) 2> /dev/null \ 127 | || cp -p $(srcdir)/$$file $(distdir); \ 128 | done 129 | 130 | update-po: Makefile 131 | $(MAKE) $(TEXTDOMAIN).pot 132 | cd $(srcdir); \ 133 | catalogs='$(MOFILES)'; \ 134 | for cat in $$catalogs; do \ 135 | cat=`echo $$cat | sed 's/^.*\/\([^\/]*\)$$/\1/'` ; \ 136 | lang=`echo $$cat | sed 's/\.mo$$//'`; \ 137 | mv $$lang.po $$lang.old.po; \ 138 | echo "$$lang:"; \ 139 | if $(MSGMERGE) $$lang.old.po $(TEXTDOMAIN).pot -o $$lang.po; then \ 140 | rm -f $$lang.old.po; \ 141 | else \ 142 | echo "msgmerge for $$cat failed!"; \ 143 | rm -f $$lang.po; \ 144 | mv $$lang.old.po $$lang.po; \ 145 | fi; \ 146 | done 147 | 148 | Makefile: Makefile.in $(top_builddir)/config.status 149 | cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \ 150 | $(SHELL) ./config.status 151 | 152 | # Tell versions [3.59,3.63) of GNU make not to export all variables. 153 | # Otherwise a system limit (for SysV at least) may be exceeded. 154 | .NOEXPORT: 155 | -------------------------------------------------------------------------------- /m4/ltsugar.m4: -------------------------------------------------------------------------------- 1 | # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 2 | # 3 | # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. 4 | # Written by Gary V. Vaughan, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # serial 6 ltsugar.m4 11 | 12 | # This is to help aclocal find these macros, as it can't see m4_define. 13 | AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 14 | 15 | 16 | # lt_join(SEP, ARG1, [ARG2...]) 17 | # ----------------------------- 18 | # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 19 | # associated separator. 20 | # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 21 | # versions in m4sugar had bugs. 22 | m4_define([lt_join], 23 | [m4_if([$#], [1], [], 24 | [$#], [2], [[$2]], 25 | [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 26 | m4_define([_lt_join], 27 | [m4_if([$#$2], [2], [], 28 | [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 29 | 30 | 31 | # lt_car(LIST) 32 | # lt_cdr(LIST) 33 | # ------------ 34 | # Manipulate m4 lists. 35 | # These macros are necessary as long as will still need to support 36 | # Autoconf-2.59 which quotes differently. 37 | m4_define([lt_car], [[$1]]) 38 | m4_define([lt_cdr], 39 | [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 40 | [$#], 1, [], 41 | [m4_dquote(m4_shift($@))])]) 42 | m4_define([lt_unquote], $1) 43 | 44 | 45 | # lt_append(MACRO-NAME, STRING, [SEPARATOR]) 46 | # ------------------------------------------ 47 | # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. 48 | # Note that neither SEPARATOR nor STRING are expanded; they are appended 49 | # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 50 | # No SEPARATOR is output if MACRO-NAME was previously undefined (different 51 | # than defined and empty). 52 | # 53 | # This macro is needed until we can rely on Autoconf 2.62, since earlier 54 | # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 55 | m4_define([lt_append], 56 | [m4_define([$1], 57 | m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 58 | 59 | 60 | 61 | # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 62 | # ---------------------------------------------------------- 63 | # Produce a SEP delimited list of all paired combinations of elements of 64 | # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 65 | # has the form PREFIXmINFIXSUFFIXn. 66 | # Needed until we can rely on m4_combine added in Autoconf 2.62. 67 | m4_define([lt_combine], 68 | [m4_if(m4_eval([$# > 3]), [1], 69 | [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 70 | [[m4_foreach([_Lt_prefix], [$2], 71 | [m4_foreach([_Lt_suffix], 72 | ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 73 | [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 74 | 75 | 76 | # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 77 | # ----------------------------------------------------------------------- 78 | # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 79 | # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 80 | m4_define([lt_if_append_uniq], 81 | [m4_ifdef([$1], 82 | [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 83 | [lt_append([$1], [$2], [$3])$4], 84 | [$5])], 85 | [lt_append([$1], [$2], [$3])$4])]) 86 | 87 | 88 | # lt_dict_add(DICT, KEY, VALUE) 89 | # ----------------------------- 90 | m4_define([lt_dict_add], 91 | [m4_define([$1($2)], [$3])]) 92 | 93 | 94 | # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 95 | # -------------------------------------------- 96 | m4_define([lt_dict_add_subkey], 97 | [m4_define([$1($2:$3)], [$4])]) 98 | 99 | 100 | # lt_dict_fetch(DICT, KEY, [SUBKEY]) 101 | # ---------------------------------- 102 | m4_define([lt_dict_fetch], 103 | [m4_ifval([$3], 104 | m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 105 | m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 106 | 107 | 108 | # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 109 | # ----------------------------------------------------------------- 110 | m4_define([lt_if_dict_fetch], 111 | [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 112 | [$5], 113 | [$6])]) 114 | 115 | 116 | # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 117 | # -------------------------------------------------------------- 118 | m4_define([lt_dict_filter], 119 | [m4_if([$5], [], [], 120 | [lt_join(m4_quote(m4_default([$4], [[, ]])), 121 | lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 122 | [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 123 | ]) 124 | -------------------------------------------------------------------------------- /libebutils/puts_eucjp.c: -------------------------------------------------------------------------------- 1 | /* -*- C -*- 2 | * Copyright (c) 2003-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifdef HAVE_CONFIG_H 30 | #include "config.h" 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #ifdef HAVE_ICONV_H 40 | #include 41 | #endif 42 | 43 | #if defined(HAVE_LIBCHARSET_H) 44 | #include 45 | #elif defined(HAVE_LANGINFO_H) 46 | #include 47 | #endif 48 | 49 | /* 50 | * Convert `string' from EUC-JP to the current locale encoding, and 51 | * then write it to `stream'. 52 | */ 53 | int 54 | fputs_eucjp_to_locale(const char *string, FILE *stream) 55 | { 56 | #if defined(HAVE_ICONV_OPEN) 57 | size_t string_length; 58 | const char *locale_encoding; 59 | char *buffer = NULL; 60 | size_t buffer_size; 61 | iconv_t cd = (iconv_t)-1; 62 | const char *in_p; 63 | char *out_p; 64 | size_t in_left; 65 | size_t out_left; 66 | int fputs_result; 67 | 68 | string_length = strlen(string); 69 | 70 | #if defined(HAVE_LOCALE_CHARSET) 71 | locale_encoding = locale_charset(); 72 | #elif defined(HAVE_NL_LANGINFO) && defined(CODESET) 73 | locale_encoding = nl_langinfo(CODESET); 74 | #else 75 | locale_encoding = NULL; 76 | #endif 77 | if (locale_encoding == NULL) 78 | goto failed; 79 | cd = iconv_open(locale_encoding, "eucJP"); 80 | if (cd == (iconv_t)-1) 81 | cd = iconv_open(locale_encoding, "EUC-JP"); 82 | if (cd == (iconv_t)-1) 83 | goto failed; 84 | 85 | buffer_size = (string_length + 1) * 2; 86 | 87 | for (;;) { 88 | buffer = malloc(buffer_size); 89 | if (buffer == NULL) 90 | goto failed; 91 | 92 | in_p = string; 93 | in_left = string_length + 1; 94 | out_p = buffer; 95 | out_left = buffer_size; 96 | 97 | if (iconv(cd, &in_p, &in_left, &out_p, &out_left) != -1) 98 | break; 99 | if (errno == E2BIG) { 100 | /* 101 | * Reset initial state. 102 | * To avoid a bug of iconv() on Solaris 2.6, we set `in_left', 103 | * `out_p' and `out_left' to non-NULL values. 104 | */ 105 | in_left = 0; 106 | out_p = buffer; 107 | out_left = 0; 108 | iconv(cd, NULL, &in_left, &out_p, &out_left); 109 | 110 | free(buffer); 111 | buffer = NULL; 112 | buffer_size += string_length + 1; 113 | 114 | continue; 115 | } else { 116 | goto failed; 117 | } 118 | } 119 | 120 | iconv_close(cd); 121 | fputs_result = fputs(buffer, stream); 122 | free(buffer); 123 | 124 | return fputs_result; 125 | 126 | /* 127 | * An error occurs... 128 | */ 129 | failed: 130 | if (cd != (iconv_t)-1) 131 | iconv_close(cd); 132 | if (buffer != NULL) 133 | free(buffer); 134 | return fputs(string, stream); 135 | 136 | #else /* not HAVE_ICONV_OPEN */ 137 | return fputs(string, stream); 138 | #endif /* not HAVE_ICONV_OPEN */ 139 | } 140 | 141 | 142 | /* 143 | * Convert `string' from EUC-JP to the current locale encoding, and 144 | * then write it and a newline to `stdout'. 145 | */ 146 | int 147 | puts_eucjp_to_locale(const char *string) 148 | { 149 | if (fputs_eucjp_to_locale(string, stdout) == EOF) 150 | return EOF; 151 | if (fputs_eucjp_to_locale("\n", stdout) == EOF) 152 | return EOF; 153 | 154 | return 0; 155 | } 156 | -------------------------------------------------------------------------------- /eb/error.h: -------------------------------------------------------------------------------- 1 | /* -*- C -*- 2 | * Copyright (c) 1997-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef EB_ERROR_H 30 | #define EB_ERROR_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | #ifdef EB_BUILD_LIBRARY 37 | #include "defs.h" 38 | #else 39 | #include 40 | #endif 41 | 42 | /* 43 | * Error codes. 44 | */ 45 | #define EB_SUCCESS 0 46 | #define EB_ERR_MEMORY_EXHAUSTED 1 47 | #define EB_ERR_EMPTY_FILE_NAME 2 48 | #define EB_ERR_TOO_LONG_FILE_NAME 3 49 | #define EB_ERR_BAD_FILE_NAME 4 50 | 51 | #define EB_ERR_BAD_DIR_NAME 5 52 | #define EB_ERR_TOO_LONG_WORD 6 53 | #define EB_ERR_BAD_WORD 7 54 | #define EB_ERR_EMPTY_WORD 8 55 | #define EB_ERR_FAIL_GETCWD 9 56 | 57 | #define EB_ERR_FAIL_OPEN_CAT 10 58 | #define EB_ERR_FAIL_OPEN_CATAPP 11 59 | #define EB_ERR_FAIL_OPEN_TEXT 12 60 | #define EB_ERR_FAIL_OPEN_FONT 13 61 | #define EB_ERR_FAIL_OPEN_APP 14 62 | 63 | #define EB_ERR_FAIL_OPEN_BINARY 15 64 | #define EB_ERR_FAIL_READ_CAT 16 65 | #define EB_ERR_FAIL_READ_CATAPP 17 66 | #define EB_ERR_FAIL_READ_TEXT 18 67 | #define EB_ERR_FAIL_READ_FONT 19 68 | 69 | #define EB_ERR_FAIL_READ_APP 20 70 | #define EB_ERR_FAIL_READ_BINARY 21 71 | #define EB_ERR_FAIL_SEEK_CAT 22 72 | #define EB_ERR_FAIL_SEEK_CATAPP 23 73 | #define EB_ERR_FAIL_SEEK_TEXT 24 74 | 75 | #define EB_ERR_FAIL_SEEK_FONT 25 76 | #define EB_ERR_FAIL_SEEK_APP 26 77 | #define EB_ERR_FAIL_SEEK_BINARY 27 78 | #define EB_ERR_UNEXP_CAT 28 79 | #define EB_ERR_UNEXP_CATAPP 29 80 | 81 | #define EB_ERR_UNEXP_TEXT 30 82 | #define EB_ERR_UNEXP_FONT 31 83 | #define EB_ERR_UNEXP_APP 32 84 | #define EB_ERR_UNEXP_BINARY 33 85 | #define EB_ERR_UNBOUND_BOOK 34 86 | 87 | #define EB_ERR_UNBOUND_APP 35 88 | #define EB_ERR_NO_SUB 36 89 | #define EB_ERR_NO_APPSUB 37 90 | #define EB_ERR_NO_FONT 38 91 | #define EB_ERR_NO_TEXT 39 92 | 93 | #define EB_ERR_NO_STOPCODE 40 94 | #define EB_ERR_NO_ALT 41 95 | #define EB_ERR_NO_CUR_SUB 42 96 | #define EB_ERR_NO_CUR_APPSUB 43 97 | #define EB_ERR_NO_CUR_FONT 44 98 | 99 | #define EB_ERR_NO_CUR_BINARY 45 100 | #define EB_ERR_NO_SUCH_SUB 46 101 | #define EB_ERR_NO_SUCH_APPSUB 47 102 | #define EB_ERR_NO_SUCH_FONT 48 103 | #define EB_ERR_NO_SUCH_CHAR_BMP 49 104 | 105 | #define EB_ERR_NO_SUCH_CHAR_TEXT 50 106 | #define EB_ERR_NO_SUCH_SEARCH 51 107 | #define EB_ERR_NO_SUCH_HOOK 52 108 | #define EB_ERR_NO_SUCH_BINARY 53 109 | #define EB_ERR_DIFF_CONTENT 54 110 | 111 | #define EB_ERR_NO_PREV_SEARCH 55 112 | #define EB_ERR_NO_SUCH_MULTI_ID 56 113 | #define EB_ERR_NO_SUCH_ENTRY_ID 57 114 | #define EB_ERR_TOO_MANY_WORDS 58 115 | #define EB_ERR_NO_WORD 59 116 | 117 | #define EB_ERR_NO_CANDIDATES 60 118 | #define EB_ERR_END_OF_CONTENT 61 119 | #define EB_ERR_NO_PREV_SEEK 62 120 | #define EB_ERR_EBNET_UNSUPPORTED 63 121 | #define EB_ERR_EBNET_FAIL_CONNECT 64 122 | 123 | #define EB_ERR_EBNET_SERVER_BUSY 65 124 | #define EB_ERR_EBNET_NO_PERMISSION 66 125 | #define EB_ERR_UNBOUND_BOOKLIST 67 126 | #define EB_ERR_NO_SUCH_BOOK 68 127 | 128 | 129 | /* 130 | * The number of error codes. 131 | */ 132 | #define EB_NUMBER_OF_ERRORS 69 133 | 134 | /* 135 | * The maximum length of an error message. 136 | */ 137 | #define EB_MAX_ERROR_MESSAGE_LENGTH 127 138 | 139 | /* 140 | * Function declarations. 141 | */ 142 | /* error.c */ 143 | const char *eb_error_string(EB_Error_Code error_code); 144 | const char *eb_error_message(EB_Error_Code error_code); 145 | 146 | #ifdef __cplusplus 147 | } 148 | #endif 149 | 150 | #endif /* not EB_ERROR_H */ 151 | -------------------------------------------------------------------------------- /doc/html-toc: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | # 3 | # Copyright (c) 2005-2006 Motoyuki Kasahara 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 1. Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 2. Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # 3. Neither the name of the project nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software 15 | # without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 21 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | # SUCH DAMAGE. 28 | # 29 | 30 | # 31 | # html-toc -- make `table of contents' of HTML files. 32 | # 33 | # Usage: 34 | # html-index [option...] input-file... 35 | # 36 | # `html-toc' reads HTML files, and generates `table of contents' (TOC) 37 | # of the HTML files. The TOC is created from

...

tags and 38 | # tag in the HTML files. Since `html-toc' doesn't parse 39 | # HTML precisely, the tags must be the following form: 40 | # 41 | # heading 42 | # 43 | # where `?' is 1..6. Note that and above must be in the same 44 | # line. 45 | # 46 | # `html-toc' outputs TOC to standard out by default. 47 | # 48 | # Options: 49 | # -o file specify output file. 50 | # -h do not output file name in . 51 | # -m level minimum target heading level 52 | # (default: h1) 53 | # -M level maximum target heading level 54 | # (default: h6) 55 | 56 | require 5.005; 57 | use Getopt::Std; 58 | 59 | # 60 | # Usage 61 | # 62 | my $usage = "Usage: $0 [option...] input-file...\n"; 63 | 64 | # 65 | # Variables 66 | # 67 | my $out_file = '-'; 68 | my @preamble = (); 69 | my $fragment_only = 0; 70 | my $min_level = 1; 71 | my $max_level = 6; 72 | 73 | # 74 | # Parse command line arguments. 75 | # 76 | my %options; 77 | getopts('o:hm:M:', \%options) or die $usage; 78 | die $usage if (@ARGV == 0); 79 | 80 | $fragment_only = 1 if (defined($options{h}) || @ARGV == 1); 81 | $out_file = $options{o} if (defined($options{o})); 82 | if (defined($options{m})) { 83 | $options{m} =~ s/^h//; 84 | $min_level = $options{m}; 85 | } 86 | if (defined($options{M})) { 87 | $options{M} =~ s/^h//; 88 | $max_level = $options{M}; 89 | } 90 | 91 | # 92 | # Read an HTML file. 93 | # 94 | $current_level = $min_level; 95 | 96 | if ($out_file eq '-') { 97 | $out_file = 'stdout'; 98 | open(OUT_FILE, ">& STDOUT"); 99 | } else { 100 | if (!open(OUT_FILE, "> $out_file")) { 101 | die "$0: failed to open the file, $!: $out_file\n"; 102 | } 103 | } 104 | 105 | print OUT_FILE "\n"; 122 | } 123 | while ($current_level < $level) { 124 | print OUT_FILE ' ' x ($current_level - $min_level + 1); 125 | print OUT_FILE "
    \n"; 126 | $current_level++; 127 | } 128 | 129 | print OUT_FILE ' ' x ($current_level - $min_level + 1); 130 | if ($fragment_only) { 131 | print OUT_FILE sprintf("
  • %s\n", 132 | $tag, $heading); 133 | } else { 134 | print OUT_FILE sprintf("
  • %s\n", 135 | $in_file, $tag, $heading); 136 | } 137 | } 138 | } 139 | 140 | close(IN_FILE); 141 | } 142 | 143 | while ($current_level > $min_level) { 144 | $current_level--; 145 | print OUT_FILE ' ' x ($current_level - $min_level + 1); 146 | print OUT_FILE "
\n"; 147 | } 148 | 149 | print OUT_FILE "\n"; 150 | 151 | close(OUT_FILE); 152 | -------------------------------------------------------------------------------- /libebutils/strlist.c: -------------------------------------------------------------------------------- 1 | /* -*- C -*- 2 | * Copyright (c) 2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifdef HAVE_CONFIG_H 30 | #include "config.h" 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | #include "strlist.h" 38 | 39 | /* 40 | * Unexported functions. 41 | */ 42 | static String_List_Node * 43 | string_list_find_node(String_List *list, const char *string); 44 | 45 | 46 | /* 47 | * Initialize `list'. 48 | */ 49 | void 50 | string_list_initialize(String_List *list) 51 | { 52 | list->node_count = 0; 53 | list->head = NULL; 54 | list->tail = NULL; 55 | } 56 | 57 | 58 | /* 59 | * Finalize `list'. 60 | */ 61 | void 62 | string_list_finalize(String_List *list) 63 | { 64 | string_list_delete_all(list); 65 | } 66 | 67 | 68 | /* 69 | * Add `string' to `list'. 70 | * If `list' has already had `string', it doesn't do anything. 71 | */ 72 | int 73 | string_list_add(String_List *list, const char *string) 74 | { 75 | String_List_Node *new_node; 76 | 77 | if (string_list_find_node(list, string) != NULL) 78 | return 0; 79 | 80 | new_node = (String_List_Node *)malloc(sizeof(String_List_Node)); 81 | if (new_node == NULL) 82 | return -1; 83 | 84 | new_node->string = (char *)malloc(strlen(string) + 1); 85 | if (new_node->string == NULL) { 86 | free(new_node); 87 | return -1; 88 | } 89 | strcpy(new_node->string, string); 90 | 91 | if (list->node_count == 0) { 92 | new_node->back = NULL; 93 | list->head = new_node; 94 | } else { 95 | new_node->back = list->tail; 96 | list->tail->next = new_node; 97 | } 98 | 99 | new_node->next = NULL; 100 | list->tail = new_node; 101 | list->node_count++; 102 | 103 | return 0; 104 | } 105 | 106 | 107 | /* 108 | * Delete `string' from `list'. 109 | * The function doesn't complain if `list' doesn't have `string'. 110 | */ 111 | void 112 | string_list_delete(String_List *list, const char *string) 113 | { 114 | String_List_Node *p; 115 | 116 | p = string_list_find_node(list, string); 117 | if (p == NULL) 118 | return; 119 | 120 | if (p->next != NULL) 121 | p->next->back = p->back; 122 | if (p->back != NULL) 123 | p->back->next = p->next; 124 | free(p->string); 125 | free(p); 126 | 127 | list->node_count--; 128 | if (list->node_count == 0) { 129 | list->head = NULL; 130 | list->tail = NULL; 131 | } 132 | } 133 | 134 | 135 | /* 136 | * Delete all strings in `list'. 137 | */ 138 | void 139 | string_list_delete_all(String_List *list) 140 | { 141 | String_List_Node *p = list->head; 142 | String_List_Node *next_p; 143 | 144 | while (p != NULL) { 145 | next_p = p->next; 146 | free(p->string); 147 | free(p); 148 | p = next_p; 149 | } 150 | 151 | list->node_count = 0; 152 | list->head = NULL; 153 | list->tail = NULL; 154 | } 155 | 156 | 157 | /* 158 | * Return true if `list' has `string'. 159 | */ 160 | int 161 | string_list_find(String_List *list, const char *string) 162 | { 163 | return (string_list_find_node(list, string) != NULL); 164 | } 165 | 166 | 167 | /* 168 | * Count the number of strings in `list'. 169 | */ 170 | int 171 | string_list_count_node(String_List *list) 172 | { 173 | return list->node_count; 174 | } 175 | 176 | 177 | /* 178 | * Return a pointer to the node with `string' in `list'. 179 | * Return NULL if `list' doesn't have `string'. 180 | */ 181 | static String_List_Node * 182 | string_list_find_node(String_List *list, const char *string) 183 | { 184 | String_List_Node *p; 185 | 186 | for (p = list->head; p != NULL; p = p->next) { 187 | if (strcmp(string, p->string) == 0) 188 | return p; 189 | } 190 | 191 | return NULL; 192 | } 193 | 194 | 195 | -------------------------------------------------------------------------------- /doc/html-index: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | # 3 | # Copyright (c) 2005 Motoyuki Kasahara 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 1. Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 2. Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # 3. Neither the name of the project nor the names of its contributors 14 | # may be used to endorse or promote products derived from this software 15 | # without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 18 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 21 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | # SUCH DAMAGE. 28 | # 29 | 30 | # 31 | # html-index -- make index page of HTML files. 32 | # 33 | # Usage: 34 | # html-index [option...] input-file... 35 | # 36 | # `html-index' reads HTML files, and generates their indice. The indice 37 | # are created from tags in the HTML files. Since `html-index' 38 | # doesn't parse HTML precisely, `<' and `>' in tag must be in the same 39 | # line and be the following form: 40 | # 41 | # 42 | # 43 | # The corresponding reference in the index looks like: 44 | # 45 | # name 46 | # 47 | # or, if two or more input files are specified: 48 | # 49 | # name 50 | # 51 | # `category' above is category name of index. It is used to generate 52 | # more than one indice: function index and concept index, for example. 53 | # By default, the script generates `index-.html' for each index 54 | # category. 55 | # 56 | # In input HTML files, the following line has the special meaning: 57 | # 58 | # 59 | # 60 | # It sets file name in in the indice. 61 | # 62 | # Options: 63 | # -p prefix set prefix of index files. 64 | # (default: `index-') 65 | # -s suffix set suffix of index files. 66 | # (default: `html') 67 | # -h do not output file name in . 68 | # 69 | 70 | require 5.005; 71 | use Getopt::Std; 72 | 73 | # 74 | # Usage 75 | # 76 | my $usage = "Usage: $0 [-p prefix] [-s suffix] [-h] file...\n"; 77 | 78 | # 79 | # Variables 80 | # 81 | my $out_prefix = 'index'; 82 | my $out_suffix = 'html'; 83 | my %indice = (); 84 | my $fragment_only = 0; 85 | 86 | # 87 | # Parse command line arguments. 88 | # 89 | my %options; 90 | getopts('p:s:h', \%options) or die $usage; 91 | die $usage if (@ARGV == 0); 92 | 93 | $out_prefix = $options{p} if (defined($options{p})); 94 | $out_suffix = $options{s} if (defined($options{s})); 95 | $fragment_only = 1 if (defined($options{h}) || @ARGV == 1); 96 | 97 | # 98 | # Read HTML files. 99 | # 100 | for (my $i = 0; $i < @ARGV; $i++) { 101 | my $in_file_name = $ARGV[$i]; 102 | if (!open(IN_FILE, "< $in_file_name")) { 103 | die "$0: failed to open the file, $!: $in_file_name\n"; 104 | } 105 | 106 | while () { 107 | chomp; 108 | if (m|^[ \t]*$|) { 109 | $in_file_name = $1; 110 | } elsif (m||) { 111 | my $name = $1; 112 | if ($name =~ m|^([a-z_][0-9a-z_]+):(.+)$|) { 113 | my $type = $1; 114 | my $value = $2; 115 | if (!defined($indice{$type})) { 116 | $indice{$type} = {}; 117 | } 118 | $indice{$type}->{$value} = $in_file_name; 119 | } 120 | } 121 | } 122 | 123 | close(IN_FILE); 124 | } 125 | 126 | # 127 | # Generate index files. 128 | # 129 | foreach my $i (sort {uc($a) cmp uc($b)} keys(%indice)) { 130 | my $out_file_name = sprintf("%s-%s.%s", $out_prefix, $i, $out_suffix); 131 | 132 | if (!open(OUT_FILE, "> $out_file_name")) { 133 | die "$0: failed to open the file, $!: $out_file_name\n"; 134 | } 135 | 136 | print OUT_FILE "
\n"; 137 | my $prev_head_char = ''; 138 | 139 | foreach my $j (sort(keys(%{$indice{$i}}))) { 140 | my $cur_head_char = uc(substr($j, 0, 1)); 141 | if ($cur_head_char ne $prev_head_char) { 142 | print OUT_FILE '
', $cur_head_char, "\n"; 143 | } 144 | 145 | if ($fragment_only) { 146 | printf(OUT_FILE "
%s\n", 147 | $i, $j, $j); 148 | } else { 149 | printf(OUT_FILE "
%s\n", 150 | $indice{$i}->{$j}, $i, $j, $j); 151 | } 152 | $prev_head_char = $cur_head_char; 153 | } 154 | 155 | print OUT_FILE "
\n"; 156 | close(OUT_FILE); 157 | } 158 | -------------------------------------------------------------------------------- /po-ebutils/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile for program source directory in GNU NLS utilities package. 2 | # Copyright (C) 1995, 1996, 1997 by Ulrich Drepper 3 | # 4 | # This file file be copied and used freely without restrictions. It can 5 | # be used in projects which are not available under the GNU Public License 6 | # but which still want to provide support for the GNU gettext functionality. 7 | # Please note that the actual code is *not* freely available. 8 | 9 | ## Note that the following macros must be set by your hand. 10 | top_builddir = .. 11 | subdir = po-ebutils 12 | 13 | TEXTDOMAIN = ebutils 14 | POFILES = ja.po 15 | MOFILES = ja.mo 16 | POTFILES = \ 17 | $(top_srcdir)/libebutils/ebutils.c \ 18 | $(top_srcdir)/libebutils/getopt.c \ 19 | $(top_srcdir)/ebfont/ebfont.c \ 20 | $(top_srcdir)/ebinfo/ebinfo.c \ 21 | $(top_srcdir)/ebrefile/ebrefile.c \ 22 | $(top_srcdir)/ebstopcode/ebstopcode.c \ 23 | $(top_srcdir)/ebzip/copyfile.c \ 24 | $(top_srcdir)/ebzip/ebzip.c \ 25 | $(top_srcdir)/ebzip/ebzip1.c \ 26 | $(top_srcdir)/ebzip/sebxa.c \ 27 | $(top_srcdir)/ebzip/speedup.c \ 28 | $(top_srcdir)/ebzip/unlinkfile.c \ 29 | $(top_srcdir)/ebzip/unzipbook.c \ 30 | $(top_srcdir)/ebzip/unzipfile.c \ 31 | $(top_srcdir)/ebzip/zipbook.c \ 32 | $(top_srcdir)/ebzip/zipfile.c \ 33 | $(top_srcdir)/ebzip/zipinfobook.c \ 34 | $(top_srcdir)/ebzip/zipinfofile.c 35 | ## end 36 | 37 | PACKAGE = @PACKAGE@ 38 | VERSION = @VERSION@ 39 | 40 | SHELL = /bin/sh 41 | 42 | srcdir = @srcdir@ 43 | top_srcdir = @top_srcdir@ 44 | VPATH = @srcdir@ 45 | prefix = @prefix@ 46 | datarootdir = @datarootdir@ 47 | datadir = @datadir@ 48 | localedir = @localedir@ 49 | 50 | mkdir_p = @mkdir_p@ 51 | INSTALL = @INSTALL@ 52 | INSTALL_DATA = @INSTALL_DATA@ 53 | mkinstalldirs = $(install_sh) -d 54 | install_sh = @install_sh@ 55 | 56 | MSGFMT = @MSGFMT@ 57 | XGETTEXT = @XGETTEXT@ 58 | MSGMERGE = msgmerge 59 | 60 | DISTFILES = Makefile.in $(TEXTDOMAIN).pot $(MOFILES) $(POFILES) 61 | 62 | .SUFFIXES: 63 | .SUFFIXES: .po .pox .mo 64 | 65 | .po.pox: 66 | $(MAKE) $(TEXTDOMAIN).pot 67 | $(MSGMERGE) $< $(srcdir)/$(TEXTDOMAIN).pot -o $*.pox 68 | 69 | .po.mo: 70 | file=$(srcdir)/`echo $* | sed 's,.*/,,'`.mo \ 71 | && rm -f $$file && $(MSGFMT) -o $$file $< 72 | 73 | all: all-@ENABLE_NLS@ 74 | 75 | all-yes: $(MOFILES) 76 | all-no: 77 | 78 | $(TEXTDOMAIN).pot: $(POTFILES) 79 | $(XGETTEXT) --default-domain=$(TEXTDOMAIN) --add-comments \ 80 | --keyword=_ --keyword=N_ $(POTFILES) \ 81 | && test ! -f $(TEXTDOMAIN).po \ 82 | || ( rm -f $(srcdir)/$(TEXTDOMAIN).pot \ 83 | && mv $(TEXTDOMAIN).po $(srcdir)/$(TEXTDOMAIN).pot ) 84 | 85 | install: install-exec install-data 86 | install-exec: 87 | install-data: install-data-@ENABLE_NLS@ 88 | install-data-no: all 89 | install-data-yes: all 90 | $(mkinstalldirs) $(DESTDIR)$(datadir) 91 | @catalogs='$(MOFILES)'; \ 92 | for cat in $$catalogs; do \ 93 | cat=`echo $$cat | sed 's/^.*\/\([^\/]*\)$$/\1/'` ; \ 94 | lang=`echo $$cat | sed 's/\.mo$$//'`; \ 95 | dir=$(localedir)/$$lang/LC_MESSAGES; \ 96 | $(mkinstalldirs) $(DESTDIR)$$dir; \ 97 | if test -r $$cat; then \ 98 | $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(TEXTDOMAIN).mo; \ 99 | echo "installing $$cat as" \ 100 | "$(DESTDIR)$$dir/$(TEXTDOMAIN).mo"; \ 101 | else \ 102 | $(INSTALL_DATA) $(srcdir)/$$cat \ 103 | $(DESTDIR)$$dir/$(TEXTDOMAIN).mo; \ 104 | echo "installing $(srcdir)/$$cat as" \ 105 | "$(DESTDIR)$$dir/$(TEXTDOMAIN).mo"; \ 106 | fi; \ 107 | done 108 | 109 | # Define this as empty until I found a useful application. 110 | installcheck: 111 | 112 | uninstall: 113 | catalogs='$(MOFILES)'; \ 114 | for cat in $$catalogs; do \ 115 | cat=`echo $$cat | sed 's/^.*\/\([^\/]*\)$$/\1/'` ; \ 116 | lang=`echo $$cat | sed 's/\.mo$$//'`; \ 117 | rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(TEXTDOMAIN).mo; \ 118 | done 119 | rm -f $(DESTDIR)$(gettextsrcdir)/po-Makefile.in 120 | 121 | check: all 122 | 123 | dvi info tags TAGS ID: 124 | 125 | mostlyclean: 126 | rm -f core core.* *.pox $(TEXTDOMAIN).po *.old.po 127 | rm -fr *.o 128 | 129 | clean: mostlyclean 130 | 131 | distclean: clean 132 | rm -f Makefile *.mo 133 | 134 | maintainer-clean: distclean 135 | @echo "This command is intended for maintainers to use;" 136 | @echo "it deletes files that may require special tools to rebuild." 137 | rm -f *.mo 138 | 139 | distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) 140 | dist distdir: update-po $(DISTFILES) 141 | dists="$(DISTFILES)"; \ 142 | for file in $$dists; do \ 143 | ln $(srcdir)/$$file $(distdir) 2> /dev/null \ 144 | || cp -p $(srcdir)/$$file $(distdir); \ 145 | done 146 | 147 | update-po: Makefile 148 | $(MAKE) $(TEXTDOMAIN).pot 149 | cd $(srcdir); \ 150 | catalogs='$(MOFILES)'; \ 151 | for cat in $$catalogs; do \ 152 | cat=`echo $$cat | sed 's/^.*\/\([^\/]*\)$$/\1/'` ; \ 153 | lang=`echo $$cat | sed 's/\.mo$$//'`; \ 154 | mv $$lang.po $$lang.old.po; \ 155 | echo "$$lang:"; \ 156 | if $(MSGMERGE) $$lang.old.po $(TEXTDOMAIN).pot -o $$lang.po; then \ 157 | rm -f $$lang.old.po; \ 158 | else \ 159 | echo "msgmerge for $$cat failed!"; \ 160 | rm -f $$lang.po; \ 161 | mv $$lang.old.po $$lang.po; \ 162 | fi; \ 163 | done 164 | 165 | Makefile: Makefile.in $(top_builddir)/config.status 166 | cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \ 167 | $(SHELL) ./config.status 168 | 169 | # Tell versions [3.59,3.63) of GNU make not to export all variables. 170 | # Otherwise a system limit (for SysV at least) may be exceeded. 171 | .NOEXPORT: 172 | -------------------------------------------------------------------------------- /eb/log.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #include "build-pre.h" 30 | #include "eb.h" 31 | #include "build-post.h" 32 | 33 | #include 34 | 35 | 36 | /* 37 | * Mutex. 38 | */ 39 | #ifdef ENABLE_PTHREAD 40 | static pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER; 41 | #endif 42 | 43 | /* 44 | * Initialization flag. 45 | */ 46 | int eb_log_initialized = 0; 47 | 48 | /* 49 | * Debug log flag. 50 | */ 51 | int eb_log_flag = 0; 52 | 53 | /* 54 | * Pointer to log function. 55 | */ 56 | static void (*eb_log_function)(const char *message, va_list) = eb_log_stderr; 57 | 58 | 59 | /* 60 | * Initialize logging sub-system. 61 | */ 62 | void 63 | eb_initialize_log(void) 64 | { 65 | if (eb_log_initialized) 66 | return; 67 | 68 | eb_log_flag = (getenv(EB_DEBUG_ENVIRONMENT_VARIABLE) != NULL); 69 | eb_log_function = eb_log_stderr; 70 | eb_log_initialized = 1; 71 | } 72 | 73 | /* 74 | * Set log function. 75 | */ 76 | void 77 | eb_set_log_function(void (*function)(const char *message, va_list ap)) 78 | { 79 | if (!eb_log_initialized) 80 | eb_initialize_log(); 81 | eb_log_function = function; 82 | } 83 | 84 | /* 85 | * Enable logging. 86 | */ 87 | void 88 | eb_enable_log(void) 89 | { 90 | if (!eb_log_initialized) 91 | eb_initialize_log(); 92 | eb_log_flag = 1; 93 | } 94 | 95 | /* 96 | * Disable logging. 97 | */ 98 | void 99 | eb_disable_log(void) 100 | { 101 | if (!eb_log_initialized) 102 | eb_initialize_log(); 103 | eb_log_flag = 0; 104 | } 105 | 106 | /* 107 | * Log a message. 108 | */ 109 | void 110 | eb_log(const char *message, ...) 111 | { 112 | va_list ap; 113 | 114 | va_start(ap, message); 115 | 116 | if (eb_log_flag && eb_log_function != NULL) 117 | eb_log_function(message, ap); 118 | 119 | va_end(ap); 120 | } 121 | 122 | /* 123 | * Output a log message to standard error. 124 | * This is the default log handler. 125 | * 126 | * Currently, this function doesn't work if the system lacks vprintf() 127 | * and dopront(). 128 | */ 129 | void 130 | eb_log_stderr(const char *message, va_list ap) 131 | { 132 | pthread_mutex_lock(&log_mutex); 133 | 134 | fputs("[EB] ", stderr); 135 | 136 | vfprintf(stderr, message, ap); 137 | fputc('\n', stderr); 138 | fflush(stderr); 139 | 140 | pthread_mutex_unlock(&log_mutex); 141 | } 142 | 143 | #define MAX_QUOTED_STREAM_LENGTH 100 144 | 145 | /* 146 | * Return Quoted printable string of `stream'. 147 | */ 148 | const char * 149 | eb_quoted_stream(const char *stream, size_t stream_length) 150 | { 151 | static char quoted_streams[EB_MAX_KEYWORDS][MAX_QUOTED_STREAM_LENGTH + 3]; 152 | static int current_index = 0; 153 | unsigned char *quoted_p; 154 | const unsigned char *stream_p; 155 | size_t quoted_length = 0; 156 | int i; 157 | 158 | current_index = (current_index + 1) % EB_MAX_KEYWORDS; 159 | quoted_p = (unsigned char *)quoted_streams[current_index]; 160 | stream_p = (const unsigned char *)stream; 161 | 162 | if (stream == NULL) 163 | return ""; 164 | 165 | for (i = 0; i < stream_length && *stream_p != '\0'; i++) { 166 | if (0x20 <= *stream_p && *stream_p <= 0x7f && *stream_p != '=') { 167 | if (MAX_QUOTED_STREAM_LENGTH < quoted_length + 1) { 168 | *quoted_p++ = '.'; 169 | *quoted_p++ = '.'; 170 | break; 171 | } 172 | *quoted_p++ = *stream_p; 173 | quoted_length++; 174 | } else { 175 | if (MAX_QUOTED_STREAM_LENGTH < quoted_length + 3) { 176 | *quoted_p++ = '.'; 177 | *quoted_p++ = '.'; 178 | break; 179 | } 180 | *quoted_p++ = '='; 181 | *quoted_p++ = "0123456789ABCDEF" [*stream_p / 0x10]; 182 | *quoted_p++ = "0123456789ABCDEF" [*stream_p % 0x10]; 183 | quoted_length += 3; 184 | } 185 | stream_p++; 186 | } 187 | 188 | *quoted_p = '\0'; 189 | return quoted_streams[current_index]; 190 | } 191 | 192 | 193 | /* 194 | * Return Quoted printable string. 195 | */ 196 | const char * 197 | eb_quoted_string(const char *string) 198 | { 199 | return eb_quoted_stream(string, strlen(string)); 200 | } 201 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | pkgdoc_DATA = eb.html ebappendix.html ebfont.html ebinfo.html ebrefile.html \ 2 | ebstopcode.html ebzip.html 3 | 4 | EXTRA_DIST = eb.html.in ebappendix.html.in ebfont.html.in ebinfo.html.in \ 5 | ebrefile.html.in ebstopcode.html.in ebzip.html.in eb.css ebutils.css \ 6 | c2html html-include html-index html-split html-toc 7 | 8 | CLEANFILES = *.html 9 | 10 | install-data-hook: 11 | for i in $(pkgdoc_DATA); do \ 12 | base="`echo $$i | sed -e 's/\.html//'`"; \ 13 | for j in $$base-[0-9][0-9].html; do \ 14 | test -r $$j || continue; \ 15 | echo " $(INSTALL_DATA) '$$j' '$(DESTDIR)$(pkgdocdir)/$$j'"; \ 16 | $(INSTALL_DATA) "$$j" "$(DESTDIR)$(pkgdocdir)/$$j"; \ 17 | done; \ 18 | done 19 | 20 | uninstall-hook: 21 | for i in $(pkgdoc_DATA); do \ 22 | base="`echo $$i | sed -e 's/\.html//'`"; \ 23 | rm -f "$(DESTDIR)$(pkgdocdir)"/$$base-*.html; \ 24 | done 25 | 26 | version.html: 27 | rm -f $@ 28 | echo $(VERSION) > version.html 29 | 30 | splitted: eb-splitted ebappendix-splitted ebfont-splitted ebinfo-splitted \ 31 | ebrefile-splitted ebstopcode-splitted ebzip-splitted 32 | 33 | eb.html: eb-cat.html 34 | rm -f $@ 35 | $(PERL) $(srcdir)/html-split -Z -p eb -w 2 eb-cat.html 36 | 37 | ebappendix.html: ebappendix-cat.html 38 | rm -f $@ 39 | $(PERL) $(srcdir)/html-split -Z -p ebappendix -w 2 ebappendix-cat.html 40 | 41 | ebfont.html: ebfont-cat.html 42 | rm -f $@ 43 | $(PERL) $(srcdir)/html-split -Z -p ebfont -w 2 ebfont-cat.html 44 | 45 | ebinfo.html: ebinfo-cat.html 46 | rm -f $@ 47 | $(PERL) $(srcdir)/html-split -Z -p ebinfo -w 2 ebinfo-cat.html 48 | 49 | ebrefile.html: ebrefile-cat.html 50 | rm -f $@ 51 | $(PERL) $(srcdir)/html-split -Z -p ebrefile -w 2 ebrefile-cat.html 52 | 53 | ebstopcode.html: ebstopcode-cat.html 54 | rm -f $@ 55 | $(PERL) $(srcdir)/html-split -Z -p ebstopcode -w 2 ebstopcode-cat.html 56 | 57 | ebzip.html: ebzip-cat.html 58 | rm -f $@ 59 | $(PERL) $(srcdir)/html-split -Z -p ebzip -w 2 ebzip-cat.html 60 | 61 | 62 | eb-cat.html: eb.html.in version.html eb-toc.html eb-sample-appendix.html \ 63 | eb-sample-booklist.html eb-sample-disctype.html eb-sample-font.html \ 64 | eb-sample-initexit.html eb-sample-subbook.html eb-sample-text.html \ 65 | eb-sample-word.html eb-index-type.html eb-index-func.html \ 66 | eb-index-const.html 67 | rm -f $@ 68 | $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/eb.html.in 69 | 70 | ebappendix-cat.html: $(srcdir)/ebappendix.html.in version.html \ 71 | ebappendix-toc.html 72 | rm -f $@ 73 | $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebappendix.html.in 74 | 75 | ebfont-cat.html: $(srcdir)/ebfont.html.in version.html ebfont-toc.html 76 | rm -f $@ 77 | $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebfont.html.in 78 | 79 | ebinfo-cat.html: $(srcdir)/ebinfo.html.in version.html ebinfo-toc.html 80 | rm -f $@ 81 | $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebinfo.html.in 82 | 83 | ebrefile-cat.html: $(srcdir)/ebrefile.html.in version.html ebrefile-toc.html 84 | rm -f $@ 85 | $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebrefile.html.in 86 | 87 | ebstopcode-cat.html: $(srcdir)/ebstopcode.html.in version.html \ 88 | ebstopcode-toc.html 89 | rm -f $@ 90 | $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebstopcode.html.in 91 | 92 | ebzip-cat.html: $(srcdir)/ebzip.html.in version.html ebzip-toc.html 93 | rm -f $@ 94 | $(PERL) $(srcdir)/html-include -o $@ $(srcdir)/ebzip.html.in 95 | 96 | 97 | eb-toc.html: $(srcdir)/eb.html.in 98 | rm -f $@ 99 | $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/eb.html.in > $@ 100 | 101 | ebappendix-toc.html: $(srcdir)/ebappendix.html.in 102 | rm -f $@ 103 | $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebappendix.html.in > $@ 104 | 105 | ebfont-toc.html: $(srcdir)/ebfont.html.in 106 | rm -f $@ 107 | $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebfont.html.in > $@ 108 | 109 | ebinfo-toc.html: $(srcdir)/ebinfo.html.in 110 | rm -f $@ 111 | $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebinfo.html.in > $@ 112 | 113 | ebrefile-toc.html: $(srcdir)/ebrefile.html.in 114 | rm -f $@ 115 | $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebrefile.html.in > $@ 116 | 117 | ebstopcode-toc.html: $(srcdir)/ebstopcode.html.in 118 | rm -f $@ 119 | $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebstopcode.html.in > $@ 120 | 121 | ebzip-toc.html: $(srcdir)/ebzip.html.in 122 | rm -f $@ 123 | $(PERL) $(srcdir)/html-toc -m h2 -M h3 $(srcdir)/ebzip.html.in > $@ 124 | 125 | eb-sample-appendix.html: $(top_srcdir)/samples/appendix.c 126 | rm -f $@ 127 | $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/appendix.c > $@ 128 | 129 | eb-sample-booklist.html: $(top_srcdir)/samples/booklist.c 130 | rm -f $@ 131 | $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/booklist.c > $@ 132 | 133 | eb-sample-disctype.html: $(top_srcdir)/samples/disctype.c 134 | rm -f $@ 135 | $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/disctype.c > $@ 136 | 137 | eb-sample-font.html: $(top_srcdir)/samples/font.c 138 | rm -f $@ 139 | $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/font.c > $@ 140 | 141 | eb-sample-initexit.html: $(top_srcdir)/samples/initexit.c 142 | rm -f $@ 143 | $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/initexit.c > $@ 144 | 145 | eb-sample-subbook.html: $(top_srcdir)/samples/subbook.c 146 | rm -f $@ 147 | $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/subbook.c > $@ 148 | 149 | eb-sample-text.html: $(top_srcdir)/samples/text.c 150 | rm -f $@ 151 | $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/text.c > $@ 152 | 153 | eb-sample-word.html: $(top_srcdir)/samples/word.c 154 | rm -f $@ 155 | $(PERL) $(srcdir)/c2html $(top_srcdir)/samples/word.c > $@ 156 | 157 | 158 | eb-index-type.html eb-index-func.html eb-index-const.html: \ 159 | $(srcdir)/eb.html.in 160 | $(PERL) $(srcdir)/html-index -h -p eb-index $(srcdir)/eb.html.in 161 | -------------------------------------------------------------------------------- /m4/lt~obsolete.m4: -------------------------------------------------------------------------------- 1 | # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- 2 | # 3 | # Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004. 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # serial 4 lt~obsolete.m4 11 | 12 | # These exist entirely to fool aclocal when bootstrapping libtool. 13 | # 14 | # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) 15 | # which have later been changed to m4_define as they aren't part of the 16 | # exported API, or moved to Autoconf or Automake where they belong. 17 | # 18 | # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN 19 | # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us 20 | # using a macro with the same name in our local m4/libtool.m4 it'll 21 | # pull the old libtool.m4 in (it doesn't see our shiny new m4_define 22 | # and doesn't know about Autoconf macros at all.) 23 | # 24 | # So we provide this file, which has a silly filename so it's always 25 | # included after everything else. This provides aclocal with the 26 | # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything 27 | # because those macros already exist, or will be overwritten later. 28 | # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 29 | # 30 | # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. 31 | # Yes, that means every name once taken will need to remain here until 32 | # we give up compatibility with versions before 1.7, at which point 33 | # we need to keep only those names which we still refer to. 34 | 35 | # This is to help aclocal find these macros, as it can't see m4_define. 36 | AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) 37 | 38 | m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) 39 | m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) 40 | m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) 41 | m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) 42 | m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) 43 | m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) 44 | m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) 45 | m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) 46 | m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) 47 | m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) 48 | m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) 49 | m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) 50 | m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) 51 | m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) 52 | m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) 53 | m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) 54 | m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) 55 | m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) 56 | m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) 57 | m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) 58 | m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) 59 | m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) 60 | m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) 61 | m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) 62 | m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) 63 | m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) 64 | m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) 65 | m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) 66 | m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) 67 | m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) 68 | m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) 69 | m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) 70 | m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) 71 | m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) 72 | m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) 73 | m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) 74 | m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) 75 | m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) 76 | m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) 77 | m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) 78 | m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) 79 | m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) 80 | m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])]) 81 | m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) 82 | m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) 83 | m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) 84 | m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) 85 | m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) 86 | m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) 87 | m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) 88 | m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) 89 | m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) 90 | m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) 91 | m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) 92 | m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) 93 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | 必要なソフトウェア 2 | ================== 3 | 4 | 本ソフトウェアをインストールするには、前もって zlib をインストールして 5 | おく必要があります。zlib は次の場所から入手することができます。 6 | 7 | http://www.gzip.org/zlib/ 8 | 9 | システムによっては、最初から zlib がインストールされている場合もありま 10 | す。 11 | 12 | 13 | 基本的なインストール方法 14 | ======================== 15 | 16 | 本ソフトウェアの最も単純なコンパイル方法は次の通りです。 17 | 18 | 1. ソフトウェアのソースコードが置かれているディレクトリに移動 (`cd') 19 | し、`./configure' を実行します。`configure' の実行には少々時間が 20 | かかります。 21 | 22 | 実行している間は、どのような項目をチェックしているのかを記したメッ 23 | セージが出力されます。 24 | 25 | 2. `make' を実行してソフトウェアをコンパイルします。 26 | 27 | 3. 任意で、ソフトウェアに付属しているセルフテストを実行する場合は、 28 | `make check' を実行します。 29 | 30 | 4. `make install' を実行して、プログラムおよびデータファイル、ドキュ 31 | メントをインストールします。 32 | 33 | 5. `make clean' を実行すると、生成されたプログラムのバイナリファイル 34 | やオブジェクトファイルを、ソースコードの置かれたディレクトリから 35 | 消すことができます。 一緒に `configure' が生成したファイルも消す 36 | には (こうすることで、別の種類のコンピュータでソフトウェアをコン 37 | パイルできます)、 `make distclean' を実行します。 38 | 39 | コンパイラとコンパイルオプション 40 | ================================ 41 | 42 | システムによっては、`configure' スクリプトが理解していない、コンパイ 43 | ルやリンクのための特別なオプションを与える必要があります。オプションは 44 | 環境変数を通して、`configure' に対して初期値を与えることができます。 45 | 46 | env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure 47 | 48 | インストール名 49 | ============== 50 | 51 | デフォルトでは、`make install' を実行すると、ソフトウェア中のファイル 52 | が `/usr/local/bin'、`/usr/local/man' などにインストールされます。 53 | `configure' に対して `--prefix=パス' オプションを指定することで、 54 | `/usr/local' 以外のインストール先を指定するとができま ます。 55 | 56 | アーキテクチャに依存したファイルとそうでないファイルを、それぞれ異なっ 57 | たインストール先にインストールすることも可能です。 `configure' に対し 58 | て `--exec-prefix=パス' を指定すると、プログラムやライブラリなどのイン 59 | ストール先が「パス」に変わります。ドキュメントや、データファイルなどは、 60 | 通常のインストール先にインストールされます。 61 | 62 | 加えて、あなたが通常とは異なったディレクトリレイアウトを採用している 63 | 場合は、`--bindir=パス' といったオプションを指定することで、特定の種類 64 | のファイルのインストール先だけを変えることができます。 `configure 65 | --help' を実行すると、どのようなディレクトリを変更できるのか、どのよう 66 | な種類のファイルがどのディレクトリにインストールされるのかが分かります。 67 | 68 | ソフトウェアがサポートしているならば、`configure' に `--program-prefix= 69 | 接頭辞' や `--program-suffix=接尾辞' というオプションを与えることで、 70 | インストール時にプログラム名に接頭辞や接尾辞を付加することができます。 71 | 72 | `configure' の動作の制御 73 | ======================== 74 | 75 | `configure' は次に記したオプションを認識します。 76 | 77 | `--cache-file=ファイル' 78 | テストの結果の読み込みや書き出しに使用するファイルは、通常 79 | `./config.cache' ですが、代わりに「ファイル」を用います。 80 | `configure' をデバッグするときは、ファイル に `/dev/null' を指定 81 | することで、キャッシュを抑制することができます。 82 | 83 | `--help' 84 | `configure' のオプションの一覧を表示して、終了します。 85 | 86 | `--quiet' 87 | `--silent' 88 | `-q' 89 | どのチェック項目を行っているのかを示すメッセージを出力しません。 90 | 通常のメッセージ出力をすべて抑制するには、`/dev/null' へリダイレ 91 | クトして下さい (ただし、エラーメッセージについては出力されてしま 92 | いますが)。 93 | 94 | `--srcdir=ディレクトリ' 95 | ソフトウェアのソースコードを探し出す際に、「ディレクトリ」を探しま 96 | す。通常、`configure' は自動的にディレクトリを決定します。 97 | 98 | `--version' 99 | `configure' スクリプトがどのバージョンの Autoconf によって生成さ 100 | れたのかを表示し、終了します。 101 | 102 | 役に立つ場面は限られますが、`configure' には他にもいくつかのオプション 103 | が用意されています。 104 | 105 | 選択可能な機能の一覧 106 | ==================== 107 | 108 | 本ソフトウェアの `configure' は以下に記した `--enable-' および 109 | `--with-' オプションを認識します。 110 | 111 | `--enable-ebnet' 112 | 遠隔アクセス対応を有効にします。無指定時は `yes' です。 113 | 114 | `--enable-ipv6' 115 | 遠隔アクセスでの IPv6 対応を有効にします。IPv6 に対応したシステム 116 | では、無指定時は `yes' が指定されたものとみなされます。`yes' を指 117 | 定したにもかかわらず、`configure' が IPv6 を使ったサンプルプログラ 118 | ムのコンパイルに失敗すると、エラーが報告されます。`--enable-ebnet= 119 | no' を指定した場合、このオプションは無視されます。 120 | 121 | `--enable-pthread' 122 | コンパイルされた EB ライブラリに pthread 対応コードが付加さます。 123 | 無指定時は `no' です。`yes' を指定したにもかかわらず、`configure' 124 | が pthread を使ったサンプルプログラムのコンパイルや実行に失敗する 125 | と、エラーが報告されます。 126 | 127 | 注意: pthread への対応は、まだ不完全で実験的なものです。 128 | 129 | `--with-pthread-cppflags=FLAGS' 130 | `--with-pthread-cflags=FLAGS' 131 | `--with-pthread-ldflags=FLAGS' 132 | pthread サポート版の EB ライブラリを作成する際に付加する 133 | CPPFLAGS, CFLAGS, LDFLAGS です。 134 | 135 | `--with-zlib-includes=DIR' 136 | DIR ディレクトリにインストールされている zlib のヘッダファイルを 137 | 参照します。 138 | 139 | `--with-zlib-libraries=DIR' 140 | DIR ディレクトリにインストールされている zlib のライブラリファイ 141 | ルを参照します。 142 | 143 | `--enable-nls' 144 | メッセージの国際化機能 (正確には NLS は Native/National Language 145 | Support)。EB ライブラリおよびユーティリティは、メッセージの国際化 146 | 機能が有効になるようにコンパイルされます。 147 | 148 | この機能を使うには GNU gettext が必要です。システムに GNU gettext 149 | がなければ、このソフトウェアをインストールする前に GNU gettext をイ 150 | ンストールして下さい。本ソフトウェアは、たとえば Solaris の実装のよ 151 | うに、GNU gettext と非互換な gettext には対応していません。 152 | 153 | 無指定時は、gettext が利用可能であれば `yes' に、そうでなければ 154 | `no' になります。`yes' を指定したにもかかわらず `configure' が 155 | gettext() 関数を用いたサンプルプログラムのコンパイルや実行に失敗 156 | すると、エラーが報告されます。 157 | 158 | `--with-gettext-includes=DIR' 159 | DIR ディレクトリにインストールされている gettext のヘッダファイル 160 | を参照します。メッセージの国際化機能が無効になっている場合、この 161 | オプションは意味を持ちません。 162 | 163 | `--with-gettext-libraries=DIR' 164 | DIR ディレクトリにインストールされている gettext のライブラリファ 165 | イルを参照します。メッセージの国際化機能が無効になっている場合、 166 | このオプションは意味を持ちません。 167 | 168 | `--with-iconv-includes=DIR' 169 | DIR ディレクトリにインストールされている iconv のヘッダファイル 170 | を参照します。メッセージの国際化機能が無効になっている場合、ある 171 | いはシステム上の gettext() 関数が iconv() を使用しない場合、この 172 | オプションは意味を持ちません。 173 | 174 | `--with-iconv-libraries=DIR' 175 | DIR ディレクトリにインストールされている iconv のライブラリファ 176 | イルを参照します。メッセージの国際化機能が無効になっている場合、 177 | あるいはシステム上の gettext() 関数が iconv() を使用しない場合、 178 | このオプションは意味を持ちません。 179 | 180 | `--enable-shared' 181 | 共有ライブラリ版の EB ライブラリを作成します。無指定時は `yes' で 182 | す。 183 | 184 | `--enable-static' 185 | 静的ライブラリ版の EB ライブラリを作成します。無指定時は `yes' で 186 | す。 187 | 188 | `--with-gnu-ld' 189 | C コンパイラが GNU ld を使用していると仮定します。 190 | 無指定時は、`no' です。 191 | 192 | `--disable-libtool-lock' 193 | ロックしないようにします。(並列コンパイルは、正しく行われない可能 194 | 性があります。) 195 | 196 | `--enable-samples' 197 | サンプルプログラムもコンパイルするようにします。無指定時は `no' で 198 | す。コンパイルしても、サンプルプログラムは何処にもインストールされ 199 | ません。 200 | 201 | `--enable-largefile' 202 | 2GB を超える、大きなファイルを扱えるようにします。システム側で対応 203 | していないと、指定しても効果はありません。無指定時は `yes' です。 204 | -------------------------------------------------------------------------------- /doc/ebstopcode.html.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ebstopcode コマンド 8 | 9 | 10 | 11 |

ebstopcode コマンド

12 |

13 | この文書は EB ライブラリバージョン 14 | 15 | に対応しています。 16 |

17 | 18 |

19 | 目次: 20 |

21 | 22 | 23 | 24 |

25 | Copyright (c) 2003-2006 Motoyuki Kasahara 26 |

27 | 28 | 29 |

はじめに

30 | 31 |

32 | あなたが EB ライブラリのアプリケーションを使って CD-ROM 書籍の中のある 33 | 単語を引く際、その単語の説明が終了する箇所で、アプリケーションが本文の 34 | 出力を止めることをあなたは期待するのではないでしょうか。 35 | しかし、EB ライブラリはそのような動作を保証することができません。 36 | なぜなら、CD-ROM 書籍の本文には、項目の終わりを示す印が存在しないから 37 | です。 38 |

39 | 40 |

41 | 幸いにも、多くの CD-ROM 書籍には、項目の終わりを示す印の代替として 42 | 使える、本文の区切りコード (text stop code) というものを持って 43 | います。 44 | 通常、EB ライブラリはこの区切りコードを自動的に推測するようになって 45 | いるのですが、時々誤った区切りコードを導き出すことがあります。 46 | その場合は、appendix (付録) というものを用いて、EB ライブラリに 47 | 正しい区切りコードを教えてやらなくてはなりません。 48 |

49 | 50 |

51 | ebstopcode コマンドは、CD-ROM 書籍の本文の区切りコードを解析 52 | するためのツールです。 53 |

54 | 55 | 56 |

ebstopcode の実行

57 | 58 |

59 | ebstopcode の一般的な起動方法は次の通りです。 60 |

61 | 62 |
63 |
 64 | % ebstopcode 書籍へのパス 副本
 65 | 
66 |
67 | 68 |

69 | 書籍へのパス には、CD-ROM 書籍のトップディレクトリ、つまり 70 | catalog または catalogs ファイルが存在する 71 | ディレクトリを指定します。 72 | 遠隔アクセス用の識別子 (ebnet://...) を指定することも可能です。 73 | 書籍へのパス が省略された場合は、カレントディレクトリが指定された 74 | ものと見なされます。 75 |

76 | 77 |

78 | 副本 には、処理の対象とする副本のディレクトリ名を指定します。 79 | ebinfo コマンドを用いると、CD-ROM 書籍にどのような副本が 80 | 含まれているのかを知ることができます。 81 |

82 | 83 |
84 |
 85 | % ebinfo /cdrom
 86 | ディスクの形式: EB/EBG/EBXA/EBXA-C/S-EBXA
 87 | 文字コード: JIS X 0208
 88 | 副本の数: 2
 89 | 
 90 | 副本 1:
 91 |   題名: 新英和辞典(第四版)
 92 |   ディレクトリ: english
 93 |   検索方式: 前方一致 後方一致 条件 メニュー
 94 |   フォントの大きさ: 16 24 30 48
 95 |   半角フォントの文字: 0xa121 -- 0xa24e
 96 |   全角フォントの文字: 0xa321 -- 0xa27e
 97 | 
 98 | 副本 2:
 99 |   題名: CD-ROM 仏和辞典(第三版)
100 |   ディレクトリ: french
101 |   検索方式: 前方一致 後方一致 条件 メニュー
102 |   フォントの大きさ: 16 24 30 48
103 |   半角フォントの文字: 
104 |   全角フォントの文字: 0xa321 -- 0xa27e
105 | 
106 | 
107 |
108 | 109 |

110 | (ebinfo コマンドに関しての詳細は、 111 | ebinfo コマンドのマニュアル を参照のこと。) 112 | この例では、2 つの副本が書籍には含まれており、その名前は english 113 | と french だということが分かります。 114 |

115 | 116 |

117 | 副本 english の区切りコードを解析するには、以下を実行します。 118 |

119 | 120 |
121 |
122 | % ebstopcode /cdrom english
123 | 
124 |
125 | 126 |

127 | ebstopcode は、副本の本文と区切りコードの候補を次のように 128 | 出力します。 129 |

130 | 131 |
132 |
133 | === stop-code?: 0x1f09 0x0001 ===
134 | 
135 | === stop-code?: 0x1f41 0x0100 ===
136 | A
137 | 
138 | === stop-code?: 0x1f09 0x0001 ===
139 | [名] 1: A 抗原を有する赤血球を持つ血液型
140 | 
141 | === stop-code?: 0x1f09 0x0001 ===
142 | 2: メートル基準の長さの単位。10億分の 1 メートル。
143 | 
144 | === stop-code?: 0x1f09 0x0001 ===
145 | 3: アンペア。電流の基本単位で、SI単位系の一つ。
146 | 
147 | === stop-code?: 0x1f09 0x0001 ===
148 | 
149 | === stop-code?: 0x1f41 0x0100 ===
150 | (以下略)
151 | 
152 |
153 | 154 |

155 | stop-code?: と書かれた行はそれぞれ、区切りコードの候補を 156 | 示しています。 157 | これを区切りコードとして指定すると、EB ライブラリはその地点で本文の 158 | 出力を停止します。 159 |

160 | 161 |

162 | この english という副本の適切な区切りコードは、"0x1f41 0x0100" 163 | になります。 164 | --no-candidate--code オプションを使用して、この 165 | 区切りコードを試してみます。 166 |

167 | 168 |
169 |
170 | % ebstopcode --no-candidate --code "0x1f41 0x0100" /cdrom english
171 | A
172 | [名] 1: A 抗原を有する赤血球を持つ血液型。
173 | 2: メートル基準の長さの単位。10億分の 1 メートル。
174 | 3: アンペア。電流の基本単位で、SI単位系の一つ。
175 | 
176 |
177 | 178 | 179 |

ebstopcode のオプション一覧

180 | 181 |

182 | ebstopcode コマンドは、伝統的な一文字オプション名と覚えやすい長い 183 | オプション名の両方を扱うことができます。 184 | 長いオプション名を表すには、- ではなく -- を 185 | 用います。 186 | オプション名が一意に決まる範囲内で、名前の後方部分を省略することが 187 | できます。 188 |

189 | 190 |
191 |
-c コード
192 |
--code コード
193 |
194 | コード を区切りコードに指定します (例: "0x1f09 0x0001")。 195 | ebstopcode は、コード を見つけるまで本文を出力します。 196 | 197 |
-h
198 |
--help
199 |
200 | ヘルプメッセージを標準出力に出力して、終了します。 201 | 202 |
-l 長さ
203 |
--length 長さ
204 |
205 | 本文データを最長で 長さ バイトまで出力します。 206 | 長さ を 0 にすると、ebstopcode は本文全体を出力します。 207 | このオプションを指定しなかったときは、2048 になります。 208 | 209 |
-n
210 |
--no-candidates
211 |
212 | 区切りコードの候補を出力しないようにします。 213 | 214 |
-p ページ:オフセット
215 |
--text-position ページ:オフセット
216 |
217 | 本文データの出力をこの位置から開始します。 218 | ページ には 0 より大きい 16進整数を、オフセット には、 219 | 0〜0x7FF の間の 16進整数をそれぞれ指定します。 220 | このオプションを指定しなかったときは、本文データの先頭位置から出力します。 221 | 222 |
-v
223 |
--version
224 |
225 | バージョン番号を標準出力に出力して、終了します。 226 |
227 | 228 |

229 | --code (-c) と --length 230 | (-l) オプションは、互いにもう一方のオプションを打ち消します。 231 |

232 | 233 | 234 | 235 | -------------------------------------------------------------------------------- /eb/menu.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #include "build-pre.h" 30 | #include "eb.h" 31 | #include "error.h" 32 | #include "build-post.h" 33 | 34 | /* 35 | * Examine whether the current subbook in `book' supports `MENU SEARCH' 36 | * or not. 37 | */ 38 | int 39 | eb_have_menu(EB_Book *book) 40 | { 41 | eb_lock(&book->lock); 42 | LOG(("in: eb_have_menu(book=%d)", (int)book->code)); 43 | 44 | /* 45 | * Current subbook must have been set. 46 | */ 47 | if (book->subbook_current == NULL) 48 | goto failed; 49 | 50 | /* 51 | * Check for the index page of menu search. 52 | */ 53 | if (book->subbook_current->menu.start_page == 0) 54 | goto failed; 55 | 56 | LOG(("out: eb_have_menu() = %d", 1)); 57 | eb_unlock(&book->lock); 58 | 59 | return 1; 60 | 61 | /* 62 | * An error occurs... 63 | */ 64 | failed: 65 | LOG(("out: eb_have_menu() = %d", 0)); 66 | eb_unlock(&book->lock); 67 | return 0; 68 | } 69 | 70 | 71 | /* 72 | * Menu. 73 | */ 74 | EB_Error_Code 75 | eb_menu(EB_Book *book, EB_Position *position) 76 | { 77 | EB_Error_Code error_code; 78 | int page; 79 | 80 | eb_lock(&book->lock); 81 | LOG(("in: eb_menu(book=%d)", (int)book->code)); 82 | 83 | /* 84 | * Current subbook must have been set. 85 | */ 86 | if (book->subbook_current == NULL) { 87 | error_code = EB_ERR_NO_CUR_SUB; 88 | goto failed; 89 | } 90 | 91 | /* 92 | * Check for the page number of menu search. 93 | */ 94 | page = book->subbook_current->menu.start_page; 95 | if (page == 0) { 96 | error_code = EB_ERR_NO_SUCH_SEARCH; 97 | goto failed; 98 | } 99 | 100 | /* 101 | * Copy the position to `position'. 102 | */ 103 | position->page = page; 104 | position->offset = 0; 105 | 106 | LOG(("out: eb_menu(position={%d,%d}) = %s", 107 | position->page, position->offset, eb_error_string(EB_SUCCESS))); 108 | eb_unlock(&book->lock); 109 | 110 | return EB_SUCCESS; 111 | 112 | /* 113 | * An error occurs... 114 | */ 115 | failed: 116 | LOG(("out: eb_menu() = %s", eb_error_string(error_code))); 117 | eb_unlock(&book->lock); 118 | return error_code; 119 | } 120 | 121 | /* 122 | * Examine whether the current subbook in `book' supports `GRAPHIC MENU SEARCH' 123 | * or not. 124 | */ 125 | int 126 | eb_have_image_menu(EB_Book *book) 127 | { 128 | eb_lock(&book->lock); 129 | LOG(("in: eb_have_image_menu(book=%d)", (int)book->code)); 130 | 131 | /* 132 | * Current subbook must have been set. 133 | */ 134 | if (book->subbook_current == NULL) 135 | goto failed; 136 | 137 | /* 138 | * Check for the index page of graphic menu search. 139 | */ 140 | if (book->subbook_current->image_menu.start_page == 0) 141 | goto failed; 142 | 143 | LOG(("out: eb_have_image_menu() = %d", 1)); 144 | eb_unlock(&book->lock); 145 | 146 | return 1; 147 | 148 | /* 149 | * An error occurs... 150 | */ 151 | failed: 152 | LOG(("out: eb_have_image_menu() = %d", 0)); 153 | eb_unlock(&book->lock); 154 | return 0; 155 | } 156 | 157 | 158 | /* 159 | * Graphic Menu. 160 | */ 161 | EB_Error_Code 162 | eb_image_menu(EB_Book *book, EB_Position *position) 163 | { 164 | EB_Error_Code error_code; 165 | int page; 166 | 167 | eb_lock(&book->lock); 168 | LOG(("in: eb_image_menu(book=%d)", (int)book->code)); 169 | 170 | /* 171 | * Current subbook must have been set. 172 | */ 173 | if (book->subbook_current == NULL) { 174 | error_code = EB_ERR_NO_CUR_SUB; 175 | goto failed; 176 | } 177 | 178 | /* 179 | * Check for the page number of graphic menu search. 180 | */ 181 | page = book->subbook_current->image_menu.start_page; 182 | if (page == 0) { 183 | error_code = EB_ERR_NO_SUCH_SEARCH; 184 | goto failed; 185 | } 186 | 187 | /* 188 | * Copy the position to `position'. 189 | */ 190 | position->page = page; 191 | position->offset = 0; 192 | 193 | LOG(("out: eb_image_menu(position={%d,%d}) = %s", 194 | position->page, position->offset, eb_error_string(EB_SUCCESS))); 195 | eb_unlock(&book->lock); 196 | 197 | return EB_SUCCESS; 198 | 199 | /* 200 | * An error occurs... 201 | */ 202 | failed: 203 | LOG(("out: eb_image_menu() = %s", eb_error_string(error_code))); 204 | eb_unlock(&book->lock); 205 | return error_code; 206 | } 207 | -------------------------------------------------------------------------------- /eb/cross.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997-2006 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #include "build-pre.h" 30 | #include "eb.h" 31 | #include "error.h" 32 | #include "build-post.h" 33 | 34 | /* 35 | * Examine whether the current subbook in `book' supports `KEYWORD SEARCH' 36 | * or not. 37 | */ 38 | int 39 | eb_have_cross_search(EB_Book *book) 40 | { 41 | eb_lock(&book->lock); 42 | LOG(("in: eb_have_cross_search(book=%d)", (int)book->code)); 43 | 44 | /* 45 | * Current subbook must have been set. 46 | */ 47 | if (book->subbook_current == NULL) 48 | goto failed; 49 | 50 | if (book->subbook_current->cross.start_page == 0) 51 | goto failed; 52 | 53 | LOG(("out: eb_have_cross_search() = %d", 1)); 54 | eb_unlock(&book->lock); 55 | 56 | return 1; 57 | 58 | /* 59 | * An error occurs... 60 | */ 61 | failed: 62 | LOG(("out: eb_have_cross_search() = %d", 0)); 63 | eb_unlock(&book->lock); 64 | return 0; 65 | } 66 | 67 | 68 | /* 69 | * Keyword search. 70 | */ 71 | EB_Error_Code 72 | eb_search_cross(EB_Book *book, const char * const input_words[]) 73 | { 74 | EB_Error_Code error_code; 75 | EB_Search_Context *context; 76 | EB_Word_Code word_code; 77 | int word_count; 78 | int i; 79 | 80 | /* 81 | * Lock the book. 82 | */ 83 | eb_lock(&book->lock); 84 | LOG(("in: eb_search_cross(book=%d, input_words=[below])", 85 | (int)book->code)); 86 | 87 | if (eb_log_flag) { 88 | for (i = 0; i < EB_MAX_KEYWORDS && input_words[i] != NULL; i++) { 89 | LOG((" input_words[%d]=%s", i, 90 | eb_quoted_string(input_words[i]))); 91 | } 92 | LOG((" input_words[%d]=NULL", i)); 93 | } 94 | 95 | /* 96 | * Current subbook must have been set. 97 | */ 98 | if (book->subbook_current == NULL) { 99 | error_code = EB_ERR_NO_CUR_SUB; 100 | goto failed; 101 | } 102 | 103 | /* 104 | * Check whether the current subbook has cross search. 105 | */ 106 | if (book->subbook_current->cross.start_page == 0) { 107 | error_code = EB_ERR_NO_SUCH_SEARCH; 108 | goto failed; 109 | } 110 | 111 | /* 112 | * Attach a search context for each word, and pre-search the word. 113 | */ 114 | eb_reset_search_contexts(book); 115 | word_count = 0; 116 | 117 | for (i = 0; i < EB_MAX_KEYWORDS; i++) { 118 | if (input_words[i] == NULL) 119 | break; 120 | 121 | /* 122 | * Initialize search context. 123 | */ 124 | context = book->search_contexts + word_count; 125 | context->code = EB_SEARCH_CROSS; 126 | 127 | /* 128 | * Choose comparison functions. 129 | */ 130 | if (book->character_code == EB_CHARCODE_ISO8859_1) { 131 | context->compare_pre = eb_pre_match_word; 132 | context->compare_single = eb_match_word; 133 | context->compare_group = eb_match_word; 134 | } else { 135 | context->compare_pre = eb_pre_match_word; 136 | context->compare_single = eb_match_word; 137 | context->compare_group = eb_match_word_kana_group; 138 | } 139 | context->page = book->subbook_current->cross.start_page; 140 | 141 | /* 142 | * Make a fixed word and a canonicalized word to search from 143 | * `input_words[i]'. 144 | */ 145 | error_code = eb_set_keyword(book, input_words[i], context->word, 146 | context->canonicalized_word, &word_code); 147 | if (error_code == EB_ERR_EMPTY_WORD) 148 | continue; 149 | else if (error_code != EB_SUCCESS) 150 | goto failed; 151 | 152 | /* 153 | * Pre-search. 154 | */ 155 | error_code = eb_presearch_word(book, context); 156 | if (error_code != EB_SUCCESS) 157 | goto failed; 158 | 159 | word_count++; 160 | } 161 | if (word_count == 0) { 162 | error_code = EB_ERR_NO_WORD; 163 | goto failed; 164 | } else if (EB_MAX_KEYWORDS <= i && input_words[i] != NULL) { 165 | error_code = EB_ERR_TOO_MANY_WORDS; 166 | goto failed; 167 | } 168 | 169 | /* 170 | * Set `EB_SEARCH_NONE' to the rest unused search context. 171 | */ 172 | for (i = word_count; i < EB_MAX_KEYWORDS; i++) 173 | (book->search_contexts + i)->code = EB_SEARCH_NONE; 174 | 175 | LOG(("out: eb_search_cross() = %s", eb_error_string(EB_SUCCESS))); 176 | eb_unlock(&book->lock); 177 | 178 | return EB_SUCCESS; 179 | 180 | /* 181 | * An error occurs... 182 | */ 183 | failed: 184 | eb_reset_search_contexts(book); 185 | LOG(("out: eb_search_cross() = %s", eb_error_string(error_code))); 186 | eb_unlock(&book->lock); 187 | return error_code; 188 | } 189 | 190 | 191 | --------------------------------------------------------------------------------