pax_global_header00006660000000000000000000000064117521437730014524gustar00rootroot0000000000000052 comment=d25d1224bbcf7b6fe36977bb27a80a5827b514d7 ruby-eb-2.6/000077500000000000000000000000001175214377300127405ustar00rootroot00000000000000ruby-eb-2.6/COPYING000066400000000000000000000431051175214377300137760ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. ruby-eb-2.6/ChangeLog000066400000000000000000000037601175214377300145200ustar00rootroot000000000000002004-07-04 Kazuhiko * eb.c (rebfont_topng): add for eb-4.1 (font2bitmapformat): conv_func returns EB_Error_Code when eb-4.1 or later 2004-03-21 nyasu3w * eb.c: fixed the mispatched eb_set_appendix_subbook() 2004-03-15 nyasu3w * eb.c: delete the modification in 2004-03-14 eb-4.0 needs to be patched by ftp://ftp.sra.co.jp/pub/misc/eb/eb-4.0+.diff * eb.c: Bumped version number to 2.5 2004-03-14 nyasu3w * eb.c: add EB_P definition for its misdefinition in original eb-4.0 2004-03-11 Kazuhiko * extconf.rb: use 'RUBY_PLATFORM' instead of 'PLATFORM' 2004-03-07 nyasu3w * extconf.rb: change the way to support pthread * eb.c: add #include for eb-4.0 2004-02-29 nyasu3w * eb.c: Add eb_set_appendix_subbook() in reb_setsubbook(). Patched by YAMADA Kazushige. * eb.c: Move declaration of get_eb_appendix() 2004-01-07 nyasu3w * extconf.rb: Add "-lintl" flags for FreeBSD, patched by Kouhei Sutou. 2003-12-26 Kazuhiko * extconf.rb: read eb.conf and check whether eb supports pthread or not. 2003-11-21 Kazuhiko * eb.c: Bumped version number to 2.4. Add new hooks HOOK_BEGIN_DECORATION and HOOK_END_DECORATION. 2003-08-20 Kazuhiko * eb.c: Bumped version number to 2.3. Use 'rb_block_proc' if possible. * extconf.rb: Check 'rb_block_proc' for ruby-1.8. 2003-01-26 nyasu3w * eb.c: Reform coding convention.(ANSI & indent -npcs -br -ts 0 -i 4) * eb.c: Revise HOOK mis-definition(HOOK_END_IN_COLOR_GRAPHIC) * eb.c: Add a new constant EB::RUBYEB_VERSION. 2003-01-24 Kazuhiko * eb.c: Remove code for eb < 3.2 support. Bug fix of HOOK definition in case of eb-3.2. (copyright_available?): New method. ruby-eb-2.6/eb.c000066400000000000000000001254371175214377300135060ustar00rootroot00000000000000/********************************************** * eb.c * Ruby Extension Library for EB * $Id: eb.c,v 2.24 2004/07/12 17:45:15 nyasu3w Exp $ * Author: NISHIKAWA Yasuhiro * http://rubyeb.sourceforge.net/ * Copyleft ************************************************/ #define RUBYEB_VERSION "2.6" #include "ruby.h" #ifndef rb_iterator_p #define rb_iterator_p() rb_block_given_p() #endif #if HAVE_EB_SYSDEFS_H #include #endif #include #include #include #include #include #include #if EB_VERSION_MAJOR < 3 || (EB_VERSION_MAJOR==3 && EB_VERSION_MINOR<2) #error EB version too small. #endif /* eb_???_font_xbm_size() doesn't work on eb-3.2.3 */ #define HAVE_XBMSIZE_BUG 0 #include /* my decided numbers */ #define MAX_HITS 50 /* max hit results */ #define MAX_STRLEN 65530 /* (^^); */ #define MAX_KEYWORDS 8 /* max keywords */ /* my decided numbers end */ #define SEARCHTYPE_WORD 1 #define SEARCHTYPE_WORDLIST 2 #define HOOKSET_EB_IVAR "__hookset" #define HOOKSET_PROCS_IVAR "__hookprocs" #define APPENDIX_EB_IVAR "__appendix" struct ExtFont { int code; int wideflag; /* boolean */ EB_Font_Code fontsize; /* EB_FONT_?? */ char bitmap[EB_SIZE_WIDE_FONT_48]; }; static EB_Error_Code eb_error; VALUE mEB; VALUE cEBook; VALUE cEBCancel; VALUE cEBPosition; VALUE cEBExtFont; VALUE cEBHook; VALUE cEBAppendix; ID id_call; int text_hook(EB_Book * book, EB_Appendix * appendix, void *container, EB_Hook_Code code, int argc, const int *argv) { VALUE func, ret_buff, rb_argv, rb_eb, rb_hookset; int idx; char *tmpbuffer; rb_eb = (VALUE) container; rb_hookset = rb_iv_get(rb_eb, HOOKSET_EB_IVAR); if (rb_hookset == Qnil) { return 0; } func = rb_ary_entry(rb_iv_get(rb_hookset, HOOKSET_PROCS_IVAR), code); rb_argv = rb_ary_new2(argc); for (idx = 0; idx < argc; idx++) { rb_ary_store(rb_argv, idx, INT2FIX(argv[idx])); } ret_buff = rb_funcall(func, id_call, 2, rb_eb, rb_argv); if (ret_buff != Qnil) { if (TYPE(ret_buff) == T_STRING) { ret_buff = rb_funcall(ret_buff, rb_intern("to_str"), 0); } tmpbuffer = STR2CSTR(ret_buff); eb_write_text_string(book, tmpbuffer); } return 0; } /********** * Finalizers */ static void finalize_book(EB_Book * eb) { eb_finalize_book(eb); free(eb); } static void finalize_hookset(EB_Hookset * hk) { eb_finalize_hookset(hk); free(hk); } static void finalize_appendix(EB_Appendix * apx) { eb_finalize_appendix(apx); free(apx); } static EB_Appendix * get_eb_appendix(VALUE reb) { VALUE rebapx; EB_Appendix *appendix; rebapx = rb_iv_get(reb, APPENDIX_EB_IVAR); if (rebapx != Qnil) { Data_Get_Struct(rebapx, EB_Appendix, appendix); } else { appendix = NULL; } return appendix; } /****************************** ** EB Book */ static VALUE reb_initialize(VALUE klass) { VALUE robj, reb_appendix; EB_Book *eb; EB_Appendix *appendix; robj = Data_Make_Struct(klass, EB_Book, 0, finalize_book, eb); eb_initialize_book(eb); reb_appendix = Data_Make_Struct(cEBAppendix, EB_Appendix, 0, finalize_appendix, appendix); eb_initialize_appendix(appendix); rb_iv_set(robj, APPENDIX_EB_IVAR, reb_appendix); return robj; } static VALUE rEB_error(VALUE module) { return INT2NUM(eb_error); } static VALUE rEB_errormsg(VALUE module) { return rb_str_new2(eb_error_message(eb_error)); } static VALUE reb_bind(VALUE obj, VALUE path) { EB_Book *eb; int r; Data_Get_Struct(obj, EB_Book, eb); r = eb_bind(eb, STR2CSTR(path)); if (r != EB_SUCCESS) { rb_raise(rb_eRuntimeError, eb_error_message(r)); return Qfalse; } return obj; } static VALUE reb_disktype(VALUE obj) { EB_Book *eb; EB_Disc_Code r; Data_Get_Struct(obj, EB_Book, eb); eb_error = eb_disc_type(eb, &r); switch (r) { case EB_DISC_EB: return rb_str_new2("EB/EBG/EBXA/EBXA-C/S-EBXA"); break; case EB_DISC_EPWING: return rb_str_new2("EPWING"); break; } return rb_str_new2("Unknown"); } static VALUE reb_suspend(VALUE obj) { EB_Book *eb; Data_Get_Struct(obj, EB_Book, eb); eb_suspend(eb); return Qnil; } static VALUE reb_isbound(VALUE obj) { EB_Book *eb; int r; Data_Get_Struct(obj, EB_Book, eb); r = eb_is_bound(eb); return (r) ? Qtrue : Qfalse; } static VALUE reb_path(VALUE obj) { EB_Book *eb; char r[1024]; /*絶対値はまずいと思う */ Data_Get_Struct(obj, EB_Book, eb); eb_error = eb_path(eb, r); return rb_str_new2(r); } static VALUE reb_charcode(VALUE obj) { EB_Book *eb; EB_Character_Code r; Data_Get_Struct(obj, EB_Book, eb); eb_error = eb_character_code(eb, &r); switch (r) { case EB_CHARCODE_ISO8859_1: return rb_str_new2("ISO8859_1"); break; case EB_CHARCODE_JISX0208: return rb_str_new2("JISX0208"); break; } return Qnil; } static VALUE reb_subbookcount(VALUE obj) { EB_Book *eb; int r; EB_Subbook_Code sbooks[EB_MAX_SUBBOOKS]; Data_Get_Struct(obj, EB_Book, eb); /* eb_subbook_count(eb,&r); */ eb_subbook_list(eb, sbooks, &r); return INT2NUM(r); } static VALUE reb_subbooklist(VALUE obj) { EB_Book *eb; EB_Subbook_Code slist[EB_MAX_SUBBOOKS]; int i, r; VALUE robj; Data_Get_Struct(obj, EB_Book, eb); eb_error = eb_subbook_list(eb, slist, &r); robj = rb_ary_new2(r); for (i = 0; i < r; i++) rb_ary_push(robj, INT2NUM(slist[i])); return robj; } static VALUE reb_subbooktitle(int argc, VALUE * argv, VALUE obj) { EB_Book *eb; char r[1024]; /*絶対値はまずいと思う */ Data_Get_Struct(obj, EB_Book, eb); eb_error = (argc == 0) ? eb_subbook_title(eb, r) : eb_subbook_title2(eb, NUM2INT(argv[0]), r); return rb_str_new2(r); } static VALUE reb_subbookdirectory(int argc, VALUE * argv, VALUE obj) { EB_Book *eb; char r[1024]; /*絶対値はまずいと思う */ Data_Get_Struct(obj, EB_Book, eb); eb_error = (argc == 0) ? eb_subbook_directory(eb, r) : eb_subbook_directory2(eb, NUM2INT(argv[0]), r); return rb_str_new2(r); } static VALUE reb_setsubbook(VALUE obj, VALUE sbook) { EB_Book *eb; EB_Appendix *appendix; int r; int sub_code = NUM2INT(sbook); Data_Get_Struct(obj, EB_Book, eb); r = eb_set_subbook(eb, NUM2INT(sbook)); if(r != EB_SUCCESS) return Qfalse; appendix = get_eb_appendix(obj); if (eb_is_appendix_bound(appendix)) { r = eb_set_appendix_subbook(appendix, sub_code); if (r != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "eb_set_appendix_subbook() failed\n"); return Qfalse; } } return obj; } static VALUE reb_getsubbook(VALUE obj, VALUE sbook) { EB_Book *eb; int r; Data_Get_Struct(obj, EB_Book, eb); eb_error = eb_subbook(eb, &r); return INT2NUM(r); } static VALUE reb_unsetsubbook(VALUE obj) { EB_Book *eb; Data_Get_Struct(obj, EB_Book, eb); eb_unset_subbook(eb); return obj; } VALUE have_search(VALUE obj, EB_Error_Code(*funct) (EB_Book *)) { EB_Book *eb; int r; Data_Get_Struct(obj, EB_Book, eb); r = (*funct) (eb); if (!r && eb_error == EB_ERR_NO_CUR_SUB) { rb_raise(rb_eRuntimeError, eb_error_message(eb_error)); return Qfalse; } return (r) ? Qtrue : Qfalse; } static VALUE reb_haveexactsearch(VALUE obj) { return have_search(obj, eb_have_exactword_search); } static VALUE reb_havewordsearch(VALUE obj) { return have_search(obj, eb_have_word_search); } static VALUE reb_haveendsearch(VALUE obj) { return have_search(obj, eb_have_endword_search); } static VALUE reb_havekeywordsearch(VALUE obj) { return have_search(obj, eb_have_keyword_search); } /****************************** ** for result */ static EB_Hookset * get_eb_texthook(VALUE reb) { VALUE rebhook; EB_Hookset *text_hookset; rebhook = rb_iv_get(reb, HOOKSET_EB_IVAR); if (rebhook != Qnil) { Data_Get_Struct(rebhook, EB_Hookset, text_hookset); } else { text_hookset = NULL; } return text_hookset; } static VALUE content_read(VALUE reb, EB_Book * eb, EB_Appendix * appendix, EB_Hookset * text_hookset) { int len; char desc[MAX_STRLEN + 1]; eb_error = eb_read_text(eb, appendix, text_hookset, (void *) reb, MAX_STRLEN, desc, &len); if (len < 0) { rb_raise(rb_eRuntimeError, "fail fetching text"); return Qfalse; } return rb_str_new(desc, len); } static VALUE content_fetch_from_pos(VALUE reb, EB_Book * eb, EB_Position * pos, EB_Appendix * appendix, EB_Hookset * text_hookset) { if (eb_seek_text(eb, pos) != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "fail seeking(text)"); return Qfalse; } return content_read(reb, eb, appendix, text_hookset); } VALUE get_item(VALUE reb, EB_Book * eb, EB_Hit * hit) { EB_Hookset *text_hookset; EB_Appendix *appendix; VALUE item; char desc[MAX_STRLEN + 1]; int len; item = rb_ary_new2(2); if (eb_seek_text(eb, &(hit->heading)) < 0) { rb_raise(rb_eRuntimeError, "fail seeking"); return Qfalse; } text_hookset = get_eb_texthook(reb); appendix = get_eb_appendix(reb); eb_error = eb_read_heading(eb, appendix, text_hookset, (void *) reb, MAX_STRLEN, desc, &len); if (len < 0) { rb_raise(rb_eRuntimeError, "fail fetching heading"); return Qfalse; } rb_ary_push(item, rb_str_new(desc, len)); rb_ary_push(item, content_fetch_from_pos(reb, eb, &(hit->text), appendix, text_hookset)); return item; } VALUE hitmaker(VALUE reb, EB_Book * eb, unsigned int max, int flag) { int hitpushed, hitcount; EB_Hit hits[MAX_HITS]; VALUE robj, item, can; int i, broken; EB_Hookset *text_hookset; hitpushed = 0; text_hookset = get_eb_texthook(reb); robj = rb_ary_new(); broken = 0; while (1) { eb_error = eb_hit_list(eb, MAX_HITS, hits, &hitcount); if (hitcount == 0) break; /* return */ if (hitcount < 0) { rb_raise(rb_eRuntimeError, "fail getting list"); return Qfalse; } for (i = 0; i < hitcount; i++) { item = get_item(reb, eb, &hits[i]); if (flag == 0) { rb_ary_push(robj, item); } else { can = rb_yield(item); if (rb_obj_id(can) == rb_obj_id(cEBCancel)) { broken = 1; break; /* return */ } } hitpushed++; if (hitpushed >= max) { broken = 1; break; /* return */ } } if (broken) break; } return (flag == 0) ? robj : INT2NUM(hitpushed); } void set_keywords(VALUE array, char **buffer) { int i, sz; if (TYPE(array) != T_ARRAY) { rb_raise(rb_eTypeError, "wordlist must be array of String."); } sz = RARRAY(array)->len; if (sz > MAX_KEYWORDS) { rb_raise(rb_eRuntimeError, "too many keywords(%d).", sz); } for (i = 0; i < sz; i++) { buffer[i] = STR2CSTR(rb_ary_entry(array, i)); } buffer[sz] = NULL; } static VALUE easy_search(int argc, VALUE * argv, VALUE obj, int wordtype, EB_Error_Code(*funct) ()) { EB_Book *eb; void *word; char *buffer[MAX_KEYWORDS + 1]; int max; int r; if (argc < 1) { rb_raise(rb_eArgError, "missing searchstring"); return Qfalse; } if (wordtype == SEARCHTYPE_WORD) { word = STR2CSTR(argv[0]); } else { set_keywords(argv[0], buffer); word = buffer; } max = (argc > 1) ? NUM2INT(argv[1]) : -1; Data_Get_Struct(obj, EB_Book, eb); r = (*funct) (eb, word); if (r == -1) { rb_raise(rb_eRuntimeError, "fail searching"); return Qfalse; } /* tricky max: signed<->unsigned -1 */ return hitmaker(obj, eb, (unsigned) max, (rb_iterator_p())? 1 : 0); } static VALUE reb_searchword(int argc, VALUE * argv, VALUE obj) { return easy_search(argc, argv, obj, SEARCHTYPE_WORD, eb_search_word); } static VALUE reb_exactsearchword(int argc, VALUE * argv, VALUE obj) { return easy_search(argc, argv, obj, SEARCHTYPE_WORD, eb_search_exactword); } static VALUE reb_endsearchword(int argc, VALUE * argv, VALUE obj) { return easy_search(argc, argv, obj, SEARCHTYPE_WORD, eb_search_endword); } static VALUE reb_searchkeyword(int argc, VALUE * argv, VALUE obj) { return easy_search(argc, argv, obj, SEARCHTYPE_WORDLIST, eb_search_keyword); } /* Thanks for Kuroda-san */ VALUE hitmaker2(VALUE reb, EB_Book * eb, unsigned int max, int flag) { int hitcount, i, len, broken; int hitpushed; VALUE robj, item, can; EB_Hit hits[MAX_HITS]; char *desc; char descbuf1[MAX_STRLEN + 1]; EB_Position *ebpos; char descbuf2[MAX_STRLEN + 1]; char *prevdesc; int prevpage, prevoffset; desc = descbuf1; /*** this 2 lines necessary? (2/4) eblook do like this ***/ prevdesc = descbuf2; *prevdesc = '\0'; prevpage = 0; prevoffset = 0; robj = rb_ary_new(); hitpushed = 0; broken = 0; while (1) { eb_error = eb_hit_list(eb, MAX_HITS, hits, &hitcount); if (hitcount == 0) break; /* return */ if (hitcount < 0) { rb_raise(rb_eRuntimeError, "fail getting list"); return Qfalse; } for (i = 0; i < hitcount; i++) { if (eb_seek_text(eb, &(hits[i].heading)) < 0) { rb_raise(rb_eRuntimeError, "fail seeking"); return Qfalse; } eb_error = eb_read_heading(eb, get_eb_appendix(reb), get_eb_texthook(reb), (void *) reb, MAX_STRLEN, desc, &len); if (len < 0) { rb_raise(rb_eRuntimeError, "fail fetching heading"); return Qfalse; } /*** this 4 lines necessary? (3/4) eblook do like this ***/ if (prevpage == hits[i].text.page && prevoffset == hits[i].text.offset && strcmp(desc, prevdesc) == 0) continue; item = rb_ary_new2(2); rb_ary_push(item, Data_Make_Struct(cEBPosition, EB_Position, 0, free, ebpos)); rb_ary_push(item, rb_str_new(desc, len)); ebpos->page = hits[i].text.page; ebpos->offset = hits[i].text.offset; if (flag == 0) { /* non-iterator */ rb_ary_push(robj, item); } else { /* iterator */ can = rb_yield(item); if (rb_obj_id(can) == rb_obj_id(cEBCancel)) { broken = 1; break; /* return */ } } hitpushed++; if (hitpushed >= max) { broken = 1; break; } /*** this 6 lines necessary? (4/4) eblook do like this ***/ if (desc == descbuf1) { desc = descbuf2; prevdesc = descbuf1; } else { desc = descbuf1; prevdesc = descbuf2; } prevpage = hits[i].text.page; prevoffset = hits[i].text.offset; } if (broken) break; } return (flag == 0) ? robj : INT2NUM(hitpushed); } VALUE position_search(int argc, VALUE * argv, VALUE obj, int wordtype, EB_Error_Code(*funct) ()) { EB_Book *eb; char *buffer[MAX_KEYWORDS]; void *word; int max; int r; if (argc < 1) { rb_raise(rb_eArgError, "missing searchstring"); return Qfalse; } if (wordtype == SEARCHTYPE_WORD) { word = STR2CSTR(argv[0]); } else { set_keywords(argv[0], buffer); word = buffer; } max = (argc > 1) ? NUM2INT(argv[1]) : -1; Data_Get_Struct(obj, EB_Book, eb); r = (*funct) (eb, word); if (r == -1) { rb_raise(rb_eRuntimeError, "fail searching"); return Qfalse; } return hitmaker2(obj, eb, (unsigned) max, (rb_iterator_p())? 1 : 0); } static VALUE reb_exactsearchword2(int argc, VALUE * argv, VALUE obj) { return position_search(argc, argv, obj, SEARCHTYPE_WORD, eb_search_exactword); } static VALUE reb_searchword2(int argc, VALUE * argv, VALUE obj) { return position_search(argc, argv, obj, SEARCHTYPE_WORD, eb_search_word); } static VALUE reb_endsearchword2(int argc, VALUE * argv, VALUE obj) { return position_search(argc, argv, obj, SEARCHTYPE_WORD, eb_search_endword); } static VALUE reb_searchkeyword2(int argc, VALUE * argv, VALUE obj) { return position_search(argc, argv, obj, SEARCHTYPE_WORDLIST, eb_search_keyword); } static VALUE reb_content(VALUE obj, VALUE position) { EB_Position *ppos; EB_Book *eb; EB_Appendix *apx; EB_Hookset *thook; int dlen; VALUE robj; Data_Get_Struct(obj, EB_Book, eb); Data_Get_Struct(position, EB_Position, ppos); apx = get_eb_appendix(obj); thook = get_eb_texthook(obj); robj = content_fetch_from_pos(obj, eb, ppos, apx, thook); if (rb_iterator_p()) { do { rb_yield(robj); robj = content_read(obj, eb, apx, thook); dlen = MAX_STRLEN - RSTRING(robj)->len; } while (dlen == 0); } return robj; } static VALUE reb_content_noseek(VALUE obj) { EB_Book *eb; Data_Get_Struct(obj, EB_Book, eb); return content_read(obj, eb, get_eb_appendix(obj), get_eb_texthook(obj)); } static VALUE reb_sethookset(VALUE obj, VALUE hkset) { if (rb_funcall(hkset, rb_intern("is_a?"), 1, cEBHook) != Qtrue && hkset != Qnil) { rb_raise(rb_eArgError, "hookset must be nil or an instance of Hookset"); return Qfalse; } return rb_iv_set(obj, HOOKSET_EB_IVAR, hkset); }; static VALUE reb_gethookset(VALUE obj) { return rb_iv_get(obj, HOOKSET_EB_IVAR); } static VALUE reb_havecopyright(VALUE obj) { EB_Book *eb; int r; Data_Get_Struct(obj, EB_Book, eb); r = eb_have_copyright(eb); if (r) return Qtrue; return Qfalse; } static VALUE reb_copyright(VALUE obj) { EB_Book *eb; EB_Position pos; EB_Error_Code err; Data_Get_Struct(obj, EB_Book, eb); err = eb_copyright(eb, &pos); if (err == EB_ERR_NO_SUCH_SEARCH) { return Qnil; } else if (err != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "searching copyright was failed."); return Qfalse; } return content_fetch_from_pos(obj, eb, &pos, get_eb_appendix(obj), get_eb_texthook(obj)); } /* FONT */ static VALUE reb_font_list(VALUE obj) { EB_Font_Code font_list[EB_MAX_FONTS]; EB_Book *eb; VALUE robj; int font_count; int i; Data_Get_Struct(obj, EB_Book, eb); if (eb_font_list(eb, font_list, &font_count) != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "eb_font_list failed.\n"); return Qfalse; } robj = rb_ary_new2(font_count); for (i = 0; i < font_count; i++) { rb_ary_push(robj, INT2FIX(font_list[i])); } return robj; } EB_Font_Code get_fontcode(EB_Book * eb) { EB_Font_Code r; if (eb_font(eb, &r) != EB_SUCCESS) { return -1; } return r; } static VALUE reb_get_fontheight(VALUE obj) { EB_Book *eb; EB_Font_Code r; Data_Get_Struct(obj, EB_Book, eb); r = get_fontcode(eb); return INT2NUM(r); } static VALUE reb_set_fontheight(VALUE obj, VALUE height) { EB_Book *eb; Data_Get_Struct(obj, EB_Book, eb); if (eb_set_font(eb, NUM2UINT(height)) != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "font set failed."); return Qfalse; } return height; } static VALUE reb_font(VALUE obj, VALUE code, int wideflag, EB_Error_Code(*funct) (EB_Book *, int, char *)) { EB_Book *eb; VALUE robj; struct ExtFont *font; Data_Get_Struct(obj, EB_Book, eb); robj = Data_Make_Struct(cEBExtFont, struct ExtFont, 0, free, font); font->code = NUM2UINT(code); font->wideflag = wideflag; font->fontsize = get_fontcode(eb); if ((*funct) (eb, NUM2UINT(code), font->bitmap) != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "font[%x] bitmap retrieve failed.", NUM2UINT(code)); return Qfalse; } return robj; } static VALUE reb_widefont(VALUE obj, VALUE code) { return reb_font(obj, code, 1, eb_wide_font_character_bitmap); } static VALUE reb_narrowfont(VALUE obj, VALUE code) { return reb_font(obj, code, 0, eb_narrow_font_character_bitmap); } static VALUE reb_widestart(VALUE obj) { int code; EB_Book *eb; Data_Get_Struct(obj, EB_Book, eb); if (eb_wide_font_start(eb, &code) != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "subbook not selected or extfont not used in subbook"); return Qfalse; } return UINT2NUM(code); } static VALUE reb_wideend(VALUE obj) { int code; EB_Book *eb; Data_Get_Struct(obj, EB_Book, eb); if (eb_wide_font_end(eb, &code) != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "subbook not selected or extfont not used in subbook"); return Qfalse; } return UINT2NUM(code); } static VALUE reb_narrowstart(VALUE obj) { int code; EB_Book *eb; Data_Get_Struct(obj, EB_Book, eb); if (eb_narrow_font_start(eb, &code) != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "subbook not selected or extfont not used in subbook"); return Qfalse; } return UINT2NUM(code); } static VALUE reb_narrowend(VALUE obj) { int code; EB_Book *eb; Data_Get_Struct(obj, EB_Book, eb); if (eb_narrow_font_end(eb, &code) != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "subbook not selected or extfont not used in subbook"); return Qfalse; } return UINT2NUM(code); } static VALUE read_binary(EB_Book * eb, long maxlen, int iterateflag) { char buffer[MAX_STRLEN]; long readbytes; int bitmap_len; int blocksize; EB_Error_Code retcode; VALUE robj; robj = rb_str_new2(""); if (MAX_STRLEN < maxlen || maxlen < 0) { blocksize = MAX_STRLEN; } else { blocksize = maxlen; } bitmap_len = 1; /* set non-zero */ readbytes = 0; while (bitmap_len != 0) { retcode = eb_read_binary(eb, blocksize, buffer, &bitmap_len); if (retcode != EB_SUCCESS) { rb_raise(rb_eRuntimeError, eb_error_message(retcode)); return Qfalse; } if (iterateflag) { rb_yield(rb_str_new(buffer, bitmap_len)); readbytes += bitmap_len; } else { rb_str_cat(robj, buffer, bitmap_len); readbytes += bitmap_len; if (maxlen > 0 && readbytes >= maxlen) break; } } return iterateflag ? INT2NUM(readbytes) : robj; } static VALUE reb_read_monographic(VALUE obj, VALUE pos, VALUE width, VALUE height) { EB_Error_Code retcode; EB_Book *eb; EB_Position *epos; Data_Get_Struct(obj, EB_Book, eb); Data_Get_Struct(pos, EB_Position, epos); retcode = eb_set_binary_mono_graphic(eb, epos, NUM2UINT(width), NUM2UINT(height)); if (retcode != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "failed to set binary mode [monographic]"); return Qfalse; } return read_binary(eb, -1, 0); } static VALUE reb_read_colorgraphic(int argc, VALUE * argv, VALUE obj) { EB_Error_Code retcode; EB_Book *eb; EB_Position *epos; long maxlen; if (argv == 0) { rb_raise(rb_eArgError, "wrong # of arguments(0 for 1 or 2)"); return Qfalse; } Data_Get_Struct(obj, EB_Book, eb); Data_Get_Struct(argv[0], EB_Position, epos); maxlen = (argc > 1) ? NUM2UINT(argv[1]) : MAX_STRLEN; retcode = eb_set_binary_color_graphic(eb, epos); if (retcode != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "failed to set binary mode [colorgraphic]"); return Qfalse; } return read_binary(eb, maxlen, (rb_iterator_p()? 1 : 0)); } static VALUE reb_read_wavedata(int argc, VALUE * argv, VALUE obj) { EB_Error_Code retcode; EB_Book *eb; EB_Position *spos, *epos; long maxlen; if (argc < 2) { rb_raise(rb_eArgError, "both start_pos and end_pos needed.(argument shortage)"); return Qfalse; } maxlen = (argc > 2) ? NUM2UINT(argv[2]) : MAX_STRLEN; Data_Get_Struct(obj, EB_Book, eb); Data_Get_Struct(argv[0], EB_Position, spos); Data_Get_Struct(argv[1], EB_Position, epos); retcode = eb_set_binary_wave(eb, spos, epos); if (retcode != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "failed to set binary mode [wave]"); return Qfalse; } return read_binary(eb, maxlen, (rb_iterator_p()? 1 : 0)); } static VALUE reb_read_mpeg(int argc, VALUE * argv, VALUE obj) { EB_Error_Code retcode; EB_Book *eb; long maxlen; int param[4]; int i; if (argc < 4) { rb_raise(rb_eArgError, "need code1,code2,code3,code4."); return Qnil; } for (i = 0; i < 4; i++) param[i] = NUM2UINT(argv[i]); maxlen = (argc > 4) ? NUM2UINT(argv[4]) : MAX_STRLEN; Data_Get_Struct(obj, EB_Book, eb); retcode = eb_set_binary_mpeg(eb, param); if (retcode != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "failed to set binary mode [mpeg]"); return Qfalse; } return read_binary(eb, maxlen, (rb_iterator_p()? 1 : 0)); } static VALUE reb_compose_mpegfilename(int argc, VALUE * argv, VALUE obj) { EB_Error_Code retcode; char buffer[1024]; int param[4]; int i; if (argc != 4) { rb_raise(rb_eArgError, "4 args needed.(code1-code4)"); return Qfalse; } for (i = 0; i < 4; i++) param[i] = NUM2UINT(argv[i]); retcode = eb_compose_movie_file_name(param, buffer); if (retcode != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "failed to compose movie filename."); return Qfalse; } return rb_str_new2(buffer); } static VALUE reb_havemenu(VALUE obj) { EB_Book *eb; int r; Data_Get_Struct(obj, EB_Book, eb); r = eb_have_menu(eb); if (r) return Qtrue; return Qfalse; } static VALUE reb_menu(VALUE obj) { EB_Book *eb; EB_Position pos; EB_Error_Code err; Data_Get_Struct(obj, EB_Book, eb); err = eb_menu(eb, &pos); if (err == EB_ERR_NO_SUCH_SEARCH) { return Qnil; } else if (err != EB_SUCCESS) { rb_raise(rb_eRuntimeError, eb_error_message(err)); return Qfalse; } return content_fetch_from_pos(obj, eb, &pos, get_eb_appendix(obj), get_eb_texthook(obj)); } static VALUE reb_menu2(VALUE obj) { EB_Book *eb; EB_Position pos, *rpos; EB_Error_Code err; VALUE robj; Data_Get_Struct(obj, EB_Book, eb); err = eb_menu(eb, &pos); if (err == EB_ERR_NO_SUCH_SEARCH) { return Qnil; } else if (err != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "failed to fetch menu(%d)\n", err); return Qfalse; } robj = Data_Make_Struct(cEBPosition, EB_Position, 0, free, rpos); rpos->page = pos.page; rpos->offset = pos.offset; return robj; } static VALUE reb_appendixpath(VALUE obj, VALUE path) { EB_Appendix *appendix; appendix = get_eb_appendix(obj); if (path != Qnil) { eb_bind_appendix(appendix, STR2CSTR(path)); } else { eb_finalize_appendix(appendix); eb_initialize_appendix(appendix); } return path; } /** * ExtFont **/ static VALUE rebfont_wide_p(VALUE obj) { struct ExtFont *font; Data_Get_Struct(obj, struct ExtFont, font); if (font->wideflag) return Qtrue; return Qfalse; } static VALUE rebfont_code(VALUE obj) { struct ExtFont *font; Data_Get_Struct(obj, struct ExtFont, font); return UINT2NUM(font->code); } static VALUE font2bitmapformat(struct ExtFont *font, EB_Error_Code(*w_size_func) (), EB_Error_Code(*n_size_func) (), #if EB_VERSION_MAJOR < 4 || (EB_VERSION_MAJOR == 4 && EB_VERSION_MINOR < 1) void (*conv_func) ()) #else EB_Error_Code(*conv_func) ()) #endif { int size, retcode; int height, width; char *buffer; VALUE robj; #if HAVE_XBMSIZE_BUG /* eb_???_font_xbm_size() doesn't work on eb-3.2.3 */ if (font->wideflag == 1) { retcode = (*w_size_func) (font->fontsize, &size); } else { retcode = (*n_size_func) (font->fontsize, &size); } if (size == 0) { rb_raise(rb_eRuntimeError, "conversion size error[return code%d]", retcode); return Qfalse; } #else /* quick and loose hack */ size = 0xffff; #endif buffer = malloc(size + 1); if (buffer == NULL) { rb_raise(rb_eRuntimeError, "malloc error"); return Qfalse; } if (font->wideflag == 1) { retcode = eb_wide_font_width2(font->fontsize, &width); } else { retcode = eb_narrow_font_width2(font->fontsize, &width); } if (retcode != EB_SUCCESS || eb_font_height2(font->fontsize, &height) != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "fontsize unknown."); return Qfalse; }; (*conv_func) (font->bitmap, width, height, buffer, &size); robj = rb_str_new(buffer, size); free(buffer); return robj; } static VALUE rebfont_toxbm(VALUE extfont) { struct ExtFont *font; Data_Get_Struct(extfont, struct ExtFont, font); return font2bitmapformat(font, eb_wide_font_xbm_size, eb_narrow_font_xbm_size, eb_bitmap_to_xbm); } static VALUE rebfont_toxpm(VALUE extfont) { struct ExtFont *font; Data_Get_Struct(extfont, struct ExtFont, font); return font2bitmapformat(font, eb_wide_font_xpm_size, eb_narrow_font_xpm_size, eb_bitmap_to_xpm); } static VALUE rebfont_togif(VALUE extfont) { struct ExtFont *font; Data_Get_Struct(extfont, struct ExtFont, font); return font2bitmapformat(font, eb_wide_font_gif_size, eb_narrow_font_gif_size, eb_bitmap_to_gif); } static VALUE rebfont_tobmp(VALUE extfont) { struct ExtFont *font; Data_Get_Struct(extfont, struct ExtFont, font); return font2bitmapformat(font, eb_wide_font_bmp_size, eb_narrow_font_bmp_size, eb_bitmap_to_bmp); } #if HAVE_EB_BITMAP_TO_PNG static VALUE rebfont_topng(VALUE extfont) { struct ExtFont *font; Data_Get_Struct(extfont, struct ExtFont, font); return font2bitmapformat(font, eb_wide_font_png_size, eb_narrow_font_png_size, eb_bitmap_to_png); } #endif /** * EBPosition **/ static VALUE reb_pos_initialize(int argc, VALUE * argv, VALUE klass) { VALUE robj, page, offset; EB_Position *ebpos; robj = Data_Make_Struct(klass, EB_Position, 0, free, ebpos); if (rb_scan_args(argc, argv, "02", &page, &offset) > 0) { Check_Type(page, T_FIXNUM); Check_Type(offset, T_FIXNUM); ebpos->page = FIX2INT(page); ebpos->offset = FIX2INT(offset); } return robj; } static VALUE reb_pos_get_page(VALUE obj) { EB_Position *pos; Data_Get_Struct(obj, EB_Position, pos); return INT2FIX(pos->page); } static VALUE reb_pos_get_offset(VALUE obj) { EB_Position *pos; Data_Get_Struct(obj, EB_Position, pos); return INT2FIX(pos->offset); } static VALUE reb_pos_set_page(VALUE obj, VALUE spage) { EB_Position *pos; Data_Get_Struct(obj, EB_Position, pos); pos->page = FIX2INT(spage); return obj; } static VALUE reb_pos_set_offset(VALUE obj, VALUE soffset) { EB_Position *pos; Data_Get_Struct(obj, EB_Position, pos); pos->offset = FIX2INT(soffset); return obj; } static VALUE rebhk_new(VALUE klass) { VALUE robj; EB_Hookset *text_hookset; robj = Data_Make_Struct(cEBHook, EB_Hookset, 0, finalize_hookset, text_hookset); eb_initialize_hookset(text_hookset); rb_iv_set(robj, HOOKSET_PROCS_IVAR, rb_ary_new2(EB_NUMBER_OF_HOOKS)); return robj; } static VALUE rebhk_register(int argc, VALUE * argv, VALUE self) { VALUE proc = Qnil; int hook_type; EB_Hookset *text_hookset; EB_Hook hook; switch (argc) { case 1: #if HAVE_RB_BLOCK_PROC proc = rb_block_proc(); #else proc = rb_f_lambda(); #endif break; case 2: proc = argv[1]; break; default: rb_raise(rb_eArgError, "wrong # of arguments"); break; } hook_type = FIX2UINT(argv[0]); rb_ary_store(rb_iv_get(self, HOOKSET_PROCS_IVAR), hook_type, proc); Data_Get_Struct(self, EB_Hookset, text_hookset); hook.code = hook_type; if (proc != Qnil) { hook.function = (int (*)()) (text_hook); } else { hook.function = NULL; } if (eb_set_hook(text_hookset, &hook) != EB_SUCCESS) { rb_raise(rb_eRuntimeError, "set_hook(%d) failed", hook_type); return Qfalse; } return Qnil; } static VALUE reb_mod_initialize(VALUE obj) { eb_initialize_library(); return obj; } static VALUE reb_mod_finalize(VALUE obj) { /* printf("mod_finalize\n"); */ eb_finalize_library(); return obj; } static VALUE reb_dontuseexception(VALUE obj) { rb_raise(rb_eNameError, "Don't use this method."); return Qfalse; } void define_constants_under(VALUE mod) { rb_define_const(mod, "HOOK_INITIALIZE", INT2FIX(EB_HOOK_INITIALIZE)); rb_define_const(mod, "HOOK_BEGIN_NARROW", INT2FIX(EB_HOOK_BEGIN_NARROW)); rb_define_const(mod, "HOOK_END_NARROW", INT2FIX(EB_HOOK_END_NARROW)); rb_define_const(mod, "HOOK_BEGIN_SUBSCRIPT", INT2FIX(EB_HOOK_BEGIN_SUBSCRIPT)); rb_define_const(mod, "HOOK_END_SUBSCRIPT", INT2FIX(EB_HOOK_END_SUBSCRIPT)); rb_define_const(mod, "HOOK_SET_INDENT", INT2FIX(EB_HOOK_SET_INDENT)); rb_define_const(mod, "HOOK_NEWLINE", INT2FIX(EB_HOOK_NEWLINE)); rb_define_const(mod, "HOOK_BEGIN_SUPERSCRIPT", INT2FIX(EB_HOOK_BEGIN_SUPERSCRIPT)); rb_define_const(mod, "HOOK_END_SUPERSCRIPT", INT2FIX(EB_HOOK_END_SUPERSCRIPT)); rb_define_const(mod, "HOOK_BEGIN_NO_NEWLINE", INT2FIX(EB_HOOK_BEGIN_NO_NEWLINE)); rb_define_const(mod, "HOOK_END_NO_NEWLINE", INT2FIX(EB_HOOK_END_NO_NEWLINE)); rb_define_const(mod, "HOOK_BEGIN_EMPHASIS", INT2FIX(EB_HOOK_BEGIN_EMPHASIS)); rb_define_const(mod, "HOOK_END_EMPHASIS", INT2FIX(EB_HOOK_END_EMPHASIS)); rb_define_const(mod, "HOOK_BEGIN_CANDIDATE", INT2FIX(EB_HOOK_BEGIN_CANDIDATE)); rb_define_const(mod, "HOOK_END_CANDIDATE_GROUP", INT2FIX(EB_HOOK_END_CANDIDATE_GROUP)); rb_define_const(mod, "HOOK_END_CANDIDATE_LEAF", INT2FIX(EB_HOOK_END_CANDIDATE_LEAF)); rb_define_const(mod, "HOOK_BEGIN_REFERENCE", INT2FIX(EB_HOOK_BEGIN_REFERENCE)); rb_define_const(mod, "HOOK_END_REFERENCE", INT2FIX(EB_HOOK_END_REFERENCE)); rb_define_const(mod, "HOOK_BEGIN_KEYWORD", INT2FIX(EB_HOOK_BEGIN_KEYWORD)); rb_define_const(mod, "HOOK_END_KEYWORD", INT2FIX(EB_HOOK_END_KEYWORD)); rb_define_const(mod, "HOOK_NARROW_FONT", INT2FIX(EB_HOOK_NARROW_FONT)); rb_define_const(mod, "HOOK_WIDE_FONT", INT2FIX(EB_HOOK_WIDE_FONT)); rb_define_const(mod, "HOOK_ISO8859_1", INT2FIX(EB_HOOK_ISO8859_1)); rb_define_const(mod, "HOOK_NARROW_JISX0208", INT2FIX(EB_HOOK_NARROW_JISX0208)); rb_define_const(mod, "HOOK_WIDE_JISX0208", INT2FIX(EB_HOOK_WIDE_JISX0208)); rb_define_const(mod, "HOOK_GB2312", INT2FIX(EB_HOOK_GB2312)); rb_define_const(mod, "HOOK_BEGIN_MONO_GRAPHIC", INT2FIX(EB_HOOK_BEGIN_MONO_GRAPHIC)); rb_define_const(mod, "HOOK_END_MONO_GRAPHIC", INT2FIX(EB_HOOK_END_MONO_GRAPHIC)); rb_define_const(mod, "HOOK_BEGIN_GRAY_GRAPHIC", INT2FIX(EB_HOOK_BEGIN_GRAY_GRAPHIC)); rb_define_const(mod, "HOOK_END_GRAY_GRAPHIC", INT2FIX(EB_HOOK_END_GRAY_GRAPHIC)); rb_define_const(mod, "HOOK_BEGIN_COLOR_BMP", INT2FIX(EB_HOOK_BEGIN_COLOR_BMP)); rb_define_const(mod, "HOOK_BEGIN_COLOR_JPEG", INT2FIX(EB_HOOK_BEGIN_COLOR_JPEG)); rb_define_const(mod, "HOOK_END_COLOR_GRAPHIC", INT2FIX(EB_HOOK_END_COLOR_GRAPHIC)); rb_define_const(mod, "HOOK_END_IN_COLOR_GRAPHIC", INT2FIX(EB_HOOK_END_IN_COLOR_GRAPHIC)); rb_define_const(mod, "HOOK_BEGIN_GRAPHIC_REFERENCE", INT2FIX(EB_HOOK_BEGIN_GRAPHIC_REFERENCE)); rb_define_const(mod, "HOOK_END_GRAPHIC_REFERENCE", INT2FIX(EB_HOOK_END_GRAPHIC_REFERENCE)); rb_define_const(mod, "HOOK_GRAPHIC_REFERENCE", INT2FIX(EB_HOOK_GRAPHIC_REFERENCE)); #if !(EB_VERSION_MAJOR == 3 && EB_VERSION_MINOR == 2) rb_define_const(mod, "HOOK_BEGIN_IN_COLOR_BMP", INT2FIX(EB_HOOK_BEGIN_IN_COLOR_BMP)); rb_define_const(mod, "HOOK_BEGIN_IN_COLOR_JPEG", INT2FIX(EB_HOOK_BEGIN_IN_COLOR_JPEG)); #endif rb_define_const(mod, "HOOK_BEGIN_WAVE", INT2FIX(EB_HOOK_BEGIN_WAVE)); rb_define_const(mod, "HOOK_END_WAVE", INT2FIX(EB_HOOK_END_WAVE)); rb_define_const(mod, "HOOK_BEGIN_MPEG", INT2FIX(EB_HOOK_BEGIN_MPEG)); rb_define_const(mod, "HOOK_END_MPEG", INT2FIX(EB_HOOK_END_MPEG)); rb_define_const(mod, "HOOK_BEGIN_DECORATION", INT2FIX(EB_HOOK_BEGIN_DECORATION)); rb_define_const(mod, "HOOK_END_DECORATION", INT2FIX(EB_HOOK_END_DECORATION)); rb_define_const(mod, "FONT_16", INT2FIX(EB_FONT_16)); rb_define_const(mod, "FONT_24", INT2FIX(EB_FONT_24)); rb_define_const(mod, "FONT_30", INT2FIX(EB_FONT_30)); rb_define_const(mod, "FONT_48", INT2FIX(EB_FONT_48)); rb_define_const(mod, "FONT_INVALID", INT2FIX(EB_FONT_INVALID)); } /****************************** ** Init */ void Init_eb() { id_call = rb_intern("call"); mEB = rb_define_module("EB"); rb_define_const(mEB,"RUBYEB_VERSION",rb_str_new2(RUBYEB_VERSION)); cEBook = rb_define_class_under(mEB, "Book", rb_cObject); cEBCancel = rb_define_class_under(mEB, "Cancel", rb_cObject); cEBPosition = rb_define_class_under(mEB, "Position", rb_cObject); cEBExtFont = rb_define_class_under(mEB, "ExtFont", rb_cObject); cEBHook = rb_define_class_under(mEB, "Hookset", rb_cObject); cEBAppendix = rb_define_class_under(mEB, "Appendix", rb_cObject); rb_define_singleton_method(mEB, "errorcode", rEB_error, 0); rb_define_singleton_method(mEB, "error_message", rEB_errormsg, 0); rb_define_singleton_method(cEBook, "new", reb_initialize, 0); rb_define_method(cEBook, "bind", reb_bind, 1); rb_define_method(cEBook, "disctype", reb_disktype, 0); rb_define_method(cEBook, "disktype", reb_disktype, 0); rb_define_method(cEBook, "suspend", reb_suspend, 0); rb_define_method(cEBook, "bound?", reb_isbound, 0); rb_define_method(cEBook, "path", reb_path, 0); rb_define_method(cEBook, "charcode", reb_charcode, 0); rb_define_method(cEBook, "subbook_count", reb_subbookcount, 0); rb_define_method(cEBook, "subbook_list", reb_subbooklist, 0); rb_define_method(cEBook, "title", reb_subbooktitle, -1); rb_define_method(cEBook, "directory", reb_subbookdirectory, -1); rb_define_method(cEBook, "set", reb_setsubbook, 1); rb_define_method(cEBook, "subbook=", reb_setsubbook, 1); rb_define_method(cEBook, "subbook", reb_getsubbook, 0); rb_define_method(cEBook, "unset", reb_unsetsubbook, 0); rb_define_method(cEBook, "search", reb_searchword, -1); rb_define_method(cEBook, "exactsearch", reb_exactsearchword, -1); rb_define_method(cEBook, "endsearch", reb_endsearchword, -1); rb_define_method(cEBook, "keywordsearch", reb_searchkeyword, -1); rb_define_method(cEBook, "search2", reb_searchword2, -1); rb_define_method(cEBook, "exactsearch2", reb_exactsearchword2, -1); rb_define_method(cEBook, "endsearch2", reb_endsearchword2, -1); rb_define_method(cEBook, "keywordsearch2", reb_searchkeyword2, -1); rb_define_method(cEBook, "content", reb_content, 1); rb_define_method(cEBook, "content_noseek", reb_content_noseek, 0); rb_define_method(cEBook, "search_available?", reb_havewordsearch, 0); rb_define_method(cEBook, "exactsearch_available?", reb_haveexactsearch, 0); rb_define_method(cEBook, "endsearch_available?", reb_haveendsearch, 0); rb_define_method(cEBook, "keywordsearch_available?", reb_havekeywordsearch, 0); rb_define_method(cEBook, "hookset=", reb_sethookset, 1); rb_define_method(cEBook, "hookset", reb_gethookset, 0); rb_define_method(cEBook, "copyright_available?", reb_havecopyright, 0); rb_define_method(cEBook, "copyright", reb_copyright, 0); rb_define_method(cEBook, "fontcode_list", reb_font_list, 0); rb_define_method(cEBook, "get_widefont", reb_widefont, 1); rb_define_method(cEBook, "get_narrowfont", reb_narrowfont, 1); rb_define_method(cEBook, "fontcode", reb_get_fontheight, 0); rb_define_method(cEBook, "fontcode=", reb_set_fontheight, 1); rb_define_method(cEBook, "wide_startcode", reb_widestart, 0); rb_define_method(cEBook, "wide_endcode", reb_wideend, 0); rb_define_method(cEBook, "narrow_startcode", reb_narrowstart, 0); rb_define_method(cEBook, "narrow_endcode", reb_narrowend, 0); rb_define_method(cEBook, "read_monographic", reb_read_monographic, 3); rb_define_method(cEBook, "read_colorgraphic", reb_read_colorgraphic, -1); rb_define_method(cEBook, "read_wavedata", reb_read_wavedata, -1); rb_define_method(cEBook, "read_mpeg", reb_read_mpeg, -1); rb_define_method(cEBook, "compose_mpegfilename", reb_compose_mpegfilename, -1); /* menues */ rb_define_method(cEBook, "menu_available?", reb_havemenu, 0); rb_define_method(cEBook, "menu", reb_menu, 0); rb_define_method(cEBook, "menu2", reb_menu2, 0); /* appendix_path= is temporal now */ rb_define_method(cEBook, "appendix_path=", reb_appendixpath, 1); rb_define_singleton_method(cEBHook, "new", rebhk_new, 0); rb_define_method(cEBHook, "register", rebhk_register, -1); rb_define_singleton_method(cEBExtFont, "new", reb_dontuseexception, 0); rb_define_method(cEBExtFont, "widefont?", rebfont_wide_p, 0); rb_define_method(cEBExtFont, "code", rebfont_code, 0); rb_define_method(cEBExtFont, "to_xbm", rebfont_toxbm, 0); rb_define_method(cEBExtFont, "to_xpm", rebfont_toxpm, 0); rb_define_method(cEBExtFont, "to_gif", rebfont_togif, 0); rb_define_method(cEBExtFont, "to_bmp", rebfont_tobmp, 0); #if HAVE_EB_BITMAP_TO_PNG rb_define_method(cEBExtFont, "to_png", rebfont_topng, 0); #endif rb_define_singleton_method(cEBPosition, "new", reb_pos_initialize, -1); rb_define_method(cEBPosition, "page", reb_pos_get_page, 0); rb_define_method(cEBPosition, "offset", reb_pos_get_offset, 0); rb_define_method(cEBPosition, "page=", reb_pos_set_page, 1); rb_define_method(cEBPosition, "offset=", reb_pos_set_offset, 1); eb_initialize_library(); /* Don't call the following methods manually */ rb_define_module_function(mEB, "Initialize", reb_mod_initialize, 0); rb_define_module_function(mEB, "Finalize", reb_mod_finalize, 0); rb_eval_string("at_exit do EB::Finalize(); end\n"); define_constants_under(mEB); } ruby-eb-2.6/eb.html000066400000000000000000000443211175214377300142200ustar00rootroot00000000000000 module EB

Ruby/EB $B3HD%%i%$%V%i%j(J

for version 2.5

$BL\

$B35MW(J

EPWING/EB$B$J$I$N(JCD-ROM $B=q@R$K%"%/%;%9$9$k$?$a$N4X?t$r=8$a$?!"(JC $B8@8l$N%i%$%V%i%j(J $B!V(JEB$B!W(J $B$r(Jruby$B$+$iMxMQ$9$k$?$a$N3HD%%i%$%V%i%j$G$9!#(JEB$B$K$D$$$F>\$7$/$OG[I[85$G$"$k(J $B$3$A$i(J $B$N%Z!<%8$X$I$&$>!#(JEB$B$N:n

$BMxMQ$K$OEvA3(JEB$B$,@5$7$/%$%s%9%H!<%k$5$l$F$$$kI,MW$,$"$j$^$9!#(J
Ruby/EB version2$B$h$j!"(JEB$B$N(J3.2$B0J9_$rMW5a$7$^$9!#(J $B$^$?!"(JRuby/EB$B$N(J1.x$B$KBP$7$F%F%-%9%H%U%C%/4X78$N;EMM$,JQ99$5$l$F$$$^$9!#$4Cm0U2<$5$$!#(J

EB$B$,4A;z%3!<%I$H$7$F(JEUC$B$rMW5a$7$^$9$N$G!"(J$KCODE$B$O(JEUC$B$G$*4j$$$7$^$9!#(J

EB$B<+?H$,(JGPL$B$N$?$a!"K\(JRuby$B3HD%%i%$%V%i%j$b(JGPL$B$H$7$^$9!#(J

$BO$O(J $B$3$A$i(J $B$N3^86MM$NJ8>O$N%Q%/%j$NItJ,$,B?!9$"$j$^$9!#$I$&$b$9$_$^$;$s!#(J

Book#search2$B7O!"(JBook#content,$B%U%C%/4XO"!"(JPosition$B%/%i%9$J$I$O9uEDMM$+$i$N%Q%C%A$K5r$k$H$3$m$,Bg$-$$$G$9!#$I$&$b$"$j$,$H$&$4$6$$$^$7$?!#(J

EB$B$N(J3.0alpha$B$X$NBP1~$O?72~MM$N%3!<%G%#%s%0$K0M$k$b$N$G$9!#$I$&$b$"$j$,$H$&$4$6$$$^$7$?!#(J

EB3.0+$B$X$NBP1~$O!"$d$^$@MM!"$&$($AMMN>L>$h$j%Q%C%A$rD:$-$^$7$?!#$I$&$b$"$j$,$H$&$4$6$$$^$7$?!#(J

EB-3.2.1$B$X$NBP1~$O!"9b=!MM!"(Jknu$BMM:n@.$N%Q%C%A$K$h$j$^$9!#$I$&$b$"$j$,$H$&$4$6$$$^$7$?!#(J

$B$$$$$+$2$s$@$C$?(JAppendix$B$X$NBP1~$O!";3EDMM$K$h$C$F=$@5$5$l$^$7$?!#$I$&$b$"$j$,$H$&$4$6$$$^$9!#(J

EB-4.0$B$rMxMQ$9$k>l9g$O!"(JEB-4.0$BK\BN$K(J$B%Q%C%A(J$B$,I,MW$G$9!#(J

RubyEB 2.2$B$h$j!"$+$:$R$3;a$,3+H/$K;22C$5$l$^$7$?!#(J

$B

RubyEB$B$N%Z!<%8(J$B$+$i $B$^$?!"(Jcvs$B$+$i $B"*(J$BJ}K!(J

$BJ8Cf$N:GBg%V%m%C%/D9$O%G%U%)%k%H$G$O(J65530bytes$B$G$9!#(J

module EB

errorcode
eb$B$G%(%i!<$,H/@8$7$?$H$-%;%C%H$5$l$^$9!#(J
error_message
errorcode$B$rJ8;zNs$K$7$?$b$N$rJV$7$^$9(J

EB::Book

$B%/%i%9%a%=%C%I(J

new

$B%a%=%C%I(J($B=q@R(J)

bind
$B%*%V%8%'%/%H$r!"%Q%9(J path $B$K$"$k(J CD-ROM $B=q@R$K7k$SIU$1$^$9!#%Q%9$O=q@R$N%H%C%W%G%#%l%/%H%j!"$D$^$j(J `CATALOG' $B$+(J `CATALOGS' $B%U%!%$%k$N$"$k%G%#%l%/%H%j$G$J$/$F$O$J$j$^$;$s!#(J
suspend
$B%*%V%8%'%/%H$,8=:_A*BrCf$N$b$N!"$9$J$o$A!"A*BrCf$NI{K\!"8@8l!"%U%)%s%H$N9b$5$r$9$Y$FL$A*Br$K$7$^$9(J
bound?
$B=q@R$K7k$SIU$$$F$$$k$+$I$&$+$rD4$Y$^$9!#(J
disctype
$B%G%#%9%/$N7A<0$rJV$7$^$9!#(J $B%*%V%8%'%/%H$O$"$i$+$8$a=q@R$K7k$SIU$$$F$$$J$1$l$P$J$j$^$;$s!#(J
path
$B=q@R$N%Q%9$rJV$7$^$9!#(J $B%*%V%8%'%/%H$O$"$i$+$8$a=q@R$K7k$SIU$$$F$$$J$1$l$P$J$j$^$;$s!#(J
charcode
$B=q$+$l$F$$$kJ8;z%3!<%I$rJV$7$^$9!#(J $B%*%V%8%'%/%H$O$"$i$+$8$a=q@R$K7k$SIU$$$F$$$J$1$l$P$J$j$^$;$s!#(J
subbook_count
$B%*%V%8%'%/%HFb$NI{K\$N?t$rJV$7$^$9!#%*%V%8%'%/%H$O!"$"$i$+$8$a=q@R$K7k$SIU$1$i$l$F$$$J$/$F$O$J$j$^$;$s!#(J
subbook_list
$BI{K\$N%j%9%H$r:n@.$7$FI{K\%3!<%I$NG[Ns$H$7$FJV$7$^$9!#$3$3$GF@$i$l$kI{K\%3!<%I$rMQ$$$F!"(Jset(subbook)/title/directory$B%a%=%C%I$K$*$$$FI{K\$r;XDj$7$^$9!#(J
set(subbook) : alias subbook=
$BI{K\$rA*Br$7$^$9!#(J
subbook
$B8=:_A*BrCf$NI{K\$NI{K\%3!<%I$rJV$7$^$9!#$"$i$+$8$a!"%*%V%8%'%/%HFb$N$$$:$l$+$NI{K\$,A*Br$5$l$F$$$J$/$F$O$J$j$^$;$s!#(J $B@_Dj$5$l$F$$$J$$>l9g$O(J-1$B$H$J$j$^$9!#(J
unset
$BI{K\$NA*Br$r2r=|$7$^$9!#(J
hookset/hooset=
$B%F%-%9%H%U%C%/$N%;%C%H$rl9g$O(JEB::Hookset$B$N%$%s%9%?%s%9$+(Jnil$B$7$+=PMh$^$;$s!#(Jnil$B$r@_Dj$7$?$H$-$O%U%C%/$r2r=|$7$^$9!#(J
appendix_path=
Appendix$B$r@_Dj$7$^$9!#(J

$B%a%=%C%I(J($BI{K\(J)

title(subbook=currently)
$B8=:_A*BrCf$NI{K\$NBjL>$rJV$7$^$9!#$"$i$+$8$a!"%*%V%8%'%/%HFb$N$$$:$l$+$NI{K\$,A*Br$5$l$F$$$J$/$F$O$J$j$^$;$s!#(J
$B0z?t$r>JN,$9$k$H!"8=:_A*Br$5$l$F$$$kI{K\$NBjL>$rJV$7$^$9!#(J
directory(subbook=currently)
$B8=:_A*BrCf$NI{K\$N%G%#%l%/%H%jL>$rJV$7$^$9!#$"$i$+$8$a!"%*%V%8%'%/%HFbFb$N$$$:$l$+$NI{K\$,A*Br$5$l$F$$$J$/$F$O$J$j$^$;$s!#(J
$B0z?t$r>JN,$9$k$H!"8=:_A*Br$5$l$F$$$kI{K\$N%G%#%l%/%H%j$rJV$7$^$9!#(J
search_available?
$B8=:_A*BrCf$NI{K\$,A0J}0lCW8!:w%a%=%C%I$r;}$C$F$$$k$+$I$&$+D4$Y$^$9!#(J
$BI{K\$,A*Br$5$l$F$$$J$$>l9g$O(JRuntimeError$B$r(Jraise$B$7$^$9!#(J
exactsearch_available?
$B8=:_A*BrCf$NI{K\$,40A40lCW8!:w%a%=%C%I$r;}$C$F$$$k$+$I$&$+D4$Y$^$9!#(J
$BI{K\$,A*Br$5$l$F$$$J$$>l9g$O(JRuntimeError$B$r(Jraise$B$7$^$9!#(J
endsearch_available?
$B8=:_A*BrCf$NI{K\$,8eJ}0lCW8!:w%a%=%C%I$r;}$C$F$$$k$+$I$&$+D4$Y$^$9!#(J
$BI{K\$,A*Br$5$l$F$$$J$$>l9g$O(JRuntimeError$B$r(Jraise$B$7$^$9!#(J
keywordsearch_available?
$B8=:_A*BrCf$NI{K\$,%-!<%o!<%I8!:w%a%=%C%I$r;}$C$F$$$k$+$I$&$+D4$Y$^$9!#(J
$BI{K\$,A*Br$5$l$F$$$J$$>l9g$O(JRuntimeError$B$r(Jraise$B$7$^$9!#(J
menu_available?
$B%a%K%e!<$,MxMQ$G$-$k$+$I$&$+$rD4$Y$^$9!#(J
$BI{K\$,A*Br$5$l$F$$$J$$>l9g$J$I$G(JRuntimeError$B$r(Jraise$B$7$^$9!#(J
copyright_available?
$BCx:n8"I=<($,MxMQ$G$-$k$+$I$&$+$rD4$Y$^$9!#(J
copyright
$BCx:n8"I=<($rJV$7$^$9!#(J

$B%a%=%C%I(J($B8!:w(J)

search(word,max=all)
word$B$r%-!<$H$7$FA0J}0lCW8!:w$r9T$$!"7k2L$rG[Ns$KF~$l$FJV$7$^$9!#G[Ns$N3FMWAG$O(J[ heading, text ]$B$H$7$FM?$($i$l$^$9!#(J
$B%$%F%l!<%?$H$7$FMQ$$$k$H!"(J[heading,text]$B$NG[Ns$r(Jyield$B$7$^$9!#JV$jCM$H$7$F(JEB::Cancel$B$rM?$($k$H!"%$%F%l!<%H$r=*N;$7$^$9!#(J(break$B$GH4$1$F$bNI$$$G$9(J)
exactsearch(word,max=all)
word$B$r%-!<$H$7$F40A40lCW8!:w$r9T$$!"7k2L$rG[Ns$KF~$l$FJV$7$^$9!#G[Ns$N3FMWAG$O(J[ heading, text ]$B$H$7$FM?$($i$l$^$9!#(J
$B%$%F%l!<%?$H$7$FMQ$$$k$H!"(J[heading,text]$B$NG[Ns$r(Jyield$B$7$^$9!#JV$jCM$H$7$F(JEB::Cancel$B$rM?$($k$H!"%$%F%l!<%H$r=*N;$7$^$9!#(J(break$B$GH4$1$F$bNI$$$G$9(J)
endsearch(word,max=all)
word$B$r%-!<$H$7$F8eJ}0lCW8!:w$r9T$$!"7k2L$rG[Ns$KF~$l$FJV$7$^$9!#G[Ns$N3FMWAG$O(J[ heading, text ]$B$H$7$FM?$($i$l$^$9!#(J
$B%$%F%l!<%?$H$7$FMQ$$$k$H!"(J[heading,text]$B$NG[Ns$r(Jyield$B$7$^$9!#JV$jCM$H$7$F(JEB::Cancel$B$rM?$($k$H!"%$%F%l!<%H$r=*N;$7$^$9!#(J(break$B$GH4$1$F$bNI$$$G$9(J)
keywordsearch(words,max=all)
words$B$O%-!<%o!<%I$NG[Ns$H$7!"%-!<%o!<%I$K$h$k8!:w$r9T$$$^$9!#$=$l0J30$O>e5-8!:w%a%=%C%I$HF1$8!#(J
search2(word,max=all)
exactsearch2(word,max=all)
endsearch2(word,max=all)
$B$3$N#3$D$O$=$l$>$l!"(Jsearch/exactsearch/endsearch$B$HF1$8$G$9$,!"G[Ns$KF~$l$?$j(Jyield$B$9$k$b$N$,0[$J$j$^$9!#(J
$B%$%F%l!<%?$H$7$FMQ$$$k$H!"(J[$B7k2L$N(JEB::Position$B%$%s%9%?%s%9(J,$B8!:w8l(J]$B$r(Jyield$B$7$^$9!#$=$&$G$J$$>l9g$O!"F1$8J*$rG[Ns$KF~$l$FJV$7$^$9!#(J
keywordsearch2(words,max=all)
words$B$O%-!<%o!<%I$NG[Ns$H$7!"%-!<%o!<%I$K$h$k8!:w$r9T$$$^$9!#$=$l0J30$O>e5-8!:w%a%=%C%I$HF1$8!#(J
menu
$B%H%C%W%a%K%e!<$NFbMF$rJV$7$^$9!#3F%a%K%e!<9`L\$N;2>H@h$O%F%-%9%H%U%C%/$N(JCANDIDATE$B$d(JREFERENCE$B$H$7$FEO$5$l$^$9!#(J
menu2
$B%H%C%W%a%K%e!<$N=q@R>e$N0LCV$r(JEB::Position$B$N%$%s%9%?%s%9$GJV$7$^$9!#(J
content(position)
position$B$O(JEB::Position$B$N%$%s%9%?%s%9$G$9!#(J
position$B$G<($5$l$k0LCV$NK\J8$NFbMF$rJV$7$^$9!#:GBg%V%m%C%/D9$^$GFI$_9~$_$^$9!#(J
$B%$%F%l!<%?$H$7$FMQ$$$k$H:GBg%V%m%C%/D9$N%V%m%C%/$r(Jyield$B$7$J$,$iK\J8$N6h@Z$j$,Mh$k$^$GFI$_9~$_$^$9!#(J
content_noseek
$B%7!<%/F0:n$r9T$o$:$KK\J8$NFbMF$rFI$_$H$jJV$7$^$9!#:GBg%V%m%C%/D9$@$1FI$_9~$_$^$9!#$3$N%a%=%C%I$rFI$`A0$K$O(Jcontent()$B$J$I$G%7!<%/$r9T$C$F$*$/I,MW$,$"$j$^$9!#(J

$B%a%=%C%I!JI{K\!'30;z!&%U%)%s%H!K(J

fontcode_list
$BMxMQ2DG=$J%U%)%s%H$N0lMw!JG[Ns!K$rJV$7$^$9!#Cf?H$O(Jinteger$B$G$9$,!"$=$l$>$l(JEB::FONT_**$B$NDj?t$KBP1~$7$^$9!#(JFONT_16,FONT_24,FONT_30,FONT_48$B$,$=$l$>$l(J0,1,2,3$B$G$9!#(J
fontcode/fontcode=
$B%U%)%s%H$NBg$-$5$rl9g$O(JEB::FONT_INVALID(-1)$B$H$J$j$^$9!#(J
get_widefont(code)
code$B$G<($5$l$kA43Q30;z%U%)%s%H$rF@$^$9!#JVCM$O(JEB::ExtFont$B$N%$%s%9%?%s%9$G$9!#(J
get_narrowfont
code$B$G<($5$l$kH>3Q30;z%U%)%s%H$rF@$^$9!#JVCM$O(JEB::ExtFont$B$N%$%s%9%?%s%9$G$9!#(J
wide_startcode
$BA*BrCf$NI{K\$K$*$1$kA43Q30;z$N@hF,%3!<%I$rJV$7$^$9!#(J
wide_endcode
$BA*BrCf$NI{K\$K$*$1$kA43Q30;z$N=*N;%3!<%I$rJV$7$^$9!#(J
narrow_startcode
$BA*BrCf$NI{K\$K$*$1$kH>3Q30;z$N@hF,%3!<%I$rJV$7$^$9!#(J
narrow_endcode
$BA*BrCf$NI{K\$K$*$1$kH>3Q30;z$N=*N;%3!<%I$rJV$7$^$9!#(J

$B%a%=%C%I(J($B%^%k%A%a%G%#%"%G!<%?(J)

read_monographic(pos,width,height)
$B%b%N%/%m?^HG$N%G!<%?$rpos$B$O(JEB::Position$B$N%$%s%9%?%s%9$GFI$_9~$_0LCV$r<($7$^$9!#$^$?!"(Jwidth$B$H(Jheight$B$GFI$_9~$^$l$k$Y$-?^HG$N%5%$%:$r;XDj$7$^$9!#%5%$%:$d0LCV$O%F%-%9%H%U%C%/$N0z?t$H$7$FF@$i$l$^$9!#(J
read_colorgraphic(pos,stoplength=$B:GBg%V%m%C%/D9(J)
read_colorgraphic(pos,stoplength=$B:GBg%V%m%C%/D9(J){|block| proc}
$B%+%i!<$N?^HG$r$B%$%F%l!<%?$H$7$FMQ$$$k$H(Jstoplength$B%P%$%H$rFI$_=P$7$F(Jblock$B$H$7$FM?$(!"=*$o$k$^$G7+$jJV$7$^$9!#$=$N>l9g!"%a%=%C%I$NJVCM$OFI$_9~$_D9$rJV$7$^$9!#(J
pos$B$O(JEB::Position$B$N%$%s%9%?%s%9$GFI$_9~$_0LCV$r<($7$^$9!#$^$?!"(Jstoplength$B$GFI$_9~$_%P%$%H?t$r;XDj$7$^$9!#(Jstoplength$B$OFI$_9~$`%P%$%H?t$N>e8B$G$9!#EE;R%V%C%/$G$O(JEB$B%i%$%V%i%j$K!V%G!<%?=*N;0LCV$,Mh$F$bFI$_9~$_$r$d$a$J$$!W$H$$$&@)8B;v9`$,$"$j$^$9!#!J(JBMP$B$d(JJPEG$B$N%G%3!<%I$rK\%i%$%V%i%j$G9T$$!"E,Ev$K;_$a$l$l$PNI$$$N$G$9$,!K(J
read_wavedata(startpos,endpos,stoplength=$B:GBg%V%m%C%/D9(J)
$B2;@<%G!<%?$r(JString$B$H$7$F$B%$%F%l!<%?$H$7$FMQ$$$k$H(Jstoplength$B%P%$%H$rFI$_=P$7$F(Jblock$B$H$7$FM?$(!"=*$o$k$^$G7+$jJV$7$^$9!#$=$N>l9g!"%a%=%C%I$NJVCM$OFI$_9~$_D9$rJV$7$^$9!#(J
startpos$B$O3+;O0LCV!"(Jendpos$B$O=*N;0LCV$r<($9!"(JEB::Position$B$N%$%s%9%?%s%9$G$9!#$3$l$i$O%F%-%9%H%U%C%/$+$i>pJs$,F@$i$l$^$9!#(J
read_mpeg(code1,code2,code3,code4,stoplength=$B:GBg%V%m%C%/D9(J)
$BF02h%G!<%?$r(JString$B$H$7$F$B%$%F%l!<%?$H$7$FMQ$$$k$H(Jstoplength$B%P%$%H$rFI$_=P$7$F(Jblock$B$H$7$FM?$(!"=*$o$k$^$G7+$jJV$7$^$9!#$=$N>l9g!"%a%=%C%I$NJVCM$OFI$_9~$_D9$rJV$7$^$9!#(J
code1$B$+(Jcode4$B$^$G$O!"(JHOOK_BEGIN_MPEG$B$N(Jargv[2]$B$+$i(Jargv[5]$B$KAjEv$7$^$9!#(J
compose_mpegfilename(code1,code2,code3,code4)
code1$B$+$i(Jcode4$B$G<($5$l$kF02h$N%U%!%$%kL>$r

EB::Position

$B%/%i%9%a%=%C%I(J

new(page,offset)
$B%Z!<%8$H%*%U%;%C%H$+$i(JEB_Position$B$r@_Dj$7$^$9!#(J

$BB0@-(J

$BFI$_=q$-2DG=$G$9!#(J
page
offset

EB::ExtFont

$B30;z$rI=$7$^$9!#%$%s%9%?%s%9$O(JEB::Book#get_widefont$B$b$7$/$O(JEB::Bookget_narrowfont$B$G
widefont?
$B30;z$,A43Q$G$"$l$P(Jtrue$B$rJV$7$^$9!#(J
code
$B30;z$N%3!<%I$rJV$7$^$9!#(J
to_xbm
$B30;z$N%S%C%H%^%C%W%G!<%?$r(Jxbm$B7A<0$N(JString$B$GJV$7$^$9!#(J
to_xpm
$B30;z$N%S%C%H%^%C%W%G!<%?$r(Jxpm$B7A<0$N(JString$B$GJV$7$^$9!#(J
to_gif
$B30;z$N%S%C%H%^%C%W%G!<%?$r(Jgif$B7A<0$N(JString$B$GJV$7$^$9!#(J
$B%U%!%$%k$KMn$H$;$P$=$N$^$^(Jgif$B%U%!%$%k$K$J$j$^$9!#(J
to_bmp
$B30;z$N%S%C%H%^%C%W%G!<%?$r(Jbmp$B7A<0$N(JString$B$GJV$7$^$9!#(J
$B%U%!%$%k$KMn$H$;$P$=$N$^$^(Jbmp$B%U%!%$%k(J(Windows$B!&(JOS/2)$B$K$J$j$^$9!#(J
to_png
$B30;z$N%S%C%H%^%C%W%G!<%?$r(Jpng$B7A<0$N(JString$B$GJV$7$^$9!#(J
$B%U%!%$%k$KMn$H$;$P$=$N$^$^(Jpng$B%U%!%$%k$K$J$j$^$9!#(J

EB::Hookset

$B%/%i%9%a%=%C%I(J

new
Hookset$B$N%$%s%9%?%s%9$r:n@.$7$^$9!#$3$l$O%F%-%9%H%U%C%/$r07$$$^$9!#(J

$B%a%=%C%I(J

register(hook,proc)
register(hook){|eb,argv| proc }
hook$B$O%U%C%/$Neb$B$O8F$S=P$785$N(JEB::Book$B$G$"$j!"(Jargv$B$O%F%-%9%H%U%C%/$N0z?t$NG[Ns$G$9!#(J
$B%$%Y%s%HH/@8;~$K8F$P$l$k%a%=%C%I$r@_Dj$7$^$9!#(Jhook$B$KM?$($kDj?t$O!"(JEB::$B$N2<$KDj?t$H$7$FDj5A$5$l$F$$$^$9(J(EB::HOOK_****)$B!#(J"EB::$BDj?t(J"$B$N9`;2>H!#(J
$B$^$?!"JVCM$,(Jnil$B0J30$N>l9g$O%F%-%9%H$KJVCM$r=q$-9~$_$^$9!#(J(String$B0J30$N>l9g$O(JObject#to_str$B$7$^$9!K(J
$BF1$8%U%C%/$KBP$7$FJ#?t2s@_Dj$r9T$&$H!":G8e$K9T$C$?@_Dj$N$_M-8z$G$9!#(J

EB::$BDj?t(J

Ruby EB $B$N%P!<%8%g%s$O0J2<$NDj?t$GDj5A$5$l$F$$$^$9!#(J
  • RUBYEB_VERSION
$B$^$?!"(Jeb-3.2$B0J9_$G$O0J2<$NDj?t$,Dj5A$5$l$F$$$^$9!#(Jeb.c$B$N:G8e$NJ}$H!"(JEB Library$B$N%j%U%!%l%s%9$r;2>H$7$F2<$5$$!#(J
  • RUBYEB_VERSION
  • FONT_16
  • FONT_24
  • FONT_30
  • FONT_48
  • FONT_INVALID
  • HOOK_BEGIN_CANDIDATE
  • HOOK_BEGIN_COLOR_BMP(hookcode,?,page,offset)
  • HOOK_BEGIN_COLOR_JPEG(hookcode,?,page,offset)
  • HOOK_BEGIN_DECORATION(decoration)
  • HOOK_BEGIN_EMPHASIS
  • HOOK_BEGIN_GRAPHIC_REFERENCE
  • HOOK_BEGIN_GRAY_GRAPHIC
  • HOOK_BEGIN_IN_COLOR_BMP(hookcode,?,page,offset)
  • HOOK_BEGIN_IN_COLOR_JPEG(hookcode,?,page,offset)
  • HOOK_BEGIN_KEYWORD
  • HOOK_BEGIN_MONO_GRAPHIC(hookcode,?,height,width)
  • HOOK_BEGIN_MPEG(hookcode,?,code1,code2,code3,code4)
  • HOOK_BEGIN_NARROW
  • HOOK_BEGIN_NO_NEWLINE
  • HOOK_BEGIN_REFERENCE
  • HOOK_BEGIN_SUBSCRIPT
  • HOOK_BEGIN_SUPERSCRIPT
  • HOOK_BEGIN_WAVE(hookcode,?, begin_page, begin_offset, end_page, end_offset)
  • HOOK_END_CANDIDATE_GROUP(hookcode,page,offset)
  • HOOK_END_CANDIDATE_LEAF(hookcode,0,0)
  • HOOK_END_COLOR_GRAPHIC(hookcode)
  • HOOK_END_DECORATION
  • HOOK_END_EMPHASIS
  • HOOK_END_GRAPHIC_REFERENCE
  • HOOK_END_GRAY_GRAPHIC
  • HOOK_END_IN_COLOR_GRAPHIC(hookcode)
  • HOOK_END_KEYWORD
  • HOOK_END_MONO_GRAPHIC(hookcode,page,offset)
  • HOOK_END_MPEG
  • HOOK_END_NARROW
  • HOOK_END_NO_NEWLINE
  • HOOK_END_REFERENCE (hookcode,page,offset)
  • HOOK_END_SUBSCRIPT
  • HOOK_END_SUPERSCRIPT
  • HOOK_END_WAVE
  • HOOK_GB2312
  • HOOK_GRAPHIC_REFERENCE
  • HOOK_INITIALIZE
  • HOOK_ISO8859_1()
  • HOOK_NARROW_FONT(code)
  • HOOK_NARROW_JISX0208()
  • HOOK_NEWLINE()
  • HOOK_SET_INDENT(hookcode,indent)
  • HOOK_WIDE_FONT(code)
  • HOOK_WIDE_JISX0208()

$BNc(J


#!/bin/env ruby -Ke
require "eb"

b=EB::Book.new
b.bind("/cdrom")
b.subbook=0
b.exactsearch( "$B$8$7$g(J" ) do |word,desc|
  print "====================\n"
  print "==   ",word,"\n"
  print "\n",desc,"\n"
#  EB::Cancel   # yield will be stopped
end

$BNc(J2


require "eb"

b=EB::Book.new
b.bind("/cdrom")
b.subbook=0
b.exactsearch2( "$B$8$7$g(J" ) do |pos,word|
  print "====================\n"
  print "==   ",word,"\n"
  print "\n",b.content(pos),"\n"
#  EB::Cancel   # yield will be stopped
end

$BMzNr(J

  • v2.6 2004/??/?? eb-4.1$B$KBP1~!#(JEB::ExtFont#to_png$B$NDI2C!#(J
  • v2.5 2004/03/15 Appendix$B$r@5$7$/FI$`$h$&$K=$@5!#(Jeb-4.0($B%Q%C%AI,MW!K$KBP1~!#(J
  • v2.4 2003/12/26 $BJ8;zAu>~7O%U%C%/$H(J pthread $B$KBP1~(J
  • v2.3 2003/08/20 ruby-1.8$B$KBP1~(J
  • v2.2 2003/01/26 eb-3.2.3$B$G$NIT6q9g=$@5$H$+$:$R$3;a$K$h$k5!G=DI2C(J
  • v2.1 2003/01/22 $B$+$:$R$3;a$K$h$kDj?tDj5A%_%9$H(Jcompose_mpegfilename$B$N%P%0%U%#%/%9(J
  • v2.0 2003/01/05 $B5!G=6/2=!J2hA|!&2;@v1.7 2002/03/31 $B9b=!MM!"(Jknu$BMM$N%Q%C%A$K$h$j!"(JEB-3.2.1$B$XBP1~!JDj?t!K(J
  • v1.6 2001/06/22 $B$d$^$@MM!"$&$($AMM$N%Q%C%A$K$h$j(JEB3.0$B$NDj?tL>JQ99$KBP1~(J
  • v1.5 2001/04/04 $B?72~MM$N%3!<%I$K$h$j!"(JEB$B$N(J3.0$B$KBP1~(J
  • v1.4($B:F(J) 2000/06/26 $B@^EDMM$N%Q%C%A$K$h$j!"?M$rOG$o$9(Jextconf.rb$B$r=$@5(J
  • v1.4 2000/06/23 search2$B7O!"%$%F%l!<%?;HMQ;~$N%-%c%s%;%k$,8z$/$h$&$K(J
  • v1.3 2000/06/22 $B9uEDMM$+$i$N:F%Q%C%A!#3hF0;~4V$N:90[$K$h$k%?%$%_%s%0$:$l$,(J....
  • v1.2 2000/06/22 v1.1$B$X$N=$@5!#%a%=%C%IDI2C!"5!G=@0M}$J$I!#(J($BL$8x3+(J)
  • v1.1 2000/06/21 $B9uEDMM$+$i$N%Q%C%A$K$h$k(Jsearch2$B7O!"(JPosition$B!"%U%C%/!JL$8x3+!K(J
  • v1.0 2000/04/10 $B=iHG(J

Email: nyasu3w@users.sourceforge.net
ruby-eb-2.6/extconf.rb000066400000000000000000000005721175214377300147370ustar00rootroot00000000000000require 'mkmf' have_library("z") have_library("intl") if /freebsd/ =~ RUBY_PLATFORM have_library('eb') have_func("rb_block_proc") have_func("eb_bitmap_to_png") have_header('eb/sysdefs.h') # uncomment the following line if you use eb-4.0beta* with pthread support. # $defs << '-DEBCONF_ENABLE_PTHREAD' create_makefile("eb") ruby-eb-2.6/hook2.rb000066400000000000000000000041641175214377300143140ustar00rootroot00000000000000#!/bin/env ruby -Ke require "eb" eb=EB::Book.new hkset = EB::Hookset.new eb.bind("/cdrom") eb.set(0) eb.hookset=hkset eb.fontcode=0 puts "Copyright:" puts eb.copyright hkset.register(EB::HOOK_BEGIN_REFERENCE) do |eb2,argv| "<#begin reference>" end hkset.register(EB::HOOK_END_REFERENCE) do |eb2,argv| format('<#end reference page=%d offset=%d>',argv[1], argv[2]) end hkset.register(EB::HOOK_NEWLINE) do |eb2,argv| "
\n" end hkset.register(EB::HOOK_WIDE_FONT) do |eb2,argv| efont = eb2.get_widefont(argv[0]) puts efont.to_xbm format("",argv[0]) end hkset.register(EB::HOOK_NARROW_FONT) do |eb2,argv| efont = eb2.get_narrowfont(argv[0]) puts efont.to_xbm format("",argv[0]) end hkset.register(EB::HOOK_BEGIN_COLOR_BMP) do |eb2,argv| page = argv[2] offset = argv[3] open("#{page}-#{offset}.bmp","w") do |f| txt= eb2.read_colorgraphic(EB::Position.new(page,offset),0x40000) puts "binary size="<< format("%x",txt.size) f.write txt end format "<#begin bmp page=%d offset=%d obj=%s>",page,offset,argv.inspect end hkset.register(EB::HOOK_BEGIN_COLOR_JPEG) do |eb2,argv| "<#begin jpeg>" end hkset.register(EB::HOOK_END_COLOR_GRAPHIC) do |eb2,argv| format "<#end graphic obj=%s>",argv.inspect end puts "16dot ext-font size support? : #{ eb.fontcode_list.include?(EB::FONT_16)}" puts "24dot ext-font size support? : #{ eb.fontcode_list.include?(EB::FONT_24)}" puts "30dot ext-font size support? : #{ eb.fontcode_list.include?(EB::FONT_30)}" puts "48dot ext-font size support? : #{ eb.fontcode_list.include?(EB::FONT_48)}" puts "FontSize set to " << EB::FONT_16.to_s eb.fontcode=EB::FONT_16 puts "Current Font:" << eb.fontcode.to_s puts eb.wide_startcode puts eb.wide_endcode font= eb.get_widefont(eb.wide_startcode) puts "Font code: #{font.code}" puts "Font wide?:#{font.widefont?}" p eb.content(EB::Position.new(1352,932)) eb.exactsearch2('うぐいす') do |pos,word| p [pos,word] print "====================\n" print pos.page,":", pos.offset,"\n" print "== ",word,"\n" print "\n",eb.content(pos),"\n" EB::Cancel # yield will be stopped end print "END\n" ruby-eb-2.6/test.rb000066400000000000000000000016361175214377300142520ustar00rootroot00000000000000#!/bin/env ruby -Ke require "eb" if $KCODE!="EUC" then raise RuntimeError,"lib eb requires EUC coding system" end b=EB::Book.new WORD1="じしょ" WORD2="ちしき" print "\n****** Initial Test\n" b.bind("/cdrom") p b.disktype p b.bound? p b.path p b.charcode p b.subbook_count p b.subbook_list print "\n****** Sub Books\n" 0.upto(b.subbook_count-1) do |i| print "===============\n" p b.title(i), b.directory(i) end print "\n****** Sub Book Test\n" b.subbook=0 p b.subbook p b.search_available? p b.exactsearch_available? p b.endsearch_available? print "\n****** Search Test\n" items=b.exactsearch( WORD1 ) print "Hit :", items.size,"\n" items.each do |item| print "====================\n" print "== ",item[0],"\n" print "\n",item[1],"\n" end b.exactsearch( WORD2 ) do |item| print "====================\n" print "== ",item[0],"\n" print "\n",item[1],"\n" # EB::Cancel # yield will be stopped end